This example illustrates how to create a XYZ scatter cluster stack bar chart..

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Chart.Tools;
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 - NXYZScatterClusterStackBarExample";
// 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 = "XYZ Scatter Cluster Stack";
// configure chart
m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.Standard);
// configure title
chartView.Surface.Titles[0].Text = "XYZ Scatter Cluster Stack Bar";
// set predefined projection and lighting
m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted);
m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight);
m_Chart.ModelWidth = 50;
m_Chart.ModelHeight = 35;
m_Chart.ModelDepth = 50;
m_Chart.Enable3D = true;
m_Chart.Interactor = new NInteractor(new NTrackballTool());
// configure the axes
NLinearScale linearScale = new NLinearScale();
m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = linearScale;
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, true);
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, true);
linearScale = new NLinearScale();
m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale = linearScale;
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, true);
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, true);
// add interlace stripes to the Y axis
NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
stripStyle.SetShowAtWall(ENChartWall.Back, true);
stripStyle.SetShowAtWall(ENChartWall.Left, true);
stripStyle.Interlaced = true;
linearScale.Strips.Add(stripStyle);
linearScale = new NLinearScale();
m_Chart.Axes[ENCartesianAxis.Depth].Scale = new NOrdinalScale();
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, true);
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, true);
AddBarSeries(m_Chart, ENMultiBarMode.Series);
AddBarSeries(m_Chart, ENMultiBarMode.Stacked);
AddBarSeries(m_Chart, ENMultiBarMode.Clustered);
AddBarSeries(m_Chart, ENMultiBarMode.Stacked);
OnNewDataButtonClick(null);
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel propertyStack = new NStackPanel();
NUniSizeBoxGroup boxGroup = new NUniSizeBoxGroup(propertyStack);
NButton newDataButton = new NButton("New Data");
newDataButton.Click += OnNewDataButtonClick;
propertyStack.Add(newDataButton);
return boxGroup;
}
public string GetExampleDescription()
{
return @"This example illustrates how to create a XYZ scatter cluster stack bar chart..
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Bar Series", "https://www.nevron.com/docs/openvision/bar-chart-series.html"),
("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"),
("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"),
("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"),
("Linear Scale", "https://www.nevron.com/docs/openvision/linear-scale.html"),
};
}
#endregion
#region Implementation
private void AddBarSeries(NCartesianChart chart, ENMultiBarMode mode)
{
NBarSeries bar = new NBarSeries();
chart.Series.Add(bar);
bar.WidthSizeMode = ENBarSizeMode.Fixed;
bar.DepthSizeMode = ENBarSizeMode.Fixed;
bar.MultiBarMode = mode;
bar.UseXValues = true;
bar.UseZValues = true;
bar.InflateMargins = true;
}
///
/// Creates a new data label style object
///
///
private NDataLabelStyle CreateDataLabelStyle()
{
NDataLabelStyle dataLabelStyle = new NDataLabelStyle();
dataLabelStyle.Format = "";
return dataLabelStyle;
}
void GenerateXYZData(NBarSeries bar)
{
bar.DataPoints.Clear();
Random random = new Random();
for (int i = 0; i < c_DataPointCount; i++)
{
NBarDataPoint dataPoint = new NBarDataPoint();
dataPoint.X = random.NextDouble() * 5;
dataPoint.Z = random.NextDouble() * 5;
dataPoint.Y = random.NextDouble();
bar.DataPoints.Add(dataPoint);
}
}
void GenerateYData(NBarSeries bar)
{
bar.DataPoints.Clear();
Random random = new Random();
for (int i = 0; i < c_DataPointCount; i++)
{
bar.DataPoints.Add(new NBarDataPoint(random.NextDouble()));
}
}
#endregion
#region Event Handlers
private void OnNewDataButtonClick(NEventArgs arg)
{
for (int i = 0; i < m_Chart.Series.Count; i++)
{
NBarSeries bar = (NBarSeries)m_Chart.Series[i];
if (i == 0)
{
// the master series needs Y, X and Z values
GenerateXYZData(bar);
}
else
{
// the other series need only Y values
GenerateYData(bar);
}
}
}
#endregion
#region Fields
NCartesianChart m_Chart;
#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.Chart.Tools
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 - NXYZScatterClusterStackBarExample"
' 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 = "XYZ Scatter Cluster Stack"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.Standard)
' configure title
chartView.Surface.Titles(0).Text = "XYZ Scatter Cluster Stack Bar"
' set predefined projection and lighting
m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted)
m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.BrightCameraLight)
m_Chart.ModelWidth = 50
m_Chart.ModelHeight = 35
m_Chart.ModelDepth = 50
m_Chart.Enable3D = True
m_Chart.Interactor = New NInteractor(New NTrackballTool())
' configure the axes
Dim linearScale As NLinearScale = New NLinearScale()
m_Chart.Axes(ENCartesianAxis.PrimaryX).Scale = linearScale
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, True)
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, True)
linearScale = New NLinearScale()
m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale = linearScale
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, True)
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, True)
' add interlace stripes to the Y axis
Dim stripStyle As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
stripStyle.SetShowAtWall(ENChartWall.Back, True)
stripStyle.SetShowAtWall(ENChartWall.Left, True)
stripStyle.Interlaced = True
linearScale.Strips.Add(stripStyle)
linearScale = New NLinearScale()
m_Chart.Axes(ENCartesianAxis.Depth).Scale = New NOrdinalScale()
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, True)
linearScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, True)
AddBarSeries(m_Chart, ENMultiBarMode.Series)
AddBarSeries(m_Chart, ENMultiBarMode.Stacked)
AddBarSeries(m_Chart, ENMultiBarMode.Clustered)
AddBarSeries(m_Chart, ENMultiBarMode.Stacked)
OnNewDataButtonClick(Nothing)
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim propertyStack As NStackPanel = New NStackPanel()
Dim boxGroup As NUniSizeBoxGroup = New NUniSizeBoxGroup(propertyStack)
Dim newDataButton As NButton = New NButton("New Data")
newDataButton.Click += AddressOf OnNewDataButtonClick
propertyStack.Add(newDataButton)
Return boxGroup
End Function
Public Function GetExampleDescription() As String
Return "This example illustrates how to create a XYZ scatter cluster stack bar chart..
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Bar Series", "https://www.nevron.com/docs/openvision/bar-chart-series.html"), ("Common Series Functionality", "https://www.nevron.com/docs/openvision/chart-common-series-functionality.html"), ("3D Charts", "https://www.nevron.com/docs/openvision/3d-charts.html"), ("Cartesian Axes", "https://www.nevron.com/docs/openvision/cartesian-chart-axes.html"), ("Linear Scale", "https://www.nevron.com/docs/openvision/linear-scale.html")}
End Function
#End Region
#Region "Implementation"
Private Sub AddBarSeries(chart As NCartesianChart, mode As ENMultiBarMode)
Dim bar As NBarSeries = New NBarSeries()
chart.Series.Add(bar)
bar.WidthSizeMode = ENBarSizeMode.Fixed
bar.DepthSizeMode = ENBarSizeMode.Fixed
bar.MultiBarMode = mode
bar.UseXValues = True
bar.UseZValues = True
bar.InflateMargins = True
End Sub
'''
''' Creates a new data label style object
'''
'''
Private Function CreateDataLabelStyle() As NDataLabelStyle
Dim dataLabelStyle As NDataLabelStyle = New NDataLabelStyle()
dataLabelStyle.Format = ""
Return dataLabelStyle
End Function
Private Sub GenerateXYZData(bar As NBarSeries)
bar.DataPoints.Clear()
Dim random As Random = New Random()
For i = 0 To c_DataPointCount - 1
Dim dataPoint As NBarDataPoint = New NBarDataPoint()
dataPoint.X = random.NextDouble() * 5
dataPoint.Z = random.NextDouble() * 5
dataPoint.Y = random.NextDouble()
bar.DataPoints.Add(dataPoint)
Next
End Sub
Private Sub GenerateYData(bar As NBarSeries)
bar.DataPoints.Clear()
Dim random As Random = New Random()
For i = 0 To c_DataPointCount - 1
bar.DataPoints.Add(New NBarDataPoint(random.NextDouble()))
Next
End Sub
#End Region
#Region "Event Handlers"
Private Sub OnNewDataButtonClick(arg As NEventArgs)
For i = 0 To m_Chart.Series.Count - 1
Dim bar = CType(m_Chart.Series(i), NBarSeries)
If i = 0 Then
' the master series needs Y, X and Z values
GenerateXYZData(bar)
Else
' the other series need only Y values
GenerateYData(bar)
End If
Next
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