How to show all labels without grouping?

4 posts, 0 answers
  1. Eda
    Eda avatar
    3 posts
    Member since:
    Mar 2016

    Posted 07 Mar Link to this post

    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.

  2. Eda
    Eda avatar
    3 posts
    Member since:
    Mar 2016

    Posted 08 Mar Link to this post

    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;
                        }
                    }
                }

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Eda
    Eda avatar
    3 posts
    Member since:
    Mar 2016

    Posted 08 Mar Link to this post

    I used LabelFormatProvider so it is OK now.
  5. Hristo
    Admin
    Hristo avatar
    716 posts

    Posted 08 Mar Link to this post

    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
Back to Top