搜档网

搜档网

当前位置:搜档网 > flot API

flot API

Flot Reference
flot参考文档
--------------

Consider a call to the plot function:
下面是对绘图函数plot的调用:

var plot = $.plot(placeholder, data, options)

The placeholder is a jQuery object or DOM element or jQuery expression
that the plot will be put into. This placeholder needs to have its
width and height set as explained in the README (go read that now if
you haven't, it's short). The plot will modify some properties of the
placeholder so it's recommended you simply pass in a div that you
don't use for anything else. Make sure you check any fancy styling
you apply to the div, e.g. background images have been reported to be a
problem on IE 7.

占位符placeholder是一个jQuery对象或者DOM元素或者jQuery表单式,绘图函数将把图表画在placeholder内。
这个占位符需要设置高宽(这在README文档里面已经介绍过,如果你还没有阅读过现在就去阅读吧,文档很短)。
plot函数画图时将修改这个占位符的内容,因此你最好使用一个空的DIV元素作为占位符,另外注意不要给占位符
设置花哨的样式,比如,在IE7.0下,给占位符设置背景图将会出错。



The format of the data is documented below, as is the available
options. The "plot" object returned has some methods you can call.
These are documented separately below.

函数可以使用的数据格式会在后面说明,plot返回对象有一些方法可供调用,在后面会分开介绍。

Note that in general Flot gives no guarantees if you change any of the
objects you pass in to the plot function or get out of it since
they're not necessarily deep-copied.

另外请注意,flot不保证plot函数内的对象被修改或删除后仍然能正常工作(废话)。

Data Format
数据格式
-----------

The data is an array of data series:
flot的数据是一个数列数组(plot函数中的data参数:每条曲线一个data项参数,绘制多条曲线时,是一个数组,每个数组元素是一条曲线的data项参数):

[ series1, series2, ... ]

A series can either be raw data or an object with properties. The raw
data format is an array of points:

数列可以是原始数据,也可以是数据对象,原始数据格式是由一组表示数据点的坐标值的数组构成:

[ [x1, y1], [x2, y2], ... ]

E.g.

[ [1, 3], [2, 14.01], [3.5, 3.14] ]

Note that to simplify the internal logic in Flot both the x and y
values must be numbers (even if specifying time series, see below for
how to do this). This is a common problem because you might retrieve
data from the database and serialize them directly to JSON without
noticing the wrong type. If you're getting mysterious errors, double
check that you're inputting numbers and not strings.

请注意,flot的纵横坐标值都必须是数字(即使用时间数列也是,后面会介绍到),
这是个很常见的错误,因为你很可能从

TOP相关主题