TeeChart for .NET是优秀的工业4.0 WinForm图表控件,官方独家授权汉化,集功能全面、性能稳定、价格实惠等优势于一体。TeeChart for .NET 中文版还可让您在使用和学习上没有任何语言障碍,至少可以节省30%的开发时间。
TeeChart for .NET最新版下载https://www.evget.com/resource/detail-download-22162
在TeeChar系列教程中,上一章完成了使用系列中“系列类的结构”的介绍,本次我们将为大家带来使用系列教程中的第三节,关于“将数据添加到系列中”的讲解,希望对大家有所帮助。
大多数系列类型(除ADO.NET数据源教程8和函数教程7外)都使用24种通用重载的添加方法来添加数据。但也有一些例外情况,见下表。
请注意,除了ShapeSeries之外,所有特定系列的添加方法都被自动添加为通用添加方法的进一步重载,因此可以从那里访问(例如candleSeries1.Add(new DateTime(2002,11,27),100,400,200,300);)。
在添加点的时候,可以手动为其添加颜色
[C#] bar1.Add(50,"Tomatoes",Color.Tomato); [VB.Net] Bar1.Add(50, "Tomatoes", Color.Tomato)
另外,你也可以让TeeChart分配一种颜色。TeeChart将为每个新系列选择最多19种独特的、尚未使用的颜色,如果Series.ColorEach = True,则为每个新系列点选择颜色。
例如:
[C#] Random rnd = new Random(); bar1.ColorEach = true; for(int i = 0; i < 19; ++i) { int higher = i + 65; char letter = (char) higher; bar1.Add(rnd.Next(100),letter.ToString()); } [VB.Net] Dim i As Integer Bar1.ColorEach = True For i = 0 To 19 Bar1.Add(Rnd() * 100, Chr(i + 65)) Next
一个透明的颜色可以被添加到一个点上,以便为ValueList中的值保留一个空间,而不在图表上显示。
例如
[C#] bar1.Add(45, "My Transparent Bar", Color.Transparent); [VB.Net] Bar1.Add(45, "My Transparent Bar", Color.Transparent)
从系列中删除数据点
使用Series.Delete来从一个系列中删除一个点。Series.Delete有两个重载。
public Void Delete(System.Int32)
删除系列中的第n个点。
public Void Delete(System.Int32, System.Int32)
从系列中的第n个点开始,删除若干个点n。
例如
[C#] bar1.Delete(7,2); (deletes two points starting from the 8th Series point (index starts at zero)) [VB.Net] Bar1.Delete(7, 2) (deletes two points starting from the 8th Series point (index starts at zero))
Series.Clear清除一个系列中的所有点。
Series.Add有三个重载,允许你向系列中添加一个空点。
添加一个新的空(透明)点。
public Int32 Add()
添加一个新的空点并指定文本。
public Int32
Add(System.String)
在指定的X值处添加一个新的空点,并指定文字。
public Int32 Add(System.Double,
System.String)
上述第二个重载将在系列中添加一个空点,允许你为该点定义一个标签,但在系列中的该点留下一个断点。在线型系列的情况下,断裂前的最后一个点不会与断裂后的第一个点连接。
例如
[C#] line1.Add("Null Point"); [VB.Net] Line1.Add("Null Point")
请在TeeChart帮助文件中查找其他两个重载,了解它们的使用实例。