Bubble Chart (Bubble Chart) can be used to show three vb.net tutorials
The relationship between the variables. By plotting the x value, y value and size value, the coordinates and size of the bubble in the chart can be determined. The following shows how to create a bubble chart in Excel through the back-end C# code and VB.NET code exhibition c# tutorial .
Program environment:
Visual Studio
.Net FrameWork 4.5.1
Spire.XLS for .NET Version 10.12.0
Note: Before editing the code, add Spire.Xls.dll (the dll file can be obtained under the Bin folder of the Python basic tutorial compression package) and add a reference to it The VS program can be downloaded from the official website or Nuget. Refer to the following citation effects:
【C#】
using Spire.Xls;
using Spire.Xls.Charts;
using System.Drawing;
namespace CreateBubbleChart_XLS
{
class Program
{
static void Main(string[] args)
{
//创建一个Excel工作簿,并获取第一张工作表
Workbook wb = new Workbook();
wb.Version = ExcelVersion.Version2013;
Worksheet sheet = wb.Worksheets[0];
//添加图表,指定图表类型
Chart chart = sheet.Charts.Add();
chart.ChartType = ExcelChartType.Bubble;
chart.PrimaryCategoryAxis.Title = "人均消费";
chart.PrimaryValueAxis.Title = "点评数";
//设置图表的名称和数据
Spire.Xls.Charts.ChartSerie cs1 = chart.Series.Add("气泡图");
cs1.EnteredDirectlyValues = new object[]{
2, 5, 3, 6, 7};
cs1.EnteredDirectlyCategoryLabels = new object[]{
1, 4.5, 1.2, 3.3, 2};
cs1.EnteredDirectlyBubbles = new object[]{
3, 6, 1, 4, 7};
//设置图表位置
chart.LeftColumn = 4;
chart.TopRow = 2;
chart.RightColumn = 12;
chart.BottomRow = 22;
//设置图表标题
chart.ChartTitle = "人均消费VS点评数";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 12;
chart.Legend.Position = LegendPositionType.Top;
//保存文档
wb.SaveToFile("BubbleChart.xlsx", ExcelVersion.Version2013);
System.Diagnostics.Process.Start("BubbleChart.xlsx");
}
}
}
Bubble chart effect:
【vb.net】
Imports Spire.Xls
Imports Spire.Xls.Charts
Imports System.Drawing
Namespace CreateBubbleChart_XLS
Class Program
Private Shared Sub Main(args As String())
'创建一个Excel工作簿,并获取第一张工作表
Dim wb As New Workbook()
wb.Version = ExcelVersion.Version2013
Dim sheet As Worksheet = wb.Worksheets(0)
'添加图表,指定图表类型
Dim chart As Chart = sheet.Charts.Add()
chart.ChartType = ExcelChartType.Bubble
chart.PrimaryCategoryAxis.Title = "人均消费"
chart.PrimaryValueAxis.Title = "点评数"
'设置图表的名称和数据
Dim cs1 As Spire.Xls.Charts.ChartSerie = chart.Series.Add("气泡图")
cs1.EnteredDirectlyValues = New Object() {
2, 5, 3, 6, 7}
cs1.EnteredDirectlyCategoryLabels = New Object() {
1, 4.5, 1.2, 3.3, 2}
cs1.EnteredDirectlyBubbles = New Object() {
3, 6, 1, 4, 7}
'设置图表位置
chart.LeftColumn = 4
chart.TopRow = 2
chart.RightColumn = 12
chart.BottomRow = 22
'设置图表标题
chart.ChartTitle = "人均消费VS点评数"
chart.ChartTitleArea.IsBold = True
chart.ChartTitleArea.Size = 12
chart.Legend.Position = LegendPositionType.Top
'保存文档
wb.SaveToFile("BubbleChart.xlsx", ExcelVersion.Version2010)
System.Diagnostics.Process.Start("BubbleChart.xlsx")
End Sub
End Class
End Namespace