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

Message ListMessage List     Post MessagePost Message

  How to make a bar chart overlaid with a line chart?
Posted by Steve on Aug-31-2021 04:24
Hi.  I am trying to make a chart displaying counts of news articles by day as a horizontal bar overlayed with an average sentiment (+/-) line chart.  I suppose it would need different scales on the left/right.  I'm not sure how to accomplish this.  The docs present them as different kinds of charts. Can anyone point me in the right direction?

  Re: How to make a bar chart overlaid with a line chart?
Posted by Peter Kwan on Aug-31-2021 11:20
Hi Steve,

The following is an example included in the ChartDirector distribution that displays a bar chart overlaid with a line chart, with two different scales on left / right.

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

For your requirement, I am not sure exactly the chart type you need. You mentioned "horizontal bar". Does it mean that the bars are horizontal like the followings?

https://www.advsofteng.com/doc/cdcpp.htm#gradientbar.htm

In the above example, the bars are horizontal, and the left axis displays the date, and the top axis is the value. You mentioned above "left/right" scale. If the left scale is date, what is the right scale for your chart? Also, does the line flow from left to right, or from top to bottom?

If what you want is like the first example above, but with the bars horizontal and the line flowing vertically, you can simply call $c->swapXY();. In this case, the left/right axes will become top/bottom axes. The line will flow from bottom to top (the origin is at the bottom-left corner). If you want the line to flow from top to bottom, you can call $c->xAxis()->setReverse();

Regards
Peter Kwan