2012-10-05 45 views
2

我試圖把圖例中的顏色線與框中的顏色相關聯,但由於某些原因框出現十字顏色不顯示。Dojo圖表傳說沒有顏色1.6

// Require the basic 2d chart resource: Chart2D dojo.require("dojox.charting.Chart2D"); // Require the theme of our choosing //"Claro", new in Dojo 1.6, will be used dojo.require('dojox.charting.widget.Chart2D'); dojo.require("dojox.charting.widget.Legend"); 
 
dojo.require("dojox.charting.action2d.Tooltip"); //dojo.require('dojox.charting.plot2d.Columns'); //dojo.require('dojox.charting.themes.PlotKit.blue'); dojo.require("dojox.charting.themes.Claro"); dojo.require('dojox.charting.DataSeries'); dojo.require('dojox.charting.StoreSeries'); 
 
// Define the data var chartData = [10000,9200,11811,12000,7662,13887,14200,12222,12000,10009,11288,12099]; var chartData2 = [100,200,1111,1200,7662,13287,14260,18222,14000,9009,10288,11099]; function trans1(store, item){ // let's create our object 
 
var o = { 
 
x: store.getValue(item, "first_online"), 
 
y: store.getValue(item, "t"), 
 
tooltip: store.getValue(item, "t"); //,color: store.getValue(item, "urgency") ? "red" : "green" }; // we can massage the object, if we want, and return it return o; } 
 
// When the DOM is ready and resources are loaded... dojo.ready(function() { // Create the chart within it's "holding" node var chartA = new dojox.charting.Chart2D("chartNode"); // Set the theme chartA.setTheme(dojox.charting.themes.Claro); //chart.setTheme(dojox.charting.themes.PlotKit.blue); 
 
// Add the only/default plot chartA.addPlot("default", { type: "Lines", markers: true }); // Add axes chartA.addAxis("x", {"title" : "Mês", min: 1, max: 12}); chartA.addAxis("y", { min: 1, max: 500, vertical: true, fixLower: "major", fixUpper: "major" 
 
}); // Add the series of data //addSeries("My Month", new dojox.charting.DataSeries(mystore, {query:{}}, "MyMonth")). // var jsonStoreChart1 = new dojo.data.ItemFileReadStore({ url: "/docsismodem/getnewbymonths/year/ 
 
<?= d ate("Y", strtotime("-1 year")) ?> ", id: 'jsonStoreChart1' }); var jsonStoreChart2 = new dojo.data.ItemFileReadStore({ url: "/docsismodem/getnewbymonths/year/
 
    <?= d ate("Y") ?> ", id: 'jsonStoreChart2' }); var jsonStoreChartCuda = new dojo.data.ItemFileReadStore({ url: "/docsismodem/getnewbymonthsnetwork/year/
 
    <?= d ate("Y") ?> /network/10.1 ", id: 'jsonStoreChartCuda' }); var jsonStoreChartArris = new dojo.data.ItemFileReadStore({ url: "/docsismodem/getnewbymonthsnetwork/year/
 
    <?= d ate("Y") ?> /network/10.2 ", id: 'jsonStoreChartArris' }); var jsonStoreChartTera = new dojo.data.ItemFileReadStore({ url: "/docsismodem/getnewbymonthsnetwork/year/
 
    <?= d ate("Y") ?> /network/10.3 ", id: 'jsonStoreChartTera' }); chartA.addSeries(" 
 

 
<?= d ate("Y", strtotime("-1 year")) ?> ",new dojox.charting.DataSeries(jsonStoreChart1, {query: {first_online: '*'}} ,trans1)); chartA.addSeries(" 
 

 
<?= d ate("Y") ?> ",new dojox.charting.DataSeries(jsonStoreChart2, {query: {first_online: '*'}}, trans1)); chartA.addSeries(" 
 

 
<?= d ate("Y") ?> Cuda ",new dojox.charting.DataSeries(jsonStoreChartCuda, {query: {first_online: '*'}}, trans1)); chartA.addSeries(" <?= d ate("Y") ?> Terayon ",new dojox.charting.DataSeries(jsonStoreChartTera, {query: {first_online: '*'}}, trans1)); chartA.addSeries(" <?= d ate("Y") ?> Arris ",new dojox.charting.DataSeries(jsonStoreChartArris, {query: {first_online: '*'}}, trans1)); // Render the chart! chartA.render(); var legend1 = new dojox.charting.widget.Legend({ chart: chartA }, " 
 
legend "); new dojox.charting.action2d.Tooltip(chartA); 
 
         });
<div style="float: left; background-color: #E0E4E7; border: 1px solid black; width:400px;"> 
 
    <!-- create the DOM node for the chart --> 
 
    <p style="text-align: center;">Novos CM registrados por mês</p> 
 
    <div id="chartNode" style="width:300px;height:150px; float: none;"></div> 
 
    <div id="legend"></div> 
 

 

 
</div>

+0

與演示會更容易.. – anvd

+0

對不起,沒明白你的意思。 –

回答

0

更改以下行:

var legend1 = new dojox.charting.widget.Legend({ chart: chartA }, "legend "); 

var legend1 = new dojox.charting.widget.Legend({ chart: chartA }, "legend");