gpt4 book ai didi

javascript - dimplejs timeseries 未使用时间轴绘制

转载 作者:行者123 更新时间:2023-12-02 17:25:29 27 4
gpt4 key购买 nike

我有这个jsfiddle:http://jsfiddle.net/Ra2xS/42/ 。我完全不知道哪里出了问题。谁能看一下代码并提出更正建议吗?

var dim = {"width":590,"height":450}; //chart container width
var data = [{"date":"2008-07-16T07:00:00.000000000+0000","units":0},{"date":"2008-07-16T08:00:00.000000000+0000","units":0.97},{"date":"2008-07-16T09:00:00.000000000+0000","units":0.96},{"date":"2008-07-16T10:00:00.000000000+0000","units":1.66},{"date":"2008-07-16T11:00:00.000000000+0000","units":1.56},{"date":"2008-07-16T12:00:00.000000000+0000","units":1.53},{"date":"2008-07-16T13:00:00.000000000+0000","units":1.99},{"date":"2008-07-16T14:00:00.000000000+0000","units":2.22},{"date":"2008-07-16T15:00:00.000000000+0000","units":1.20},{"date":"2008-07-16T16:00:00.000000000+0000","units":0.10}];

function barplot(id,dim,data)
{
keys = Object.keys(data[0]);
var xcord = keys[0];
var ycord = keys[1];
var svg = dimple.newSvg(id, dim.width, dim.height);

var myChart = new dimple.chart(svg,data);
myChart.setBounds(60, 30, 505, 305);
var x = myChart.addTimeAxis("x", xcord, "%Y-%m-%dT%H:%M:%S.%LZ","%Y-%m-%dT%H:%M:%S.%LZ");

x.addOrderRule(xcord);
x.showGridlines = true;
x.timePeriod = d3.time.hours;

var y = myChart.addMeasureAxis("y", ycord);
y.showGridlines = true;
y.tickFormat = ',.2f';

var s1 = myChart.addSeries(null, dimple.plot.line);
s1.lineWeight = 3;
s1.lineMarkers = true;

myChart.draw(1500);
}

barplot("body",dim,data);

最佳答案

日期输入格式错误。应该是:

%Y-%m-%dT%H:%M:%S.%L000000+0000

http://jsfiddle.net/Ra2xS/43/

关于javascript - dimplejs timeseries 未使用时间轴绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23539574/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com