當前位置:編程學習大全網 - 編程語言 - 如何使用TeeChart實現圖表

如何使用TeeChart實現圖表

您好,很高興為您解答。

使用?regsvr32註冊ocx,就可以在程序環境中使用了,插入壹個teechart控件到window裏面,具體見下圖

插入後就可以使用該控件了,teechart支持的圖表類型很多,可以使用editor進行設置,參考下圖

TeeChart主要有幾個概念,壹個是axis(軸),壹個是series(序列),掌握了這兩個基本的東西就可以進行設置和編程了。

看這壹段代碼:

chart.object.axis.top.visible=false?//設置圖表上界不顯示

chart.object.axis.right.visible=false?//設置圖表右界不顯示

chart.object.frame.visible=false//不顯示邊框

chart.object.header.text.clear()//由於teechart支持多行title,所以必須clear

chart.object.axis.left.automatic=false//這個自動標註功能

以上的代碼基本設置完成,具體的設置可以通過editor詳細了解到

如何來顯示坐標軸:

chart.object.axis.left.startposition=70

chart.object.axis.left.endposition=100

chart.object.axis.left.maximum=val[1]

chart.object.axis.left.minimum=0

chart.object.axis.left.title.caption=item[1]

chart.object.axis.bottom.title.caption="勘探線"

chart.object.series(0).clear()

long?hor,ver

hor=chart.object.axis.addcustom(TRUE)

ver=chart.object.axis.addcustom(FALSE)

chart.object.axis.Custom(ver).automatic=false

chart.object.axis.Custom(ver).minimum=0

chart.object.axis.custom(ver).maximum=val[2]

chart.object.axis.Custom(ver).startposition=35

chart.object.axis.Custom(ver).EndPosition?=?65

chart.object.axis.Custom(ver).Title.Angle?=?90

chart.object.axis.Custom(ver).Title.Caption?=?item[2]

chart.object.axis.Custom(hor).EndPosition?=?100

chart.object.axis.Custom(hor).PositionPercent?=35

chart.object.Series(1).VerticalAxisCustom?=?ver

chart.object.Series(1).HorizontalAxisCustom?=?hor

chart.object.series(1).clear()

這段代碼是設置兩個坐標軸的代碼,可以參考下圖

有了坐標軸,就可以顯示數據了,代碼如下:

chart.object.series(0).add(round(cc/nums,2),ktx,255)

chart.object.series(1).add(round(dd/nums,2),ktx,255)

這是向裏面加了兩個序列的數據,代碼本來在循環裏面,要加多個數據到序列,多調用幾次add

如若滿意,請點擊右側采納答案,如若還有問題,請點擊追問

希望我的回答對您有所幫助,望采納!

~ O(∩_∩)O~

  • 上一篇:妳想發明什麽樣的機器人
  • 下一篇:計算機應用技術主要有哪些課程?
  • copyright 2024編程學習大全網