Hyn*_*nek 1 dojo dojox.charting
我有一个Dojo 1.8的工作图表.
chart1 = new dojox.charting.Chart2D("chart1");
chart1.addPlot("default", {type: "Lines", ...
chart1.addSeries("Series A", [{ x: 1, y: 2.3, tooltip: "Value 1"}, ...
Run Code Online (Sandbox Code Playgroud)
我的系列数据正确显示为行,整行(系列)的颜色为"绿色".我知道如何更改整个系列的颜色,但是这条线可能会根据数据值改变颜色吗?让我们假设x轴是一个时间轴,我需要线(系列)为绿色直到今天,然后红色为未来值.这有可能吗?怎么样?(我正在使用值的标记.如果这些值可以根据值改变就足够了)
我在文档中发现了类似的东西:
chart.addSeries("Series A", [
{y: 4, color: "red"},
{y: 2, color: "green"},
{y: 1, color: "blue"},
{y: 1, text: "Other", **color: "white", fontColor: "red"**}
]);
Run Code Online (Sandbox Code Playgroud)
但它仅适用于PIE图表而不适用于LINES图表.
先感谢您.
小智 5
你可以尝试这个http://jsfiddle.net/jUS54/
在addPlot方法中使用styleFunc来更改标记颜色:
var chart1 = new Chart("simplechart");
chart1.addPlot("default", {type: Lines, markers:true, styleFunc: function(item {
if(item <= 2){
return { fill : "red" };
}else if(item > 3){
return { fill: "green" };
}
return {};
}});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1846 次 |
| 最近记录: |