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

Message ListMessage List     Post MessagePost Message

  Stacked bar Overlap Problem
Posted by Nitesh on Jun-14-2016 19:07
Attachments:
Sometimes In case of Stacked Bar, Stacked bar is overlapping. For that i am using code
addBarLayer2(cd.Stack, 0)

So Please provide me the solution in which stacked bar should not be overlap.


Thanks for your help.
StackedBar_Overlap.png

  Re: Stacked bar Overlap Problem
Posted by Peter Kwan on Jun-14-2016 23:41
Hi Nitesh,

It is probably because the bar charts are using x-coordinates with Layer.setXData. In this case, there is no reliable way to determine the bar width, so ChartDirector may have to guess, and the guess may or may not be what you want.

For example, suppose the x-coordinates of the bars are 0, 4, 8.47, 10, 12.19. It is hard to see how wide should the bar be. It can be 4 units, 2 units, 1 unit or other values. In this case, ChartDirector will guess a value.

For your case, after studying your chart carefully, I believe the x-coordinates of the bars are unevenly spaced. In this case, you may need to specify the bar width with your own code. A common method is:

Call myBarLayer.setBarWidth(c.getPlotArea().getWidth() / barCount * 4 / 5)

However, the above assume the bars are approximately evenly spaced. If some bars can be spaced every closely together (like 15 seconds apart) then the above may not be suitable and you may have to keep the bars very narrow. Similarly, if some bars can spaced very far away (eg. 2 hours), the above may not be suitable as the chart will contain wide gaps and it squeezes the rest of the bars into some small space, and each bar will need to be quite narrow.

If you know the bar width approximately in number of seconds, you can compute the bar width approximately as:

barWidth = c.getPlotArea().getWidth() * barWidthInSeconds / xAxisRangeInSeconds * 4 / 5
Call myBarLayer.setBarWidth(barWidth)

Regards
Peter Kwan