|
Offset Barlayer |
Posted by Stevod on Sep-21-2013 23:51 |
|
Hi Peter,
I have quite a complex barlayer, which uses datagroups and datasets, as shown below.
However, I need to add a second layer, which has exactly the same data structure, but
which has different data values, different colours, and which is offset slightly so that it sits
behind this layer, but can still be seen.
Is there any easy way just to offset the whole of the second barlayer from the first one?
Thanks,
Stevod
|
Re: Offset Barlayer |
Posted by Peter Kwan on Sep-24-2013 03:04 |
|
Hi Stevod,
You may use Layer.setXData to shift the layer a little bit horizontally.
Normally, the x-axis labels are at 0, 1, 2, 3, and the bar groups are centered on these positions. You may shift the bar group a little bit, like:
// Shift by 0.05 unit for the 2nd bar layer
myBarLayer2.setXData(0.05, myXLabels.length - 1 + 0.05);
You may also want to change the Axis.setLabels to Axis.setLinearScale:
//c.xAxis().setLabels(myXLabels);
c.xAxis().setLinearScale(0, myXLabels.length - 1, myXLabels);
Normally, the x-axis scale would be from 0 to myXLabels.length - 1. However, if a layer is shifted by 0.05 unit, ChartDirector will extend the x-axis scale to myXLabels.length - 1 + 0.05. The setLinearScale method above will explicitly tell ChartDirector to end the x-axis at myXLabels.length - 1 instead.
Hope this can help.
Regards
Peter Kwan |
|