문제

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())
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top