Nevron Forum

How to make the legend panel scrollable

https://www.nevron.com/Forum/Topic7667.aspx

By Xiaolong Zhu - Monday, April 15, 2013

Hi

I have a chart displays lots of different series. At before i added the legend pane to the same nevron chart control as the chart was added to, but i found the chart control seemed very crowded since too many legend items listed in the legen pane, and even worse, some of the legend items have too long text. So i decided to build a additional floatable winform user control to host a nchartcontrol only for legend panel. i just wonder is there any way to make the legend pane scrollable like the attached pic? thanks.

Regards,

xl

By Nevron Support - Tuesday, April 16, 2013

Hi Xialong,

You can place the chart inside a scrollable panel and resize the chart inside using the following code:

         nChartControl1.Panels.Clear();
         nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

         NLegend legend = new NLegend();
         legend.UseAutomaticSize = true;
         nChartControl1.Panels.Add(legend);
         legend.Mode = LegendMode.Manual;
         legend.Location = new Nevron.GraphicsCore.NPointL(0, 0);

         for (int i = 0; i < 10; i++)
         {
            NLegendItemCellData licd = new NLegendItemCellData();
            licd.Text = "Legend Item " + i.ToString();

            legend.Data.Items.Add(licd);
         }


         nChartControl1.Document.Calculate();
         nChartControl1.Document.RecalcLayout(nChartControl1.View.Context);

         nChartControl1.Width = (int)legend.ContentArea.Width;
         nChartControl1.Height = (int)legend.ContentArea.Height;

Hope this helps - let us know if you meet any problems.
By Xiaolong Zhu - Friday, April 19, 2013

HI

Thanks for your reply. i tried using  the attached code based on your provide to achieve that but it still didn't show the srcoll bar, could you take a look? Thanks.

 

xiaolong