Dojo StackedAreas chart doesn't accept objects as values

≡放荡痞女 提交于 2019-12-13 03:20:19

问题


Every Dojo chart that I have worked with has allowed for the use of an array of objects that contain the series of values and tooltips for each value point.

When using the StackedAreas chart type, Dojo seems to ignore my values inside the objects. For example:

var values = [
    {x: 1, y: 10, tooltip: 'test1'},
    {x: 2, y: 30, tooltip: 'test2'},
    {x: 3, y: 60, tooltip: 'test3'}
];

This works in Lines, Columns and StackedColumns chart types. The chart renders the axis and you can see the markers sitting on the base line of the char as if I had only supplied zero for all values.

Thanks in advance. Hope this makes sense.


回答1:


The doc specifies the different types on this page : http://dojotoolkit.org/reference-guide/dojox/charting.html in the paragraph "Connecting Charts to Data and Specifying a Data Series".

For any non “stacked” line plot type you can specify coordinate pairs. You need to use keys that correspond to the hAxis and vAxis parameters defined in the addPlot() call. These default to x and y.

[...]

With any of the stacked plot types each data set added with addSeries() is placed relative to the previous set. Here is a simple example that shows this concept. Instead of the second data set being a straight line across at 1, all the points are 1 above the point from the first data set.

chart1.addSeries("Series 1", [1, 2, 3, 4, 5]);
chart1.addSeries("Series 2", [1, 1, 1, 1, 1], {stroke: {color: "red"}});

So, for your tooltips on a stackedareas graph, first you have to activate the markers on your plot, then you have to use a custom dojox/charting/action2d/Tooltip, which takes a custom function to produce the desired tooltip.

I've made an example here : http://jsfiddle.net/psoares/nUe3C/

Hope it helps...



来源:https://stackoverflow.com/questions/9366221/dojo-stackedareas-chart-doesnt-accept-objects-as-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!