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. function getPipe() {  
  4.         var dc = dojox.charting;  
  5.         var chartTwo = new dc.Chart2D("chartTwo");  
  6.         chartTwo.setTheme(dc.themes.MiamiNice).addPlot("default", {  
  7.             type: "Pie",  
  8.             font: "normal normal 11pt Tahoma",  
  9.             fontColor: "black",  
  10.             labelOffset: -30,  
  11.             radius: 80  
  12.         }).addSeries("Series A", [{  
  13.             y: 4,  
  14.             text: "Red",  
  15.             stroke: "black",  
  16.             tooltip: "Red is 50%" 
  17.         },  
  18.         {  
  19.             y: 2,  
  20.             text: "Green",  
  21.             stroke: "black",  
  22.             tooltip: "Green is 25%" 
  23.         },  
  24.         {  
  25.             y: 1,  
  26.             text: "Blue",  
  27.             stroke: "black",  
  28.             tooltip: "I am feeling Blue!" 
  29.         },  
  30.         {  
  31.             y: 1,  
  32.             text: "Other",  
  33.             stroke: "black",  
  34.             tooltip: "Mighty <strong>strong</strong><br>With two lines!" 
  35.         }]);  
  36.         var anim_a = new dc.action2d.MoveSlice(chartTwo, "default");  
  37.         var anim_b = new dc.action2d.Highlight(chartTwo, "default");  
  38.         var anim_c = new dc.action2d.Tooltip(chartTwo, "default");  
  39.         chartTwo.render();  
  40.         var legendTwo = new dojox.charting.widget.Legend({  
  41.             chart: chartTwo  
  42.         },  
  43.         "legendTwo");  
  44.     } 
  45. dojo.addOnLoad(getPipe);//添加onload事件

2.HTML代碼:

 
   
  1. <div id="legendTwo"> 
  2. </div>  

3.展示效果: