Standard Bubble 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.

Standard Bubble Example for WinForms Description

This example demonstrates how to create a standard bubble chart.


Standard Bubble Example

C# Standard Bubble 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.Windows.Forms;

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

		public Form1()
		{
			InitializeComponent();

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

			// 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 = "Standard Bubble";

			// 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"));

			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 bubbleShapeComboBox = new NComboBox();
			bubbleShapeComboBox.Items.FillFromEnum();
			bubbleShapeComboBox.SelectedIndexChanged += OnBubbleShapeComboBoxSelectedIndexChanged;
			stack.Add(NPairBox.Create("Bubble Shape: ", bubbleShapeComboBox));
			bubbleShapeComboBox.SelectedIndex = (int)ENPointShape3D.Ellipse;

			NNumericUpDown minBubbleSizeUpDown = new NNumericUpDown();
			minBubbleSizeUpDown.ValueChanged += OnMinBubbleSizeUpDownValueChanged;
			stack.Add(NPairBox.Create("Min Bubble Size:", minBubbleSizeUpDown));
			minBubbleSizeUpDown.Value = 50;

			NNumericUpDown maxBubbleSizeUpDown = new NNumericUpDown();
			maxBubbleSizeUpDown.ValueChanged += OnMaxBubbleSizeUpDownValueChanged;
			stack.Add(NPairBox.Create("Max Bubble Size:", maxBubbleSizeUpDown));
			maxBubbleSizeUpDown.Value = 200;

			NCheckBox inflateMarginsCheckBox = new NCheckBox();
			inflateMarginsCheckBox.CheckedChanged += OnInflateMarginsCheckBoxCheckedChanged;
            inflateMarginsCheckBox.Checked = true;
			stack.Add(NPairBox.Create("Inflate Margins: ", inflateMarginsCheckBox));

			NComboBox legendFormatComboBox = CreateLegendFormatCombo();
			legendFormatComboBox.SelectedIndexChanged += OnLegendFormatComboBoxSelectedIndexChanged;
			stack.Add(NPairBox.Create("Legend Format:", legendFormatComboBox));

			return group;
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to create a standard 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"), }; } #endregion #region Implementation private NComboBox CreateLegendFormatCombo() { NComboBox comboBox = new NComboBox(); NComboBoxItem item = new NComboBoxItem("Value and Label"); item.Tag = "

Download a fully functional C# (.cs) Standard Bubble Example for WinForms Solution

VB.NET Standard Bubble 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

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 - NStandardBubbleExample"

        ' 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 = "Standard Bubble"

            ' 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"))

            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 bubbleShapeComboBox As NComboBox = New NComboBox()
            bubbleShapeComboBox.Items.FillFromEnum(Of ENPointShape3D)()
            bubbleShapeComboBox.SelectedIndexChanged += AddressOf OnBubbleShapeComboBoxSelectedIndexChanged
            stack.Add(NPairBox.Create("Bubble Shape: ", bubbleShapeComboBox))
            bubbleShapeComboBox.SelectedIndex = CInt(ENPointShape3D.Ellipse)

            Dim minBubbleSizeUpDown As NNumericUpDown = New NNumericUpDown()
            minBubbleSizeUpDown.ValueChanged += AddressOf OnMinBubbleSizeUpDownValueChanged
            stack.Add(NPairBox.Create("Min Bubble Size:", minBubbleSizeUpDown))
            minBubbleSizeUpDown.Value = 50

            Dim maxBubbleSizeUpDown As NNumericUpDown = New NNumericUpDown()
            maxBubbleSizeUpDown.ValueChanged += AddressOf OnMaxBubbleSizeUpDownValueChanged
            stack.Add(NPairBox.Create("Max Bubble Size:", maxBubbleSizeUpDown))
            maxBubbleSizeUpDown.Value = 200

            Dim inflateMarginsCheckBox As NCheckBox = New NCheckBox()
            inflateMarginsCheckBox.CheckedChanged += AddressOf OnInflateMarginsCheckBoxCheckedChanged
            inflateMarginsCheckBox.Checked = True
            stack.Add(NPairBox.Create("Inflate Margins: ", inflateMarginsCheckBox))

            Dim legendFormatComboBox As NComboBox = CreateLegendFormatCombo()
            legendFormatComboBox.SelectedIndexChanged += AddressOf OnLegendFormatComboBoxSelectedIndexChanged
            stack.Add(NPairBox.Create("Legend Format:", legendFormatComboBox))

            Return group
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to create a standard 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")} End Function #End Region #Region "Implementation" Private Function CreateLegendFormatCombo() As NComboBox Dim comboBox As NComboBox = New NComboBox() Dim item As NComboBoxItem = New NComboBoxItem("Value and Label") item.Tag = "

Download a fully functional VB.NET (.vb) Standard Bubble Example for WinForms Solution

Related Documentation Links