这是我拥有的数据(由2个图形表示的2个对象的数组)
[{"label":"Estimated Profit","color":"#4572A7","lines":{"show":true,"lineWidth":4},"points":{"show":true,"radius":4},"data":[[1443628800000,"29.00"],[1441036800000,"33.55"],[1438358400000,"32.55"],[1435680000000,"32.37"],[1433088000000,"35.12"],[1430409600000,"29.74"],[1427817600000,"36.00"],[1425139200000,"33.93"],[1422720000000,"31.37"],[1420041600000,"30.13"],[1417363200000,"31.09"],[1414771200000,"30.51"]]},{"label":"Actual Profit","color":"#AA4643","lines":{"show":true,"lineWidth":4},"points":{"show":true,"radius":4},"data":[[1443628800000,"29.00"],[1441036800000,"33.55"],[1438358400000,"32.55"],[1435680000000,"32.37"],[1433088000000,"35.12"],[1430409600000,"29.74"],[1427817600000,"36.00"],[1425139200000,"33.93"],[1422720000000,"31.37"],[1420041600000,"30.13"],[1417363200000,"31.09"],[1414771200000,"30.51"]]}]
和非常普通的
Flot's plot
函数调用$.plot($("#Profits"), profit_data, {
lines: {
show: true
},
legend: {
show: true
},
points: {
show: true
},
grid: {
show: true,
hoverable: true,
clickable: false,
borderColor: '#cccccc'
},
xaxis: {
min: (new Date(data.min)).getTime(),
max: (new Date(data.max)).getTime(),
mode: "time",
timeformat: "%b",
tickSize: [1, "month"],
monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
tickLength: 0, // hide gridlines
axisLabel: 'Month',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5
},
yaxis: {
axisLabel: 'Profits (%)',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5
}
});
但是由于某些原因,即使图例框显示有2个图形,它也只能绘制1个图形。见照片:
我在这里想念什么?
最佳答案
两个数据点相同。
[[1443628800000,"29.00"],[1441036800000,"33.55"],[1438358400000,"32.55"],[1435680000000,"32.37"],[1433088000000,"35.12"],[1430409600000,"29.74"],[1427817600000,"36.00"],[1425139200000,"33.93"],[1422720000000,"31.37"],[1420041600000,"30.13"],[1417363200000,"31.09"],[1414771200000,"30.51"]]
[[1443628800000,"29.00"],[1441036800000,"33.55"],[1438358400000,"32.55"],[1435680000000,"32.37"],[1433088000000,"35.12"],[1430409600000,"29.74"],[1427817600000,"36.00"],[1425139200000,"33.93"],[1422720000000,"31.37"],[1420041600000,"30.13"],[1417363200000,"31.09"],[1414771200000,"30.51"]]
估计利润线与实际利润重叠,因此不可见。检查您生成的数据。