我正在使用 Flotr2 使用 DateTime 渲染一些图形。这一直很好地处理折线图,但我现在需要在购物车上渲染折线图和条形图。这应该很容易,并且在 fltr2 站点上有一个示例。
当我使用int
值时,一切都按预期工作。当我将其更改为DateTime
,它会失败,因为折线图按需要显示,但条形图根本不显示。
下面是我的 Javascript(带有注释掉的 DateTime 值)
function CreateRequiredChart(container)
{
var bars = {
data: [],
bars: {
show: true,
barWidth: 0.03,
lineWidth: 0,
fillColor: {
colors: ['#f00', '#f66'],
start: 'top',
end: 'bottom'
},
fillOpacity: 1
}
},
lines = {
data: [],
lines: {
show: true,
fillColor: ['#900', '#EDC13E', '#4DD43B'],
fill: true,
fillOpacity: 1
}
};
//The next lines displays the result which is desired (in that both line and bar graphs are shown). Comment these out and uncomment the next section to see the fault
bars.data.push([1, 7]);
lines.data.push([0, 4], [1, 9], [2, 5], [3, 3]);
/*The next 2 lines do not display as desired. The line graph works, the bar graph does not
bars.data.push([new Date('01/01/2013 08:30:00'), 7]);
lines.data.push([new Date('01/01/2013 08:29:00'), 5], [new Date('01/01/2013 08:30:00'), 8], [new Date('01/01/2013 08:31:00'), 4]);
*/
graph = Flotr.draw(container, [lines, bars], {
HtmlText: false,
yaxis: {
showLabels: true,
title: "Value"
},
xaxis: {
mode: "time",
timeformat: "%H%M%S",
minorTickFreq: 1,
showLabels: true,
title: "Time from start of logging",
labelsAngle: 90
},
grid: {
verticalLines: true,
backgroundColor: ['#fff', '#ccc']
}
});
}
我做错了什么,还是这是 flotr2 的限制?