0

Suppose I want to create two charts with horizontal bars. The names of the objects are listed on the y-axis and the horizontal bars represents some quantity. The first chart has 100 items and the second chart has 5 items.

When I create the charts the horizontal bars have different widths. I'd like the bars to be the same width across all of my charts.

I know I can try different values for the height parameter to the AddShape function. But that seems time-consuming and unreliable since the number of items can change. I'd like to do something like:

Chart.BarWidth = 10

CoolBreeze
  • 381
  • 4
  • 14
  • Are you referring to the scale/bounds used for the bars on your horizontal axis? So for example, maybe you want both charts' far right end of the horizontal axis to max out at the same value, say 100? – Tim Andersen Jun 23 '16 at 15:53
  • Maybe I should have used the word thickness instead of width. I don't think I can add an image to show what I want. If in one chart the bar is thick like this ==== in the 2nd chart the bar thickness is like ---- I want to make the bars in both charts the same thickness. Chart 1: ----, Chart 2 ---- – CoolBreeze Jun 23 '16 at 16:32
  • I wanted to update my comment but it looks like there is a limit. I thought of a better way to explain what I want: Let's say in chart 1 the horizontal bar is 100 pixels wide and 20 pixels high. In chart 2 the horizontal bar is 100 wide and 5 pixels high. The bar height is not consistent across the two charts 20 vs 5. I want to make the bar height 5 for both charts. – CoolBreeze Jun 23 '16 at 17:00

1 Answers1

0

The "thickness" of each bar will be primarily determined by the number of data points that need to be plotted. The more data points to plot, the thinner the bars will be. There are some options to further tweak them, such as IChartGroup.GapWidth, and you're welcome to try to adjust this so that both charts match. But I suspect that it will be very difficult to do this reliably, particularly if the number of plotted points is expected to change over time.

To maintain the same bar thickness for multiple charts, I think your best option will be to ensure both charts' series refer to the same size range. So if your first chart refers to 100 cells, have your second chart refer to 100 cells, even if only 5 are populated with values. The empty cells should not plot but will still take up space and therefore maintain consistent bar thicknesses between your two charts.

Tim Andersen
  • 3,014
  • 1
  • 15
  • 11