• <menu id="w2i4a"></menu>
  • logo 【TeeChart Pro ActiveX教程】2018

    文檔首頁>>【TeeChart Pro ActiveX教程】2018>>【TeeChart Pro ActiveX教程】(十二):導(dǎo)入和導(dǎo)出圖表(下)

    【TeeChart Pro ActiveX教程】(十二):導(dǎo)入和導(dǎo)出圖表(下)


    下載TeeChart Pro ActiveX最新版本

    導(dǎo)出數(shù)據(jù)

    系列數(shù)據(jù)有四種導(dǎo)出格式:

    • 文字:TextFormat類
    • XML:XMLFormat類
    • HTML:HTMLFormat類
    • Excel:ExcelFormat類

    上述組件可以與圖表系列相關(guān)聯(lián),從中可以將數(shù)據(jù)導(dǎo)出為文件,流或剪貼板。以下示例將圖表系列中的數(shù)據(jù)導(dǎo)出到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 

    帶有隨機(jī)數(shù)據(jù)集的上述輸出如下:

    <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> 
    

    TeeChart的'Ten'模板和數(shù)據(jù)導(dǎo)出/導(dǎo)入格式

    ten文件

    ten文件是TeeChart自己的模板格式,用于保存圖表及其數(shù)據(jù)。 修改的圖表屬性隨模板一起保存,并在模板導(dǎo)入新圖表時(shí)重現(xiàn)。 好處:

    • 十個文件的大小非常小,在大多數(shù)情況下,它提供了優(yōu)于純圖形格式(qicker)的優(yōu)勢。
    • 模板的目標(biāo)圖表是“實(shí)時(shí)”,可以進(jìn)行縮放和滾動,并修改其屬性。
    • 根據(jù)您的偏好,數(shù)據(jù)可以選擇包含在十個模板中。

    [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 

    導(dǎo)入

    導(dǎo)入XML到TeeChart

    從TextBox導(dǎo)入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導(dǎo)入XML。

    [C#]

    protected override void button2_Click(object sender, System.EventArgs e)  
                tChart1.Series.RemoveAllSeries(); 
                xmlSource1.Chart = tChart1.Chart; 
                xmlSource1.Load("http://www.steema.com/SampleNETData.xml"); 
     
                tChart1.Refresh(); 
             
    導(dǎo)入ten格式文件

    從本地文件源或http數(shù)據(jù)源導(dǎo)入已保存的Tee文件。

    例,從文件導(dǎo)入

    [C#]

    tChart1.Import.Template.LoadFileDialog(); 

    [VB.Net]

    TChart1.Import.Template.LoadFileDialog() 
    

    URL

    [C#]

    tChart1.Import.Template.FromURL("http://www.berneda.com/demo.ten"); 

    [VB.Net]

    TChart1.Import.Template.FromURL("http://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) 
    

    在導(dǎo)入時(shí)所做更改的效果

    效果僅保存對標(biāo)準(zhǔn)圖表定義的更改,如果目標(biāo)圖表包含未導(dǎo)入要導(dǎo)入的圖表的屬性更改,則原件將繼續(xù)執(zhí)行。一個例子是圖表頁腳。如果.ten文件未設(shè)置頁腳并且目標(biāo)圖表具有,則頁腳將在導(dǎo)入后通過圖表顯示。這可能是理想的結(jié)果。如果您希望在導(dǎo)入圖表后對導(dǎo)入圖表進(jìn)行更改可能會對所需結(jié)果產(chǎn)生負(fù)面影響,那么您可以創(chuàng)建圖表的新實(shí)例,如下例所示:

    [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正版授權(quán),請點(diǎn)擊“咨詢在線客服”喲!

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();