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

How to show all labels without grouping?

3 Answers 78 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Eda
Top achievements
Rank 1
Eda asked on 07 Mar 2016, 03:05 PM

Hi. I am having a problem with converting the RadChart that we used earlier to ChartView. I am using this code to generate the LineSeries with DataTable.

radChart1.Axes.Clear();
 
           radChart1.BackColor = Color.White;
           radChart1.ShowPanZoom = true;
           Telerik.WinControls.UI.LineSeries ls = new Telerik.WinControls.UI.LineSeries();
           radChart1.Series.Add(ls);
           ls.DataSource = dt;
           ls.ShowLabels = true;
           ls.ValueMember = "Value";
           ls.CategoryMember = "Label";
           ls.CombineMode = Telerik.Charting.ChartSeriesCombineMode.None;
 
           foreach (DataColumn dc in dt.Columns)
           {
               if (dc.ColumnName == "LSL" || dc.ColumnName == "USL" || dc.ColumnName == "LWL" || dc.ColumnName == "UWL")
               {
                   DataTable LSLDt = dt.Copy();
                   LSLDt.Columns.Remove("Value");
 
                   Telerik.WinControls.UI.LineSeries LSLSeries = new Telerik.WinControls.UI.LineSeries();
 
                   radChart1.Series.Add(LSLSeries);
                   LSLSeries.DataSource = dt;
                   LSLSeries.ShowLabels = false;
                   LSLSeries.ValueMember = dc.ColumnName;
                   LSLSeries.Name = dc.ColumnName;
                   LSLSeries.CategoryMember = "Label";
                   LSLSeries.CombineMode = Telerik.Charting.ChartSeriesCombineMode.None;
 
                   if (dc.ColumnName.Contains("SL"))
                   {
                       LSLSeries.BackColor = Color.Red;
                   }
                   else if (dc.ColumnName.Contains("WL"))
                   {
                       LSLSeries.BackColor = Color.Yellow;
                   }
               }
           }
 
           //  radChart1.ShowSmartLabels = true;
           radChart1.Axes.Get<Telerik.WinControls.UI.CategoricalAxis>(0).PlotMode = Telerik.Charting.AxisPlotMode.OnTicksPadded;
           radChart1.Axes.Get<Telerik.WinControls.UI.CategoricalAxis>(0).LabelFitMode = Telerik.Charting.AxisLabelFitMode.Rotate;
           radChart1.Axes.Get<Telerik.WinControls.UI.CategoricalAxis>(0).LabelRotationAngle = 270;
           radChart1.Axes.Get<Telerik.WinControls.UI.CategoricalAxis>(0).ShowLabels = true;
           radChart1.Axes.Get<Telerik.WinControls.UI.LinearAxis>(1).ShowLabels = true;

But I need to show every single detail without grouping the labels. I have attached the way it used to look with RadChart and the new ChartView.

One of my other problems is that, when there is only one category and one Y value, I want to show a dot. But when I give the DataTable(which has 5 rows, all the values and labels are the same) as a source to LineSeries, nothing is shown. It is also attached as a file below. I'd appreciate it if you can help me with these issues.

3 Answers, 1 is accepted

Sort by
0
Eda
Top achievements
Rank 1
answered on 08 Mar 2016, 08:01 AM

Right now I am doing it so, I am taking the minutes in to count too. I just have one more question, how can I set up the label format, so that it doesn't show the minutes, only dates?

 

    radChart1.Axes.Clear();

            DateTimeCategoricalAxis ax = new DateTimeCategoricalAxis();
         
            ax.DateTimeComponent = Telerik.Charting.DateTimeComponent.TimeOfDay;
            ax.LabelFormat = "{0:dd.MM.yyyy}";

            ax.PlotMode = Telerik.Charting.AxisPlotMode.OnTicksPadded;
            ax.LabelFitMode = Telerik.Charting.AxisLabelFitMode.Rotate;
            ax.LabelRotationAngle = 270;
            ax.ShowLabels = true;

            radChart1.BackColor = Color.White;
            radChart1.ShowPanZoom = true;
            Telerik.WinControls.UI.LineSeries ls = new Telerik.WinControls.UI.LineSeries();
            ls.DataSource = dt;
            ls.ShowLabels = true;
            ls.ValueMember = "Value";
            ls.CategoryMember = "Label";
            ls.HorizontalAxis = ax;
            radChart1.Series.Add(ls);


            foreach (DataColumn dc in dt.Columns)
            {
                if (dc.ColumnName == "LSL" || dc.ColumnName == "USL" || dc.ColumnName == "LWL" || dc.ColumnName == "UWL")
                {
                    DataTable LSLDt = dt.Copy();
                    LSLDt.Columns.Remove("Value");

                    Telerik.WinControls.UI.LineSeries LSLSeries = new Telerik.WinControls.UI.LineSeries();
                  
                    LSLSeries.DataSource = dt;
                    LSLSeries.ShowLabels = false;
                    LSLSeries.ValueMember = dc.ColumnName;
                    LSLSeries.Name = dc.ColumnName;
                    LSLSeries.CategoryMember = "Label";
                    LSLSeries.HorizontalAxis = ax;
                    radChart1.Series.Add(LSLSeries);

                    if (dc.ColumnName.Contains("SL"))
                    {
                        LSLSeries.BackColor = Color.Red;
                    }
                    else if (dc.ColumnName.Contains("WL"))
                    {
                        LSLSeries.BackColor = Color.Yellow;
                    }
                }
            }

0
Eda
Top achievements
Rank 1
answered on 08 Mar 2016, 08:36 AM
I used LabelFormatProvider so it is OK now.
0
Hristo
Telerik team
answered on 08 Mar 2016, 10:45 AM
Hello Eda,

Thank you for writing.

I am glad that you have a working solution. Additional information is available in the following documentation articles: 
I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo Merdjanov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
ChartView
Asked by
Eda
Top achievements
Rank 1
Answers by
Eda
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or