- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
各位,我在原始 flot.js 库中遇到了这个错误。我想知道这部分脚本有什么问题?*错误是来自 Firefox 的 shwon Fire bug错误消息是:
ReferenceError: $ is not defined
$(document).ready(function () {
开始声称是错误代码的行是:
$(document).ready(function () {
$.plot($("#flot-placeholder1"), dataset, options);
$("#flot-placeholder1").UseTooltip();
});
下面是错误行之前的内容:
<script>
//******* 2012 Gold Price Chart
var data1 = [
[gd(2012, 0, 1), 1652.21], [gd(2012, 1, 1), 1742.14], [gd(2012, 2, 1), 1673.77], [gd(2012, 3, 1), 1649.69],
[gd(2012, 4, 1), 1591.19], [gd(2012, 5, 1), 1598.76], [gd(2012, 6, 1), 1589.90], [gd(2012, 7, 1), 1630.31],
[gd(2012, 8, 1), 1744.81], [gd(2012, 9, 1), 1746.58], [gd(2012, 10, 1), 1721.64], [gd(2012, 11, 2), 1684.76]
];
var data2 = [
[gd(2012, 0, 1), 0.63], [gd(2012, 1, 1), 5.44], [gd(2012, 2, 1), -3.92], [gd(2012, 3, 1), -1.44],
[gd(2012, 4, 1), -3.55], [gd(2012, 5, 1), 0.48], [gd(2012, 6, 1), -0.55], [gd(2012, 7, 1), 2.54],
[gd(2012, 8, 1), 7.02], [gd(2012, 9, 1), 0.10], [gd(2012, 10, 1), -1.43], [gd(2012, 11, 2), -2.14]
];
var dataset = [
{ label: "Gold Price", data: data1, points: { symbol: "triangle"} },
{ label: "Change", data: data2, yaxis: 2 }
];
var options = {
series: {
lines: {
show: true
},
points: {
radius: 3,
fill: true,
show: true
}
},
xaxis: {
mode: "time",
tickSize: [1, "month"],
tickLength: 0,
axisLabel: "2012",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial',
axisLabelPadding: 10
},
yaxes: [{
axisLabel: "Gold Price(USD)",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial',
axisLabelPadding: 3,
tickFormatter: function (v, axis) {
return $.formatNumber(v, { format: "#,###", locale: "us" });
}
}, {
position: "right",
axisLabel: "Change(%)",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial',
axisLabelPadding: 3
}
],
legend: {
noColumns: 0,
labelBoxBorderColor: "#000000",
position: "nw"
},
grid: {
hoverable: true,
borderWidth: 2,
borderColor: "#633200",
backgroundColor: { colors: ["#ffffff", "#EDF5FF"] }
},
colors: ["#FF0000", "#0022FF"]
};
=================更新============================= ========================大家好。感谢你的回答!这是我加载脚本的顺序(加载正确,因为我在 DW CS4 中测试它1.jquery-1.8.3.min.js2.jquery.flot.min.js”3.jquery.flot.time.js”4.jquery.flot.symbol.js5.jquery.flot.axislabels.js6.jshashtable-2.1.js7.jquery.numberformatter-1.2.3.min.js
所以我认为顺序应该不是问题,它遵循教程告诉我在这里做: http://www.pureexample.com/jquery-flot-tutorial-how-to-make-a-jquery-flot-line-chart.html
我还发现这些代码被 Firefox/firebug 阻止了,也许它有帮助。停止点放在代码的第 2 行前面 --> '$(this).bind("plot...'.
$.fn.UseTooltip = function () {
$(this).bind("plothover", function (event, pos, item) {
if (item) {
if ((previousLabel != item.series.label) || (previousPoint != item.dataIndex)) {
previousPoint = item.dataIndex;
previousLabel = item.series.label;
$("#tooltip").remove();
var x = item.datapoint[0];
var y = item.datapoint[1];
var color = item.series.color;
var month = new Date(x).getMonth();
//console.log(item);
if (item.seriesIndex == 0) {
showTooltip(item.pageX,
item.pageY,
color,
"<strong>" + item.series.label + "</strong><br>" + monthNames[month] + " : <strong>" + y + "</strong>(USD)");
} else {
showTooltip(item.pageX,
item.pageY,
color,
"<strong>" + item.series.label + "</strong><br>" + monthNames[month] + " : <strong>" + y + "</strong>(%)");
}
}
} else {
$("#tooltip").remove();
previousPoint = null;
}
});
};
谢谢。
凯文的进一步问题在他的回答的评论下被问到....
最佳答案
错误在这里:
$(document)
$
未定义。这意味着您要么没有包括 jQuery,包括得太晚了,要么错误地使用了 $.noConflict()
。
更具体地说,$ === undefined
,undefined 不是函数,因此无法执行。
关于javascript - 引用错误 : $ is not defined for original flot library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16090976/
你能用 flot 渲染这样的条形图吗? 我是否需要手动创建数据集才能获得此结果,而不是使用 mode: 'time' ? 最佳答案 其实pretty easy使用浮点生产。 var options =
我刚刚将我的 Flot 版本从 0.6 更改为 0.7,但是,当我这样做时,我的 Flot 图中的图例会改变样式。以前,我使用“LabelClass”属性来更改样式,但在阅读 0.7 的源代码时,我发
我在弄清楚如何控制 Flot 上的外边距时遇到了一些困难。图我已经实现。我尝试了很多选择; minBorderMargin,边距,axisMargin,labelMargin。无论是单独设置还是全部设
有谁知道如何根据时间戳显示浮点中的日期 $(function () { var d1 = [ [1262818800,100],[1262732400,100],[1262646000,100],[
我想做的就是标记我的x轴: function doPlot(position) {//Flot $.plot("#placeholder", [//data { data: t
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
首先,对于按照网站规则正确提问而出现的错误,我深表歉意,这是我第一次这样做,我已经尽力了。 所以我有以下问题: 假设我有该数据(考虑它 - 日期/值): 然后我用它初始化一个图表,那一刻唯一相关的选项
所以我正在使用 jquery.flot 和 jquery.flot.selection 并且因为 define({... 异步加载模块我遇到了问题因为选择插件试图将自己插入 $.plot.plugin
我正在使用 FLOT 图表库来绘制随时间消耗的卡路里。我希望 y 轴使用自动缩放(仅显示数据集中 +/- 最小值和最大值的值)。 但是,图表始终使用 0 作为条形图的最小值,而不是自动缩放 y 轴值。
我在同一页面上显示两个或多个流程图,并使用 flot.navigate 插件进行拖动和缩放。我可以独立于其他图表缩放和拖动单个图表,但我希望其他图表与应用导航操作的图表一起移动或缩放。有些页面可能只有
我正在使用 Flot 绘制折线图,我的数据集是一个相当大的 JSON blob 数组,看起来像(为简洁起见被 chop ): [{"load_data": 5047, "url": "ht
在生产环境中运行 Angular 6 时出现此错误。 91%额外的 Assets 处理脚本-webpack-plugin✖「wdm」: Error: ENOENT: no such file or d
我遇到了另一个小的堆叠条问题:填充绘图时,flot 自上而下添加图例条目并将条条自下而上堆叠。这样,图例的顺序与条形图完全相反。 flot API 允许按照标签的添加顺序、字母顺序或提供自定义排序功能
我正在使用 Flot 构建图表,数据收集结束时的空项被忽略。 我的代码如下: var d1 = []; for (var i = 0; i 使用 Flot 0.8.1,这会产生以下结果: JS
我有一个基本的条形图,我在 flot 中展示(5 个条形,显示每个状态的百分比)。 $.plot($("#placeholder"), [ { label: 'Failed',
我正在创建一个需要大量复杂多折线图的网站。我看到两个最适合这份工作的候选人 Flot Google Charts 有没有人对这个决定有任何建议或偏好? 最佳答案 谷歌图表:每次需要绘图时都需要调用谷歌
在以下 fiddle 中: http://jsfiddle.net/jamitzky/9x7aJ/ 如果窗口宽度发生变化,如何使图形的宽度发生变化? 代码: $(function () { var d
我在学生图表 div 中使用 flot 绘制了折线图: $.plot(jQuery("#studentavgchart"), DATA, options); Graph 将在具有 oneTwo 类的
我在我的应用程序中使用 Flot,它运行良好。我想从图表背景中删除垂直线和水平线。我尝试过,但无法实现该功能。 grid: { verticalLines:false, horizon
我有一个图表,其中显示代表 24 小时降雨量的条形图。现在我遇到的第一个问题是 flot 中条形的默认 1px 宽度,请参阅此示例: 我搜索了一个解决方案,发现指定 barwidth 像这样: bar
我是一名优秀的程序员,十分优秀!