This example demonstrates how to create a XYZ scatter bubble 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 - NXYZScatterBubbleExample";
// 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 Bubble";
// configure chart
m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYZLinear);
// setup chart
m_Chart.Enable3D = true;
m_Chart.ModelWidth = 50;
m_Chart.ModelDepth = 50;
m_Chart.ModelHeight = 50;
m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted);
m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft);
m_Chart.Interactor = new NInteractor(new NTrackballTool());
NLinearScale depthScale = new NLinearScale();
depthScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
depthScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, true);
depthScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, true);
m_Chart.Axes[ENCartesianAxis.Depth].Scale = depthScale;
NLinearScale yScale = new NLinearScale();
yScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
yScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, true);
yScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, true);
// add interlace style
NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
strip.Interlaced = true;
strip.SetShowAtWall(ENChartWall.Back, true);
strip.SetShowAtWall(ENChartWall.Left, true);
strip.Interlaced = true;
yScale.Strips.Add(strip);
m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale = yScale;
// switch the x axis in linear mode
NLinearScale xScale = new NLinearScale();
xScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
xScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, true);
xScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, true);
m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = xScale;
m_Bubble = new NBubbleSeries();
m_Chart.Series.Add(m_Bubble);
m_Bubble.InflateMargins = true;
m_Bubble.Shape = ENPointShape3D.Sphere;
m_Bubble.LegendView.Format = "x: y: z: sz:";
m_Bubble.LegendView.Mode = ENSeriesLegendMode.DataPoints;
m_Bubble.MinSize = 20;
m_Bubble.MaxSize = 100;
m_Bubble.UseXValues = true;
m_Bubble.UseZValues = true;
chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.DataPoints));
OnChangeDataButtonClick(null);
return chartViewWithCommandBars;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NButton changeDataButton = new NButton("Change Data");
changeDataButton.Click += OnChangeDataButtonClick;
stack.Add(changeDataButton);
return stack;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to create a XYZ scatter bubble chart.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Bubble Series", "https://www.nevron.com/docs/openvision/bubble-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
#endregion
#region Event Handlers
///
///
///
///
void OnChangeDataButtonClick(NEventArgs arg)
{
Random random = new Random();
m_Bubble.DataPoints.Clear();
for (int i = 0; i < 6; i++)
{
NBubbleDataPoint dataPoint = new NBubbleDataPoint();
dataPoint.Value = random.Next(-100, 100);
dataPoint.X = random.Next(-100, 100);
dataPoint.Z = random.Next(-100, 100);
dataPoint.Size = random.NextDouble();
m_Bubble.DataPoints.Add(dataPoint);
}
}
#endregion
#region Fields
NBubbleSeries m_Bubble;
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 - NXYZScatterBubbleExample"
' 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 Bubble"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYZLinear)
' setup chart
m_Chart.Enable3D = True
m_Chart.ModelWidth = 50
m_Chart.ModelDepth = 50
m_Chart.ModelHeight = 50
m_Chart.Projection.SetPredefinedProjection(ENPredefinedProjection.PerspectiveTilted)
m_Chart.LightModel.SetPredefinedLightModel(ENPredefinedLightModel.GlitterLeft)
m_Chart.Interactor = New NInteractor(New NTrackballTool())
Dim depthScale As NLinearScale = New NLinearScale()
depthScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot
depthScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, True)
depthScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, True)
m_Chart.Axes(ENCartesianAxis.Depth).Scale = depthScale
Dim yScale As NLinearScale = New NLinearScale()
yScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot
yScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, True)
yScale.MajorGridLines.SetShowAtWall(ENChartWall.Left, True)
' add interlace style
Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
strip.Interlaced = True
strip.SetShowAtWall(ENChartWall.Back, True)
strip.SetShowAtWall(ENChartWall.Left, True)
strip.Interlaced = True
yScale.Strips.Add(strip)
m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale = yScale
' switch the x axis in linear mode
Dim xScale As NLinearScale = New NLinearScale()
xScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot
xScale.MajorGridLines.SetShowAtWall(ENChartWall.Bottom, True)
xScale.MajorGridLines.SetShowAtWall(ENChartWall.Back, True)
m_Chart.Axes(ENCartesianAxis.PrimaryX).Scale = xScale
m_Bubble = New NBubbleSeries()
m_Chart.Series.Add(m_Bubble)
m_Bubble.InflateMargins = True
m_Bubble.Shape = ENPointShape3D.Sphere
m_Bubble.LegendView.Format = "x: y: z: sz:"
m_Bubble.LegendView.Mode = ENSeriesLegendMode.DataPoints
m_Bubble.MinSize = 20
m_Bubble.MaxSize = 100
m_Bubble.UseXValues = True
m_Bubble.UseZValues = True
chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.DataPoints))
OnChangeDataButtonClick(Nothing)
Return chartViewWithCommandBars
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim changeDataButton As NButton = New NButton("Change Data")
changeDataButton.Click += AddressOf OnChangeDataButtonClick
stack.Add(changeDataButton)
Return stack
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to create a XYZ scatter bubble chart.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Bubble Series", "https://www.nevron.com/docs/openvision/bubble-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"
#End Region
#Region "Event Handlers"
'''
'''
'''
'''
Private Sub OnChangeDataButtonClick(arg As NEventArgs)
Dim random As Random = New Random()
m_Bubble.DataPoints.Clear()
For i = 0 To 5
Dim dataPoint As NBubbleDataPoint = New NBubbleDataPoint()
dataPoint.Value = random.Next(-100, 100)
dataPoint.X = random.Next(-100, 100)
dataPoint.Z = random.Next(-100, 100)
dataPoint.Size = random.NextDouble()
m_Bubble.DataPoints.Add(dataPoint)
Next
End Sub
#End Region
#Region "Fields"
Private m_Bubble As NBubbleSeries
Private m_Chart As NCartesianChart
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class