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.
Unfortunately, activation email could not send to your email. Please try again.

Multiple XAxis

Thread ID:

Created:

Updated:

Platform:

Replies:

105937 Nov 29,2012 03:45 AM Dec 20,2012 12:36 AM WPF 1
loading
Tags: Chart
Syed Sadaqat Hussain
Asked On November 29, 2012 03:45 AM

Hi,

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#.

Thanks,
Sadaqat

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

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++)
            {
                _labelSource.Add(_viewModel.DataCollection[i].XData);
            }

            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 };
            area.Series.Add(series);

            Chart chart = new Chart();
            chart.Areas.Add(area);

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.

Sample:

Please let us know if you have any queries.

Thanks,
Vinoth Kumar J


MultipleXAxis_176b88a2.zip

CONFIRMATION

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.

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.

;