This example demonstrates how to create a table scale. The table scale is a type of categorical scale that allows the visualization of tabular data. It contains rows that show data for series in the chart or custom, user-specified data.

| 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 - NTableScaleExample";
// 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 = "Table Scale";
// configure chart
m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
// configure axes
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);
m_Chart.SetPredefinedInteractor(ENPredefinedInteractor.DataZoomingAndScrolling);
// configure the y axis
NLinearScale linearScale = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale;
NScaleGridLines majorGrid = new NScaleGridLines();
majorGrid.Stroke = new NStroke(1, NColor.DarkGray, ENDashStyle.Dot);
linearScale.MajorGridLines = majorGrid;
// add a strip line style
NScaleStrip strip = new NScaleStrip();
strip.Fill = new NColorFill(NColor.Beige);
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// add some random data
Random random = new Random();
// create two series with random data
NBarSeries alcoholSales = new NBarSeries();
alcoholSales.Name = "Alcohol";
alcoholSales.MultiBarMode = ENMultiBarMode.Stacked;
alcoholSales.DataLabelStyle = new NDataLabelStyle(false);
for (int i = 0; i < 12; i++)
{
alcoholSales.DataPoints.Add(new NBarDataPoint(random.Next(100), 12));
}
m_Chart.Series.Add(alcoholSales);
NBarSeries beveragesSales = new NBarSeries();
beveragesSales.Name = "Beverages";
beveragesSales.MultiBarMode = ENMultiBarMode.Stacked;
beveragesSales.DataLabelStyle = new NDataLabelStyle(false);
for (int i = 0; i < 12; i++)
{
beveragesSales.DataPoints.Add(new NBarDataPoint(random.Next(100)));
}
m_Chart.Series.Add(beveragesSales);
// setup X axis with table scale
NCartesianAxis axis = m_Chart.Axes[ENCartesianAxis.PrimaryX];
m_TableScale = new NTableScale();
axis.Scale = m_TableScale;
NCustomTableScaleRow customRow = new NCustomTableScaleRow();
customRow.Items = new NDomArray(new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
m_TableScale.Rows.Add(customRow);
for (int i = 0; i < m_Chart.Series.Count; i++)
{
NSeriesTableScaleRow row = new NSeriesTableScaleRow();
row.Series = m_Chart.Series[i];
m_TableScale.Rows.Add(row);
}
// Setup the stock series
chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.Series));
return chartViewWithCommandBars;
}
///
///
///
///
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(stack);
NCheckBox showRowInterlacingCheckBox = new NCheckBox("Show Row Interlacing");
showRowInterlacingCheckBox.CheckedChanged += OnShowRowInterlacingCheckBoxCheckedChanged;
stack.Add(showRowInterlacingCheckBox);
NCheckBox showColumnInterlacingCheckBox = new NCheckBox("Show Column Interlacing");
showColumnInterlacingCheckBox.CheckedChanged += OnShowColumnInterlacingCheckBoxCheckedChanged;
stack.Add(showColumnInterlacingCheckBox);
NCheckBox showLeftHeadersCheckBox = new NCheckBox("Show Left Headers");
showLeftHeadersCheckBox.CheckedChanged += OnShowLeftHeadersCheckBoxCheckedChanged;
showLeftHeadersCheckBox.Checked = false;
stack.Add(showLeftHeadersCheckBox);
NCheckBox showRightHeadersCheckBox = new NCheckBox("Show Right Headers");
showRightHeadersCheckBox.CheckedChanged += OnShowRightHeadersCheckBoxCheckedChanged;
showRightHeadersCheckBox.Checked = false;
stack.Add(showRightHeadersCheckBox);
NComboBox labelFormatComboBox = new NComboBox();
labelFormatComboBox.SelectedIndexChanged += OnLabelFormatComboBoxSelectedIndexChanged;
stack.Add(NPairBox.Create("Label Format:", labelFormatComboBox));
// init form controls
showRowInterlacingCheckBox.Checked = true;
showColumnInterlacingCheckBox.Checked = true;
showLeftHeadersCheckBox.Checked = true;
labelFormatComboBox.Items.Add("");
labelFormatComboBox.Items.Add("");
labelFormatComboBox.SelectedIndex = 0;
return boxGroup;
}
///
///
///
///
public string GetExampleDescription()
{
return @"This example demonstrates how to create a table scale. The table scale is a type of categorical scale that allows the visualization of tabular data. It contains rows that show data for series in the chart or custom, user-specified data.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Table Scale", "https://www.nevron.com/docs/openvision/table-scale.html"),
("Ordinal Scale", "https://www.nevron.com/docs/openvision/ordinal-scale.html"),
("Label Formatting", "https://www.nevron.com/docs/openvision/chart-label-formatting.html"),
("Chart Data Series", "https://www.nevron.com/docs/openvision/chart-data-series.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
///
///
///
///
private void OnShowRowInterlacingCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
// row interlacing
if ((bool)arg.NewValue)
{
NTableInterlaceStyle interlaceStyle = new NTableInterlaceStyle();
interlaceStyle.Type = ENTableInterlaceStyleType.Row;
interlaceStyle.Length = 1;
interlaceStyle.Interval = 1;
interlaceStyle.Fill = new NColorFill(NColor.FromColor(NColor.Beige, 124));
m_TableScale.InterlaceStyles.Add(interlaceStyle);
}
else
{
for (int i = m_TableScale.InterlaceStyles.Count - 1; i >= 0; i--)
{
NTableInterlaceStyle interlaceStyle = m_TableScale.InterlaceStyles[i];
if (interlaceStyle.Type == ENTableInterlaceStyleType.Row)
{
m_TableScale.InterlaceStyles.RemoveAt(i);
break;
}
}
}
}
///
///
///
///
private void OnShowColumnInterlacingCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
// col interlacing
if ((bool)arg.NewValue)
{
NTableInterlaceStyle interlaceStyle = new NTableInterlaceStyle();
interlaceStyle.Type = ENTableInterlaceStyleType.Column;
interlaceStyle.Length = 1;
interlaceStyle.Interval = 1;
interlaceStyle.Fill = new NColorFill(NColor.FromColor(NColor.Red, 124));
m_TableScale.InterlaceStyles.Add(interlaceStyle);
}
else
{
for (int i = m_TableScale.InterlaceStyles.Count - 1; i >= 0; i--)
{
NTableInterlaceStyle interlaceStyle = m_TableScale.InterlaceStyles[i];
if (interlaceStyle.Type == ENTableInterlaceStyleType.Column)
{
m_TableScale.InterlaceStyles.RemoveAt(i);
break;
}
}
}
}
///
///
///
///
private void OnShowLeftHeadersCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
for (int i = 0; i < m_TableScale.Rows.Count; i++)
{
NSeriesTableScaleRow seriesRow = m_TableScale.Rows[i] as NSeriesTableScaleRow;
if (seriesRow != null)
{
seriesRow.ShowLeftRowHeader = (bool)arg.NewValue;
}
}
}
///
///
///
///
private void OnShowRightHeadersCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
for (int i = 0; i < m_TableScale.Rows.Count; i++)
{
NSeriesTableScaleRow seriesRow = m_TableScale.Rows[i] as NSeriesTableScaleRow;
if (seriesRow != null)
{
seriesRow.ShowRightRowHeader = (bool)arg.NewValue;
}
}
}
///
///
///
///
private void OnLabelFormatComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
switch ((int)arg.NewValue)
{
case 0: // value
for (int i = 0; i < m_Chart.Series.Count; i++)
{
NSeries series = m_Chart.Series[i];
series.LegendView.Format = "";
}
break;
case 1: // percent
for (int i = 0; i < m_Chart.Series.Count; i++)
{
NSeries series = m_Chart.Series[i];
series.LegendView.Format = "";
}
break;
default:
NDebug.Assert(false);
break;
}
}
#endregion
#region Fields
NCartesianChart m_Chart;
NTableScale m_TableScale;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
} | 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.Wpf
Imports System
Class MainWindow
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Title = "NOV WPF - NTableScaleExample"
' 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)
Content = 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 = "Table Scale"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
' configure axes
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear)
m_Chart.SetPredefinedInteractor(ENPredefinedInteractor.DataZoomingAndScrolling)
' configure the y axis
Dim linearScale As NLinearScale = m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale
Dim majorGrid As NScaleGridLines = New NScaleGridLines()
majorGrid.Stroke = New NStroke(1, NColor.DarkGray, ENDashStyle.Dot)
linearScale.MajorGridLines = majorGrid
' add a strip line style
Dim strip As NScaleStrip = New NScaleStrip()
strip.Fill = New NColorFill(NColor.Beige)
strip.Interlaced = True
linearScale.Strips.Add(strip)
' add some random data
Dim random As Random = New Random()
' create two series with random data
Dim alcoholSales As NBarSeries = New NBarSeries()
alcoholSales.Name = "Alcohol"
alcoholSales.MultiBarMode = ENMultiBarMode.Stacked
alcoholSales.DataLabelStyle = New NDataLabelStyle(False)
For i = 0 To 11
alcoholSales.DataPoints.Add(New NBarDataPoint(random.Next(100), 12))
Next
m_Chart.Series.Add(alcoholSales)
Dim beveragesSales As NBarSeries = New NBarSeries()
beveragesSales.Name = "Beverages"
beveragesSales.MultiBarMode = ENMultiBarMode.Stacked
beveragesSales.DataLabelStyle = New NDataLabelStyle(False)
For i = 0 To 11
beveragesSales.DataPoints.Add(New NBarDataPoint(random.Next(100)))
Next
m_Chart.Series.Add(beveragesSales)
' setup X axis with table scale
Dim axis = m_Chart.Axes(ENCartesianAxis.PrimaryX)
m_TableScale = New NTableScale()
axis.Scale = m_TableScale
Dim customRow As NCustomTableScaleRow = New NCustomTableScaleRow()
customRow.Items = New NDomArray(Of String)(New String() {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"})
m_TableScale.Rows.Add(customRow)
For i = 0 To m_Chart.Series.Count - 1
Dim row As NSeriesTableScaleRow = New NSeriesTableScaleRow()
row.Series = m_Chart.Series(i)
m_TableScale.Rows.Add(row)
Next
' Setup the stock series
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)
Dim showRowInterlacingCheckBox As NCheckBox = New NCheckBox("Show Row Interlacing")
showRowInterlacingCheckBox.CheckedChanged += AddressOf OnShowRowInterlacingCheckBoxCheckedChanged
stack.Add(showRowInterlacingCheckBox)
Dim showColumnInterlacingCheckBox As NCheckBox = New NCheckBox("Show Column Interlacing")
showColumnInterlacingCheckBox.CheckedChanged += AddressOf OnShowColumnInterlacingCheckBoxCheckedChanged
stack.Add(showColumnInterlacingCheckBox)
Dim showLeftHeadersCheckBox As NCheckBox = New NCheckBox("Show Left Headers")
showLeftHeadersCheckBox.CheckedChanged += AddressOf OnShowLeftHeadersCheckBoxCheckedChanged
showLeftHeadersCheckBox.Checked = False
stack.Add(showLeftHeadersCheckBox)
Dim showRightHeadersCheckBox As NCheckBox = New NCheckBox("Show Right Headers")
showRightHeadersCheckBox.CheckedChanged += AddressOf OnShowRightHeadersCheckBoxCheckedChanged
showRightHeadersCheckBox.Checked = False
stack.Add(showRightHeadersCheckBox)
Dim labelFormatComboBox As NComboBox = New NComboBox()
labelFormatComboBox.SelectedIndexChanged += AddressOf OnLabelFormatComboBoxSelectedIndexChanged
stack.Add(NPairBox.Create("Label Format:", labelFormatComboBox))
' init form controls
showRowInterlacingCheckBox.Checked = True
showColumnInterlacingCheckBox.Checked = True
showLeftHeadersCheckBox.Checked = True
labelFormatComboBox.Items.Add("")
labelFormatComboBox.Items.Add("")
labelFormatComboBox.SelectedIndex = 0
Return boxGroup
End Function
'''
'''
'''
'''
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create a table scale. The table scale is a type of categorical scale that allows the visualization of tabular data. It contains rows that show data for series in the chart or custom, user-specified data.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Table Scale", "https://www.nevron.com/docs/openvision/table-scale.html"), ("Ordinal Scale", "https://www.nevron.com/docs/openvision/ordinal-scale.html"), ("Label Formatting", "https://www.nevron.com/docs/openvision/chart-label-formatting.html"), ("Chart Data Series", "https://www.nevron.com/docs/openvision/chart-data-series.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
'''
'''
'''
'''
Private Sub OnShowRowInterlacingCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
' row interlacing
If arg.NewValue Then
Dim interlaceStyle As NTableInterlaceStyle = New NTableInterlaceStyle()
interlaceStyle.Type = ENTableInterlaceStyleType.Row
interlaceStyle.Length = 1
interlaceStyle.Interval = 1
interlaceStyle.Fill = New NColorFill(NColor.FromColor(NColor.Beige, 124))
m_TableScale.InterlaceStyles.Add(interlaceStyle)
Else
For i = m_TableScale.InterlaceStyles.Count - 1 To 0 Step -1
Dim interlaceStyle = m_TableScale.InterlaceStyles(i)
If interlaceStyle.Type Is ENTableInterlaceStyleType.Row Then
m_TableScale.InterlaceStyles.RemoveAt(i)
Exit For
End If
Next
End If
End Sub
'''
'''
'''
'''
Private Sub OnShowColumnInterlacingCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
' col interlacing
If arg.NewValue Then
Dim interlaceStyle As NTableInterlaceStyle = New NTableInterlaceStyle()
interlaceStyle.Type = ENTableInterlaceStyleType.Column
interlaceStyle.Length = 1
interlaceStyle.Interval = 1
interlaceStyle.Fill = New NColorFill(NColor.FromColor(NColor.Red, 124))
m_TableScale.InterlaceStyles.Add(interlaceStyle)
Else
For i = m_TableScale.InterlaceStyles.Count - 1 To 0 Step -1
Dim interlaceStyle = m_TableScale.InterlaceStyles(i)
If interlaceStyle.Type Is ENTableInterlaceStyleType.Column Then
m_TableScale.InterlaceStyles.RemoveAt(i)
Exit For
End If
Next
End If
End Sub
'''
'''
'''
'''
Private Sub OnShowLeftHeadersCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
For i = 0 To m_TableScale.Rows.Count - 1
Dim seriesRow As NSeriesTableScaleRow = TryCast(m_TableScale.Rows(i), NSeriesTableScaleRow)
If seriesRow IsNot Nothing Then
seriesRow.ShowLeftRowHeader = CBool(arg.NewValue)
End If
Next
End Sub
'''
'''
'''
'''
Private Sub OnShowRightHeadersCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
For i = 0 To m_TableScale.Rows.Count - 1
Dim seriesRow As NSeriesTableScaleRow = TryCast(m_TableScale.Rows(i), NSeriesTableScaleRow)
If seriesRow IsNot Nothing Then
seriesRow.ShowRightRowHeader = CBool(arg.NewValue)
End If
Next
End Sub
'''
'''
'''
'''
Private Sub OnLabelFormatComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
Select Case arg.NewValue
Case 0 ' value
For i = 0 To m_Chart.Series.Count - 1
Dim series As NSeries = m_Chart.Series(i)
series.LegendView.Format = ""
Next
Case 1 ' percent
For i = 0 To m_Chart.Series.Count - 1
Dim series As NSeries = m_Chart.Series(i)
series.LegendView.Format = ""
Next
Case Else
NDebug.Assert(False)
End Select
End Sub
#End Region
#Region "Fields"
Private m_Chart As NCartesianChart
Private m_TableScale As NTableScale
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class