mofeeta
mofeeta

Reputation: 1189

Setting a four hour range in highcharts

I'm showing some vital signs in a highstock graph, with the scrollbar enabled. I only want to show a 4 hour window along the xAxis no matter where the user scrolls, or how much data is loaded. When the graph is initially loaded, I set the min and max value, and I've set the minRange to four hours, but when the scrollbar is used some really weird behavior ensues: the xAxis scale changes, and the scrollbar seems to jump back and forth. Here are some of the config options:

defaultOptions = {
    title: {
        text: ""
    },
    navigator: {
        enabled: false
    },
    rangeSelector: {
        enabled: false
    },
    plotOptions: {
        series: {
            stickyTracking: false
        }
    },
    tooltip: {
        animation: false,
        crosshairs: false,
        shared: false,
        formatter: tooltipFormatter
    },
    credits: {
        enabled: false
    },
    xAxis: {
        minRange: chartRangeInMillis,
        maxZoom: chartRangeInMillis,
        min: 1364229900000,
        max: 1364244300000,
        tickInterval: 15 * 60 * 1000,
        minTickInterval: 15 * 60 * 1000,
        startOnTick: true,
        gridLineWidth: 1,
        ordinal: false,
        endOnTick: false,
        labels: {
            formatter: function () {
                var d = new Date(this.value);
                return (d.getMinutes() === 0) ? '<b>' + Highcharts.dateFormat('%H:%M', this.value) + '</b>' : d.getMinutes();
            }
        }
    },
    yAxis: {
        lineWidth: 2,
        min: 0,
        max: 250,
        offset: 0,
        tickInterval: 50,
        showLastLabel: true,
        labels: {
            align: 'right',
            x: -5,
            y: 3
        }
    }
};

You can see the behavior here: http://jsfiddle.net/6w3C3/

I've tried setting the extremes on redraw and via other event callbacks, but to no avail. What am I missing?

Upvotes: 1

Views: 1351

Answers (1)

mofeeta
mofeeta

Reputation: 1189

Turns out that if I set the startOnTick option to false, and remove the minRange, the scrolling issue is resolved.

Upvotes: 1

Related Questions