1.js脚本:


  1.     dojo.require("dojox.charting.Chart2D");
        dojo.require("dojox.charting.plot2d.Pie");
        dojo.require("dojox.charting.action2d.Highlight");
        dojo.require("dojox.charting.action2d.MoveSlice");
        dojo.require("dojox.charting.action2d.Tooltip");
        dojo.require("dojox.charting.themes.MiamiNice");
        dojo.require("dojox.charting.widget.Legend");
  2.  
  3. makeCharts = function(){  
  4. var chart1 = new dojox.charting.Chart2D("simplechart");  
  5. /* type:  
  6.  * Lines,Markers,Areas,MarkersOnly  
  7. */ 
  8. //chart1.addPlot("default", {type: "Lines"});  
  9. //chart1.addPlot("default", {type: "StackedAreas", lines: true, areas: true, markers: false});  
  10.    chart1.addPlot("default", {type: "Lines", markers: true,tension: "X", shadows: {dx: 2, dy: 2}});  
  11. chart1.addPlot("other", {type: "Areas"});  
  12.  
  13. chart1.addPlot("Grid", {type: "Grid",  
  14.      hAxis: "other x",  
  15.      vAxis: "other y",  
  16.      hMajorLines: true,  
  17.      hMinorLines: false,  
  18.      vMajorLines: true,  
  19.      vMinorLines: false 
  20.    });  
  21. //chart1.addAxis("x");  
  22. chart1.addAxis("x", {  
  23.      labels: [  
  24.              {value: 1, text: "Jan"},{value: 2, text: "Feb"},  
  25.              {value: 3, text: "Mar"}, {value: 4, text: "Apr"},  
  26.              {value: 5, text: "May"}, {value: 6, text: "Jun"},  
  27.              {value: 7, text: "Jul"}, {value: 8, text: "Aug"},  
  28.              {value: 9, text: "Sep"}, {value: 10, text: "Oct"},  
  29.              {value: 11, text: "Nov"}, {value: 12, text: "Dec"}  
  30.              ]  
  31.      });  
  32.  
  33. chart1.addAxis("y", {vertical: true});  
  34. chart1.addSeries("Series 1", [0,1.5, 2, 2, 3, 4, 5, 5, 7]);  
  35. chart1.addSeries("Series 2", [4, 1, 4, 2, 1, 6, 4, 3], {plot: "other", stroke: {color:"green"}, fill: "lightblue"});  
  36. chart1.addSeries("Series A", [{x: 1, y: 5}, {x: 1.5, y: 1.7},{x: 2, y: 9}, {x: 5, y: 3}],{stroke: {color:"red"}});  
  37. chart1.render();  
  38.   }; 
  39. dojo.addOnLoad(makeCharts);

2.HTML代码:


  1. <div id="simplechart" style="width: 600px; height: 400px;"></div> 

 3.页面展示效果:

dojo+线性图