線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1904
推到 Plurk!
推到 Facebook!

請問使用TChart出現X軸會跳開無資料日期而顯示的狀況..

尚未結案
akccbh
一般會員


發表:32
回覆:30
積分:12
註冊:2004-07-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-11 23:52:35 IP:61.242.xxx.xxx 未訂閱
請問一下小弟使用TChart撰寫一個畫K線的功能. 但是發生一件事情,就是我資料日期是 11/1 11/2 11/3 11/6, 結果發生, 11/1 - 11/3 的圖會在一起,但是到 11/6 時, 會自動跳兩格,也就是跳開 11/4 11/5 兩天的位置,我以座標來說 就是例如 11/1 - 11/3 畫在 X1 - X3 ,而 11/6 就畫在 6 其中 X4 ,X5 就空著,感覺上就很奇怪.. 不知道是否有什麼設定要做呢?? 謝謝....
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-14 21:30:08 IP:211.76.xxx.xxx 未訂閱
如果您的橫軸是用文字而不是日期,應該就不會了。 也就是 11/1, 11/2, 11/3, 11/6, 11/7 ... 是以文字而不是日期, 那 TChart 就會把它們視為沒有相關的文字資料,自然就不會去空那二天。 一般來說 AddXY 所加入的 X 之間是有關係的, AddY 所加入的 X 之間是沒有關係的,以下取自線上說明
引言: AddY Method Applies to TChartSeries component Declaration function AddY(Const AYValue: Double; Const AXLabel: String; AColor: TColor): Longint; Description The TChartSeries AddY method can be used to insert new Series points when you do not have an X Value for the point. This function inserts a new point in the Series. The new point only has Y values. X value is automatically calculated. The AXLabel parameter is optional (can be empty ''). The AColor parameter is optional (can be clTeeColor). The function returns the new point position in the Values list.
吃軟也吃硬 dllee.ktop.com.tw StatPlus 系統資源監測器 @ KTOP VMASK - ViewMove Automation Software Kernel
------
http://www.ViewMove.com
akccbh
一般會員


發表:32
回覆:30
積分:12
註冊:2004-07-07

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-11-15 00:16:16 IP:61.242.xxx.xxx 未訂閱
再請問.. 感謝 dllee 大大,Line Chart我已經順利解決.. 不過K線圖卻是不知道該怎麼做哩.. 他還是會跳日期.... Use the AddCandle method to manually fill Candle points: Series1.AddCandle( EncodeDate( 2002, 10, 16), 100, 120, 80, 90 ); Note: If you want to skip "weekends", pass an incremental integer number to Date parameter of AddCandle method: var tmp : Integer; tmp := Series1.AddCandle( Series1.Count, 100, 120, 80, 90 ); Series1.Label[ tmp ]:= DateToStr( EncodeDate( 2002, 10, 16 )); The rectangles dimensions are determined by OpenValues and CloseValues properties. The vertical line that crosses each candle point is defined by the HighValues and LowValues properties 這是相關的 Help ,不過當我弄成 Label 時,跳日期還是一樣會發生,而且當我K線圖與 Line Chart 一起畫時, 會變成對不上, 變成K線圖在一邊,線圖再另一邊,各自有各自的 X 軸...不能整合在一起.. 是不是那邊沒注意到呢 ? 再麻煩大大幫忙嚕... 謝謝..
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-11-15 20:50:20 IP:211.76.xxx.xxx 未訂閱
因為K線的功能我的 BCB5 內建的 TChart 沒有提供,所以不能直接寫一個 DEMO 給您看,不過,就如您所提到的線上說明: http://www.berneda.com/TeeChart6Docs/TCandleSeries.AddCandle.html 不知道您是否有看懂
引言: Note: If you want to skip "weekends", pass an incremental integer number to Date parameter of AddCandle method:
這句話呢?您是否有試用它所提供的範例:
引言: var tmp : Integer; tmp := Series1.AddCandle( Series1.Count, 100, 120, 80, 90 ); Series1.Label[ tmp ]:= DateToStr( EncodeDate( 2002, 10, 16 ));
基本上,這三行程式與 Line 的 AddY 算是一樣的效果,因為同樣是把 X 軸給文字化,在數字上只給單純的 1,2,3,4... 這樣的數列,所以應該不會有資料分開的狀況,是否可以把您這個部分的程式碼 post 上來呢? 吃軟也吃硬 dllee.ktop.com.tw StatPlus 系統資源監測器 @ KTOP VMASK - ViewMove Automation Software Kernel
------
http://www.ViewMove.com
akccbh
一般會員


發表:32
回覆:30
積分:12
註冊:2004-07-07

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-11-15 23:31:54 IP:61.242.xxx.xxx 未訂閱
我這邊的程式碼是這樣.    for i := 1 to Data_Max_Inx do    Begin       tmp := srCandleChart.AddCandle(Data_Array[i].Data_Date,                               Data_Array[i].OpenPrice,                               Data_Array[i].HighPrice,                               Data_Array[i].LowPrice,                               Data_Array[i].MatchPrice);       srCandleChart.Labels[tmp] := DateToStr(Data_Array[i].Data_Date);    end;    我的Data_Array是已經放好的一個陣列.. 只是照順序畫出來而已. 寫法是按照範例來弄的,不過仍然是會跳開沒資料的日期, 我是覺得可能跟設定有關, 但是一直找不到..    另外,當我X軸弄成文字時,兩個圖就不會重疊了,變成各自跑一邊, 有各自的 X 軸...變得很奇怪...如附圖... 麻煩您了...謝謝...    
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-11-16 08:38:36 IP:220.139.xxx.xxx 未訂閱
引言:
   for i := 1 to Data_Max_Inx do
   Begin
      tmp := srCandleChart.AddCandle(Data_Array[i].Data_Date,
                              Data_Array[i].OpenPrice,
                              Data_Array[i].HighPrice,
                              Data_Array[i].LowPrice,
                              Data_Array[i].MatchPrice);
      srCandleChart.Labels[tmp] := DateToStr(Data_Array[i].Data_Date);
   end;
紅色部分改成如下:
      tmp := srCandleChart.AddCandle(srCandleChart.Count,
                              Data_Array[i].OpenPrice,
                              Data_Array[i].HighPrice,
                              Data_Array[i].LowPrice,
                              Data_Array[i].MatchPrice);
藍色部分是重點,也是那個線上說明所說的重點!! 吃軟也吃硬 dllee.ktop.com.tw StatPlus 系統資源監測器 @ KTOP VMASK - ViewMove Automation Software Kernel
------
http://www.ViewMove.com
akccbh
一般會員


發表:32
回覆:30
積分:12
註冊:2004-07-07

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-11-16 20:55:05 IP:61.242.xxx.xxx 未訂閱
原來是要用連續數字來騙他...嘿嘿.. 我沒看清楚... :-P    終於都搞定了,感謝 dllee 大大... 
系統時間:2024-05-17 14:37:20
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!