private void LoadView() { // Paste your license key here. mNChartView.Chart.LicenseKey = ""; // Margin to ensure some free space for the iOS status bar. mNChartView.Chart.CartesianSystem.Margin = new NChartMargin(10.0f, 10.0f, 10.0f, 20.0f); // We'll use 3D chart. mNChartView.Chart.DrawIn3D = true; // Create series that will be displayed on the chart. NChartSurfaceSeries series = new NChartSurfaceSeries(); // Set data source for the series. series.DataSource = this; // Add series to the chart. mNChartView.Chart.AddSeries(series); // Create brush scale for series. // First create an array of solid color brushes with the scale colors. NChartBrush[] brushes = { new NChartSolidColorBrush(Color.Red), new NChartSolidColorBrush(Color.Yellow), new NChartSolidColorBrush(Color.Green), new NChartSolidColorBrush(Color.Cyan) }; // Then create array of values that will indicate intervals to choose colors. Note, that the rule of getting brush // from the scale for given value x is: // if x <= values[0] then choose brush[0] // else if x > values[i] and x <= values[i + 1] then choose brush[i + 1], i = 0 .. n - 1, n is number of values // else if x > values[n - 1] then choose brush[n] // This is why array of brushes should have one more element than array of values. Number[] values = { (Number)(-0.5), (Number)(0.0), (Number)(0.5) }; // Now create the brush scale itself. NChartBrushScale scale = new NChartBrushScale(brushes, values); // If you want smooth color transitions, let this line commented. // scale.IsGradient = false; // Assign the scale to the series. series.Scale = scale; // You probably want to have a legend on the chart displaying the scale. So create one. NChartScaleLegend scaleLegend = new NChartScaleLegend(scale); // Let it be on the left. Feel free to experiment with different locations. scaleLegend.BlockAlignment = NChartLegendBlockAlignment.Left; // Let it have a single column. scaleLegend.ColumnCount = 1; // Set the delegate for the legend to customize the strings in the entries. Do not assign the delegate if the // default behavior is ok for you. scaleLegend.ScaleDelegate = this; // Add the legend to the chart. mNChartView.Chart.AddScaleLegend(scaleLegend); // Update data in the chart. mNChartView.Chart.UpdateData(); }
public override void LoadView() { // Create a chart view that will display the chart. m_view = new NChartView(); // Paste your license key here. m_view.Chart.LicenseKey = ""; // Switch on antialiasing. m_view.Chart.ShouldAntialias = true; // Margin to ensure some free space for the iOS status bar. m_view.Chart.CartesianSystem.Margin = new NChartMargin(10.0f, 10.0f, 10.0f, 20.0f); m_view.Chart.PolarSystem.Margin = new NChartMargin(10.0f, 10.0f, 10.0f, 20.0f); // Create series that will be displayed on the chart. NChartHeatmapSeries series = new NChartHeatmapSeries(); series.DataSource = this; series.Tag = 0; // Create brush scale. // See NChartBrushScale for details. series.Scale = NChartBrushScale.BrushScaleWithBrushes(brushes, new NSNumber[] { NSNumber.FromDouble(-0.3), NSNumber.FromDouble(0.3) }); m_view.Chart.AddSeries(series); m_view.Chart.CartesianSystem.XAxis.ShouldBeautifyMinAndMax = false; m_view.Chart.CartesianSystem.YAxis.ShouldBeautifyMinAndMax = false; // Update data in the chart. m_view.Chart.UpdateData(); // Set chart view to the controller. this.View = m_view; }