问题
I am trying to create a stacked bars chart in dimple.js with the stacked bar starting from a negative position.
Is there any property of the chart that does this or is there any tweak that we can put into dimple.js file?
回答1:
That's a slightly unusual requirement and dimple doesn't support it as a simple property, however you can create the impression of a bar starting below zero by using a fake axis. Here's an example with accompanying fiddle to show what I mean:
var svg = dimple.newSvg("#chartContainer", 600, 400);
var data = [
{ bar: "A", value: "100" },
{ bar: "B", value: "110" },
{ bar: "C", value: "120" },
{ bar: "D", value: "130" }
];
var chart = new dimple.chart(svg, data);
var x = chart.addCategoryAxis("x", "bar");
var y1 = chart.addMeasureAxis("y", "My Fake Axis Title");
var y2 = chart.addMeasureAxis("y", "value");
y1.overrideMin = -100;
y1.overrideMax = 200;
y2.overrideMin = -10;
y2.hidden = true;
chart.addSeries(null, dimple.plot.bar, [x, y2]);
chart.draw();
http://jsfiddle.net/LVKfa/1/
来源:https://stackoverflow.com/questions/20673476/how-to-start-stacked-bars-from-a-negative-value