資源簡介
本資源主要為c#中使用chart控件繪制曲線圖,當數據量較大時,x軸出現滾動條,實現全局視圖和滾動視圖的功能

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Windows.Forms.DataVisualization.Charting;
namespace?test_chart
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????InitChart();
????????????for?(int?i?=?0;?i?3;?i++)
????????????{
????????????????AddSeries(r.Next(1100).ToString()?Color.Red);
????????????}
????????}
????????static?int?range?=?0;
????????Random?r?=?new?Random(6);
????????private?void?AddSeries(string?seriersName?Color?serierscolor)
????????{
????????????Series?series?=?new?Series(seriersName);
????????????//圖表類型??設置為樣條圖曲線
????????????series.ChartType?=?SeriesChartType.Line;
????????????series.IsXValueIndexed?=?true;
????????????series.XValueType?=?ChartValueType.Time;
????????????series.Markerstyle?=?Markerstyle.Circle;
????????????series.MarkerColor?=?Color.Black;
????????????//設置點的大小
????????????series.MarkerSize?=?5;
????????????//設置曲線的顏色
????????????series.Color?=?serierscolor;
????????????//設置曲線寬度
????????????series.BorderWidth?=?2;
????????????series.CustomProperties?=?“PointWidth=2“;
????????????series.IsValueShownAsLabel?=?true;
????????????chart.Series.Add(series);
????????}
????????private?void?CreateChart()
????????{
????????????ChartArea?chartArea?=?new?ChartArea();
????????????//chartArea.Name?=?“FirstArea“;
????????????chartArea.CursorX.IsUserEnabled?=?true;
????????????chartArea.CursorX.IsUserSelectionEnabled?=?true;
????????????chartArea.CursorX.SelectionColor?=?Color.SkyBlue;
????????????chartArea.CursorY.IsUserEnabled?=?true;
????????????chartArea.CursorY.AutoScroll?=?true;
????????????chartArea.CursorY.IsUserSelectionEnabled?=?true;
????????????chartArea.CursorY.SelectionColor?=?Color.SkyBlue;
????????????chartArea.CursorX.IntervalType?=?DateTimeIntervalType.Auto;
????????????chartArea.AxisX.ScaleView.Zoomable?=?false;
????????????chartArea.AxisX.ScrollBar.Buttonstyle?=?ScrollBarButtonstyles.All;//啟用X軸滾動條按鈕
????????????chartArea.BackColor?=?Color.BlueViolet;??????????????????????//背景色
????????????chartArea.BackSecondaryColor?=?Color.White;?????????????????//漸變背景色
????????????chartArea.BackGradientstyle?=?Gradientstyle.TopBottom;??????//漸變方式
????????????chartArea.BackHatchstyle?=?ChartHatchstyle.None;????????????//背景陰影
????????????chartArea.BorderDashstyle?=?ChartDashstyle.NotSet;??????????//邊框線樣式
????????????chartArea.BorderWidth?=?1;??????????????????????????????????//邊框寬度
????????????chartArea.BorderColor?=?Color.Black;
????????????//chartArea.AxisX.
????????????chartArea.AxisX.MajorGrid.Enabled?=?true;
????????????chartArea.AxisY.MajorGrid.Enabled?=?true;
????????????//?Axis
????????????chartArea.AxisY.title?=?@“Value“;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????14336??2018-10-24?10:05??test_chart\test_chart\bin\Debug\test_chart.exe
?????文件??????28160??2018-10-24?10:05??test_chart\test_chart\bin\Debug\test_chart.pdb
?????文件??????14328??2018-10-24?10:06??test_chart\test_chart\bin\Debug\test_chart.vshost.exe
?????文件????????490??2009-06-11?05:14??test_chart\test_chart\bin\Debug\test_chart.vshost.exe.manifest
?????文件???????7748??2018-06-01?09:47??test_chart\test_chart\Form1.cs
?????文件???????4141??2018-06-01?09:27??test_chart\test_chart\Form1.Designer.cs
?????文件???????6003??2018-06-01?09:27??test_chart\test_chart\Form1.resx
?????文件???????6034??2018-05-25?11:12??test_chart\test_chart\obj\Debug\ResolveAssemblyReference.cache
?????文件????????953??2018-10-24?10:06??test_chart\test_chart\obj\Debug\test_chart.csproj.FileListAbsolute.txt
?????文件????????847??2018-06-01?09:27??test_chart\test_chart\obj\Debug\test_chart.csproj.GenerateResource.Cache
?????文件??????14336??2018-10-24?10:05??test_chart\test_chart\obj\Debug\test_chart.exe
?????文件????????180??2018-10-24?10:05??test_chart\test_chart\obj\Debug\test_chart.Form1.resources
?????文件??????28160??2018-10-24?10:05??test_chart\test_chart\obj\Debug\test_chart.pdb
?????文件????????180??2018-10-24?10:05??test_chart\test_chart\obj\Debug\test_chart.Properties.Resources.resources
?????文件????????491??2018-05-25?11:07??test_chart\test_chart\Program.cs
?????文件???????1370??2018-05-25?11:07??test_chart\test_chart\Properties\AssemblyInfo.cs
?????文件???????2870??2018-05-25?11:07??test_chart\test_chart\Properties\Resources.Designer.cs
?????文件???????5612??2018-05-25?11:07??test_chart\test_chart\Properties\Resources.resx
?????文件???????1095??2018-05-25?11:07??test_chart\test_chart\Properties\Settings.Designer.cs
?????文件????????249??2018-05-25?11:07??test_chart\test_chart\Properties\Settings.settings
?????文件???????3866??2018-05-25?11:12??test_chart\test_chart\test_chart.csproj
?????文件????????920??2018-05-25?11:08??test_chart\test_chart.sln
????..A..H.?????16384??2018-10-24?10:06??test_chart\test_chart.suo
?????文件??????15360??2018-10-24?10:07??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\windowsformsapplication1.exe
?????文件??????30208??2018-10-24?10:07??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
?????文件??????14328??2018-10-24?10:07??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
?????文件????????490??2009-06-11?05:14??WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
?????文件???????8890??2018-05-25?17:02??WindowsFormsApplication1\WindowsFormsApplication1\Form2.cs
?????文件???????4376??2018-05-25?16:49??WindowsFormsApplication1\WindowsFormsApplication1\Form2.Designer.cs
?????文件???????6003??2018-05-25?16:49??WindowsFormsApplication1\WindowsFormsApplication1\Form2.resx
............此處省略37個文件信息
評論
共有 條評論