Scale Ruler Palette Example for WinForms

Nevron NOV Chart for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms Chart examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Scale Ruler Palette Example for WinForms Description

This example demonstrates how to apply a palette on the axis ruler and to use this palette to synchronize the filling of several series.


Scale Ruler Palette Example

C# Scale Ruler Palette Example Code for Nevron Chart for WinForms
Language: C#

using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NScaleRulerPaletteExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		public NWidget CreateExampleContent()
		{
			NChartViewWithCommandBars chartViewWithCommandBars = new NChartViewWithCommandBars();
			NChartView chartView = chartViewWithCommandBars.View;
			chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);

			// configure title
			chartView.Surface.Titles[0].Text = "Scale Ruler Palette";

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.Padding = new NMargins(20);

            // configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

			// feed some random data 
			NBarSeries bar = new NBarSeries();
            bar.UseXValues = false;
            bar.DataLabelStyle = new NDataLabelStyle(false);
			bar.Palette = new NAxisPalette();

            // fill in some random data
            Random random = new Random();

			for (int i = 0; i < 30; i++)
			{
                bar.DataPoints.Add(new NBarDataPoint(5 + random.Next(90)));
			}

            m_Chart.Series.Add(bar);

			// apply palette to the Y axis
			NScaleRuler ruler = m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Ruler;
            ruler.Palette = new NRangeMultiColorPalette();
			ruler.Height = 10;
            ruler.Shape = ENScaleRulerShape.PaletteBar;

			chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series));

			return chartViewWithCommandBars;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);

            return boxGroup;
		}

        public string GetExampleDescription()
		{
			return @"

This example demonstrates how to apply a palette on the axis ruler and to use this palette to synchronize the filling of several series.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Scales Overview", "https://www.nevron.com/docs/openvision/scales-overview.html"), ("chart-palettes", "https://www.nevron.com/docs/openvision/chart-palettes.html"), ("Stroke", "https://www.nevron.com/docs/openvision/graphics-stroke.html"), }; } #endregion #region Implementation #endregion #region Event Handlers private void OnEnable3DCheckBoxCheckedChanged(NValueChangeEventArgs arg) { m_Chart.Enable3D = (bool)arg.NewValue; } #endregion #region Fields NCartesianChart m_Chart; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Scale Ruler Palette Example for WinForms Solution

VB.NET Scale Ruler Palette Example Code for Nevron Chart for WinForms
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms
Imports System

Public Class Form1

#Region "Constructors"

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        ' Set form title
        Text = "NOV WinForms - NScaleRulerPaletteExample"

        ' Create the NOV example and its controls
        Dim exampleContent As NWidget = CreateExampleContent()
        Dim exampleControls As NWidget = CreateExampleControls()
        If Not exampleControls Is Nothing Then
            exampleControls.PreferredWidth = 300
        End If

        ' Place the example and its controls in a pair box
        Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
        pairBox.FillMode = ENStackFillMode.First
        pairBox.FitMode = ENStackFitMode.First
        pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

        ' Host the example in the form
        Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
        host.Dock = DockStyle.Fill
        Controls.Add(host)
    End Sub


#End Region

#Region "Example"

        Public Function CreateExampleContent() As NWidget
            Dim chartViewWithCommandBars As NChartViewWithCommandBars = New NChartViewWithCommandBars()
            Dim chartView = chartViewWithCommandBars.View
            chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian)

            ' configure title
            chartView.Surface.Titles(0).Text = "Scale Ruler Palette"

            ' configure chart
            m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
            m_Chart.Padding = New NMargins(20)

            ' configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear)

            ' feed some random data 
            Dim bar As NBarSeries = New NBarSeries()
            bar.UseXValues = False
            bar.DataLabelStyle = New NDataLabelStyle(False)
            bar.Palette = New NAxisPalette()

            ' fill in some random data
            Dim random As Random = New Random()

            For i = 0 To 29
                bar.DataPoints.Add(New NBarDataPoint(5 + random.Next(90)))
            Next

            m_Chart.Series.Add(bar)

            ' apply palette to the Y axis
            Dim ruler As NScaleRuler = m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale.Ruler
            ruler.Palette = New NRangeMultiColorPalette()
            ruler.Height = 10
            ruler.Shape = ENScaleRulerShape.PaletteBar

            chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series))

            Return chartViewWithCommandBars
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()
            Dim boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)

            Return boxGroup
        End Function

        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to apply a palette on the axis ruler and to use this palette to synchronize the filling of several series.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Scales Overview", "https://www.nevron.com/docs/openvision/scales-overview.html"), ("chart-palettes", "https://www.nevron.com/docs/openvision/chart-palettes.html"), ("Stroke", "https://www.nevron.com/docs/openvision/graphics-stroke.html")} End Function #End Region #Region "Implementation" #End Region #Region "Event Handlers" Private Sub OnEnable3DCheckBoxCheckedChanged(arg As NValueChangeEventArgs) m_Chart.Enable3D = CBool(arg.NewValue) End Sub #End Region #Region "Fields" Private m_Chart As NCartesianChart #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Scale Ruler Palette Example for WinForms Solution

Related Documentation Links