We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Column Series X-Axis Labels - Only shows every other label

Column series is only showing every other label for the data points on the X-Axis. If I put a Line series on the same chart (with no other changes to the chart), I get all the labels on the X-Axis.


4 Replies

MP Murugavel P Syncfusion Team June 17, 2010 09:06 AM UTC

Hi John,

Thanks for choosing Syncfusion products.

Chart axis ranges are calculated based on the series types. Column series requires an additional value to be added to the range values, so that the series will not be hidden. But Line series doesn't require these additional range values. This is the reason for this change in axis range values.

To disable this label changes, you can initialize the RangeCalculationMode property of Chart axis as AdjustAcrossChartTypes. So that all chart types add the additional range values.

The following code demonstrates how to disable this label changes in both XAML and C#.

[XAML]








[C#]

chart.Areas[0].PrimaryAxis.RangeCalculationMode = RangeCalculationMode.ConsistentAcrossChartTypes;



Please let us know if you have any questions about this.

Thanks,
Murugavel


JS john simmons June 17, 2010 02:08 PM UTC

Before I tell you the result of your suggestion, here's what I am doing:

The chart legend is configured to show the show/hide checkboxes.

I add a column chart series
I add a line chart series

When the chart is rendered, The X-Axis labels show every other data point label, starting at the 2nd data point. If I hide the column series, ALL of the labels are displayed. If I then hide the line series and re-show the column series, the labels revert to showing every other one.

I added those property settings you provided, and:

I still only see every other datapoint label, but when I hide the column series, I STILL only get every other label.

For grins, I set RangeCalculationMode="ConsistentAcrossChartTypes", and:

The chart now displays all datapoint labels for the column series and the line series, but the column series extends to the edges of the chart which results in the columns at the end being clipped.

I think this is a bug in your code.


JS john simmons June 17, 2010 03:12 PM UTC

I've attached a Word document that contains my code, XAML, and screenshots of what I'm seeing.




Syncfusion_126cf507.zip


MP Murugavel P Syncfusion Team June 18, 2010 10:46 AM UTC

Hi Jhon,

Thanks for choosing Syncfusion products.

You can display every labels of Chart based on the IsAutoSetRange property of Chart axis control.

If IsAutoSetRange property of Chart axis as True then axis labels interval are calculated based on the desired interval count. In the following lines of code, the DesiredIntervalsCount property is used to initialize the number of axis labels need to be display on the Chart.

[C#]
mainChart.Areas[0].PrimaryAxis.IsAutoSetRange = true;

//The DesiredIntervalsCount property is used to determine number of labels need to be display in Chart
mainChart.Areas[0].PrimaryAxis.DesiredIntervalsCount = data.Count;
mainChart.Areas[0].PrimaryAxis.RangeCalculationMode = SFChart.RangeCalculationMode.AdjustAcrossChartTypes;


If IsAutoSetRange property of Chart axis as False then you can manually initialize the Range values based on the series data count and set Interval as 1.

[C#]
mainChart.Areas[0].PrimaryAxis.IsAutoSetRange = false;
mainChart.Areas[0].PrimaryAxis.Range = new Syncfusion.Windows.Chart.DoubleRange(0, data.Count + 1);
mainChart.Areas[0].PrimaryAxis.Interval = 1;

I have modified the sample based on your requirement. Here with I have attached the updated sample.

Please let me know if you have any queries.

Thanks,
Murugavel




ChartSample_2dcfeaf6.zip

Loader.
Live Chat Icon For mobile
Up arrow icon