C# mschart 控件的基本使用和图表控件Series的概念
使用sharpdevelop;
此工具默認(rèn)沒(méi)有mschart控件;把如下dll添加到引用;
?
工具箱里面把控件加出來(lái);sharpdevelop加控件到工具箱見(jiàn)此;
? ??https://blog.csdn.net/bcbobo21cn/article/details/109432788
代碼;
/** Created by SharpDevelop.* User: Administrator* Date: 2020/12/21/周一* Time: 3:15* * To change this template use Tools | Options | Coding | Edit Standard Headers.*/ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting;namespace mschartdemo {/// <summary>/// Description of MainForm./// </summary>public partial class MainForm : Form{public MainForm(){//// The InitializeComponent() call is required for Windows Forms designer support.//InitializeComponent();//// TODO: Add constructor code after the InitializeComponent() call.//Series series = new Series("Spline");series.ChartType = SeriesChartType.Spline;series.BorderWidth = 3;series.ShadowOffset = 2;// Populate new series with dataseries.Points.AddY(67);series.Points.AddY(57);series.Points.AddY(83);series.Points.AddY(23);series.Points.AddY(70);series.Points.AddY(60);series.Points.AddY(90);series.Points.AddY(20);// Add series into the chart's series collectionchart1.Series.Add(series);chart1.Series["Series1"].ChartType=SeriesChartType.Line;chart1.Series["Series1"].BorderWidth = 5;chart1.Series["Series1"].Points.AddY(67);chart1.Series["Series1"].Points.AddY(57);chart1.Series["Series1"].Points.AddY(83);chart1.Series["Series1"].Points.AddY(23);chart1.Series["Series1"].Points.AddY(70);chart1.Series["Series1"].Points.AddY(60);chart1.Series["Series1"].Points.AddY(90);chart1.Series["Series1"].Points.AddY(20);Series series2 = new Series("Bubble");series2.ChartType = SeriesChartType.Bubble;series2.BorderWidth = 3;//series.ShadowOffset = 2;// Populate new series with dataseries2.Points.AddY(67);series2.Points.AddY(57);series2.Points.AddY(83);series2.Points.AddY(23);series2.Points.AddY(70);series2.Points.AddY(60);series2.Points.AddY(90);series2.Points.AddY(20);chart1.Series.Add(series2);chart1.Series.Clear();Series series3 = new Series("Pie");series3.ChartType = SeriesChartType.Pie;series3.BorderWidth = 3;//series.ShadowOffset = 2;// Populate new series with dataseries3.Points.AddXY(0,10);series3.Points.AddXY(0,20);series3.Points.AddXY(0,10);series3.Points.AddXY(0,10);series3.Points.AddXY(0,10);series3.Points.AddXY(0,20);series3.Points.AddXY(0,10);series3.Points.AddXY(0,10);chart1.Series.Add(series3); }} }第一段繪圖代碼;圖表類型為?Spline ;?
? ? 曲線出來(lái)了;但是右上角有2個(gè) Series,這是啥?
看設(shè)計(jì)時(shí)的默認(rèn)界面,有一個(gè) Series;
運(yùn)行完第二段繪圖代碼之后如下;Series指的是,同一片繪圖區(qū)域,不同的兩個(gè)圖表;
第三段繪圖代碼;圖表類型為?SeriesChartType.Bubble;繪出來(lái)是大個(gè)的方點(diǎn)這個(gè);bubble,英文意思是氣泡;目前有三個(gè)Series;
如果把第三段繪圖代碼的圖表類型改為Pie;則出現(xiàn)一個(gè)奇怪的圖形;可能第三段繪圖代碼的數(shù)據(jù)不適合繪餅圖;
第四段繪圖代碼;圖表類型是?SeriesChartType.Pie; 可以繪制出;但是前面的三個(gè)Series沒(méi)有了; 此段代碼前要加?chart1.Series.Clear(),才能繪出下面的餅圖;
?
總結(jié)
以上是生活随笔為你收集整理的C# mschart 控件的基本使用和图表控件Series的概念的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 数据库多对多关系示例 - 使用sqlit
- 下一篇: Windows内核HAL相关学习