請問Tchart的座標軸標示問題 |
尚未結案
|
lgm55
一般會員 ![]() ![]() 發表:14 回覆:34 積分:9 註冊:2004-03-01 發送簡訊給我 |
|
dllee
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
使用 Series 的 AddY 即可。
例如:在 TChart 上加一個 Series1 為一個 TLineSeries,
以下是範例碼:
void __fastcall TForm1::Button1Click(TObject *Sender) { this->Series1->Clear(); TStringList *nameList=new TStringList; for(int i=0;i<100;i ) // 假設您要的名稱已存在一個 StringList 中 nameList->Add(String("Test") IntToStr(i)); for(int i=0;i<100;i ) // 在 Series 中使用 AddY 把資料及名稱加入 Chart 中 this->Series1->AddY(i,nameList->Strings[i],clRed); delete nameList; }沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
lgm55
一般會員 ![]() ![]() 發表:14 回覆:34 積分:9 註冊:2004-03-01 發送簡訊給我 |
|
dllee
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
你可以把 TLineSeries 改成 THorizBarSeries 也就是水平的線條圖,
由 AddY() 改成 AddX() 即可
void __fastcall TForm1::Button1Click(TObject *Sender) { this->Series1->Clear(); TStringList *nameList=new TStringList; for(int i=0;i<100;i ) // 假設您要的名稱已存在一個 StringList 中 nameList->Add(String("Test") IntToStr(i)); for(int i=0;i<100;i ) // 在 Series 中使用 AddX 把資料及名稱加入 Chart 中 this->Series1->AddX(i,nameList->Strings[i],clRed); delete nameList; }沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
lgm55
一般會員 ![]() ![]() 發表:14 回覆:34 積分:9 註冊:2004-03-01 發送簡訊給我 |
|
dllee
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
要每一個棒棒不一樣顏色,就把程式中的 clRed 改成您要的顏色即可,如同 Label 可以建一個 ColorArray 依序指定。
老實說,我實在不懂您要的圖到底是什麼?
如果可以的話,請用畫的畫一張來看看,
如果您要的本來就是 TChart 作不到的功能,那我說半天也是白搭...
真的是這樣時,也只有請您去找其他的 Chart 元件或是自行開發以滿足需求。 沒空更新的網頁...
http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
lgm55
一般會員 ![]() ![]() 發表:14 回覆:34 積分:9 註冊:2004-03-01 發送簡訊給我 |
|
lgm55
一般會員 ![]() ![]() 發表:14 回覆:34 積分:9 註冊:2004-03-01 發送簡訊給我 |
|
dllee
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
object Form1: TForm1 Left = 116 Top = 225 Width = 696 Height = 480 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Chart1: TChart Left = 0 Top = 0 Width = 688 Height = 446 BackWall.Brush.Color = clWhite BackWall.Brush.Style = bsClear LeftWall.Brush.Color = clWhite Title.Text.Strings = ( 'TChart') BottomAxis.LabelsAngle = 270 BottomAxis.LabelsOnAxis = False BottomAxis.TickOnLabelsOnly = False BottomAxis.Title.Caption = '時間' LeftAxis.LabelsSeparation = 0 LeftAxis.Title.Angle = 0 LeftAxis.Title.Caption = '距離' Legend.TextStyle = ltsRightValue Legend.Visible = False RightAxis.Automatic = False RightAxis.AutomaticMaximum = False RightAxis.AutomaticMinimum = False RightAxis.Maximum = 1128 RightAxis.Visible = False TopAxis.Visible = False View3D = False Align = alClient BevelOuter = bvNone TabOrder = 0 object Series1: TLineSeries Marks.ArrowLength = 8 Marks.Visible = False SeriesColor = clRed VertAxis = aRightAxis Pointer.InflateMargins = True Pointer.Style = psCircle Pointer.Visible = True XValues.DateTime = False XValues.Name = 'X' XValues.Multiplier = 1 XValues.Order = loAscending YValues.DateTime = False YValues.Name = 'Y' YValues.Multiplier = 1 YValues.Order = loNone end object Series2: THorizBarSeries ColorEachPoint = True HorizAxis = aTopAxis Marks.ArrowLength = 20 Marks.Visible = False SeriesColor = clGreen BarWidthPercent = 1 MultiBar = mbStacked100 XValues.DateTime = False XValues.Name = 'Bar' XValues.Multiplier = 1 XValues.Order = loNone YValues.DateTime = False YValues.Name = 'Y' YValues.Multiplier = 1 YValues.Order = loNone end end end在建構元中直接產生 Chart 內容 __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { TColor colorArray[16]={clBlack, clMaroon, clGreen, clOlive, clNavy, clPurple, clTeal, clGray, clSilver, clRed, clLime, clYellow, clBlue, clFuchsia, clAqua, clWhite}; this->Series1->Clear(); this->Series2->Clear(); TStringList *nameList=new TStringList; for(int i=0;i<21;i++) // 假設您要的名稱已存在一個 StringList 中 { switch(i) { case 15: nameList->Add("彰化"+IntToStr(i*10)); break; case 8: nameList->Add("屏東"+IntToStr(i*10)); break; default: nameList->Add(IntToStr(i*10)); break; } } for(int i=0;i<21;i++) // 在 Series 中使用 AddY 把資料及名稱加入 Chart 中 { if(i==9) this->Series1->AddY((i-1)*10,i,colorArray[(i-1)]); else if(i==16) this->Series1->AddY((i-1)*10,i,colorArray[(i-1)]); else this->Series1->AddY(i*10,i,colorArray[i]); this->Series2->AddY(i,nameList->Strings[i],colorArray[i]); } this->Chart1->RightAxis->Maximum=200; this->Chart1->RightAxis->Minimum=0; delete nameList; } //---------------------------------------------------------------------------您應該再修改一下就可以了 沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
lgm55
一般會員 ![]() ![]() 發表:14 回覆:34 積分:9 註冊:2004-03-01 發送簡訊給我 |
|
dllee
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:321 回覆:2519 積分:1711 註冊:2002-04-15 發送簡訊給我 |
關於屬性設定,我貼的那些是由表單來的,您可以在 BCB 中開一個新的 Application,在 Form1 表單按右鍵,在選單中選 View as Text 應該會看到
object Form1: TForm1 Left = 364 Top = 114 Width = 696 Height = 480 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 end接著,把之前的文章中表單的敘述複製,貼入整個檔案(取代掉原來的), 在檔案中按右鍵,由選單中選 View as Form 或按 Alt F12,您就會看到表單內的 Chart 及 Chart 內的兩個圖表及其設定。 (因為這個方法算是偷改表單,IDE 並不知情,最好此時將整個 Chart 點選,按 Ctrl X 剪下後再按 Ctrl V 貼上,如此,在 Unit1.h 內才會出現正常的元件宣告) 其實,對於 TChart 我還不是很會用,只知道它很好用,對於它 AddX, AddY 到底會有什麼效果,也都是一試再試,要改成您最後想要的可能還要花一些功夫,而在我的設定中,您可以看到如何試著用多個 Series 去組合出一個複雜的圖表。 沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com |
lgm55
一般會員 ![]() ![]() 發表:14 回覆:34 積分:9 註冊:2004-03-01 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |