翻譯|使用教程|編輯:王香|2018-09-12 16:31:17.000|閱讀 358 次
概述:本文詳細介紹了在TeeChart for Java使用函數中的功能特點、添加功能和定義數據源。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載TeeChart for Java最新版本】
TeeChart Pro功能是一個系列,幾乎可以是任何系列類型,應用代數函數,數據源是另一個圖表系列。所有函數都派生自TeeFunction Component并繼承TeeFunction的Period 方法。TeeChart Pro包含以下預定義功能列表,有關所有功能類型的完整列表,請參閱TeeChart Editor Gallery和Helpfile:
功能類型 | 投入數量 | 描述 |
Add | 無限 | 繪制輸入總和 |
Average | 無限 | 平均函數將計算每組Period點的平均值 |
Copy | 1 | 輸入系列的直接副本 |
Divide | 無限 | 分割函數繪制輸入按包含的降序劃分 |
High | 無限 | 高功能繪制高輸入點 |
Low | 無限 | 低功能繪制低輸入點 |
Multiply | 無限 | 乘法函數繪制輸入值的乘積 |
Subtract | 無限 | 繪圖的輸入值按包含的降序減去 |
Mode | 1 | mode函數返回重復多次的源序列值 |
Median | 1 | 計算源系列值的中值 |
Count | 1 | 在Y位置繪制水平線,該水平線由基礎系列中的點數定義。 |
Pro版本的子集(僅函數) | ||
Bollinger | 1 | 布林線函數使用簡單或指數移動平均線來構建布林線交易區間 |
Curve Fitting | 1 | 使用TypeFitting公式通過數據輸入繪制擬合多項式 |
Exponential Average | 1 | 基于權重的指數平均值 |
Exponential Moving Average | 1 | 基于權重的指數移動平均線 |
Exponential Trend | 1 | 通過輸入系列中的點繪制最佳指數趨勢線 |
MACD | 1 | 移動平均收斂分歧 |
Momentum | 1 | 每個Y值是當前點的Y值減去最后一個Period點的Y值 |
Momentum Division | 1 | 每個Y值是當前點的Y值除以最后一個Period點的YValue,以百分比表示 |
Moving Average | 1 | 移動平均線功能將計算每組周期點的簡單或加權平均值 |
Root Mean Square | 無限 | 均方根函數繪制輸入的RMS值 |
Relative Strength Index | 1 | RSI函數根據財務數據計算百分比值。根據TRSISyle類型,將使用不同的公式來計算RSI值 |
Standard Deviation | 1 | 映射每組Period點的標準偏差(或完全標準差) |
Stochastic | 1 | |
Trend | 1 | 通過輸入系列點繪制最佳趨勢線 |
多種函數類型僅支持一個輸入系列。但是,可以鏈接鏈接函數,例如,將圖表中多個系列的平均值創建為平均函數系列,然后使用平均函數作為趨勢函數的輸入來標識平均值的趨勢。
使用圖表編輯器,在“First Chart”頁面上,選擇“Add”按鈕,就像將新系列添加到圖表一樣。在TeeChart Gallery中,選擇Functions選項卡以選擇所需的功能。每個功能都顯示為一個系列,您可以稍后通過選擇第一個圖表頁面上的更改按鈕來更改與該功能關聯的系列類型。之后,在函數系列的“Datasource”頁面上可以輕松更改函數定義。在這里,同樣容易,您可以將已添加到Chart的正常Series的定義更改為Function的定義(Function實際上是數據源的定義,而不是Series Type的定義)。
下圖顯示了編輯函數時的“Datasource”頁面,數據源頁面底部的左側列表框顯示了可用于輸入的圖表中的其他系列(此處為“Series1”)。
假設我們從一個完全空的Chart開始,這里是代碼中用于構建簡單的Series-Function相關Chart的步驟。
private void Load() { //Add a data Series Line line1 = new Line(tChart1.getChart()); //Populate it with data (here random) line1.fillSampleValues(10); //Add a series to be used for an Average Function Line line2 = new Line(tChart1.getChart()); //Define the Function Type for the new Series com.steema.teechart.functions.Average average1 = new com.steema.teechart.functions.Average(); line2.setFunction(average1); //Define the Datasource for the new Function Series line2.setDataSource(line1); //*Note - When populating your input Series manually you will need to //use the Checkdatasource method //- See the section entitled 'Defining a Datasource' //Change the Period of the Function so that it groups averages //every 2 Points line2.getFunction().setPeriod(2); line2.checkDataSource(); }
添加另一個函數來介紹有關前一個函數的信息
public void button1_actionPerformed(ActionEvent e) { //Let's change to 2D for visibility tChart1.getAspect().setView3D(false); //Add another Series to be used for a 2nd Function Line line3 = new Line(tChart1.getChart()); //Define the Function Type for the new Series com.steema.teechart.functions.High high1 = new com.steema.teechart.functions.High(); line3.setFunction(high1); //Define the Datasource for the new Function Series //Use the existing Function (Series2) as input line3.setDataSource(tChart1.getSeries(1)); //Leave the Period at default 0 (No Period set) to draw //A line at Highest of all points of the Average Function
Series使用Datasource定義Function的輸入或定義Series TDataset數據源。使用圖表編輯器,在添加函數后,函數系列的“Datasource”頁面將顯示包含在函數定義中的可用系列列表。在這里,您可以更改要應用于系列的函數類型,并從左側列表框“Available”中選擇系列,并將它們添加到右側列表框“Selected”。按代碼的數據源使用Series.Datasource屬性。例,假設我們在設計時通過TeeChart編輯器添加了2個數據系列。我們添加了一個由2系列的平均值組成的函數:
private void Load() { tChart1.getAspect().setView3D(false); bar1.fillSampleValues(10); bar2.fillSampleValues(10); } public void button1_actionPerformed(ActionEvent e) { com.steema.teechart.styles.Line line1 = new com.steema.teechart.styles.Line(tChart1.getChart()); com.steema.teechart.functions.Average average3 = new com.steema.teechart.functions.Average(); Object[] tmpDataSource ={bar1,bar1}; line1.setFunction(tmpDataSource); line1.setDataSource(bar1); line1.getMarks().setVisible(true); }
為2系列添加點數:
public void button1_actionPerformed(ActionEvent e) { java.util.Random rnd = new java.util.Random(); for(int i = 0; i < 10; ++i) bar1.add(rnd.nextInt(500)); bar2.add(rnd.nextInt(500)); } }
該功能不會顯示。您需要使用checkDataSource方法讀入Function的值。
tChart1.getSeries(2).checkDataSource();
可以在運行時更改函數定義,只需通過重新定義Series.DataSource方法將新函數分配給Series:
public void button3_actionPerformed(ActionEvent e) { com.steema.teechart.functions.Cumulative cumulative1 = new com.steema.teechart.functions.Cumulative(); tChart1.getSeries(2).setFunction(cumulative1);
購買Steema正版授權,請點擊“”喲!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn