Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- option explicit
- dim chartspace, xval, yarr, file
- ' create chart
- set chartspace = createobject("OWC11.ChartSpace") ' OWC10.ChartSpace | OWC11.ChartSpace
- chartspace.clear
- chartspace.refresh
- ' fill chart
- randomdata xval, yarr
- fillchart chartspace, xval, yarr
- ' export chart
- file =wscript.scriptfullname & ".png"
- chartspace.exportpicture file, "png", 1024, 768
- msgbox "Saved to " & vbcrlf & file, 64, "OWC11.ChartSpace"
- sub randomdata(xval, yarr)
- ' Create categories array and array of values arrays
- dim catsqty, rowsqty, yval, i, j
- randomize
- catsqty = 4 + int(rnd * 6) ' categories qty in each row
- rowsqty = int(sqr(rnd) * 4) ' rows qty
- redim xval(catsqty)
- for i = 0 to catsqty
- xval(i) = "Cat" & i
- next
- redim yval(catsqty)
- redim yarr(rowsqty)
- for j = 0 to rowsqty
- for i = 0 to catsqty
- yval(i) = int(rnd * 1000)
- next
- yarr(j) = yval
- next
- end sub
- function fillchart(chartspace, xval, yarr)
- dim c, i
- set c = chartspace.constants
- with chartspace.charts.add
- .type = c.chcharttypecolumnstacked3d
- .hastitle = true
- .title.caption = "Chart with " & (ubound(yarr) + 1) & " rows in " & (ubound(xval) + 1) & " categories"
- .title.font.name = "Arial"
- .title.font.size = 26
- .title.font.bold = true
- for i = 0 to ubound(yarr)
- with .seriescollection.add
- .interior.color = rgb(int(rnd*256), int(rnd*256), int(rnd*256))
- .caption = "Cap" & i
- .setdata c.chdimcategories, c.chdataliteral, xval
- .setdata c.chdimvalues, c.chdataliteral, yarr(i)
- with .datalabelscollection.add
- .hasvalue = (ubound(yarr) = 0)
- .haspercentage = (ubound(yarr) >= 1) and (ubound(yarr) < 3)
- .font.name = "Arial"
- .font.size = 6
- .font.bold = false
- .interior.color = rgb(255, 255, 255)
- end with
- end with
- next
- with .axes(c.chaxispositionbottom)
- .font.name = "Arial"
- .font.size = 8
- .font.bold = false
- .hastitle = true
- .title.caption = "Bottomaxisname"
- .title.font.name = "Arial"
- .title.font.size = 10
- .title.font.bold = true
- end with
- with .axes(c.chaxispositionleft)
- .font.name = "Arial"
- .font.size = 8
- .font.bold = false
- .majorunit = 500
- .hasmajorgridlines = true
- .hastitle = true
- .title.caption = "Leftaxisname"
- .title.font.name = "Arial"
- .title.font.size = 10
- .title.font.bold = true
- end with
- .haslegend = true
- .legend.position = c.chlegendpositionbottom
- .legend.font.name = "Arial"
- .legend.font.size = 8
- .legend.font.bold = false
- .plotarea.interior.color = rgb(200, 200, 200)
- end with
- set c = nothing
- set fillchart = chartspace
- end function
- ' links
- ' http://support.microsoft.com/kb/235885
- ' http://msdn.microsoft.com/en-us/library/office/aa155723(v=office.10).aspx
- ' http://support.alphasoftware.com/AlphaFiveHelp/Xdialog/XY_Graph.htm#Complete_List_of_Supported_Chart_Types
- ' http://aspnetresources.com/articles/office_web_components
- ' http://javascript.ru/forum/dom-window/32482-ne-otobrazhaetsya-dinamicheskijj-activex.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement