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

defaulting LegendItem to disabled

4 Answers 25 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 23 Apr 2021, 04:21 PM

We have Telerik UI for ASP.NET Ajax version 2018.3.910.45.

I have a requirement to default a particular legend to disabled so that the associated data points are not shown. How can I do this?

 

4 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 26 Apr 2021, 12:00 PM

I couldn't find a way to edit my post hence this post...  the chart is built dynamically in code

 

            RadHtmlChart chartAll = new RadHtmlChart() { ID = "chart_All" };

            chartAll.ChartTitle.Text = "In-Process Time for All Operators";
            chartAll.Legend.Appearance.Visible = true;
            chartAll.Legend.Appearance.Position = ChartLegendPosition.Bottom;
            chartAll.Pan.Enabled = true;
            chartAll.Zoom.Enabled = true;
            chartAll.Zoom.MouseWheel.Enabled = true;
            chartAll.Transitions = true;
            chartAll.PlotArea.XAxis.TitleAppearance.Text = "Time";
            chartAll.PlotArea.XAxis.MajorGridLines.Visible = false;
            chartAll.PlotArea.XAxis.MinorGridLines.Visible = false;
            chartAll.PlotArea.XAxis.EnableBaseUnitStepAuto = true;
            chartAll.PlotArea.YAxis.TitleAppearance.Text = "In-Process Time";
            chartAll.PlotArea.YAxis.MinorGridLines.Visible = false;
            chartAll.PlotArea.YAxis.MinValue = 0;
            chartAll.PlotArea.YAxis.MaxValue = expectedTakt * 2;
            chartAll.PlotArea.YAxis.LabelsAppearance.DataFormatString = "{0:0.#}";

            List<ScatterLineSeries> lstLines = new List<ScatterLineSeries>();
            ScatterLineSeries taktLineAll = new ScatterLineSeries();
            taktLineAll.Name = "Expected Takt";
            taktLineAll.DataFieldX = "Date";
            taktLineAll.DataFieldY = "Takt";
            taktLineAll.TooltipsAppearance.Visible = false;
            taktLineAll.LabelsAppearance.Visible = false;
            taktLineAll.MarkersAppearance.Visible = false;
            taktLineAll.Appearance.FillStyle.BackgroundColor = Color.Red;

            //nest controls
            tabStrip.Tabs.Add(tabAll);
            pageMulti.PageViews.Add(pageAll);
            tabAll.PageViewID = pageAll.ID;
            pageAll.Controls.Add(chartAll);
            chartAll.PlotArea.Series.Add(taktLineAll);

Is there a way at this point to disable the series "taktLineAll"  so that the data points are not plotted on the graph?  The series will still show on the chart but ... toggled off....

 

 

0
Accepted
Vessy
Telerik team
answered on 26 Apr 2021, 05:34 PM

Hi Kevin,

I have just answered your support ticket on the matter, for convenience I am pasting my answer as of below:

 

Setting the Visible=false property of the desired series will hide it, making it disabled at the chart legend at the same time:

        List<ScatterLineSeries> lstLines = new List<ScatterLineSeries>();
        ScatterLineSeries taktLineAll = new ScatterLineSeries();
        taktLineAll.Visible = false;

If you want to hide a series from the chart and the legend permanently, you can do it by  setting its VisibleInLegend="False" property:

        taktLineAll.VisibleInLegend = false;


Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Kevin
Top achievements
Rank 1
answered on 26 Apr 2021, 05:48 PM

Thank you Vessy!  That's I needed.... I had think the Visible threw me ....

 

thanks again!

0
Vessy
Telerik team
answered on 27 Apr 2021, 06:04 AM

Hi,

You are welcome, Kevin :) I am glad that my reply was helpful for you!

Regards,
Vessy
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
Chart (HTML5)
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or