Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在dojox.charting.chart上缩放时如何设置偏移?_Javascript_Charts_Dojo_Dojox.charting - Fatal编程技术网

Javascript 在dojox.charting.chart上缩放时如何设置偏移?

Javascript 在dojox.charting.chart上缩放时如何设置偏移?,javascript,charts,dojo,dojox.charting,Javascript,Charts,Dojo,Dojox.charting,我正在努力在dojo图表上缩放。 我的图表在javascript中定义如下: var c2 = new dojox.charting.Chart("myChart"); c2.addPlot("default", { type: "StackedAreas", tension: 4 }).addAxis("x", {

我正在努力在dojo图表上缩放。 我的图表在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();
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]
然后,我有两个水平滑块,我想用它来缩放我的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 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();
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]

有人有想法吗?

据我所知,您使用的是chart.setAxisWindow(名称、比例、偏移量),例如

chart.setWindow(“x”, 3, 2)
chart.setWindow(“y”, 3, 1)
这将X轴上的偏移设置为2,Y轴上的偏移设置为1


如果您想了解更多信息,请使用chart.setAxisWindow(名称、比例、偏移量),例如

chart.setWindow(“x”, 3, 2)
chart.setWindow(“y”, 3, 1)
这将X轴上的偏移设置为2,Y轴上的偏移设置为1


如果您想了解更多信息,请继续

解决方案似乎比我预期的要简单得多:

chart.zoomIn(thAxis, [newStart, newEnd]);

看起来解决方案比我预期的要简单得多:

chart.zoomIn(thAxis, [newStart, newEnd]);

谢谢你的投票(如果你真的投票给我的答案),如果它有效的话,你可以把它标记为最好的。请参阅我所附的链接()它们解释了如何缩放/缩放/偏移。感谢投票(如果你投票给我的答案),如果它有效,你可以将其标记为最佳。参见我所附的链接(),它们解释了如何缩放/缩放/偏移。是的,我知道。setAxisWindow(“x”,缩放,偏移)也可以工作。我的问题是offset参数的行为异常。医生说它应该在“数据量表”中,这正是我不理解的。当我将其设置为35(如我的示例中所示)时,它会跳到一个更大的值。也许它代表了我的“数据”数组中的第35个值:我必须检查一下…嗨,如果你看这个例子,你还可以看到另一个解决方法:chart.setWindow(scaleX,scaleY,offsetX,offsetY,{duration:1500}).render();我知道,这个函数将调整/缩放图形。setAxisWindow(“x”,缩放,偏移)也可以工作。我的问题是offset参数的行为异常。医生说它应该在“数据量表”中,这正是我不理解的。当我将其设置为35(如我的示例中所示)时,它会跳到一个更大的值。也许它代表了我的“数据”数组中的第35个值:我必须检查一下…嗨,如果你看这个例子,你还可以看到另一个解决方法:chart.setWindow(scaleX,scaleY,offsetX,offsetY,{duration:1500}).render();此函数将调整图形的大小/比例