翻译|使用教程|编辑:王香|2018-12-28 09:32:41.000|阅读 279 次
概述:ten文件是TeeChart自己的模板格式,用于保存图表及其数据。 修改的图表属性随模板一起保存,并在模板导入新图表时重现。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
相关链接:
系列数据有四种导出格式:
上述组件可以与图表系列相关联,从中可以将数据导出为文件,流或剪贴板。以下示例将图表系列中的数据导出到HTML表:
[C#]
private void Form1_Load(object sender, System.EventArgs e) Random rnd = new Random(); char c = new char(); for(int i = 0; i < 10; ++i) c = Convert.ToChar(65 + i); bar1.Add(Convert.ToDouble(i),rnd.Next(100),c.ToString(),Color.Red); Steema.TeeChart.Export.DataExport dataExport = new Steema.TeeChart.Export.DataExport(tChart1.Chart); dataExport.HTML.IncludeHeader = true; dataExport.HTML.IncludeIndex = true; dataExport.HTML.IncludeLabels = true; dataExport.HTML.Series = bar1; dataExport.HTML.Save(@"C:.htm");
[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim C As New Char() Dim i As New Integer() For i = 0 To 10 C = Convert.ToChar(65 + i) Bar1.Add(Convert.ToDouble(i), Rnd() * 100, C.ToString(), Color.Red) Next Dim DataExport As New Steema.TeeChart.Export.DataExport(TChart1.Chart) DataExport.HTML.IncludeHeader = True DataExport.HTML.IncludeIndex = True DataExport.HTML.IncludeLabels = True DataExport.HTML.Series = Bar1 DataExport.HTML.Save("C:.htm") End Sub
带有随机数据集的上述输出如下:
<table border="1"> <tr><td>Index</td><td>Text</td><td>bar1</td></tr> <tr><td>0</td><td>A</td><td>69</td></tr> <tr><td>1</td><td>B</td><td>93</td></tr> <tr><td>2</td><td>C</td><td>18</td></tr> <tr><td>3</td><td>D</td><td>88</td></tr> <tr><td>4</td><td>E</td><td>42</td></tr> <tr><td>5</td><td>F</td><td>33</td></tr> <tr><td>6</td><td>G</td><td>58</td></tr> <tr><td>7</td><td>H</td><td>43</td></tr> <tr><td>8</td><td>I</td><td>63</td></tr> <tr><td>9</td><td>J</td><td>49</td></tr> </table>
ten文件是TeeChart自己的模板格式,用于保存图表及其数据。 修改的图表属性随模板一起保存,并在模板导入新图表时重现。 好处:
[C#]
private void button1_Click(object sender, System.EventArgs e) saveFileDialog1.Filter = "TenFile (.ten)|*.ten"; saveFileDialog1.ShowDialog(); if(saveFileDialog1.FileName != "") tChart1.Export.Template.IncludeData = true; tChart1.Export.Template.Save(saveFileDialog1.FileName);
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SaveFileDialog1.Filter = "TenFile (.ten)|*.ten" SaveFileDialog1.ShowDialog() If SaveFileDialog1.FileName <> "" Then TChart1.Export.Template.IncludeData = True TChart1.Export.Template.Save(SaveFileDialog1.FileName) End If End Sub
从TextBox导入XML。
[C#]
protected override void button1_Click(object sender, System.EventArgs e) tChart1.Series.RemoveAllSeries(); Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart); points1.Title = "Points Series"; xmlSource1.Series = points1; xmlSource1.SeriesNode = "Points Series"; xmlSource1.Load(textBox2.Text); tChart1.Refresh();
从URL导入XML。
[C#]
protected override void button2_Click(object sender, System.EventArgs e) tChart1.Series.RemoveAllSeries(); xmlSource1.Chart = tChart1.Chart; xmlSource1.Load("//www.steema.com/SampleNETData.xml"); tChart1.Refresh();
从本地文件源或http数据源导入已保存的Tee文件。
例,从文件导入
[C#]
tChart1.Import.Template.LoadFileDialog();
[VB.Net]
TChart1.Import.Template.LoadFileDialog()
URL
[C#]
tChart1.Import.Template.FromURL("//www.berneda.com/demo.ten");
[VB.Net]
TChart1.Import.Template.FromURL("//www.berneda.com/demo.ten")
Stream
[C#]
System.IO.MemoryStream tenStream = new System.IO.MemoryStream(); tChart1.Export.Template.Save(tenStream); tChart2.Import.Template.Load(tenStream);
[VB.Net]
Dim TenStream As New System.IO.MemoryStream() TChart1.Export.Template.Save(TenStream) TChart2.Import.Template.Load(TenStream)
效果仅保存对标准图表定义的更改,如果目标图表包含未导入要导入的图表的属性更改,则原件将继续执行。一个例子是图表页脚。如果.ten文件未设置页脚并且目标图表具有,则页脚将在导入后通过图表显示。这可能是理想的结果。如果您希望在导入图表后对导入图表进行更改可能会对所需结果产生负面影响,那么您可以创建图表的新实例,如下例所示:
[C#]
private void Form1_Load(object sender, System.EventArgs e) Bar bar1 = new Bar(tChart1.Chart); bar1.FillSampleValues(20); private void button1_Click(object sender, System.EventArgs e) saveFileDialog1.Filter = "TenFile (.ten)|*.ten"; saveFileDialog1.ShowDialog(); if(saveFileDialog1.FileName != "") tChart1.Export.Template.IncludeData = true; tChart1.Export.Template.Save(saveFileDialog1.FileName); private void button2_Click(object sender, System.EventArgs e) tChart1.Dispose(); tChart1 = new Steema.TeeChart.TChart(); ini_Chart(); private void ini_Chart() this.tChart1.Header.Lines = new string[] "TeeChart"; this.tChart1.Location = new System.Drawing.Point(24, 24); this.tChart1.Name = "tChart1"; this.tChart1.Size = new System.Drawing.Size(400, 240); this.tChart1.TabIndex = 5; this.Controls.AddRange(new System.Windows.Forms.Control[] this.tChart1); private void button3_Click(object sender, System.EventArgs e) tChart1.Import.Template.LoadFileDialog();
[VB.Net]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Bar1 As New Steema.TeeChart.Styles.Bar(TChart1.Chart) Bar1.FillSampleValues(20) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SaveFileDialog1.Filter = "TenFile (.ten)|*.ten" SaveFileDialog1.ShowDialog() If Not SaveFileDialog1.FileName = "" Then TChart1.Export.Template.IncludeData = True TChart1.Export.Template.Save(SaveFileDialog1.FileName) End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TChart1.Dispose() TChart1 = New Steema.TeeChart.TChart() Ini_Chart() End Sub Private Sub Ini_Chart() Me.TChart1.Header.Lines = New String() "TeeChart" Me.TChart1.Location = New System.Drawing.Point(16, 16) Me.TChart1.Name = "TChart1" Me.TChart1.Size = New System.Drawing.Size(400, 296) Me.TChart1.TabIndex = 3 Me.Controls.AddRange(New System.Windows.Forms.Control() Me.TChart1) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TChart1.Import.Template.LoadFileDialog() End Sub
购买TeeChart Pro AciveX正版授权,请点击“”哟!
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn