2012-02-13 91 views
0

我是初學者嘗試使用DOJO的圖表示例..這是我從這個論壇中挑選的代碼。我能夠看到圖表,但根本看不到圖例...圖例不顯示--Dojo

是否在窗口小部件聲明或某些文件丟失? 所有文件都availbale在我的系統,雖然..我徹底失去了..

dojo.require("dojox.charting.Chart2D"); 
 
    dojo.require("dojox.charting.Chart2D"); 
 
    dojo.require("dojox.charting.themes.PlotKit.blue"); 
 
    dojo.require("dojox.charting.widget.Legend"); 
 
    dojo.require("dojox.layout.FloatingPane"); 
 
    dojo.require("dojox.charting.themes.MiamiNice"); 
 
    dojo.require("dojo.colors"); 
 

 
    makeCharts = function() { 
 
     var chart1 = new dojox.charting.Chart2D("simplechart"); 
 

 
     chart1.addPlot("default", { 
 
     type: "StackedColumns", 
 
     markers: true, 
 
     tension: 3, 
 
     shadows: { 
 
      dx: 2, 
 
      dy: 2, 
 
      dw: 2 
 
     } 
 
     }); 
 
     chart1.addAxis("x", { 
 
     labels: [{ 
 
      value: 1, 
 
      text: '18-Mar' 
 
     }, { 
 
      value: 2, 
 
      text: '19-Mar' 
 
     }, { 
 
      value: 3, 
 
      text: '20-Mar' 
 
     }, { 
 
      value: 4, 
 
      text: '21-Mar' 
 
     }, { 
 
      value: 5, 
 
      text: '22-Mar' 
 
     }, { 
 
      value: 6, 
 
      text: '23-Mar' 
 
     }] 
 
     }); 
 
     chart1.addAxis("y", { 
 
     vertical: true 
 
     }); 
 

 
     chart1.addSeries("Four", [196, 209, 77, 218, 48, 243]); 
 

 
     chart1.addSeries("One", [266, 158, 131, 228, 217, 262]); 
 

 
     chart1.addSeries("Three", [296, 214, 267, 80, 40, 225]); 
 

 
     chart1.addSeries("Two", [207, 264, 115, 227, 193, 27]); 
 

 
     chart1.setTheme(dojox.charting.themes.MiamiNice); 
 

 

 
     chart1.render(); 
 
     var legend = new dojox.charting.widget.Legend({ 
 
     chart: chart1, 
 
     horizontal: true 
 
     }, "legend"); 
 

 

 
    }; 
 

 
    dojo.addOnLoad(makeCharts);
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/resources/dojo.css"> 
 
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dijit/themes/tundra/tundra.css" media="screen" /> 
 
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js" data-dojo-config="isDebug: true, parseOnLoad: true"></script> 
 

 
<body class="tundra"> 
 
    <div id="simplechart" style="width: 350px; height: 150px;"></div>

請幫助..

回答

4

我補充這樣

一些代碼
<div id="legend"></div> 

在此密碼下

<div id="simplechart" style="width: 350px; height: 150px;"></div> 

我得到了這張照片。

show legend

是,你需要嗎?

(我不強的英文,對不起那個。)

0

dojox.charting.widget.Legend需要一個容器節點(類似div)。 你的情況,並補充說:

<div id="legend"></div>

後:

<div id="simplechart" style="width: 350px; height: 150px;"></div>

應該做的伎倆。