开发者

How to get dojox.charting labels on irregular (eg. 31, 28, 31... so on) values?

I'm trying to use dojox.charting to output a simple graph of monthly data.

For now, I want it to display one point per day in each month, for a duration of a year. This I have working.

The problem with this is: I can't find a way to add chart labels for each month.

I want "January" at 0, "February" at 31, "March" at 59 and so on.

As far as I can tell, dojox.charting only supports having labels on regular values, eg. 30, 60, 90 and so on.

Is there some way I can easily do this, or is changing dojo's code 开发者_开发知识库required?

Please see this jsfiddle for example: http://jsfiddle.net/svjrz/


dojox.charting does not support timeseries yet.

When I need to present irregular data (like monthly), usually I interpolate daily data to present on monthly scale with regular ticks (Jan, Feb, and so on) as a line/area chart (you can try splines there). And I switch to weekly/daily view when user drills down.

Yes, it is more work, yet the result is exactly what I want, rather then "what's available".


I provided a possible solution in this post.

Time-based charting requires padding non-contiguous data.

You will need to generate the full series of date values for the X axis in SQL or PHP. I'm using the MySQL trick of a calendar table with one DATE field, and a procedure to populate it with all dates in a range. JavaScript can convert ISO dates directly.

Your scattered data can then be output as a contiguous time-based series using:

SELECT DISTINCT(t0.datefield) AS Date, SUM(t1.sales) AS Sales FROM T_Sales AS t1 RIGHT JOIN T_Cal AS t0 ON t0.datefield = DATE(t1.saledate) WHERE t0.datefield >= DATE(NOW() - INTERVAL 6 MONTH) AND t0.datefield <= DATE(NOW())
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜