Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用不同的符号打印不工作的数据_Javascript_Jquery_Flot - Fatal编程技术网

Javascript 使用不同的符号打印不工作的数据

Javascript 使用不同的符号打印不工作的数据,javascript,jquery,flot,Javascript,Jquery,Flot,我试图在flot图上为我的一个数据系列使用一个不同的符号,因为它比其他数据的规模大得多。我用这个例子作为参考: 以下是我到目前为止的情况: 我的建议包括: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.flot.js"></script> <script type="text/javasc

我试图在flot图上为我的一个数据系列使用一个不同的符号,因为它比其他数据的规模大得多。我用这个例子作为参考:

以下是我到目前为止的情况:

我的建议包括:

<script  type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.flot.js"></script>
<script type="text/javascript" src="jquery.flot.symbol.js"></script>
然后我实际绘制数据:

 $.plot('#placeholder', [{
               data: my_data,
               lines: { show : true},
               points: { symbol: "square"},
               color: '#CB4B4B',
               label: 'My Data'
               }], options);
        }
但是,
flot
仍将点绘制为默认圆。我在firebug中没有收到错误消息,我甚至尝试在
jquery.flot.symbol.js
库中添加一条日志消息,以查看“square”处理程序是否被这样调用:

var handlers = {
            square: function (ctx, x, y, radius, shadow) {
                console.log("Square handler was called");
                // pi * r^2 = (2s)^2  =>  s = r * sqrt(pi)/2
                var size = radius * Math.sqrt(Math.PI) / 2;
                ctx.rect(x - size, y - size, size + size, size + size);
            },
我没有收到任何控制台消息,因此我假设处理程序没有被正确调用。我是不是遗漏了什么

编辑:

我试图绘制的数据示例:

var d1 = [
[1364342400000, 208],
[1364346000000, 107],
[1364353200000, 42],
[1364371200000, 1680],
[1364360400000, 52],
[1364349600000, 67],
[1364385600000, 1118],
[1364367600000, 163],
[1364382000000, 1359],
[1364378400000, 1468],
[1364389200000, 1023],
[1364356800000, 63],
[1364374800000, 1601],
[1364392800000, 556],
[1364364000000, 84],
],
d2 = [
[1364342400000, 86],
[1364346000000, 42],
[1364353200000, 13],
[1364371200000, 458],
[1364360400000, 10],
[1364349600000, 22],
[1364385600000, 453],
[1364367600000, 45],
[1364382000000, 369],
[1364378400000, 379],
[1364389200000, 358],
[1364356800000, 17],
[1364374800000, 471],
[1364392800000, 147],
[1364364000000, 16],
],
d3 = [
[1364342400000, 7],
[1364346000000, 5],
[1364382000000, 11709],
[1364371200000, 58336],
[1364360400000, 1],
[1364349600000, 1],
[1364367600000, 2],
[1364389200000, 1191],
[1364378400000, 9085],
[1364385600000, 4688],
[1364374800000, 9386],
[1364392800000, 1140],
[1364364000000, 1],
];
我还编辑了我的
选项
参数以及plot函数的调用方式:

var options = {
grid: {hoverable : true},
xaxis: { mode: "time", timeformat: "%H:%M", tickLength: 1}
}; 

 $.plot("#placeholder", [{
data: d1,
lines: { show : true },
points: { show: true},
color: '#EDC240',
label: "d1"
}, {
data: d2,
lines: { show : true },
points: { show : true},
color: '#AFD8F8',
label: "d2"
}, {
data: d3,
yaxis: 2,
lines: { show : true},
points: { show: true, symbol: "square"},
color: '#CB4B4B',
label: "d3"
}], options);

我还确信
符号
库已经包含在内,因为我已经在库中添加了一些日志记录本身,并且显示得很好。

我认为您所做的没有问题。我在这里举了一个快速工作的例子:

我猜你没有包括符号库(即使你说你有)

或者显示您的数据,可能存在某种问题(可疑?)

这是我运行的完整的
flot
代码,用于制作一个工作示例(包括flot和符号库):


我看你所做的没有问题。我在这里举了一个快速工作的例子:

我猜你没有包括符号库(即使你说你有)

或者显示您的数据,可能存在某种问题(可疑?)

这是我运行的完整的
flot
代码,用于制作一个工作示例(包括flot和符号库):


谢谢你迄今为止的帮助。我已经编辑了我的问题以包含更多信息,包括我试图绘制的数据。我很困惑为什么它不工作,因为我的代码和你上面的代码非常相似。事实上。。。。即使添加了这些细节,仍然不清楚问题是什么-显示了所有的更改,看起来仍然很好…我应该检查一下我运行的是什么版本的
flot
。我使用的版本是
0.6
,当我升级到
0.7
时,方形符号就工作得很好。你的回答使我走上了正确的道路。谢谢你的帮助!谢谢你迄今为止的帮助。我已经编辑了我的问题以包含更多信息,包括我试图绘制的数据。我很困惑为什么它不工作,因为我的代码和你上面的代码非常相似。事实上。。。。即使添加了这些细节,仍然不清楚问题是什么-显示了所有的更改,看起来仍然很好…我应该检查一下我运行的是什么版本的
flot
。我使用的版本是
0.6
,当我升级到
0.7
时,方形符号就工作得很好。你的回答使我走上了正确的道路。谢谢你的帮助!
var options = {
grid: {hoverable : true},
xaxis: { mode: "time", timeformat: "%H:%M", tickLength: 1}
}; 

 $.plot("#placeholder", [{
data: d1,
lines: { show : true },
points: { show: true},
color: '#EDC240',
label: "d1"
}, {
data: d2,
lines: { show : true },
points: { show : true},
color: '#AFD8F8',
label: "d2"
}, {
data: d3,
yaxis: 2,
lines: { show : true},
points: { show: true, symbol: "square"},
color: '#CB4B4B',
label: "d3"
}], options);
$.plot('#placeholder', [{
    data: [
        [1, 1],
        [2, 3],
        [4, 4],
        [5, 9]
    ],
    lines: {
        show: true
    },
    points: {
        show: true,
        symbol: "square"
    },
    color: '#CB4B4B',
    label: 'My Data'
}]);