Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
925
Bar chart - Multiple X-Axis
posted

Hi,

I am trying to create a bar chart for two metrics (with the same set of categorical values) and want two axis top and bottom for the bar chart. I create the chart and add a PrimaryX, SecondaryX and PrimaryY axis.

I then add two series, both of ChartType.Bar and add to the chart. When I set the AxisY and AxisX values of the bar chart I am unable to get the bars to work as standard series values and instead the bars sit on top of each other. If I point both series at the same X axis (PrimaryX for example) this works fine, but obviously I only then have one axis displaying.

Here is the code I am using to create the series:

var barSeries1 = new Series
                                 {
                                     ChartType = ChartType.Bar,
                                     DataSource = seriesData1,
                                     DataMapping = "Value = Value1; Label = ShortLabel1",
                                     Label = seriesData1.Title + ", " + seriesData1.Measure1,
                                     AxisX = "PrimaryX",
                                     DataPointStyle = Application.Current.Resources["BarChart"as Style,
                                     Fill = brush
                                 };

var barSeries2 = new Series
                                 {
                                     ChartType = ChartType.Bar,
                                     DataSource = seriesData2,
                                     DataMapping = "Value = Value2; Label = ShortLabel2",
                                     Label = seriesData2.Title + ", " + seriesData2.Measure2,
                                     AxisX = "SecondaryX",
                                     DataPointStyle = Application.Current.Resources["BarChart"as Style,
                                     Fill = brush
                                 };

And the resulting chart:

 
Please advice if this is a known bug, or any possible workaround for the problem.

Thanx,
Chris