Profile Picture

Bar Chart Legend Position

Posted By Mike Holmes 2 Years Ago
Author
Message
Mike Holmes
Posted 2 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 2 Years Ago
Posts: 11, Visits: 45
How can I, move the Bar Chart Legend Position to be away from the chart, also ideally I would like to remove the boxhttps://www.nevron.com/forum/uploads/images/bae595a8-ede6-45e7-9245-c82f.jpg

Nevron Support
Posted 2 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Mike,

We would recommend that you docking to achive this layout. In this case you can dock the lagend to the right,  the label to the top and finally dock the chart to fill the rest. That way the chart will automatically measure the sizes of the label and legend and they'll not overlap - for example:

   nChartControl1.Panels.Clear();

    NLabel label = new NLabel("Bar Chart");
    label.DockMode = PanelDockMode.Top;
    label.Margins = new Nevron.GraphicsCore.NMarginsL(10);
    nChartControl1.Panels.Add(label);

    NLegend legend = new NLegend();
    legend.DockMode = PanelDockMode.Right;
    legend.FitAlignment = ContentAlignment.TopCenter;
    legend.Margins = new Nevron.GraphicsCore.NMarginsL(10);
    legend.OuterTopBorderStyle.Width = new Nevron.GraphicsCore.NLength(0);
    legend.OuterLeftBorderStyle.Width = new Nevron.GraphicsCore.NLength(0);
    legend.OuterRightBorderStyle.Width = new Nevron.GraphicsCore.NLength(0);
    legend.OuterBottomBorderStyle.Width = new Nevron.GraphicsCore.NLength(0);
    nChartControl1.Panels.Add(legend);

    NCartesianChart chart = new NCartesianChart();
    chart.BoundsMode = Nevron.GraphicsCore.BoundsMode.Stretch;
    chart.Margins = new Nevron.GraphicsCore.NMarginsL(10);
    chart.DockMode = PanelDockMode.Fill;
    nChartControl1.Panels.Add(chart);
    chart.DisplayOnLegend = legend;

    NBarSeries bar = new NBarSeries();
    bar.Values.Add(10);
    bar.Values.Add(20);
    bar.Values.Add(30);
    bar.DataLabelStyle.Visible = true;
    chart.Series.Add(bar);

This code also shows how to turn off the border around the legend.

You can take a look at the following topic in the documentation:
http://helpdotnetvision.nevron.com/#UsersGuide_Layout_Docking_Panels.html

We hope this helps - let us know if you have any questions.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic