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

How create all XAxis when chart has 2 series with CategoryAxis

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

7 Replies

SS Suresh S Syncfusion Team March 24, 2015 08:59 AM UTC

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



HM Herbert Moroni Cavallari de Costa Gois March 24, 2015 06:59 PM UTC

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




SS Suresh S Syncfusion Team March 25, 2015 01:23 PM UTC

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



HM Herbert Moroni Cavallari de Costa Gois March 25, 2015 01:48 PM UTC

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


SS Suresh S Syncfusion Team March 26, 2015 12:58 PM UTC

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



HM Herbert Moroni Cavallari de Costa Gois March 26, 2015 01:04 PM UTC

Hi Suresh

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


SS Suresh S Syncfusion Team March 27, 2015 02:27 PM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon