[英]Dojo Chart issues in column chart with positive and negative values
我正在使用dojo chart创建具有正值和负值的柱形图。在这里,我需要我的起始值从100开始而不是零。假设我的值大于100,那么它显示的是100以上的柱线,如果我的值小于100,则类似。下方显示100个类似负值的显示。 下面是我的代码
index.php
dojo.require("dojox.charting.Chart");
dojo.require("dojox.charting.axis2d.Default");
dojo.require("dojox.charting.plot2d.ClusteredColumns");
dojo.require("dojox.charting.themes.Tufte");
dojo.require("dojox.dtl");
dojo.require("dojox.dtl.Context");
charts = [
{
description: "Clustered columns with positive and negative values, readable theme, 1-second animate-in.",
makeChart: function(node){
(new dojox.charting.Chart(node)).
setTheme(dojox.charting.themes.Tufte).
addAxis("x", { fixLower: "minor", fixUpper: "minor", natural: true }).
addAxis("y", {
majorTickStep: 10,
max: 150,
vertical: true, fixLower: "major", fixUpper: "major" }).
addPlot("default", { type: "ClusteredColumns", gap: 10, animate: { duration: 1000 } }).
addSeries("Series A", [ 120, 110, 107, 115, 121 ] ).
addSeries("Series B", [ 80, 90, 75, 85, 62 ] ).
render();
}
},
];
var now = function(){
return (new Date()).getTime();
};
dojo.addOnLoad(function(){
var defaultStyle = { width: "400px", height: "200px" };
var tmpl = new dojox.dtl.Template(dojo.byId("template").value);
var context = new dojox.dtl.Context({ charts: charts });
dojo.byId("charts").innerHTML = tmpl.render(context);
dojo.forEach(charts, function(item, idx){
var start = now();
var n = dojo.byId("chart_"+idx);
dojo.style(n, item.style||defaultStyle);
item.makeChart(n);
console.debug((now()-start), "ms to create:", (idx+1)+":", item.description);
});
因此,请您提出建议,如何将轴标签设置为100而不是0。这样我就可以配置图表了
您可以在代码中添加此参数。
.addAxis("y", {
dropLabels : true,
min : 10,
max : 20,
from: 0,
to: 15
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.