Class NMathChart provides static methods for plotting NMath types using the Microsoft Chart Controls for .NET.

Namespace:  CenterSpace.NMath.Charting.Microsoft
Assembly:  NMathChartMicrosoft (in NMathChartMicrosoft.dll) Version: 5.1.0.0

Syntax

C#
public class NMathChart
Visual Basic (Declaration)
Public Class NMathChart
Visual C++
public ref class NMathChart

Remarks

Overloads of the ToChart() function are provided for common NMath types. ToChart() returns an instance of System.Windows.Forms.DataVisualization.Charting.Chart, which can be customized as desired.
CopyC#
Polynomial poly = new Polynomial( new DoubleVector( 4, 2, 5, -2, 3 ) );
Chart chart = NMathChart.ToChart( poly, -1, 1 );
chart.Titles.Add("Hello World");
The default look of the chart is governed by static properties on this class: DefaultSize, DefaultTitleFont, DefaultAxisTitleFont, DefaultMajorGridLineColor, and DefaultMarker.
For prototyping and debugging console applications, the Show() function shows a given chart in a default form.
CopyC#
NMathChart.Show( chart );
Note that when the window is closed, the chart is disposed.
If you do not need to customize the chart, overloads of Show() are also provided for common NMath types.
CopyC#
NMathChart.Show( poly );
This is equivalent to calling:
CopyC#
NMathChart.Show( NMathChart.ToChart( poly ) );
The Save() function saves a chart to a file or stream.
CopyC#
NMathChart.Save( chart, "chart.png", ChartImageFormat.Png );
If you are developing a Windows Forms application using the Designer, add a Microsoft Chart control to your form, then update it with an NMath object using the appropriate Update() function after initialization.
CopyC#
public Form1()
{
  InitializeComponent();

  Polynomial poly = new Polynomial( new DoubleVector( 4, 2, 5, -2, 3 ) );
  NMathChart.Update( ref this.chart1, poly, -1, 1 );
}
This has the following effect on your existing chart object: a new, default ChartArea is added if one does not exist, otherwise chart.ChartAreas[0] is used; axis titles, and DefaultAxisTitleFont and DefaultMajorGridLineColor, only have an effect if a new ChartArea is added; titles are added only if the given chart does not currently contain any titles; chart.Series[0] is replaced, or added if necessary.

Inheritance Hierarchy

System..::.Object
  CenterSpace.NMath.Charting.Microsoft..::.NMathChart
    CenterSpace.NMath.Charting.Microsoft..::.NMathStatsChart

See Also