This is a migrated thread and some comments may be shown as answers.

X-Axis Category values in a Multiple Y-axis chart

1 Answer 90 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Murugan S
Top achievements
Rank 1
Murugan S asked on 11 Feb 2010, 05:52 AM

Hi All,

I'm new to both Silver light and Telerik, i was trying to evaluate the multiple Y-axis support in Rad controls.

I found success in displaying multiple Y axis,but I'm not able to get how to define the X-Axis labels, by default it is coming as 1,2 and 3.

For Example, i have different Sales Represntatives and want to see the sales made by them in last 3 months as a series respectively, so i have created three series as below:

            chtAct.DefaultView.ChartArea.DataSeries.Add(GenerateSeries("Jan", string.Empty, new BarSeriesDefinition(), SelectedKPIS));  
            chtAct.DefaultView.ChartArea.DataSeries.Add(GenerateSeries("Feb", "Secondary", new BarSeriesDefinition(), SelectedKPIS));  
            chtAct.DefaultView.ChartArea.DataSeries.Add(GenerateSeries("Mar", "Secondary", new BarSeriesDefinition(), SelectedKPIS));  
        }  
 
        private DataSeries GenerateSeries(string legendLabel, string axisName, ISeriesDefinition definition, List<String> SelectedKPIS)  
        {  
            DataSeries series = new DataSeries();              
            series.Definition = definition;  
            series.LegendLabel = legendLabel;  
            series.Definition.AxisName = axisName;  
            IEnumerable<double> ChartSeriesData = null;  
 
            switch (legendLabel)  
            {  
                case "Jan":  
                    ChartSeriesData = from KPIData in KPIBowlerData  
                          where SelectedKPIS.Contains(KPIData.KPI)  
                          select KPIData.JanActual;  
                    break;  
                case "Feb":  
                    ChartSeriesData = from KPIData in KPIBowlerData  
                          where SelectedKPIS.Contains(KPIData.KPI)  
                          select KPIData.FebActual;  
                    break;  
                case "Mar":  
                    ChartSeriesData = from KPIData in KPIBowlerData  
                          where SelectedKPIS.Contains(KPIData.KPI)  
                          select KPIData.MarActual;  
                    break;  
                default:  
                    break;  
            }  
            foreach (double Plotpoint in ChartSeriesData)  
            {  
                series.Add(new DataPoint(Plotpoint));  
            }  
            return series;  
        } 

Now when i select single Sales Rep all the three series are displayed, however the X-Axis label is displayed as "1", how can i display the "Sales Representative name" instead of "1", because when i add the second Rep all the series are displayed with X-axis displayed as "2" which makes it difficult for reading the chart.

Let me know if i need to provide additional information

1 Answer, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 12 Feb 2010, 11:13 AM
Hi Murugan S,

Here is a sample code snippet that demonstrates how to combine multiple Y-axis chart with XValue category labels:

AxisY secondary = new AxisY();
secondary.AxisName = "Secondary";
 
RadChart1.DefaultView.ChartArea.AdditionalYAxes.Add(secondary);
 
DataSeries series = new DataSeries();
series.Definition = new LineSeriesDefinition();
series.Add(new DataPoint(21) { XCategory = "Category1" });
series.Add(new DataPoint(25) { XCategory = "Category2" });
series.Add(new DataPoint(23) { XCategory = "Category3" });
series.Add(new DataPoint(29) { XCategory = "Category4" });
 
RadChart1.DefaultView.ChartArea.DataSeries.Add(series);
 
DataSeries series2 = new DataSeries();
series2.Definition = new LineSeriesDefinition() { AxisName = "Secondary" };
series2.Add(new DataPoint(250) { XCategory = "Category2" });
series2.Add(new DataPoint(1230) { XCategory = "Category3" });
series2.Add(new DataPoint(290) { XCategory = "Category4" });
series2.Add(new DataPoint(190) { XCategory = "Category5" });
 
RadChart1.DefaultView.ChartArea.DataSeries.Add(series2);

Hope this helps.


Kind regards,
Manuel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Chart
Asked by
Murugan S
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or