admin管理员组文章数量:1406047
This is likely fairly simple Q (learning the ropes with Dojo).
I have successfully created a bar chart in my web app.
// Create Chart
var chartDiv = dojo.create("div");
dijit.byId("someDiv").setContent(chartDiv);
var chart1 = dojox.charting.Chart2D(chartDiv);
chart1.addPlot("default", {
type: "Bars",
gap: 3
});
chart1.addAxis("x");
chart1.addAxis("y", {
vertical: true,
labels: [{
value: 1,
text: "Field1"
}, {
value: 2,
text: "Field2"
}]
});
chart1.addSeries("MyData", [var1, var2]);
chart1.render();
I see that you can create custom themes to your charts. However, I am thinking there must be a simpler way to define a colour (ideally a subtle gradient) for each of my bars. I am also restricted to using a dojo version served up by Esri, and not sure if that allows me to then create cutom themes.
There will only ever be 5 bars (2 in the above snippet).
i.e. I want to define a different color for each bar.
Can someone put me out of my misery and provide some guidance on how to achieve this?
This is likely fairly simple Q (learning the ropes with Dojo).
I have successfully created a bar chart in my web app.
// Create Chart
var chartDiv = dojo.create("div");
dijit.byId("someDiv").setContent(chartDiv);
var chart1 = dojox.charting.Chart2D(chartDiv);
chart1.addPlot("default", {
type: "Bars",
gap: 3
});
chart1.addAxis("x");
chart1.addAxis("y", {
vertical: true,
labels: [{
value: 1,
text: "Field1"
}, {
value: 2,
text: "Field2"
}]
});
chart1.addSeries("MyData", [var1, var2]);
chart1.render();
I see that you can create custom themes to your charts. However, I am thinking there must be a simpler way to define a colour (ideally a subtle gradient) for each of my bars. I am also restricted to using a dojo version served up by Esri, and not sure if that allows me to then create cutom themes.
There will only ever be 5 bars (2 in the above snippet).
i.e. I want to define a different color for each bar.
Can someone put me out of my misery and provide some guidance on how to achieve this?
Share Improve this question edited Dec 11, 2012 at 12:00 jakc asked Dec 10, 2012 at 12:49 jakcjakc 1,1713 gold badges17 silver badges44 bronze badges2 Answers
Reset to default 5In hindsight, bit lazy on my side. Here is what worked for me:
chart1.addSeries("Languages", [
{ y: var1, fill: "#BD48E9" },
{ y: var2, fill: "#FA4848" },
]);
You add the following code before calling render
method
chart1.addSeries("MyData", [var1, var2],
{plot: "other", stroke: {color:"red"}, fill: "lightgreen"}
);
chart1.render();
本文标签: javascriptFill colour for individual bars in Dojo ChartStack Overflow
版权声明:本文标题:javascript - Fill colour for individual bars in Dojo Chart? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744966854a2635000.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论