我正在努力放大道场图表。我的图表是在 javascript 中定义的,如下所示:
var c2 = new dojox.charting.Chart("myChart");
c2.addPlot("default", {
type: "StackedAreas",
tension: 4
}).addAxis("x", {
labels : labels
}).addAxis("y", {
vertical: "true",
fixLower: "major",
fixUpper: "major"
}).setTheme(dojox.charting.themes.Tufte).addSeries("Series A", values).render();
然后,我有 2 个水平滑块,我想用它们从 x 轴的左右边界进行缩放。为此,我做了类似的事情:
dojo.connect(myMinSlider, "onChange", function(value) {
var currentMin = Math.ceil(value),
currentMax = myMaxSlider.get('value'),
// currentMax and currentMin are the values of the left and right sliders
scale = theMaxValueOfMyXAxis / (currentMax - currentMin);
offset = currentMin; // this is wrong... should be in "data coordinates" but I don't know what data coordinates refers to...
c2.setAxisWindow("x", scale, offset, { duration: 500 }).render();
});
现在,缩放看起来不错,但偏移完全错误。本教程说“偏移量在数据坐标中”,但恐怕我在这里没有得到“数据坐标”的含义。
假设 myMinSlider 值设置为 35,我希望图表的 X 轴从 35 开始。这就是我将其设置为 currentMin 值的原因。但是,我的图表移动到 Y 轴的左侧......离它应该的位置太远了......
我图表中的数据是一个如下所示的系列:
var data = [36,297,1202,205,160,130,122,121,120,111,116,65,118,123,118,104,144,114,141,216,134,216,89,89,103,95,85,95,93,101,103,98,96,116,119,129,112,104,107,103,86,100,107,81,117,96,105,115,115,116,129,117,116,127,129,121,125,118,133,128,128,136,110,142,152,144,162,154,154,134,148,166,140,168,154,158,177,186,169,210,202,230,232,237,226,251,298,313,410,469,614,765,982,1352,1796,2239,2806,3217,3800,4378,5083,5353,5728,6111,6000,6051,5901,5835,5569,5212,4736,4408,3816,3340,2782,2223,1909,1525,1218,1057,878,645,521,421,296,270,234,197,151,165,150,128,143,142,135,127,146,107,108,109,130,126,134,114,116,102,124,158,148,130,120,137,138,165,130,136,124,121,137,122,131,106,119,136,109,100,91,118,115,94,104,99,101,99,91,113,95,111,88,92,102,87,109,83,99,100,88,100,79,79,96,116,98,84,88,72,74,82,78,85,93,68,96,92,84,77,101,106,87,102,110,96,121,107,110,112,110,113,120,96,106,100,109,109,139,147,126,147,140,143,118,125,129,132,132,118,116,129,140,124,111,125,117,134,91,100,116,89,12]
有人有想法吗?