Nevron .NET Vision Documentation
Creating Multiple Charts and Legends

So far we've been working with a single chart and legend which is the default configuration of Nevron Chart for .NET. You can create an unlimited number of charts and legends and display them in the control canvas. To accomplish this you must add new instances of NChart derived objects and NLegend objects to the Panels collection of the control.

Adding New Charts

You add a new chart by adding an instance of one of the following classes to the Panels collection of the control:

NCartesianChart
NPieChart
NPolarChart
NRadarChart
NVennChart

For example:

C#
Copy Code
NCartesianChart chart = new NCartesianChart();
chartControl.Panels.Add(chart);
Visual Basic
Copy Code
Dim chart As NCartesianChart =  New NCartesianChart()
chartControl.Panels.Add(chart)

By default there is always one Cartesian chart so you can always index the first chart in the Charts collection at startup:

C#
Copy Code
NCartesianChart chart = chartControl.Charts[0];
Visual Basic
Copy Code
Dim chart As NCartesianChart = chartControl.Charts(0)

After you add the chart to the control you can modify its DisplayOnLegend property, which defines the legend where series will place data (note that individual series may override this property):

C#
Copy Code
NChart chart2 = new NCartesianChart();
chartControl.Panels.Add(chart2);
chart2.DisplayOnLegend = chartControl.Legends[0];
Visual Basic
Copy Code
Dim chart2 As New NCartesianChart
chartControl.Panels.Add(chart2)
chart2.DisplayOnLegend = chartControl.Legends(0)

You can associate the one chart with only one legend, but one legend can have many associated charts displaying data on it. The legend mode should be set to Automatic otherwise the data supplied by the chart(s) will be discarded.

Adding New Legends

You add a new legend by adding an instance of the NLegend class to the Panels collection of the control. For example:

C#
Copy Code
NLegend legend = new NLegend();
chartControl.Panels.Add(legend);
Visual Basic
Copy Code
Dim legend As NLegend =  New NLegend()
chartControl.Panels.Add(legend)

The topics under the Layout book discuss in detail how to position the chart and legends in the control canvas.

Related Examples

Windows forms: Layout\Multiple Charts And Legends

Web forms: Layout\Multiple Charts And Legends

See Also

 

 


©2017. Nevron Software LLC.

Send Feedback