File: vmlgraph1_0_1.js
/ / -------------------------------------------------------------------------------------------- ------------ // Copyright (c) 2003-2004 Leadinsoft. All rights reserved.// Version 1.0.1 // ahthor Dolphin // ----------- ------------------------------------------------ VAR bstsingle = 0; // Chart border is single line var bstdouble = 1; // Chart border is double line var fstsolid = 0; // chart background solid fill var fstTexture = 1; // chart background material Plip VAR fstregular = "regular" // Font: Normal var fstitalic = "italic"; // font: Intragonal var fstbold = "bold"; // font: bold var atleft = "left"; // chart title Left align VAR atcenter = "center"; // Chart Title hidden VAR ATRIGHT = "Right"; // Chart title right alignment
/ / Define VML Chart base class Function graph () {this.text = new text (); this.border = new border (); this.width = 500; this.height = 300; this.Fill = new Fill () "This.Legend = new legend (); this.seriescollection = []; this.container = null; this.shadow = false; THIS.VMLOBJECT = null;};
// Get a reference var_p = graph.prototype; // by the base class, CHART_P.INITIALISE = function () {if (this.container == null) return; var o; // Picture outside box VAR Group = Document.createElement ("v: group"); group.style.width = this.width "pt"; group.style.height = this.height "pt"; group.coordsize = this.width * 10 ", " this.Height * 10; group.id =" group1 ";
// Add a background layer var vrect = document.createElement ("v: Rect"); vRect.Style.Width = (this.width * 10-100) "px"; vRect.Style.Height = this.Height * 10 "PX"; VRECT.COORDSIZE = "21600, 21600";
Group.appendchild (vRect); o = vRect; // Set the border size vRect.Strokeweight = this.border.width; // Set the border color vRect.StrokeColor = this.border.color; // Set the background IF (this.fill .Style == fstSolid) {vRect.fillcolor = this.Fill.Color;}! else {if (this.Fill.background = null) vRect.style.backgroundImage = this.Fill.background; else vRect.fillcolor = this. Fill.color;} // border is double line IF (this.border.style == bstdouble) {var TMP = Document.createElement ("v: Rect"); tmp.style.width = (this.width * 10 -300) "PX"; tmp.style.Height = (this.Height * 10-200) "px"; tmp.style.top = "100px"; tmp.style.left = "100px"; TMP. strokecolor = this.border.color; if (this.fill.style == fstsolid) {tmp.fillcolor = this.fill.color;} else {if (this.Fill.Background! = null) TMP.Style.BackgroundImage = this.Fill.background; else tmp.fillcolor = this.Fill.Color;} var filltmp = document.createElement ( "v: fill"); filltmp.type = "Frame"; tmp.appendChild (filltmp); group.appendChild (TMP); o = TMP;} // Draw title Var vcaptio n = document.createElement ("v: textbox"); vcAption.style.fontsize = this.text.font.size "px"; vcAption.style.color = this.text.font.color; vcAption.style.Height = this.text.height "px"; vcAption.style.fontweight = this.text.fontweight = this.text.font.style; vcAption.innerhtml = this.text.text; vcAption.style.Textalign = this.Text.Alignment;
O.Appendchild (VcAption);
// Draw Shadow IF (this.Shadow) {var vshadow = document.createElement ("v: shadow"); vshadow.on = "t"; vshadow.type = "single"; vshadow.color = "graytext"; vshadow .offset = "4px, 4px"; vRect.Appendchild (vshadow);} this.vmlobject = group; this.container.Appendchild (group);}; // draw specific graph_p.draw = function () {Alert "Base class is not able to instantiate specific data");
// Add sequence _p.addseries = function (o) {var iCount = this.seriescollection.Length; if (o.title == null) o.title = "series" icount; this.seriescollection [icount] = O };
// Value_p.maxs = function () {var max = 0; for (var i = 0; I / / Re-serve Object's TOSTRING method_P.TOString = function () {return "OGRAPH"; // Define the VML Chart Border Class Function Border () {this.color = "Black"; this.style = bstsingle; this.width = 1;}; // Define VML Chart Background Function Fill () {this.color = "White"; this.background = null; this.style = fstsolid;}; / / Define VML Chart Title Function Text () {this.alignment = atcenter; this.Height = 24; this.Font = New font (); this.text = "VML Chart Version 1.0"; / / Define VML Chart font class function font () {this.color = "black"; this.family = "arial"; this.size = 12; this.style = fstregular;}; // Define the VML Chart map class Function legend () {this.font = new font (); / / Define VML Chart Sequence Class Function Series () {this.color = Series.getColor (); this.title = null; this.all = [];}; // Get a color series.getColor = Function ) {RTURN "RGB (" Math.Round (Math.random () * 255) " Math.Round (Math.random () * 255) ", " Math.Round (Math.random ) * 255) ")";}; var _p = series.prototype; // increase specific data _p.adddata = function (sname, svalue, shref, stooltiptext) {var odata = new object (); odata.name = sName; oData.Value = sValue; oData.Href = sHref; if (sTooltipText == null || sTooltipText == "undefined") oData.TooltipText = "value of this item:" sValue; else oData.TooltipText = sTooltipText Var iCount = this.all.Length; this.all [iCount] = odata;}; // ask the maximum value_p.max = function () {var max = 0; for (var i = 0; i < THIS.ALL.LENGTH; I ) {IF (this.all [i] .value> max) Max = this.all [i] .value;} return max; // Rear dash Object's TSTRING method_P.toString = function () {return "oseries"; / / Define VML Chart Time Series Function TimeSeries () {series.call (this);}; var _p = TimeSeries.Prototype = new series; // Add specific data _p.adddata = function (Stime, Svalue, Stype, Shref, stooltiptext) {var = new object (); var dt = new date (EVAL (STIME * 1000)); if (stype == "minute") {odata.name = dt.getHours () ":" DT.GETMINUTES ();} else if (stype == "hour") {odata.name = dt.GetHours ();} else if (stype == "day") {odata.name = evAl (Dt.getMonth () 1) "Month" DT.Getdate () "Day";} else} (stype == "month") {odata.name = dt.getYear () "Year" Eval (DT. GetMonth () 1) "Month";} else {odata.name = dt.getyear () "Year"}}}} odata.value = svalue; odata.href = shref; odata.tooltiptext = "This item is: " Svalue ", Time: " DT.Getyear () " Year " Eval (DT.GETMONTH () 1) " Month " DT.Getdate () " Day " Dt.GetHours () ":" DT.GETMINUTES () ":" Dt.getSeconds (); var iCount = this.all.Length; this.all [icount] = odata;}; // Reserved Object's Tostring method_ P.TOSTRING = function () {return "otimeseries"; / / Define VML Chart Coordinate Eserts Function Axis () {this.color = "Black"; this.ln = 0; this.Numberformat = 0; this.prefix = null; this.suffix = null; this.spacing = 30 Id.width = 0; this.ShowPoint = 12;}; // VerticalChart class, inherited graphfunction verticalchart () {graph.call (this); this.margin = new array (300, 100, 300, 200); this.axisx = new axis (); this.axisy = new axis ();}; var_p = VERTICALCHART.PROTIPE = New graph; // Painting coordinate _P.drawcoord = function (OCONTAINER) {this.AxiSy.ln = Eval (this.height * 10 - this.margin [3]) - this.margin [1 ] - 400; VAR VLINE = Document.createElement ("v: line"); vline.id = "idcoordy"; VLINE.FROM = this.margin [0] "," this.margin [1]; VLINE. To = this.margin [0] "," EVAL (this.Height * 10 - this.margin [3]); vline.style.zindex = 8; VLINE.Style.Position = "absolute"; Vline.StrokeColor = this.AxiSy.color; VLINE.STROKEWEIGHT = 1; var vStroke = Document.createElement ("v: stroke"); vStroke.startarrow = "classic"; VLINE.APpendChild (vStroke); OContainer.Appendchild (VLINE); THIS.AXISx.ln = evAl (this.width * 10 - this.margin [0]) - this.margin [2] - 300; var Vline = document.createElement ("v: line"); VLINE.ID = " IDCOORDX "; VLINE.FROM = this.margin [0] ", " EVAL (this.height * 10 - this.margin [3]); VLINE.TO = EVAL (this.width * 10 - this.margin [ 2]) "" EVAL (this.height * 10 - this.margin [3]); VLINE.Style.zindex = 8; VLINE.StyLe.Position = "absolute"; Vline.StrokeColor = this.axisx. Color vline.strokeweight = 1; VAR vStroke = Document.createElement ("v: stroke"); vStroke.endarrow = "classic"; Vline.Appendchild (vStroke); OContainer.Appendchild (VLINE); // Draw X-axis scale _p.drawlinex = function (OCONTAER) {var TotalPoint = this.seriescollection [0] .all.Length; var iCol = TotalPoint 1; var fcolwidth = math.fllor (this.axisx.ln / Icol); this.axisx.width = fcolwidth; var showpoint = this.axisx.showpoint, step = 1; if (TotalPoint> showpoint) {if (TotalPoint For (var i = 1; i <= showpoint; i ) {ln = i * step; if (ln> totalpoint) Break; newline = document.createElement ("v: line"); px = this.margin [0] (i-1) * fcolwidth * step; newline.from = px "," y; newline.to = px "," evAl (y this.axisx.spacing); newline.style.zindex = NEWLINE.Style.Position = "absolute"; Newstroke = document.createElement (" NEWTEXT = Document.createElement (" // Draw Y-axis scale _p.drawliney = function (OCONTAER) {var maxdata = this.maxs (); maxdata = (4 - maxdata% 4) var showpoint = this.axisy.showpoint; var DCS = 1; for (VAR i = showpoint; i> 0; i -) {if (MaxData% i == 0) {dcs = i; this.axiiSy.showpoint = i; break;}} var newline, newstroke, newshape, newtext; Var py; var x = this.margin [0]; var FrowHeight = math.floor (this.axisy.ln / dcs); this.axisy.width = maxdata; // Y axis stores maximum For (var i = 0; i <= dcs; i ) {py = evAl (this.Height * 10 - this.margin [3]) - i * flowheight; if (i! = 0) {newline = document.createElement ("v: line"); newline.From = evacing "," py; newline.to = x "," py; newline.style.zindex = 8; newline .Style.Position = "absolute"; Newstroke = Document.createElement (" NEWTEXT = Document.createElement (" {Var Arrseries = function (OCONTAER) {var arrseries = this.seriescollection; for (var i = 0; i Var newshape = document.createElement (" VAR newText = Document.createElement (" Newtext.innerhtml = "" arrseries [i] .title; newshape.Appendchild (newtext); ocontainer.appendchild (newshape);}}; // --------------- -------------------------------------------------- --------- // Vertical column graph, inherit the verticalChart class function verticalbarchart () {verticalchart.call (this);}; var _p = verticalbarchart.prototype = new verticalChart; // Heavy flower X-axis scale _P.drawLinex = function (OCONTAER) {var TotalPoint = this.seriescollection [0] .all.Length; var iCol = TotalPoint 1; var fcolwidth = math.floor (this.axisx.ln / ICOL); this.axisx.width = fcolwidth; var showpoint = this.axisx.showpoint, step = 1; if (TotalPoint> showpoint) {if (TotalPoint THIS.AXISx.ShowPoint = showpoint; var newline, news; newshape, newtext; var px, ln; var y = evAl (this.height * 10 - this.margin [3]); For (var i = 1; i <= showpoint; i ) {ln = i * step; if (ln> totalpoint) Break; newline = document.createElement ("v: line"); px = this.margin [0] i * fcolwidth * step; newline.from = px "," y; newline.to = px "," evAl (y this.axisx.spacing); newline.style.zindex = 8; newline. Style.Position = "absolute"; Newstroke = Document.createElement (" // Draw verticalLineChart_p.draw = function () {if (this.border.style == 1) {this.margin = new Array (400, 200, 400, 300);} var oContainer = this.VMLObject; this.AxisY.showPoint = 10; this.drawCoord (oContainer); this.drawLineX (oContainer); this.drawLineY (oContainer); this.drawSmallSeries (oContainer); this.drawLine (oContainer); } // Data of VerticalLineChart_P.drawLine = Function (Ocontainer) {var arrseries = this.seriesCollection; var fcolwidth, dcs; fcolwidth = this.axisx.width; dcs = this.axisy.ln / this.axiSy.Width Var ivalueln, iSeriesln; iSeriesln = arrseries.length var Points = New Array (iSeriesln); Var L, T, Barheight; for (var i = 0; i arrSeries [i] .all [k] .TooltipText; oContainer.appendChild (newOval);}} oContainer.appendChild (newPolyLine);}}; // ----------------- -------------------------------------------------- ---------- File: VMLGRAPH1_0_1.HTM