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

Message ListMessage List     Post MessagePost Message

  ChartFlipped
Posted by Xochitl on Mar-01-2022 00:03
Attachments:
HI, please I need your help me, I did a Bar Charts but the bars show flipped, I hade been add the code.

Thanks a lot.

Regards
seafree
medcev_anual.cgi
medcev_anual.cgi

3.41 Kb

  Re: ChartFlipped
Posted by seafree on Mar-01-2022 03:01
Attachments:
HI, please I need your help me, I did a Bar Chart but the bars show flipped,
Thanks a lot.

Regards
seafree
Barchart_Flipped.PNG

  Re: ChartFlipped
Posted by Peter Kwan on Mar-01-2022 15:20
Hi seafree,

It is normal for a bar to go up when it is positive, and go down when it is negative. See:

https://www.advsofteng.com/doc/cdperl.htm#posnegbar.htm

By default, the bar starts from y = 0. This ensures the length of the bar is proportional to the data value. For example, a bar with value 10 is twice as long as a bar with value 5. However, if the y = 0 point is very far away, ChartDirector will just display the part that is near to the end points of the bar.

For your case, all bars are negative, so they go down from the y = 0 point. The y = 0 point is also very far away, so ChartDirector only displays the part of the bars starting from y = -34160000.

For your case, would you mind clarify how you want the bars to display? Do you want to start the bars from the bottom (y = -34420000) and go up? Or do you want the axis scale to reverse, that is, the bottom is y = -34162000 and the top is y = -344220000. Note that if you reverse the axis scale, and you have positive bars as well as negative bars, the positive bars will be below the negative bars.

To start the bars from the bottom (y = -34420000), you can use:

# Add your bar layer
$layer = $c->addBarLayer($data);
# Start the bar from -1E100, which is below the bottom.
$layer->setBaseLine(-1E100);

If you want to reverse the axis scale, you may use:

$c->yAxis()->setReverse();

Regards
Peter Kwan

  Re: ChartFlipped
Posted by seafree on Mar-02-2022 02:34
Thanks  a lot Peter Kwan.

Regards
seafree