almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

Graph2d: Right axis shows wrong range #3512

Open thomai-d opened 7 years ago

thomai-d commented 7 years ago

When drawing a line chart with two axis and individual axis-range, the right axis sometimes shows the wrong range.

You can reproduce the problem using the Both axis example. Just modify the initialization on the bottom to the following code:

var options = {
    dataAxis: { 
        showMinorLabels: false,
        alignZeros: false,
        left: { range: { min: 90, max: 210 } },
        right: { range: { min: 1100, max: 2100 } }
    },
    legend: {left:{position:"bottom-left"}},
    start: '2014-06-09',
    end: '2014-07-03'
};

As you can see, the right axis should display something around 1000 to 2000, but it actually shows 1500 to 2000. bug

RightAxisWrongRange.zip

dariogoetz commented 6 years ago

I have a similar issue, where the right axis is so much off, that the graph is not being shown at all:

var items = [
    {x: "2017-08-07", y: 1, group: 0},
    {x: "2017-08-09", y: 1, group: 0},
    {x: "2017-08-07", y: 0, group: 1},
    {x: "2017-08-09", y: 12, group: 1},
];
groups = new vis.DataSet();
groups.add({
    id: 0,
    content: 'Group Left',
});
groups.add({
    id: 1,
    content: 'Group Right',
    options: {'yAxisOrientation': 'right'},
});
var options = {
    interpolation: false,
};

I have looked into the code in vis.js and have identified the method DataScale.prototype.followScale to mess up the range (i.e. this._start and this._end) of the right axis.

I assume, that this method is meant to align the horizontal lines in the background of the plot, but can't really comprehend the code to fix it myself.