Dojo 图表图例没有颜色 1.6
Posted
技术标签:
【中文标题】Dojo 图表图例没有颜色 1.6【英文标题】:Dojo charting legend no colors 1.6 【发布时间】:2012-10-05 15:02:59 【问题描述】:我正在尝试使用与图表中的颜色线相关的框颜色放置图例,但由于某种原因,框出现时带有叉号,但未显示颜色。
// 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>
【问题讨论】:
有demo会更简单.. 对不起,没明白你的意思。 【参考方案1】:更改以下行:
var legend1 = new dojox.charting.widget.Legend( chart: chartA , "legend ");
到
var legend1 = new dojox.charting.widget.Legend( chart: chartA , "legend");
【讨论】:
以上是关于Dojo 图表图例没有颜色 1.6的主要内容,如果未能解决你的问题,请参考以下文章