Use VML production statistics full Raiders
---- Cake
Author: Blue Wings CBS account: liuruhong (blue streetlights)
Email: liuruhong@263.net msn: blueswing_liu@hotmail.com Keywords: VML JavaScript OOP chart
Summary:
VML is the vector graphic implementation of Microsoft IE 5.0 and its subsequent versions, although MS also advocates the use of SVG in the future, but as an IE embedded markup, at some time the application is still more convenient. This article shows the establishment of a statistical pie chart through complete description, showing the charm of VML in web. By implementing a JavaScript class, the reader can completely see the production process of the entire pie chart.
VML (Vector Markup Language) has seen in silently since the adventure, until now, the situation still has no change. In fact, you can find that in terms of Web, MS has a built-in use, the most typical is Office's self-selected graphics, store the Word or PPT document into html, if you use a self-selected graphic inside the document, you will You can see that the graphics use VML, and another typical application is Visio's export to the web.
Some time ago, James published an example of using the ASP to generate a chart in CBS. I also read the code, and also for some questions, I asked him, James's color felt very good, but unfortunately I didn't have the same skill, so In the code implementation, I use a random color to implement, and the overall interface can look slightly more powerful.
The statistical comparison is the pie chart, the histogram, and the graph, this paper focuses on the production process of the PIE. The article uses JavaScript to implement a class. If the relevant JavaScript is not particularly known, you can refer to my additional article " Object's JavaScript programming "and" re-object-oriented JavaScript programming ".
Don't consider how to implement it, let's take a look at the final use of the code.
Objpie = new VMLPIE ("600px", "450px", "demographic"); // Initialization width, height, title
Objpie.borderwidth = 3; // Chart Border
Objpie.bordercolor = "blue"; // Chart Border Color
Objpie.width = "800px"; // Define the width of the chart
Objpie.height = "600px"; // Define the height of the chart
Objpie.backgroundcolor = "# ffffff"; // Define background color
Objpie.shadow = true; // Do you need a shadow TRUE to be false?
// Add chart data
// Sequence is name, value, description
Objpie.adddata ("Beijing", 50, "Beijing's population");
Objpie.adddata ("Shanghai", 52, "Shanghai fixed population");
Objpie.Adddata ("Tianjin", 30, "Tianjin's field population");
Objpie.adddata ("Xi'an", 58, "Xi'an City Population");
Objpie.adddata ("Wuhan", 30, "Wuhan's field population");
Objpie.adddata ("Chongqing", 58, "Chongqing City Population");
Result.innerhtml = Objpie.draw (); // Generate VML data
This code is the final call, I encapsulated a VMLPie's JavaScript class, and the focus of this article is to describe the specific implementation process of the class, and the VML must be used as the following statement.
1. HTML TAG's namespace declaration
2.
STYLE statementV /: * {behavior: URL (# default # VML)}
o /: * {behavior: URL (# default # vml)}
.shape {behavior: URL (# Default # VML)}
Style>
After completing the above work, the code will work intact.
Now we have begun to tell this VMLPie implementation, first, I will make a simple description of those implemented.
// VMLPIC main function, provide a VMLPIE instance
Function VMLPIE (PWIDTH, PHEIGHT, PCAPTION, PCONTAINER) {}
// Start the drawing, draw graphics to the specified container
Vmlpie.prototype.draw = function () {}
// Painted pie chart
Vmlpie.prototype.createpie = function () {}
// Interface function:
// Zoom or reduce graphics
//Parameter Description:
// ivalue: zoom in or reduced multiple, 1 is the original size, 50% of the original picture, 2 is the original picture
/ / Twice, in this type
Vmlpie.prototype.zoom = function (ivalue) {}
// Interface function:
// Add pie chart data
//Parameter Description:
// sname: Data Tag Name
// svalue: data value
// stooltiptext: Data Description
Vmlpie.prototype.adddata = function (sname, svalue, stooltiptext) {}
// Interface function:
/ / Clear all data
Vmlpie.prototype.clear = function () {}
// The following four functions are extended, providing some VML interactions
Function Hoverpie (EL) {}
Function Restorepie (EL) {}
Function legendmouseoverevent () {}
Function legendmouseoutevent () {}
After reading these functions, I want the reader to have a rough idea for the structure of the entire class, but for the production of VML, there may be no very clear ideas, then, I will focus on several VMLs. Elements, I just introduce some usage, specific in the "VML Chinese Tutorial" in Jaguar, more detailed, if you are interested, you can go to the reference.
1. v: group
As a container of VML, its property Coordsize defines its coordinate size, the location of the internal elements is just a coordsize defined with the group element, assuming that CoordSize is defined as 21600, 21600, is defined 21600 * 21600 canvas, if inside There is a V: shape or other element, Shape.Style.Left = "2160px", its actual location is just the location of the 1/10 width of V: Group. 2. V: RECT
Define a rectangular element, FillColor represents the background color of the fill, StokeColor represents the border color, strokeweight indicates the border width.
3. V: Shape
The default shape element provided by VML, can define any shapes required by defining the path, as for the use of PATH, can be referenced
3C
Document.
4. V: Fill
As the child element of Shape, it is used to set the background effect of Shape. The method of setting the fill by Type, the specific usage is as follows
1) Solid: Fill solid, fill the color through Color
2) Gradient: Line gradation, this time you need Color and Color2 two parameters to set the start color and end color of the gradient, and Angle sets the gradient direction.
3) GradientRadial: round gradient, other usage methods and gradient
4) TILE: Use the picture tile, SRC Set the picture
5) Pattern: Using the picture as a stamp mode
6) Frame: Use the picture to pull the god fill
Other Opacity is used to set transparency
5. V: shadow
Set whether Shape needs a shadow, mainly using the following parameters
ON: Set whether to enable shadow
Color: Color of Shadow
Offset: Shadow Deviation Location
6. V: TextBox
Define the text area of Shape
These elements are what I need to use in making VMLPIE, so I made a simple introduction, specific to the "VML Chinese tutorial", and the SDK Document of the MSDN's Vector Markup Language (VML) is a very Good reference. W
3C
Note is more abstract, and it is also a very important reference when doing some in-depth development.