Html中使用M$控件系列之OWC-图表篇

80酷酷网    80kuku.com

  控件|图表<object id=ChartSpace1 classid=CLSID:0002E500-0000-0000-C000-000000000046 LANGUAGE="VBSCRIPT">
SUB var webSiteID = 6;window.onload()
Dim categories(3), values(3)

'取得已命名的常量对象,在以后的脚本中使用
Set c = ChartSpace1.Constants

'设置图表工作区标题
ChartSpace1.HasChartSpaceTitle = True
ChartSpace1.ChartSpaceTitle.Caption = "Chart Space Title"

'设置图表工作区的图例
ChartSpace1.HasChartSpaceLegend = True

'图例位置,其中c.*为位置枚举值,值列表如下
'chLegendPositionTop :顶端
'chLegendPositionLeft :左边
'chLegendPositionRight :右边
'chLegendPositionBottom :底部
'chLegendPositionAutomatic :自动
ChartSpace1.ChartSpaceLegend.Position = c.chLegendPositionRight

categories(0) = "White"
categories(1) = "Black"
categories(2) = "Asian"
categories(3) = "Latino"

'将图表添加到图表工作区
ChartSpace1.Charts.Add

'将新系列添加到图表工作区的指定图表中,下同
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个,谁有兴趣谁一一的试吧,我懒。
'类型不同,支持的方法也有所不同,本文针对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

'设置系列的名字,将显示于图例当中,下同
ChartSpace1.Charts(0).SeriesCollection(0).Caption = "Perot"
'设定种类名称,下同
ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimCategories, c.chDataLiteral, categories
'设置系列的值,下同
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

'设定指定轴的起点及格式,String类型
'其中,c.*为轴类型的枚举值,值列表如下:
'chAxisPositionLeft
'chAxisPositionCircular
'chAxisPositionRadial
'chAxisPositionRight
'chAx

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: