图表控件TeeChart for .NET系列教程六:系列类的结构(使用系列)

在TeeChar系列教程中,上一章完成了图例设计的讲解,本次我们为大家带来“使用系列”的前部分,包括系列类型中的结构讲解,希望对大家有所帮助。

TeeChart for .NET是优秀的工业4.0 WinForm图表控件,官方独家授权汉化,集功能全面、性能稳定、价格实惠等优势于一体。TeeChart for .NET 中文版还可让您在使用和学习上没有任何语言障碍,至少可以节省30%的开发时间。

TeeChart for .NET最新版下载

在TeeChar系列教程中,上一章完成了“图例设计”的全部讲解,本次我们为大家带来“使用系列”的前部分,包括系列类型中的结构讲解,希望对大家有所帮助。

内容-目录

一、系列类型

(一)系列类的结构

(二)选择一个系列类型

(三)将数据添加到系列中

(四)从系列中删除数据点

(五)向系列中添加空点

二、在图表中混合系列类型

(一)添加新的系列

(二)为系列选择坐标轴

(三)连接系列

(四)改变系列的顺序

三、系列值列表

(一)访问系列值

(二)使用数值的例子

四、系列事件
(一)OnClickSeries
(二)OnGetSeriesPointerStyle
(三)获取系列标记(OnGetSeriesMark)
一、系列类型
TChart Series 类是所有 Series 类型的共同祖先。当使用TeeChart在线帮助获得关于任何系列类型的帮助时,请遵循位于继承类型列表中的系列类的链接,然后点击系列成员,那里将包括所有继承的属性和方法的列表。
(一)系列类的结构

作为TeeChart类型库结构的一个小背景,这里是对系列类和接口的一个解释。下图显示了TeeChart系列类之间的关系。所有的类都源于通用的 “系列 “类,因此共享 “系列 “属性和方法。有几个抽象类派生自Series(Custom3DSeries、CustomBarSeries和CircledSeries),这些类以灰色显示,它们的接口不能直接用于编程,它们的特性被它们的后代Series类型所继承。所有派生的系列(橙色)都可以在TeeChart图库中访问,以纳入你的图表中。以这种方式派生的TeeChart系列,允许通过一个共同的索引结构对继承的属性和方法进行可编程的访问(见本节后面的示例代码)。

图表控件TeeChart for .NET系列教程六:系列类的结构(使用系列)

在设计时使用TChart编辑器添加系列更容易,但你也可以在运行时创建和添加新的和不同的系列类型到同一个TChart。

[C#] //Add a series at runtime private void button1_Click(object sender, System.EventArgs e)         {             Steema.TeeChart.Styles.Area tmpAreaSeries = new Steema.TeeChart.Styles.Area(tChart1.Chart);              tmpAreaSeries.FillSampleValues(4);             //Or             //Steema.TeeChart.Styles.Area tmpAreaSeries = new Steema.TeeChart.Styles.Area();             //tChart1.Series.Add(tmpAreaSeries);             //tmpAreaSeries.FillSampleValues(4);         }  [VB.Net] 'Add a series at runtime Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click          Dim tmpAreaSeries As New Steema.TeeChart.Styles.Area(TChart1.Chart)         tmpAreaSeries.FillSampleValues(4)         'Or         'Dim tmpAreaSeries As New Steema.TeeChart.Styles.Area()         'TChart1.Series.Add(tmpAreaSeries)         'tmpAreaSeries.FillSampleValues(4) End Sub

所有AreaSeries的属性和方法对新系列都是可用的,就像在设计时创建的任何系列一样。

在同一个图表中混合使用不同系列的例子是,在设计时使用TeeChart编辑器在图表中添加一个Area(系列(0))、Bar(系列(1))和Line(系列(2))系列。所有这些都访问一个共同的索引结构,即图表的系列列表。与系列有关的工作可能看起来像下面这样。

[C#] private void Form1_Load(object sender, System.EventArgs e)         {             //You could add the Series at runtime              Steema.TeeChart.Styles.Area area1 = new Steema.TeeChart.Styles.Area(tChart1.Chart);             Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);             Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);              //Use Series common properties              tChart1.Series[0].FillSampleValues(10);             tChart1.Series[1].FillSampleValues(10);             tChart1.Series[2].FillSampleValues(10);             tChart1.Series[1].Marks.Visible = false;             tChart1.Series[2].Marks.Visible = false;              //Modify Bar specific properties              bar1.BarStyle = Steema.TeeChart.Styles.BarStyles.Pyramid; //Change Bar type              bar1.Pen.Color = Color.Yellow; //Bar bounding lines colour               //Modify Line specific properties              line1.Stairs = true; //Set line to Stairs              line1.LinePen.Color = Color.Blue; //LineSeries bounding lines colour               //Modify Area specific properties              area1.AreaBrush.Style = System.Drawing.Drawing2D.HatchStyle.Cross; //Area fill pattern          }  [VB.Net] Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         'You could add the Series at runtime          Dim Area1 As New Steema.TeeChart.Styles.Area(TChart1.Chart)         Dim Bar1 As New Steema.TeeChart.Styles.Bar(TChart1.Chart)         Dim Line1 As New Steema.TeeChart.Styles.Line(TChart1.Chart)          'Use Series common properties          TChart1.Series(0).FillSampleValues(10)         TChart1.Series(1).FillSampleValues(10)         TChart1.Series(2).FillSampleValues(10)         TChart1.Series(1).Marks.Visible = False         TChart1.Series(2).Marks.Visible = False          'Modify Bar specific properties          Bar1.BarStyle = Steema.TeeChart.Styles.BarStyles.Pyramid 'Change Bar type          Bar1.Pen.Color = Color.Yellow 'Bar bounding lines colour           'Modify Line specific properties          Line1.Stairs = True 'Set line to Stairs          Line1.LinePen.Color = Color.Blue 'LineSeries bounding lines colour           'Modify Area specific properties          Area1.AreaBrush.Style = System.Drawing.Drawing2D.HatchStyle.Cross 'Area fill pattern  End Sub 

以上就是TeeChart系列教程中的“使用系列”的介绍了,点击查看更多教程。

如果您想了解TeeChart for .NET价格,欢迎咨询在线客服

TeeChart for .NET技术交流QQ群:  欢迎加入

标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2023年1月10日
下一篇 2023年1月10日

相关推荐

发表回复

登录后才能评论