The example demonstrates how to display a bubble scale on the legend. This feature allows the user to have a visual representation of the bubble sizes.

| 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.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NBubbleSizeScaleExample";
// 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 = "Bubble Scale";
// configure chart
m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);
// configure the chart
NLinearScale yScale = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale;
yScale.MajorGridLines = new NScaleGridLines();
yScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
// add interlace stripe
NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);
strip.Interlaced = true;
yScale.Strips.Add(strip);
NOrdinalScale xScale = (NOrdinalScale)m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale;
xScale.MajorGridLines = new NScaleGridLines();
xScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot;
// add a bubble series
m_Bubble = new NBubbleSeries();
m_Bubble.DataLabelStyle = new NDataLabelStyle();
m_Bubble.DataLabelStyle.VertAlign = ENVerticalAlignment.Center;
m_Bubble.DataLabelStyle.Visible = false;
m_Bubble.LegendView.Mode = ENSeriesLegendMode.DataPoints;
m_Bubble.MinSize = 20;
m_Bubble.MaxSize = 100;
m_Bubble.Shape = ENPointShape3D.Sphere;
m_Bubble.DataPoints.Add(new NBubbleDataPoint(10, 10, "Company 1"));
m_Bubble.DataPoints.Add(new NBubbleDataPoint(15, 20, "Company 2"));
m_Bubble.DataPoints.Add(new NBubbleDataPoint(12, 25, "Company 3"));
m_Bubble.DataPoints.Add(new NBubbleDataPoint(8, 15, "Company 4"));
m_Bubble.DataPoints.Add(new NBubbleDataPoint(14, 17, "Company 5"));
m_Bubble.DataPoints.Add(new NBubbleDataPoint(11, 12, "Company 6"));
// configure legend
m_Bubble.LegendView.Mode = ENSeriesLegendMode.SeriesLogic;
NLegend legend = chartView.Surface.Legends[0];
legend.Header = new NLabel("Bubble Size Scale");
m_Chart.Series.Add(m_Bubble);
chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.DataPoints));
return chartViewWithCommandBars;
}
///
///
///
///
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NUniSizeBoxGroup group = new NUniSizeBoxGroup(stack);
NComboBox bubbleScaleMode = new NComboBox();
bubbleScaleMode.Items.FillFromEnum();
bubbleScaleMode.SelectedIndexChanged += OnBubbleScaleModeSelectedIndexChanged;
stack.Add(NPairBox.Create("Bubble Scale Mode: ", bubbleScaleMode));
NNumericUpDown textOffsetNumericUpDown = new NNumericUpDown();
textOffsetNumericUpDown.ValueChanged += OnTextOffsetNumericUpDownValueChanged;
stack.Add(NPairBox.Create("Text Offset:", textOffsetNumericUpDown));
m_TableCellOffsetNumericUpDown = new NNumericUpDown();
m_TableCellOffsetNumericUpDown.ValueChanged += OnTableCellOffsetNumericUpDownValueChanged;
stack.Add(NPairBox.Create("Table Cell Offset:", m_TableCellOffsetNumericUpDown));
NNumericUpDown bubleScaleStepsNumericUpDown = new NNumericUpDown();
bubleScaleStepsNumericUpDown.ValueChanged += OnBubleScaleStepsNumericUpDownValueChanged;
stack.Add(NPairBox.Create("Bubble Scale Steps: ", bubleScaleStepsNumericUpDown));
NCheckBox roundValuesCheckBox = new NCheckBox("Round Values:");
roundValuesCheckBox.CheckedChanged += OnRoundValuesCheckBoxCheckedChanged;
stack.Add(roundValuesCheckBox);
bubbleScaleMode.SelectedIndex = (int)ENBubbleSizeScaleMode.ConcentricUp;
textOffsetNumericUpDown.Value = 0;
m_TableCellOffsetNumericUpDown.Value = 5;
bubleScaleStepsNumericUpDown.Value = 2;
roundValuesCheckBox.Checked = true;
return group;
}
private void OnRoundValuesCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_Bubble.SizeScale.RoundValues = (bool)arg.NewValue;
}
private void OnBubleScaleStepsNumericUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Bubble.SizeScale.Steps = (int)(double)arg.NewValue;
}
private void OnTableCellOffsetNumericUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Bubble.SizeScale.TableCellOffset = (double)arg.NewValue;
}
private void OnTextOffsetNumericUpDownValueChanged(NValueChangeEventArgs arg)
{
m_Bubble.SizeScale.TextOffset = (double)arg.NewValue;
}
private void OnBubbleScaleModeSelectedIndexChanged(NValueChangeEventArgs arg)
{
ENBubbleSizeScaleMode mode = (ENBubbleSizeScaleMode)arg.NewValue;
m_Bubble.SizeScale.Mode = mode;
m_TableCellOffsetNumericUpDown.Enabled = (mode == ENBubbleSizeScaleMode.TableAscending || mode == ENBubbleSizeScaleMode.TableDescending);
}
public string GetExampleDescription()
{
return @"The example demonstrates how to display a bubble scale on the legend. This feature allows the user to have a visual representation of the bubble sizes.
";
}
///
/// 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"),
("Overview", "https://www.nevron.com/docs/openvision/chart-legeng-overview.html"),
("Legend Layout", "https://www.nevron.com/docs/openvision/chart-legend-layout.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
#endregion
#region Fields
NBubbleSeries m_Bubble;
NCartesianChart m_Chart;
NNumericUpDown m_TableCellOffsetNumericUpDown;
#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
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 - NBubbleSizeScaleExample"
' 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 = "Bubble Scale"
' configure chart
m_Chart = CType(chartView.Surface.Charts(0), NCartesianChart)
m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear)
' configure the chart
Dim yScale As NLinearScale = m_Chart.Axes(ENCartesianAxis.PrimaryY).Scale
yScale.MajorGridLines = New NScaleGridLines()
yScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot
' add interlace stripe
Dim strip As NScaleStrip = New NScaleStrip(New NColorFill(NColor.Beige), Nothing, True, 0, 0, 1, 1)
strip.Interlaced = True
yScale.Strips.Add(strip)
Dim xScale As NOrdinalScale = m_Chart.Axes(ENCartesianAxis.PrimaryX).Scale
xScale.MajorGridLines = New NScaleGridLines()
xScale.MajorGridLines.Stroke.DashStyle = ENDashStyle.Dot
' add a bubble series
m_Bubble = New NBubbleSeries()
m_Bubble.DataLabelStyle = New NDataLabelStyle()
m_Bubble.DataLabelStyle.VertAlign = ENVerticalAlignment.Center
m_Bubble.DataLabelStyle.Visible = False
m_Bubble.LegendView.Mode = ENSeriesLegendMode.DataPoints
m_Bubble.MinSize = 20
m_Bubble.MaxSize = 100
m_Bubble.Shape = ENPointShape3D.Sphere
m_Bubble.DataPoints.Add(New NBubbleDataPoint(10, 10, "Company 1"))
m_Bubble.DataPoints.Add(New NBubbleDataPoint(15, 20, "Company 2"))
m_Bubble.DataPoints.Add(New NBubbleDataPoint(12, 25, "Company 3"))
m_Bubble.DataPoints.Add(New NBubbleDataPoint(8, 15, "Company 4"))
m_Bubble.DataPoints.Add(New NBubbleDataPoint(14, 17, "Company 5"))
m_Bubble.DataPoints.Add(New NBubbleDataPoint(11, 12, "Company 6"))
' configure legend
m_Bubble.LegendView.Mode = ENSeriesLegendMode.SeriesLogic
Dim legend = chartView.Surface.Legends(0)
legend.Header = New NLabel("Bubble Size Scale")
m_Chart.Series.Add(m_Bubble)
chartView.Document.StyleSheets.ApplyTheme(New NChartTheme(ENChartPalette.Bright, ENChartPaletteTarget.DataPoints))
Return chartViewWithCommandBars
End Function
'''
'''
'''
'''
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim group As NUniSizeBoxGroup = New NUniSizeBoxGroup(stack)
Dim bubbleScaleMode As NComboBox = New NComboBox()
bubbleScaleMode.Items.FillFromEnum(Of ENBubbleSizeScaleMode)()
bubbleScaleMode.SelectedIndexChanged += AddressOf OnBubbleScaleModeSelectedIndexChanged
stack.Add(NPairBox.Create("Bubble Scale Mode: ", bubbleScaleMode))
Dim textOffsetNumericUpDown As NNumericUpDown = New NNumericUpDown()
textOffsetNumericUpDown.ValueChanged += AddressOf OnTextOffsetNumericUpDownValueChanged
stack.Add(NPairBox.Create("Text Offset:", textOffsetNumericUpDown))
m_TableCellOffsetNumericUpDown = New NNumericUpDown()
Me.m_TableCellOffsetNumericUpDown.ValueChanged += AddressOf OnTableCellOffsetNumericUpDownValueChanged
stack.Add(NPairBox.Create("Table Cell Offset:", m_TableCellOffsetNumericUpDown))
Dim bubleScaleStepsNumericUpDown As NNumericUpDown = New NNumericUpDown()
bubleScaleStepsNumericUpDown.ValueChanged += AddressOf OnBubleScaleStepsNumericUpDownValueChanged
stack.Add(NPairBox.Create("Bubble Scale Steps: ", bubleScaleStepsNumericUpDown))
Dim roundValuesCheckBox As NCheckBox = New NCheckBox("Round Values:")
roundValuesCheckBox.CheckedChanged += AddressOf OnRoundValuesCheckBoxCheckedChanged
stack.Add(roundValuesCheckBox)
bubbleScaleMode.SelectedIndex = CInt(ENBubbleSizeScaleMode.ConcentricUp)
textOffsetNumericUpDown.Value = 0
m_TableCellOffsetNumericUpDown.Value = 5
bubleScaleStepsNumericUpDown.Value = 2
roundValuesCheckBox.Checked = True
Return group
End Function
Private Sub OnRoundValuesCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_Bubble.SizeScale.RoundValues = CBool(arg.NewValue)
End Sub
Private Sub OnBubleScaleStepsNumericUpDownValueChanged(arg As NValueChangeEventArgs)
m_Bubble.SizeScale.Steps = CInt(CDbl(arg.NewValue))
End Sub
Private Sub OnTableCellOffsetNumericUpDownValueChanged(arg As NValueChangeEventArgs)
m_Bubble.SizeScale.TableCellOffset = CDbl(arg.NewValue)
End Sub
Private Sub OnTextOffsetNumericUpDownValueChanged(arg As NValueChangeEventArgs)
m_Bubble.SizeScale.TextOffset = CDbl(arg.NewValue)
End Sub
Private Sub OnBubbleScaleModeSelectedIndexChanged(arg As NValueChangeEventArgs)
Dim mode As ENBubbleSizeScaleMode = arg.NewValue
m_Bubble.SizeScale.Mode = mode
m_TableCellOffsetNumericUpDown.Enabled = mode Is ENBubbleSizeScaleMode.TableAscending OrElse mode Is ENBubbleSizeScaleMode.TableDescending
End Sub
Public Function GetExampleDescription() As String
Return "The example demonstrates how to display a bubble scale on the legend. This feature allows the user to have a visual representation of the bubble sizes.
"
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"), ("Overview", "https://www.nevron.com/docs/openvision/chart-legeng-overview.html"), ("Legend Layout", "https://www.nevron.com/docs/openvision/chart-legend-layout.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
#End Region
#Region "Fields"
Private m_Bubble As NBubbleSeries
Private m_Chart As NCartesianChart
Private m_TableCellOffsetNumericUpDown As NNumericUpDown
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class