翻譯|使用教程|編輯:王香|2018-09-12 16:31:17.000|閱讀 358 次
概述:本文詳細介紹了在TeeChart for Java使用函數(shù)中的功能特點、添加功能和定義數(shù)據(jù)源。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
【下載TeeChart for Java最新版本】
TeeChart Pro功能是一個系列,幾乎可以是任何系列類型,應(yīng)用代數(shù)函數(shù),數(shù)據(jù)源是另一個圖表系列。所有函數(shù)都派生自TeeFunction Component并繼承TeeFunction的Period 方法。TeeChart Pro包含以下預(yù)定義功能列表,有關(guān)所有功能類型的完整列表,請參閱TeeChart Editor Gallery和Helpfile:
功能類型 | 投入數(shù)量 | 描述 |
Add | 無限 | 繪制輸入總和 |
Average | 無限 | 平均函數(shù)將計算每組Period點的平均值 |
Copy | 1 | 輸入系列的直接副本 |
Divide | 無限 | 分割函數(shù)繪制輸入按包含的降序劃分 |
High | 無限 | 高功能繪制高輸入點 |
Low | 無限 | 低功能繪制低輸入點 |
Multiply | 無限 | 乘法函數(shù)繪制輸入值的乘積 |
Subtract | 無限 | 繪圖的輸入值按包含的降序減去 |
Mode | 1 | mode函數(shù)返回重復(fù)多次的源序列值 |
Median | 1 | 計算源系列值的中值 |
Count | 1 | 在Y位置繪制水平線,該水平線由基礎(chǔ)系列中的點數(shù)定義。 |
Pro版本的子集(僅函數(shù)) | ||
Bollinger | 1 | 布林線函數(shù)使用簡單或指數(shù)移動平均線來構(gòu)建布林線交易區(qū)間 |
Curve Fitting | 1 | 使用TypeFitting公式通過數(shù)據(jù)輸入繪制擬合多項式 |
Exponential Average | 1 | 基于權(quán)重的指數(shù)平均值 |
Exponential Moving Average | 1 | 基于權(quán)重的指數(shù)移動平均線 |
Exponential Trend | 1 | 通過輸入系列中的點繪制最佳指數(shù)趨勢線 |
MACD | 1 | 移動平均收斂分歧 |
Momentum | 1 | 每個Y值是當前點的Y值減去最后一個Period點的Y值 |
Momentum Division | 1 | 每個Y值是當前點的Y值除以最后一個Period點的YValue,以百分比表示 |
Moving Average | 1 | 移動平均線功能將計算每組周期點的簡單或加權(quán)平均值 |
Root Mean Square | 無限 | 均方根函數(shù)繪制輸入的RMS值 |
Relative Strength Index | 1 | RSI函數(shù)根據(jù)財務(wù)數(shù)據(jù)計算百分比值。根據(jù)TRSISyle類型,將使用不同的公式來計算RSI值 |
Standard Deviation | 1 | 映射每組Period點的標準偏差(或完全標準差) |
Stochastic | 1 | |
Trend | 1 | 通過輸入系列點繪制最佳趨勢線 |
多種函數(shù)類型僅支持一個輸入系列。但是,可以鏈接鏈接函數(shù),例如,將圖表中多個系列的平均值創(chuàng)建為平均函數(shù)系列,然后使用平均函數(shù)作為趨勢函數(shù)的輸入來標識平均值的趨勢。
使用圖表編輯器,在“First Chart”頁面上,選擇“Add”按鈕,就像將新系列添加到圖表一樣。在TeeChart Gallery中,選擇Functions選項卡以選擇所需的功能。每個功能都顯示為一個系列,您可以稍后通過選擇第一個圖表頁面上的更改按鈕來更改與該功能關(guān)聯(lián)的系列類型。之后,在函數(shù)系列的“Datasource”頁面上可以輕松更改函數(shù)定義。在這里,同樣容易,您可以將已添加到Chart的正常Series的定義更改為Function的定義(Function實際上是數(shù)據(jù)源的定義,而不是Series Type的定義)。
下圖顯示了編輯函數(shù)時的“Datasource”頁面,數(shù)據(jù)源頁面底部的左側(cè)列表框顯示了可用于輸入的圖表中的其他系列(此處為“Series1”)。
假設(shè)我們從一個完全空的Chart開始,這里是代碼中用于構(gòu)建簡單的Series-Function相關(guān)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(); }
添加另一個函數(shù)來介紹有關(guān)前一個函數(shù)的信息
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數(shù)據(jù)源。使用圖表編輯器,在添加函數(shù)后,函數(shù)系列的“Datasource”頁面將顯示包含在函數(shù)定義中的可用系列列表。在這里,您可以更改要應(yīng)用于系列的函數(shù)類型,并從左側(cè)列表框“Available”中選擇系列,并將它們添加到右側(cè)列表框“Selected”。按代碼的數(shù)據(jù)源使用Series.Datasource屬性。例,假設(shè)我們在設(shè)計時通過TeeChart編輯器添加了2個數(shù)據(jù)系列。我們添加了一個由2系列的平均值組成的函數(shù):
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系列添加點數(shù):
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();
可以在運行時更改函數(shù)定義,只需通過重新定義Series.DataSource方法將新函數(shù)分配給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正版授權(quán),請點擊“”喲!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn