bartosz.baczek
bartosz.baczek

Reputation: 1516

Highcharts - yAxis dissapears, when zooming in to area with unknown values

Is it possible to keep y axis values when zooming in to area with missing (null) values? If so how?

Fiddler: https://jsfiddle.net/fyhb1e3d/1/

Values provided to series look like this:

series: [{
    name: 'Jane',
    data: [1, 0, 3, null, null, null, null, null, null, null, null, null, 3, 1, 2, 1, 1, 0, 3, 1, 3, 1, 2, 1]
}]

EDIT: Setting min and max is not ok, since I don't know range of values I will receive (I am receiving live data, but it's not relevant in this issue). Using softMin and softMax does not work.

Upvotes: 1

Views: 59

Answers (2)

Halvor Holsten Strand
Halvor Holsten Strand

Reputation: 20536

A bit of a weird attempt at this is checking if you are about to render the axis, and have no tickPositions. If so, don't render it again. It's not perfect, but here's an example (JSFiddle):

(function (H) {
    H.wrap(H.Axis.prototype, 'render', function (proceed) {
        if(this === this.chart.yAxis[0] && this.tickPositions.length === 0)
            return;

        proceed.apply(this, Array.prototype.slice.call(arguments, 1));
    });
}(Highcharts));

Upvotes: 2

white91wolf
white91wolf

Reputation: 428

i cant comment so i have to reply as answer. i changed your code to https://jsfiddle.net/7gvswmz0/

where i just added a min and max value for the axis and so it works fine.

yAxis: {
  max: 5,
  min: 0
}

maybe this can help you.

Upvotes: 1

Related Questions