|
Problem with setBarGap on Side method bar |
Posted by djschorn on Feb-24-2015 23:59 |
|
Hi,
I'm facing a problem with bar chart.
Below a snippet of my code :
[....]
// plot area width = 888, number of bars = 24
barLayer = chart.addBarLayer2(Chart.Side);
barLayer.setBarWidth(computedBarGroupWidth); // 37
barLayer.setOverlapRatio(overlap); // 1
barLayer.addDataSet(data,
aColor,
aTitle);
barLayer.addDataSet(data2,
anotherColor,
anotherTitle);
[....]
I try to have an overlap between data (setOverlapRatio) and the computedBarGroupWidth is computed according to the width of the plotarea (width / number of bars).
The result is displayed in attachment (pb.png)
I understand that if plot area width cannot be divided by number of bars, I will have a space somewhere between bars. But in my case 24*37 = 888.
First question :
- Why in my case, there is a space ?
- How can I specify Chart Director to avoid this space ? Chart.touch ?
Thx by advance.
|
Re: Problem with setBarGap on Side method bar |
Posted by Peter Kwan on Feb-26-2015 00:23 |
|
Hi djschorn,
You may use Chart.TouchBar. The code is like:
barLayer = chart.addBarLayer2(Chart.Side);
barLayer.setBarGap(Chat.TouchBar);
With the above code, ChartDirector will adjust the bar width as necessary to ensure they
touch each other. There is no need to ensure the plot area width is divisible by the number
of bars. ChartDirector will increase the bar width of certain bars by 1 pixel if necessary to
ensure they exact touch.
Hope this can help.
Regards
Peter Kwan |
Re: Problem with setBarGap on Side method bar |
Posted by djschorn on Feb-26-2015 18:39 |
|
With your code, I loose the overlap feature (bars are 100% overlapped).
barLayer = chart.addBarLayer2(Chart.Side);
//barLayer.setBarWidth(computedBarGroupWidth.getTotalWidth());
barLayer.setBarGap(Chart.TouchBar);
barLayer.setOverlapRatio(overlap / 100.0);
barLayer.addDataSet(data,aColor,aTitle);
barLayer.addDataSet(data2,anotherColor,anotherTitle);
Image in attachment.
Thanks
|
Re: Problem with setBarGap on Side method bar |
Posted by Peter Kwan on Feb-27-2015 02:29 |
|
Hi djschorn,
Sorry. I have not read your original code carefully. For your case, I suggest to use:
barLayer = chart.addBarLayer2(Chart.Overlay);
barLayer.addDataSet(data,aColor,aTitle);
barLayer.addDataSet(data2,anotherColor,anotherTitle);
barLayer.setBarGap(Chart.TouchBar);
Hope this can help.
Regards
Peter Kwan |
Re: Problem with setBarGap on Side method bar |
Posted by djschorn on Mar-10-2015 22:01 |
|
Thanks a lot, it works. |
|