Profile Picture

Legend appears above chart

Posted By Devin Ellis 5 Years Ago
Author
Message
Devin Ellis
Problem Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 9, Visits: 81
We are using Nevron chart 18.7 for .NET.
We create our charts with two dock panels, one on the top for textual header information and one at the bottom for the actual chart. Whenever the chart has a legend, the legend appears in the middle of the header as seen in the attached image.
How do we make the legend appear below the chart in the chart's dock panel?

https://www.nevron.com/forum/uploads/images/63b138d9-a798-49d6-a2cb-45f1.png


Nevron Support
This post has been flagged as an answer
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 Weeks Ago
Posts: 3,054, Visits: 4,015
Hi Devin,

You can nest the chart and legend in a single dock panel - the following code shows how to create a layout configuration that docks a header to the top and a legend to the bottom:

   nChartControl1.Panels.Clear();

    NLabel label = new NLabel("Some Header");
    label.DockMode = PanelDockMode.Top;

    nChartControl1.Panels.Add(label);

    NDockPanel chartAndLegend = new NDockPanel();
    chartAndLegend.Margins = new NMarginsL(10);
    chartAndLegend.DockMode = PanelDockMode.Fill;
    chartAndLegend.PositionChildPanelsInContentBounds = true;
    nChartControl1.Panels.Add(chartAndLegend);

    NLegend legend = new NLegend();
    legend.DockMode = PanelDockMode.Bottom;
    chartAndLegend.ChildPanels.Add(legend);

    NCartesianChart chart = new NCartesianChart();
    chart.BoundsMode = BoundsMode.Stretch;
    chartAndLegend.ChildPanels.Add(chart);
    chart.DisplayOnLegend = legend;

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

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



Best Regards,
Nevron Support Team



Devin Ellis
Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 2 Months Ago
Posts: 9, Visits: 81
I was able to use your code to set the legend inside the chart. Thanks for the help.



Similar Topics


Reading This Topic