An ugly legend is drawn when there are many graphs

2 posts, 0 answers
  1. Valery
    Valery avatar
    65 posts
    Member since:
    May 2011

    Posted 28 Apr 2020 Link to this post

    I need to draw a series of graphs and show the legend. When the legend does not fit in the radchartview, a scroll bar appears - this is acceptable, you can quickly see the whole legend. But the title of the legend is cut off in half - the visual reproduction of the picture is sharply reduced.

    In addition, if such a graph is exported to a file (ExportToImage), then we get an image containing a scroll bar. And why do you need a scroll bar in the exported drawing? We cannot use it here. In fact, we received a printscreen, not a normal export. I would like to export more intellectually for such cases.


  2. Nadya
    Nadya avatar
    459 posts

    Posted 01 May 2020 Link to this post

    Hello Valery,

    I create a test project in order to test it on my end and I was able to observe the same behavior. This is why I have logged it in our feedback portal by creating a new feedback item on your behalf. You can track its progress, subscribe for status changes, and add your comments on the following link - feedback item

    I have updated your Telerik Points.

    To work around this, I can suggest setting the Padding property of the TitleElement and ScrollViewElement. Please refer to the following code snippet:

    public RadForm1()
                Random rand = new Random();
                List<LineSeries> list = new List<LineSeries>();
                for (var index = 1; index <= 35; index++)
                    LineSeries ls = new LineSeries();
                    ls.LegendTitle = "Series " + index;
                for (int i = 1; i <= 100; i++)
                    foreach (LineSeries s in list)
                    s.DataPoints.Add(new CategoricalDataPoint(i, rand.Next(0, rand.Next(5, 20))));
                this.radChartView1.ShowLegend = true;
                this.radChartView1.LegendTitle = "Legend";
                this.radChartView1.ChartElement.LegendPosition = LegendPosition.Right;
                this.radChartView1.ChartElement.LegendElement.TitleElement.Padding = new Padding(0, 5, 0, 0);
                this.radChartView1.ChartElement.LegendElement.ScrollViewElement.Padding = new Padding(0, 5, 0, 10);

    As to the ExportToImage method, note that it creates an image file in the specified format from the current chart. So it is normal if you have scrollbars to appear in the exported image. The possible solution that I can suggest it to enlarge the form in a way all the legend items to be visible and the scrollbar doesn't show.

    I hope this helps. Should you have further questions do not hesitate to ask.

    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top