Html中使用M$控件系列之OWC-圖表篇
發(fā)表時(shí)間:2024-05-30 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]<object id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 style="width:100%;height:350"></object> <SCRIPT LA...
<object id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 style="width:100%;height:350"></object>
<SCRIPT LANGUAGE="VBSCRIPT">
SUB Window_OnLoad()
Dim categories(3), values(3)
'取得已命名的常量對象,在以后的腳本中使用
Set c = ChartSpace1.Constants
'設(shè)置圖表工作區(qū)標(biāo)題
ChartSpace1.HasChartSpaceTitle = True
ChartSpace1.ChartSpaceTitle.Caption = "Chart Space Title"
'設(shè)置圖表工作區(qū)的圖例
ChartSpace1.HasChartSpaceLegend = True
'圖例位置,其中c.*為位置枚舉值,值列表如下
'chLegendPositionTop :頂端
'chLegendPositionLeft :左邊
'chLegendPositionRight :右邊
'chLegendPositionBottom :底部
'chLegendPositionAutomatic :自動(dòng)
ChartSpace1.ChartSpaceLegend.Position = c.chLegendPositionRight
categories(0) = "White"
categories(1) = "Black"
categories(2) = "Asian"
categories(3) = "Latino"
'將圖表添加到圖表工作區(qū)
ChartSpace1.Charts.Add
'將新系列添加到圖表工作區(qū)的指定圖表中,下同
Set a = ChartSpace1.Charts(0).SeriesCollection.Add
'指定新系列的類型,C.*為類型枚舉值,列表如下:
'chChartTypeCombo
'chChartTypeColumnClustered
'chChartTypeColumnStacked
'chChartTypeColumnStacked100
'chChartTypeBarClustered
'chChartTypeBarStacked
'chChartTypeBarStacked100
'chChartTypeLine
'chChartTypeLineMarkers
'chChartTypeLineStacked
'chChartTypeLineStackedMarkers
'chChartTypeLineStacked100
'chChartTypeLineStacked100Markers
'chChartTypeSmoothLine
'chChartTypeSmoothLineMarkers
'chChartTypeSmoothLineStacked
'chChartTypeSmoothLineStackedMarkers
'chChartTypeSmoothLineStacked100
'chChartTypeSmoothLineStacked100Markers
'chChartTypePie
'chChartTypePieExploded
'chChartTypePieStacked
'chChartTypeScatterMarkers
'chChartTypeScatterSmoothLineMarkers
'chChartTypeScatterSmoothLine
'chChartTypeScatterLineMarkers
'chChartTypeScatterLine
'chChartTypeScatterLineFilled
'chChartTypeBubble
'chChartTypeBubbleLine
'chChartTypeArea
'chChartTypeAreaStacked
'chChartTypeAreaStacked100
'chChartTypeDoughnut
'chChartTypeDoughnutExploded
'chChartTypeRadarLine
'chChartTypeRadarLineMarkers
'chChartTypeRadarLineFilled
'chChartTypeRadarSmoothLine
'chChartTypeRadarSmoothLineMarkers
'chChartTypeStockHLC
'chChartTypeStockOHLC
'chChartTypePolarMarkers
'chChartTypePolarLine
'chChartTypePolarLineMarkers
'chChartTypePolarSmoothLine
'chChartTypePolarSmoothLineMarkers
'共47個(gè),誰有興趣誰一一的試吧,我懶。
'類型不同,支持的方法也有所不同,本文針對chChartTypeColumnClustered。
a.Type = c.chChartTypeColumnClustered
ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SeriesCollection.Add
values(0) = 0.2
values(1) = 0.06
values(2) = 0.17
values(3) = 0.13
'設(shè)置系列的名字,將顯示于圖例當(dāng)中,下同
ChartSpace1.Charts(0).SeriesCollection(0).Caption = "Perot"
'設(shè)定種類名稱,下同
ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimCategories, c.chDataLiteral, categories
'設(shè)置系列的值,下同
ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values
values(0) = 0.38
values(1) = 0.82
values(2) = 0.28
values(3) = 0.62
ChartSpace1.Charts(0).SeriesCollection(1).Caption = "Clinton"
ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimCategories, c.chDataLiteral, categories
ChartSpace1.Charts(0).SeriesCollection(1).SetData c.chDimValues, c.chDataLiteral, values
values(0) = 0.42
values(1) = 0.12
values(2) = 0.55
values(3) = 0.25
ChartSpace1.Charts(0).SeriesCollection(2).Caption = "Bush"
ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimCategories, c.chDataLiteral, categories
ChartSpace1.Charts(0).SeriesCollection(2).SetData c.chDimValues, c.chDataLiteral, values
'設(shè)定指定軸的起點(diǎn)及格式,String類型
'其中,c.*為軸類型的枚舉值,值列表如下:
'chAxisPositionLeft
'chAxisPositionCircular
'chAxisPositionRadial
'chAxisPositionRight
'chAxisPositionLeft
'chAxisPositionBottom
'chAxisPositionTop
ChartSpace1.Charts(0).Axes(c.chAxisPositionLeft).NumberFormat = "0%"
'設(shè)置指定坐標(biāo)軸的主單位,Double類型
ChartSpace1.Charts(0).Axes(c.chAxisPositionLeft).MajorUnit = 0.1
END SUB
</SCRIPT>