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

Message ListMessage List     Post MessagePost Message

  touch bar overlap issue
Posted by moses on Jan-08-2024 17:31
Attachments:
I want to set the bar gap to touch each other, but I found if I use the parameter "Chart::TouchBar" and the border color is "Transparent", the bars will overlap with each other. Even if I use the parameter "setBarGap(0)", this issue still exists.
How to solve this issue?
Screenshot 2024-01-08 172910.png

  Re: touch bar overlap issue
Posted by Peter Kwan on Jan-09-2024 18:00
Attachments:
Hi Moses,

Normally, each bar has its own border. If two bars touch each other (Chart::TouchBar is used), there will be two borders between the bars, one belonging to each bar. To avoid this, ChartDirector is designed so that the two bars will overlap by 1 pixel, so that the two bars shared a single border between them.

If the border is to "Transparent" (Chart::Transparent in C++), for backwards compatibility reasons, the border color will be treated as the same color as the bar itself. So the two bars will overlap by 1 pixel, which may not be easily noticeable. It will be like the first chart below.

In your image, the overlap is much more series. Is the image magnified by some other image processing software?

If you really want to have a transparent border, you can set the border color to almost transparent (0xfeffffff, which is 99.6% transparent). In this case, ChartDirector will leave the border as transparent. This will result in a one pixel gap between the bars. See the second chart below.

The setBarGap(0) should not cause the bars to overlap. In fact, it may introduce some thin gaps between bars. If setBarGap(0) causes the bars to overlap, is it possible your code also has a line that set Chart::TouchBar?

The setBarGap(0) will causes ChartDirector to use the maximum possible pixel bar width without overlapping. For example, if the plot area width is 300 pixels, and there are 8 bars, the bar width will be 300/8 = 37.5, which will be rounded to 37 pixels. But then the 8 bars can only fill 37 x 8 = 296 pixels,  which means there must be some gaps distributed among the bars to account for the 4 remaining pixels.

To avoid the thin gaps, you can set the plot area width to be exactly divisible by the number of bars. In C++, this is by "plotAreaWidth = plotAreaWidth / barCount * barCount", where plotAreaWidth and barCount are integer variables. The last chart below illustrate this method.

Best Regards
Peter Kwan
touchbar.png
transparentborder.png
exacttouchbar.png