Dojo chart generation function

Source: Internet
Author: User

Dojo chart generation function

A function is written to generate a chart by passing parameters. The Code is as follows:

/*** Created by LZUGIS * @ param container * @ param type * @ param data * @ constructor */function AddChart (container, type, data) {require (["dojox/charting/Chart2D", "dojox/charting/themes/PlotKit/blue", "dojox/charting/action2d/Highlight ", "dojox/charting/action2d/Tooltip", "dojox/charting/action2d/MoveSlice"], function (Chart2D, themes, Highlight, Tooltip, MoveSlice) {var chart = new dojox. charting. chart2D (container); chart. setTheme (dojox. charting. themes. plotKit. blue); // set the topic switch (type) {case "bar": {// bar chart. addPlot ("default", {type: "Columns", gap: 8 // interval between control Columns}); break;} case "pie ": {// pie chart. addPlot ("default", {type: "Pie", labelOffset: 40 // control the display position of the annotation, "+" is inside, "-" is outside}); break ;} case "line": {// linear chart. addPlot ("default", {type: "Lines", markers: true, // whether the data point displays tension: "X" // The curve is smooth, "X" is similar to "S", and "x" is closed and smooth}); break;} case "stack": {// stacked chart. addPlot ("default", {type: "StackedColumns", gap: 8}); break;} default: {break;} var xStr = ["Monday ", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; // Add axes var myLabelFunc = function (text, value, precision) {return xStr [text-1] ;}; chart. addAxis ("x", {labelFunc: myLabelFunc}); chart. addAxis ("y", {vertical: true, fixLower: "major", fixUpper: "major"}); chart. addSeries ("Series A", data); new Highlight (chart, "default", {highlight: "lightskyblue"}); new Tooltip (chart, "default "); new MoveSlice (chart, "default"); // new Legend ({chart: chart}, "legend"); chart. render ();});}
The usage is simple as follows:

    
     dojo chart test        <script src="http://localhost/arcgis_js_api/library/3.9/3.9/init.js"></script>    <script src="js/dojochart.js"></script>    <script type="text/javascript">        var chartData = [40000,9200,11811,12000,8662,12000,8662];        AddChart("chart","bar",chartData);    </script>            


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.