Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- option explicit
- dim display, chartspace, xval, yarr
- ' create ie window for output
- set display = new outputwindow
- ' create chart
- set chartspace = display.document.createelement("object")
- with chartspace
- .id = "ChartSpace"
- .setattribute "width", "100%"
- .setattribute "height", "100%"
- ' OWC10.ChartSpace clsid:0002E546-0000-0000-C000-000000000046
- ' OWC11.ChartSpace clsid:0002E55D-0000-0000-C000-000000000046
- .setattribute "classid", "clsid:0002E55D-0000-0000-C000-000000000046"
- .clear
- .refresh
- end with
- ' fill and append chart
- randomdata xval, yarr
- display.body.appendchild fillchart(chartspace, xval, yarr)
- do
- wscript.sleep 100
- loop
- 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
- class outputwindow
- public ie, body, document, iequitclicked
- private sub class_initialize()
- set ie = wscript.createobject("internetexplorer.application", "ie_")
- with ie
- .menubar = false
- .toolbar = false
- .resizable = true
- .statusbar = false
- .addressbar = false
- .visible = true
- REM .fullscreen = true
- .navigate "about:blank"
- end with
- set document = ie.document
- document.write "<html><head><title>outputwindow</title></head><body></body></html>"
- set body = document.getelementsbytagname("body")(0)
- iequitclicked = false
- end sub
- public sub write(text)
- document.write text & "<br>"
- end sub
- private sub class_terminate()
- if not iequitclicked then
- ie.quit
- end if
- set ie = nothing
- end sub
- end class
- sub ie_onquit
- display.iequitclicked = true
- wscript.quit
- end sub
- ' 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