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

An ugly legend is drawn when there are many graphs

1 Answer 94 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Valery
Top achievements
Rank 1
Veteran
Valery asked on 28 Apr 2020, 10:38 AM

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.

 

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 01 May 2020, 07:56 AM

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()
        {
            InitializeComponent();
            
            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;
                list.Add(ls);
            }

            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.Series.AddRange(list.ToArray());
            
            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.

Regards,
Nadya
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.
Tags
ChartView
Asked by
Valery
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or