Nevron Open Vision Documentation
Chart / Legend / Overview
In This Topic
    In This Topic

    NOV Chart for .NET has an integrated legend that can display various information about the chart. The flexible design of the integrated legend helps you to customize the displayed data and its appearance with ease.

    The legend is represented by the NLegend class. You can have an unlimited number of legends inside a chart view surface. By default the chart will create a single legend linked to a single chart if you use CreatePredefinedChart method of the NChartViewSurface object.

     Obtaining a Reference to Existing Legend

    When you create a predefined chart type (Cartesian, Polar, Pie etc) you can obtain a reference to the to the legend using the Legends property of the NChartViewSurface object:

    Copy Code

    NChartView chartView = new NChartView();


    NLegend legend = chartView.Surface.Legends[0];

    NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];

    The above code shows how to obtain a reference to the created default cartesian chart and its associated legend object.

     Creating a New Legend

    Some charts require multiple legends as well as different legend positions. In such cases you can populate the chart view surface with code. The following code snippet shows how to create a cartesian chart with a legend that is docked to the top right corner of its plot area:

    Copy Code

    NChartView chartView = new NChartView();

    // create a dock panel with label and chart
    NDockPanel dockPanel = new NDockPanel();
    chartView.Surface.Content = dockPanel;

    // crete a docked label
    NLabel label = new NLabel();
    label.Text =
    "Legend in Plot Area";
    label.Margins =
    new NMargins(10);
    NDockLayout.SetDockArea(label, ENDockArea.Top);

    // create a new cartesian chart
    NCartesianChart chart = new NCartesianChart();
    NDockLayout.SetDockArea(chart, ENDockArea.Center);

    NLegend legend = new NLegend();
    legend.HorizontalPlacement =
    legend.BackgroundFill =
    new NColorFill(NColor.FromColor(NColor.White, 0.5f));
    NDockLayout.SetDockArea(legend, ENDockArea.Top);

    chart.Content = legend;
    chart.Legend = legend;

    NBarSeries bar = new NBarSeries();
    new NBarDataPoint(10));
    new NBarDataPoint(18));
    new NBarDataPoint(25));


    See Also