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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Multiple XAxis

Thread ID:





105937 Nov 29,2012 08:45 AM UTC Dec 20,2012 05:36 AM UTC WPF 1
Tags: Chart
Syed Sadaqat Hussain
Asked On November 29, 2012 08:45 AM UTC


I need to create multiple XAxis depending on XAxis header and OpposedPosition.
But when I create new CharAxis and assign to serie.XAxis, it is not creating the XBindPath values labels.
It is creating the labels with 0,1,2.... but when I changed the labelmode from default to Datasource and assign datasource it is also causing problems.

Please help me how to create the multiple XAxis and it should automatically pick label from XPathBindind values. I am not using the WPF designer. I am creating chart control using C#.


Vinoth Kumar J [Syncfusion]
Replied On December 20, 2012 05:36 AM UTC

Hi Sadaqat,

The LabelSource of ChartAxis should be collection of Double, String or DateTime. It should not be any other class. So you need to calculate the Labels for Axis manually as shown in below code snippet.

Code Snippet(C#):
            List<double> _labelSource = new List<double>();
            for (int i = 0; i < _viewModel.DataCollection.Count; i++)

            ChartSeries series = new ChartSeries() {Type=ChartTypes.Line, DataSource = _viewModel.DataCollection, BindingPathX = "XData", BindingPathsY = new List<String> {"YData"} };
            series.XAxis = new ChartAxis() { IsAutoSetRange = true,RangeCalculationMode=RangeCalculationMode.ConsistentAcrossChartTypes,RangePadding=ChartRangePaddingType.None};

            ChartArea area = new ChartArea();
            area.PrimaryAxis = new ChartAxis() { IsAutoSetRange=false,Range=new DoubleRange(_labelSource[0],_labelSource[_labelSource.Count-1]),LabelsMode = ChartAxisLabelsMode.DataSource, LabelsSource = _labelSource };
            area.SecondaryAxis = new ChartAxis() { IsAutoSetRange = true };

            Chart chart = new Chart();

We have prepared a sample based on this. Please find the attached sample.
If you still facing any issues, please revert to us by modifying the sample. This would be more helpful to assist you better.


Please let us know if you have any queries.

Vinoth Kumar J



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon