Frog Frog Recommended: Use OWC to make a chart in HTML

xiaoxiao2021-03-05  23

new document </ title> <meta name = "generator" content = "editplus"> < Meta Name = "Author" Content = "Frog Frog Prince"> <meta name = "keywords" content = "OWC, report, chart"> <meta name = "description" content = "Oh, the buddy thoroughly Convert to the VBS script and port it to the webpage, just to make a chart control, the buddy is looking for N more information, and the eyes look at VML, I originally wanted to write a Chart control with VML, Later, I was too much, I used OWC, and the function was also violent. OWC didn't need me to introduce it. Estimated even if I spent half a day, I learned a good to learn VML, and I learned a good-to-object development of JS. I finally wrote a VMLChart estimate is not so powerful. Why don't Microsoft provide anything to provide, yesterday and today I just saw a SQL Reporting Service video tutorial, that more NB, a space, what reports, charts are all done, but something is disadvantageous This example I wrote must be installed at the client, or you have to distribute the OWC component separately, I don't write the location of the DLL when I declare, and I don't quote the CAB package on the Internet. When you test it, you test it. Ofs200 can be "> <script language =" vbscript "> private submmand1_click ()</p> <p>'Create arrays for the x-value and the y-value' defines several arrays DIM XVALUES, YVALUES1, YVALUES2 'XVALUES = Array ("Beverages", "CONFECTIONS", "Confections", "Confections" '"Dairy Products", "Grains & Cereals", _' "MEAT & Poultry", "Product", "Seafood") XVALUES = Array ("Beverage", "Condiment", "Candy", _ "Dairy" , "Fish", "Poultry Meat", "Crop", "Sea Food") Yvalues1 = Array (104737, 50952, 78128, 117797, 52902, 80160, 47491, _ 62435) Yvalues2 = array (20000, 15000, 36000, 56000, 40000, 18000, 20000, _ 33000) 'Create A New Chart' Creates a new chart object DIM OCHART, ChconStants Chartspace1.Clear 'Empty Chart Chartspace1.Refresh' Redraw Chart Set Ochart = Chartspace1.Charts.add 'New Empty Graph Set ChconStants = ChartSpace1.constants' Use Naming Constants in VBScript</p> <p>'Add a title = true = "sale per category"</p> <p>'Add a series to the chart with the x-values ​​and y-values' from the arrays and set the series type to a column chart Dim oSeries Set oSeries = oChart.SeriesCollection.Add With oSeries .Caption = "1995" .SetData chConstants .chdimcategories, Xvalues ​​.SetData chconstants.chdimvalues, chconstants.chdataliteral, yvalues1 .type = chconstants.chcharttypecolumnclustered end with</p> <p>'Add another series to the chart with the x-values ​​and y-values' from the arrays and set the series type to a line chart Set oSeries = oChart.SeriesCollection.Add With oSeries .Caption = "1996" .SetData chConstants.chDimCategories , chConstants.chDataLiteral, xValues ​​.SetData chConstants.chDimValues, chConstants.chDataLiteral, yValues2 .Type = chConstants.chChartTypeLineMarkers End With'Add a value axis to the right of the chart for the second series oChart.Axes.Add oChart.Axes (chConstants .sscaling, chconstants.chaxispositionright, ChconStants.chvalueaxis</p> <p>'Format the Value Axes oChart.Axes (chConstants.chAxisPositionLeft) .NumberFormat = "$ #, ## 0" oChart.Axes (chConstants.chAxisPositionRight) .NumberFormat = "0" oChart.Axes (chConstants.chAxisPositionLeft) .MajorUnit = 20000 Ochart.axes (chconstants.chaxispositionright) .majorunit = 20000</p> <p>'Show the legend at the bottom of the chart ochart.haslegend = true ion.legend.position = chlegendpositionbottom</p> <p>End subsprivate sub urns2_click ()</p> <p>'Set up the DataSourceControl for the Chartspace Dim rsd, chConstants Set chConstants = ChartSpace1.Constants DataSourceControl1.ConnectionString = _ "DRIVER = {Microsoft Access Driver (* .mdb)};" & _ "DBQ = C: / Program Files / Microsoft Visual Studio / VB98 / nwind.mdb "Set rsd = DataSourceControl1.RecordsetDefs.AddNew (_" Select * from [Category Sales for 1995] ", 3) With ChartSpace1 .Clear .Refresh .DataSource = DataSourceControl1 .DataMember = rsd.Name End WITH</p> <p>'This Chartspace will contain 2 charts. Make the layout so that the' charts are positioned horizontally ChartSpace1.ChartLayout = chConstants.chChartLayoutHorizontal'Create a new bar chart from the query oBarChart = ChartSpace1.Charts.Add With Dim oBarChart Set oBarChart .Type = Chconstants.chcharttypebarclustered .SetData Chconstants.chdimcategories, 0, 0 'Categories Are First Field .SetData Chconstants.chdimvalues, 0, 1' Values ​​Are Second Field</p> <p>'Format the value axis for the bar chart so that it' shows values ​​in thousands (ie, 45000 displays as 45) and 'in increments of 25000. Remove the gridlines With .Axes (chConstants.chAxisPositionBottom) .NumberFormat = "0," .Majorunit = 25000 .hasmajorgridlines = false end with</p> <p>'Change The Color of The Series and The Plot area .seriesCollection (0). Interior.color = RGB (150, 0, 150) .plotarea.interior.color = RGB (240, 240, 10) end with</p> <p>'Create a new exploded pie chart from the query Dim oPieChart Set oPieChart = ChartSpace1.Charts.Add With oPieChart .Type = chConstants.chChartTypePie .SetData chConstants.chDimCategories, 0, 0' Categories are first field .SetData chConstants.chDimValues, 0, 1 'Values ​​Are Second Field .seriesCollection (0) .explosion = 20</p> <p>'Add a legend to the bottom of the pie chart .haslegend = true .legend.position = chconstants.chlegendPositionBottom</p> <p>'Add a title = true .title.caption = "Sales by category for 1995" .title.font.bold = true.title.font.size = 11'make the chart width 50% The size of the Bar chart's width .widthratio = 50</p> <p>'Show Data Labels on The Slics As PERESCOLLECTION (0) .datalabelscollection.add .haasvalue = false .haspercentage = true .s.size = 8 .interior.color = RGB (255, 255, 255) End with</p> <p>End with</p> <p>End subprivate sub urns3_click ()</p> <p>'Dynamically add a spreadsheet control to the form Dim chConstants Set chConstants = ChartSpace1.Constants' Fill the Sheet with data With oSheet .Range. ( "A1: A10") Formula = "= Row ()" .Range ( "B1: B10 "). Formula =" = a1 ^ 2 ".Range (" A12 "). Formula =" = Max (A1: A10) ".RANGE (" B12 "). Formula =" = max (b1: b10) "end WITH</p> <p>'Create an xy-scatter chart using the data in the spreadsheet Dim oChart With ChartSpace1 .Clear .Refresh .DataSource = oSheet.object Set oChart = .Charts.Add oChart.Type = chConstants.chChartTypeScatterSmoothLineMarkers oChart.SetData chConstants.chDimXValues, 0, "A1: A10" Ochart.SetData ChconStants.chdimyvalues, 0, "B1: B10" End with</p> <p>WITH OCHART 'DISPLAY THE MAJOR UNITS for the axes with .axes (chconstants.chaxisposition) .hastitle = true .title.caption = "x" .title.font.size = 8 .majorunit = 1 End with with .Axes (chConstants.chAxisPositionLeft) .HasTitle = True .Title.Caption = "X Squared" .Title.Font.Size = 8 .MajorUnit = 10 End With'Set the maximum and minimum axis values ​​.Scalings (chConstants.chDimXValues) .Maximum = osheet.range ("a12"). Value .scalings (chconstants.chdimxvalues) .Minimum = 1 .scalings (chconstants.chdimyvalues) .maximum = osheet.range ("b12"). Value</p> <p>'Change the Marker and Line Styles for the series with .seriescollection (0) .MARKER.Style = ChconStants.chmarkerstyledot .Marker.size = 6 .line.weight = 1 .line.color = RGB (255, 0, 0) End WITH End Wirth Sub </ script> </ head> <body> <! - Declaration a chart object chartspace1 -> <object id = chartspace1 classid = CLSID: 0002E500-0000-0000-c000-000000000046 codebase = "msowc. DLL "style =" width: 100%; Height: 350; border: #ffffffff 0px solid "> </ object> <! Declaration a chart data source object DataSourceControl1 -> <object id = DataSourceControl1 classid = CLSID: 0002E555B -0000-0000-C000-000000000046> </ Object> <! - Declare an spreadsheet object osheet -> <object id = osheet classid = CLSID: 0002E559-0000-0000-C000-000000000046 style = "Width: 0 ; Height: 0; Border: #ffffff 0px solid> </ object></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-32589.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="32589" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.038</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'uGboSvtLOPaCzMddqys9dWG2lVwg7KpPP_2F4Ryr_2F8Zyh5tMzm96_2FpIR5Uug7piImzSLe9BECI6XANKNHGRXSSJw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>