2

I've been tinkering, making a little chart with Flot and some of it's plugins. The purpose is to provide a chart tracking basal body temperature, with the date per day on the x axis, degrees on the y axis. Panning will shift the x axis, so you can see previous dates etc, clicking will result in a new point, snapped to grid.

The grid on a time based axis when panning does not move. It does when I change the axis type to normal. I really want to have the entire grid move, because now the line series sort of 'floats around' on the grid. Does anyone know how to make that work? Am I missing something in the options?

This is harder to explain than it is to see, so fsfiddle provided: http://jsfiddle.net/jorgthuijls/caM3q/1/

Triggering the change in behaviour is the option mode: 'time' on the x axis option (line 24 of the fiddle).

The bit of code to pay attention to:

        xaxis: {
            show: true,
            min: firstDay,
            max: lastDay,
            ticks: 31,
            mode: 'time',
            timezone: 'browser',
            timeformat: '%d. %m'
        },

change this to

        xaxis: {
            show: true,
            min: firstDay,
            max: lastDay,
            ticks: 31,
        },

and see what happens moving the graph after adding a few points.

Much appreciated!

4

1 回答 1

1

这是两件事的结合:

  1. 我们刚刚修复了 0.8.0 中的一个错误,因此如果您尝试使用master 的jquery.flot.time.js,您会立即注意到改进。

  2. 即使进行了修复,滴答声仍然会跳动一点。那是因为您有足够大的范围,刻度仅每 3 天出现一次。然而,在内部,报价生成器仍将一天视为最小间隔。因此,只要您平移一天,它就会重新计算,即使这只是刻度间隔大小的三分之一。

您通常可以通过分配适当高的 minTickSize 来解决该问题;[5, 'day'],例如,让滴答生成器相信它不需要重新计算。当您提前知道绘图的尺寸时,这种方法效果最好。

于 2013-04-22T13:24:03.020 回答