开发者

Loading 'flot' (graphing plugin) with a default zoom value?

I'm trying to create a data vs time graph which allows the user to zoom in/out to large/smaller time periods. You can see an example of one such graph here: http://people.iola.dk/olau/flot/examples/visitors.html

Whil开发者_开发百科e the API has been a breeze for setting up that level of functionality, I've gotten stock when trying to figure out how to create a default "zoom" value - to, for instance, set the default zoom to the past 30 days (while retaining the ability for the user to zoom out and view an entire year of data).

Does anyone have any experience or know a way of doing this? Or is it a matter of digging into the source code and customizing it?

Thanks! Walker


If you look at the code in, for example, flot zooming example, and you modify the definitions of the variable "options" thusly:

var options = {
    legend: { 
        show: false 
    },
    series: {
        lines: { 
            show: true 
        },
        points: { 
            show: true 
        }
    },
    yaxis: { 
        ticks: 10,
        min: -0.8,
        max: 0.4
    },
    selection: { 
        mode: "xy" 
    }
};

... you'll find that the graph starts out with this level of y-axis zoom, but the smaller graph still retains the full range that you can zoom out to if you want. The lines added are in the "yaxis" definition, "min" and "max". You would do something similar for "xaxis" if you want to pre-zoom the x-axis.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜