JqPlot jquery's page chart plotting tool

Source: Internet
Author: User

Jqplot is based on a basic jqplot. js files with multiple plug-ins supported by js files-that is, jqplot. js files can only be used to draw line charts. For pie charts and bar charts, pieRenderer must be introduced. js files.
Here, we will refer to the official jqPlot documentation and take the pie chart as an example to briefly describe the usage of jqPlot:
Step 1: Introduce the js file (if it is a chart other than a line chart, you need to introduce the relevant js file. Here, introduce the pie chart file pieRenderer)
Copy codeThe Code is as follows:
<! -- [If IE]> <script language = "javascript" type = "text/javascript" src = "./excanvas. js"> </script> <! [Endif] -->
<Link rel = "stylesheet" type = "text/css" href = "./jquery.jqplot.css"/>
<Script language = "javascript" type = "text/javascript" src = "./jquery-1.3.2.min.js"> </script>
<Script language = "javascript" type = "text/javascript" src = "./jquery. jqplot. js"> </script>
<Script language = "javascript" type = "text/javascript" src = "./plugins/jqplot. pieRenderer. js"> </script>

Step 2: Add a container for the chart display area
Copy codeThe Code is as follows:
<Div id = "chart" style = "margin-top: 20px; margin-left: 20px; width: 460px; height: 500px;"> </div>

Step 3: obtain data
Copy codeThe Code is as follows:
Line1 = [['frogs ', 3], ['buzzs', 7], ['deer', 2.5], ['turkeys', 6], ['moles ', 5], ['ground hogs ', 4];

Step 4: configure the Option object and create a chart
Copy codeThe Code is as follows:
$. Jqplot ('chart', [line1], {
Title: 'pierenderer', // set the title of the pie chart
SeriesDefaults: {fill: true,
ShowMarker: false,
Shadow: false,
Renderer: $. jqplot. PieRenderer,
RendererOptions :{
Diameter: undefined, // set the diameter of the pie
Padding: 20, // The distance between the pie and its category Name box or chart border, disguised as the diameter of the table pie
SliceMargin: 9, // distance between each part of the pie
Fill: true, // sets the status of each part of the pie.
Shadow: true, // sets a shadow for the border of each part of the pie to highlight its stereoscopic effect.
ShadowOffset: 2, // sets the distance between the border of each part of the pie to be removed from the shadow area.
ShadowDepth: 5, // sets the depth of the shadow area.
ShadowAlpha: 0.07 // sets the transparency of the shadow area.
}
},
Legend :{
Show: true, // set whether the category Name box appears (that is, the names of all categories appear in a certain position of the graph)
Location: 'ne ', // The position shown in the category Name box is nw, n, ne, e, se, s, sw, w.
Xoffset: 12, // The distance between the category Name box and the border on the chart area (unit: px)
Yoffset: 12, // The distance between the category Name box and the left border of the chart area (unit: px)
}
});

The complete code is as follows:
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN"
Http://www.w3.org/TR/html4/loose.dtd>
<Html lang = "en">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> Simple Test </title>
<! -- [If IE]> <script language = "javascript" type = "text/javascript" src = "./excanvas. js"> </script> <! [Endif] -->
<Link rel = "stylesheet" type = "text/css" href = "./jquery.jqplot.css"/>
<Script language = "javascript" type = "text/javascript" src = "./jquery-1.3.2.min.js"> </script>
<Script language = "javascript" type = "text/javascript" src = "./jquery. jqplot. js"> </script>
<Script language = "javascript" type = "text/javascript" src = "./plugins/jqplot. pieRenderer. js"> </script>
<Script type = "text/javascript" language = "javascript">
$ (Document). ready (function (){
Line1 = [['frogs ', 3], ['buzzs', 7], ['deer', 2.5], ['turkeys', 6], ['moles ', 5], ['ground hogs ', 4];
Plot1 = $. jqplot ('chart', [line1], {
Title: 'pierenderer', // set the title of the pie chart
SeriesDefaults: {fill: true,
ShowMarker: false,
Shadow: false,
Renderer: $. jqplot. PieRenderer,
RendererOptions :{
Diameter: undefined, // set the diameter of the pie
Padding: 20, // The distance between the pie and its category Name box or chart border, disguised as the diameter of the table pie
SliceMargin: 9, // distance between each part of the pie
Fill: true, // sets the status of each part of the pie.
Shadow: true, // sets a shadow for the border of each part of the pie to highlight its stereoscopic effect.
ShadowOffset: 2, // sets the distance between the border of each part of the pie to be removed from the shadow area.
ShadowDepth: 5, // sets the depth of the shadow area.
ShadowAlpha: 0.07 // sets the transparency of the shadow area.
}
},
Legend :{
Show: true, // set whether the category Name box appears (that is, the names of all categories appear in a certain position of the graph)
Location: 'ne ', // The position shown in the category Name box is nw, n, ne, e, se, s, sw, w.
Xoffset: 12, // The distance between the category Name box and the border on the chart area (unit: px)
Yoffset: 12, // The distance between the category Name box and the left border of the chart area (unit: px)
}
});
});
</Script>
</Head>
<Body>
<Div id = "chart" style = "margin-top: 20px; margin-left: 20px; width: 460px; height: 500px;"> </div>
</Body>
</Html>

The generated chart is shown as follows:

De life "alt =" jqPlot -- jquery-based page chart rendering tool-gaoyusi-My coDe life "src =" http://www.bkjia.com/uploads/allimg/131016/0416052Q3-0.jpg ">

Below are some other types of icons:

1. Multi-vertical axis chart

De life "alt =" jqPlot -- jquery-based page chart rendering tool-gaoyusi-My coDe life "src =" http://www.bkjia.com/uploads/allimg/131016/04160522P-1.jpg ">

2. Gantt chart with prompt information

De life "alt =" jqPlot -- jquery-based page chart rendering tool-gaoyusi-My coDe life "src =" http://www.bkjia.com/uploads/allimg/131016/041605H54-2.jpg ">

3. display the Gantt chart of the prompt information in table mode

De life "alt =" jqPlot -- jquery-based page chart rendering tool-gaoyusi-My coDe life "src =" http://www.bkjia.com/uploads/allimg/131016/0416056407-3.jpg ">

4. line chart with prompt information (can be dragged)

De life "alt =" jqPlot -- jquery-based page chart rendering tool-gaoyusi-My coDe life "src =" http://www.bkjia.com/uploads/allimg/131016/04160551Z-4.jpg ">

For details about the jqPlot function, refer to the subsequent articles in this article-Detailed description of the Option configuration object of jqPlot.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.