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.

How create all XAxis when chart has 2 series with CategoryAxis

Thread ID:

Created:

Updated:

Platform:

Replies:

118602 Mar 23,2015 09:34 AM Mar 27,2015 10:27 AM WPF 7
loading
Tags: SfChart
Herbert Moroni Cavallari de Costa Gois
Asked On March 23, 2015 09:34 AM

Hello!

I want to create a chart with two series using CategoryAxis

ex
Series 1 (X axis): 1, 2, 3, 4
Series 2 (X axis): 5, 7, 8

the graph shows only (1,2,3,4) in X Axis
and the series of columns 2 are shown in the wrong X axis, for example, the number 5 in the series 2 is represented on the axis 1 of the series 1

Suresh S [Syncfusion]
Replied On March 24, 2015 04:59 AM

Hi Herbert,

 

Thanks for using Syncfusion products.

 

We would like to let you know that the behavior of CategoryAxis, especially with your scenario. CategoryAxis is a string type axis, in which the axis labels are based on first series (Series [0]) or series with maximum number of data points (to cover all the datapoints of other series). However your requirement can be achieved by adding separate axis (Series.XAxis) to the series in order to display the corresponding axis labels or using NumericalAxis instead of CategoryAxis or using ChartColumnDefinitions to setting corresponding axis for the series at specified index as shown in the below code snippet.

 

Code Snippet [Xaml]:

<chart:SfChart.ColumnDefinitions>

         <chart:ChartColumnDefinition/>

         <chart:ChartColumnDefinition/>

</chart:SfChart.ColumnDefinitions>

<chart:ColumnSeries.XAxis>

         <chart:CategoryAxis chart:SfChart.Column="1"/>

</chart:ColumnSeries.XAxis>

 

We have also prepared sample based on this, please find the sample from the following location.

 

Sample: AxisLabel.zip

 

Regarding the ChartColumnDefinitions you can also refer our help documentation.

 

Ug link: http://help.syncfusion.com/ug/wpf/documents/area.htm

 

Please let us know if you require further assistance.

 

Regards,

Suresh S


Herbert Moroni Cavallari de Costa Gois
Replied On March 24, 2015 02:59 PM

Hi Suresh!

I saw your sample but that is half right

try
            Add(new DataValues("1", 32, "2"));
            Add(new DataValues("2", 34, "6"));
            Add(new DataValues("3", 41, "7"));
            Add(new DataValues("4", 42, "8"));

look at the first X Axis of Year1, i changed to "2" 
It creates twice the same column

sample:

Now
"1","2","3","4","2","6","7","8"

How i want:
"1","2","3","4","6","7","8"

and in the second column would have two columns, the year and year1



Suresh S [Syncfusion]
Replied On March 25, 2015 09:23 AM

Hi Herbert,

 

Thanks for your response.

 

As we informed earlier CategoryAxis in a string type axis and data points (axis label) will be plotted based on index position and not a linear. In order to display the data points in linear, we can use NumericalAxis.  We have prepared the sample based on your requirement by using numerical axis instead of ChartColumnDefinition and  please download from below location.

 

Sample: AxisLabel.zip

 

Please let us know if you require any further assistance.

 

Regards,

Suresh S


Herbert Moroni Cavallari de Costa Gois
Replied On March 25, 2015 09:48 AM

Hello Suresh!

Thanks for helping!

I Know NumericalAxis and DateTimeAxis works fine what i want

i need know how i can do with CategoryAxis because i used a simple sample to show you using numbers, but a i want with strings like:



try
            Add(new DataValues("Peter", 32, "Robert"));
            Add(new DataValues("Robert", 34, "Juliet"));
            Add(new DataValues("Anna", 41, "Roger"));
            Add(new DataValues("Jullie", 42, "Luly"));

It creates twice the same column

sample:

Now
"Peter","Robert","Anna","Jullie","Robert","Juliet","Roger","Luly"

How i want:
"Peter","Robert","Anna","Jullie","Juliet","Roger","Luly"

and in the second column would have two columns, the year and year1

Suresh S [Syncfusion]
Replied On March 26, 2015 08:58 AM

Hi Herbert,

 

Thanks for your response.

 

At present we haven’t support to plot category axis in linear as per your requirement. We have considered this as feature and we will implement this feature in any of our upcoming volume releases.

 

Please let us know if you have any query

 

Regards,

Suresh S


Herbert Moroni Cavallari de Costa Gois
Replied On March 26, 2015 09:04 AM

Hi Suresh

Can i set manually "Robert" go to column 2 in code behind?

Suresh S [Syncfusion]
Replied On March 27, 2015 10:27 AM

Hi Herbert,

 

We have tried to achieve your requirement  by using numerical axis with custom labels as shown in below code snippet.

Code Snippet[xaml]:

<chart:NumericalAxis>

        <chart:NumericalAxis.CustomLabels>

                  <chart:ChartAxisLabel Position="1" LabelContent="peter"/>

                  <chart:ChartAxisLabel Position="2" LabelContent="robert"/>

                  <chart:ChartAxisLabel Position="3" LabelContent="anna"/>

                  <chart:ChartAxisLabel Position="4" LabelContent="julie"/>

        </chart:NumericalAxis.CustomLabels>

</chart:NumericalAxis>

 

Also we have modified the sample based on it, please download it from below location.

 

Please let us know if need any further assistance on this.

 

Thanks,

Suresh S


Attachment: AxisLabel_b8d99372.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.

;