ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Multiple layers vs setDataCombineMethod()
Posted by David Thielen on Mar-22-2021 00:30
Hi;

For a line/bar/area chart, using the bar chart as an example, I can either create a single bar layer and give it several layer.addDataSet() calls. Or create a layer for each dataset.

If I create a layer for each dataset, then I can easily control the z-order of each layer. But I then lose combining the series for a stacked bar - correct?

So to be able to do stacked, I need a single layer for all datasets, but then I'm stuck with a z-order of the order in which I add the series to the layer.

Or am I missing something?

thanks - dave

  Re: Multiple layers vs setDataCombineMethod()
Posted by Peter Kwan on Mar-22-2021 02:05
Attachments:
Hi David,

Yes, if you want to "stack" the data series, they have to be in the same layer. This is why we allow multiple data series per layer.

The z-order refers to the order that the items are drawn. This is not the same as the order in which the items are stacked. By z-order, are you referring to the order that the bar segments are drawn?

The z-order only makes a difference if the bar segments overlap. If the bar segments do not overlap, there is no difference no matter what are the z orders of the segments.

For stacked bar, in some cases, the bar segments must be drawn at a specific z-order, otherwise it looks incorrect. For example, for the attached chart image, for the first bar at "Mon", the bar segments must be drawn in the order "blue, green, orange". For the second bar, it must be drawn in the order "orange, green, blue". This is because of the 3D view angle. If the bars are in 2D, then the order does not matter, so ChartDirector can draw in any order. For consistency, ChartDirector will just use the same ordering as in 3D.

So in summary, the z-order is not determined by the order you add your data set. It is determined automatically by ChartDirector to make the chart looks correct, and can be different for every bar in the chart.

If you are referring to the ordering of the stack, the first data set added will be the stack the start at 0. Subsequent data sets and stack up or down depending on whether they are positive or negative. As explained above, they order they are drawn can be different from the order they are stacked.

If you are referring to the order of the legend keys, the order of the legend keys can be reversed by using Layer.setLegendOrder.

Regards
Peter Kwan
stackedbar.png

  Re: Multiple layers vs setDataCombineMethod()
Posted by David Thielen on Mar-22-2021 02:56
Hi;

Yes, the concern is the rendering order so they look correct. And maybe a better example is a line or area chart where the rendering order determines which is rendered on top of another.

This is very important for an area chart as you don't want one series hiding another. And it's visible in a line chart where they cross over each other.

??? - thanks - dave