Advertisement
omegastripes

OWC_Chart_IE.vbs

Sep 15th, 2013
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. option explicit
  2. dim display, chartspace, xval, yarr
  3.  
  4. ' create ie window for output
  5. set display = new outputwindow
  6.  
  7. ' create chart
  8. set chartspace = display.document.createelement("object")
  9. with chartspace
  10.     .id = "ChartSpace"
  11.     .setattribute "width", "100%"
  12.     .setattribute "height", "100%"
  13.     ' OWC10.ChartSpace clsid:0002E546-0000-0000-C000-000000000046
  14.     ' OWC11.ChartSpace clsid:0002E55D-0000-0000-C000-000000000046
  15.     .setattribute "classid", "clsid:0002E55D-0000-0000-C000-000000000046"
  16.     .clear
  17.     .refresh
  18. end with
  19.  
  20. ' fill and append chart
  21. randomdata xval, yarr
  22. display.body.appendchild fillchart(chartspace, xval, yarr)
  23.  
  24. do
  25.     wscript.sleep 100
  26. loop
  27.  
  28. sub randomdata(xval, yarr)
  29.     ' Create categories array and array of values arrays
  30.     dim catsqty, rowsqty, yval, i, j
  31.     randomize
  32.     catsqty = 4 + int(rnd * 6) ' categories qty in each row
  33.     rowsqty = int(sqr(rnd) * 4) ' rows qty
  34.     redim xval(catsqty)
  35.     for i = 0 to catsqty
  36.         xval(i) = "Cat" & i
  37.     next
  38.     redim yval(catsqty)
  39.     redim yarr(rowsqty)
  40.     for j = 0 to rowsqty
  41.         for i = 0 to catsqty
  42.             yval(i) = int(rnd * 1000)
  43.         next
  44.         yarr(j) = yval
  45.     next
  46. end sub
  47.  
  48. function fillchart(chartspace, xval, yarr)
  49.     dim c, i
  50.     set c = chartspace.constants
  51.     with chartspace.charts.add
  52.         .type = c.chcharttypecolumnstacked3d
  53.         .hastitle = true
  54.         .title.caption = "Chart with " & (ubound(yarr) + 1) & " rows in " & (ubound(xval) + 1) & " categories"
  55.         .title.font.name = "Arial"
  56.         .title.font.size = 26
  57.         .title.font.bold = true
  58.         for i = 0 to ubound(yarr)
  59.             with .seriescollection.add
  60.                 .interior.color = rgb(int(rnd*256), int(rnd*256), int(rnd*256))
  61.                 .caption = "Cap" & i
  62.                 .setdata c.chdimcategories, c.chdataliteral, xval
  63.                 .setdata c.chdimvalues, c.chdataliteral, yarr(i)
  64.                 with .datalabelscollection.add
  65.                     .hasvalue = (ubound(yarr) = 0)
  66.                     .haspercentage = (ubound(yarr) >= 1) and (ubound(yarr) < 3)
  67.                     .font.name = "Arial"
  68.                     .font.size = 6
  69.                     .font.bold = false
  70.                     .interior.color = rgb(255, 255, 255)
  71.                 end with
  72.             end with
  73.         next
  74.         with .axes(c.chaxispositionbottom)
  75.             .font.name = "Arial"
  76.             .font.size = 8
  77.             .font.bold = false
  78.             .hastitle = true
  79.             .title.caption = "Bottomaxisname"
  80.             .title.font.name = "Arial"
  81.             .title.font.size = 10
  82.             .title.font.bold = true
  83.         end with
  84.         with .axes(c.chaxispositionleft)
  85.             .font.name = "Arial"
  86.             .font.size = 8
  87.             .font.bold = false
  88.             .majorunit = 500
  89.             .hasmajorgridlines = true
  90.             .hastitle = true
  91.             .title.caption = "Leftaxisname"
  92.             .title.font.name = "Arial"
  93.             .title.font.size = 10
  94.             .title.font.bold = true
  95.         end with
  96.         .haslegend = true
  97.         .legend.position = c.chlegendpositionbottom
  98.         .legend.font.name = "Arial"
  99.         .legend.font.size = 8
  100.         .legend.font.bold = false
  101.         .plotarea.interior.color = rgb(200, 200, 200)
  102.     end with
  103.     set c = nothing
  104.     set fillchart = chartspace
  105. end function
  106.  
  107. class outputwindow
  108.    
  109.     public ie, body, document, iequitclicked
  110.    
  111.     private sub class_initialize()
  112.         set ie = wscript.createobject("internetexplorer.application", "ie_")
  113.         with ie
  114.             .menubar = false
  115.             .toolbar = false
  116.             .resizable = true
  117.             .statusbar = false
  118.             .addressbar = false
  119.             .visible = true
  120.             REM .fullscreen = true
  121.             .navigate "about:blank"
  122.         end with
  123.         set document = ie.document
  124.         document.write "<html><head><title>outputwindow</title></head><body></body></html>"
  125.         set body = document.getelementsbytagname("body")(0)
  126.         iequitclicked = false
  127.     end sub
  128.    
  129.     public sub write(text)
  130.         document.write text & "<br>"
  131.     end sub
  132.    
  133.     private sub class_terminate()
  134.         if not iequitclicked then
  135.             ie.quit
  136.         end if
  137.         set ie = nothing
  138.     end sub
  139.    
  140. end class
  141.  
  142. sub ie_onquit
  143.     display.iequitclicked = true
  144.     wscript.quit
  145. end sub
  146.  
  147. ' links
  148.  
  149. ' http://support.microsoft.com/kb/235885
  150. ' http://msdn.microsoft.com/en-us/library/office/aa155723(v=office.10).aspx
  151. ' http://support.alphasoftware.com/AlphaFiveHelp/Xdialog/XY_Graph.htm#Complete_List_of_Supported_Chart_Types
  152. ' http://aspnetresources.com/articles/office_web_components
  153. ' http://javascript.ru/forum/dom-window/32482-ne-otobrazhaetsya-dinamicheskijj-activex.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement