Skip to content
This repository
Newer
Older
100644 1499 lines (1160 sloc) 53.572 kb
2b901841 »
2013-05-30 Move TOC below main title and make it horizontal
1 # Flot Reference #
2
d777b2e7 »
2013-05-30 Add table of contents
3 **Table of Contents**
4
2b901841 »
2013-05-30 Move TOC below main title and make it horizontal
5 [Introduction](#introduction)
6 | [Data Format](#data-format)
7 | [Plot Options](#plot-options)
8 | [Customizing the legend](#customizing-the-legend)
9 | [Customizing the axes](#customizing-the-axes)
10 | [Multiple axes](#multiple-axes)
11 | [Time series data](#time-series-data)
12 | [Customizing the data series](#customizing-the-data-series)
13 | [Customizing the grid](#customizing-the-grid)
14 | [Specifying gradients](#specifying-gradients)
15 | [Plot Methods](#plot-methods)
16 | [Hooks](#hooks)
17 | [Plugins](#plugins)
18 | [Version number](#version-number)
d777b2e7 »
2013-05-30 Add table of contents
19
2b901841 »
2013-05-30 Move TOC below main title and make it horizontal
20 ---
21
22 ## Introduction ##
d2a5a632 »
2007-12-04 First draft, options are not documented yet
23
24 Consider a call to the plot function:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
25
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
26 ```js
27 var plot = $.plot(placeholder, data, options)
28 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
29
5785c2db »
2008-11-20 Call $() on passed in elements to support DOM elements/CSS expression…
30 The placeholder is a jQuery object or DOM element or jQuery expression
31 that the plot will be put into. This placeholder needs to have its
3f0d6931 »
2013-04-25 Add link to README.md
32 width and height set as explained in the [README](README.md) (go read that now if
5785c2db »
2008-11-20 Call $() on passed in elements to support DOM elements/CSS expression…
33 you haven't, it's short). The plot will modify some properties of the
34 placeholder so it's recommended you simply pass in a div that you
bab13664 »
2009-03-10 Added notice about broken background images on IE 7 based on report f…
35 don't use for anything else. Make sure you check any fancy styling
36 you apply to the div, e.g. background images have been reported to be a
37 problem on IE 7.
d2a5a632 »
2007-12-04 First draft, options are not documented yet
38
aaa1cc7f »
2013-02-07 Document the new plot chainable property.
39 The plot function can also be used as a jQuery chainable property. This form
40 naturally can't return the plot object directly, but you can still access it
41 via the 'plot' data key, like this:
42
43 ```js
44 var plot = $("#placeholder").plot(data, options).data("plot");
45 ```
46
d2a5a632 »
2007-12-04 First draft, options are not documented yet
47 The format of the data is documented below, as is the available
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
48 options. The plot object returned from the call has some methods you
49 can call. These are documented separately below.
d2a5a632 »
2007-12-04 First draft, options are not documented yet
50
f4ffef25 »
2007-12-14 Added support for clicking on the plot, still a bit primitive
51 Note that in general Flot gives no guarantees if you change any of the
7a665a14 »
2008-03-06 Added support for line segments and null/NaN values
52 objects you pass in to the plot function or get out of it since
53 they're not necessarily deep-copied.
d2a5a632 »
2007-12-04 First draft, options are not documented yet
54
55
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
56 ## Data Format ##
d2a5a632 »
2007-12-04 First draft, options are not documented yet
57
58 The data is an array of data series:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
59
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
60 ```js
61 [ series1, series2, ... ]
62 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
63
d2a5a632 »
2007-12-04 First draft, options are not documented yet
64 A series can either be raw data or an object with properties. The raw
65 data format is an array of points:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
66
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
67 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
68 [ [x1, y1], [x2, y2], ... ]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
69 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
70
d2a5a632 »
2007-12-04 First draft, options are not documented yet
71 E.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
72
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
73 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
74 [ [1, 3], [2, 14.01], [3.5, 3.14] ]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
75 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
76
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
77 Note that to simplify the internal logic in Flot both the x and y
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
78 values must be numbers (even if specifying time series, see below for
f8594bd2 »
2008-09-17 Allow null values in coordinates to have an affect on axis scaling
79 how to do this). This is a common problem because you might retrieve
80 data from the database and serialize them directly to JSON without
f4de9382 »
2008-11-24 Clarify that it is important not to put in strings
81 noticing the wrong type. If you're getting mysterious errors, double
82 check that you're inputting numbers and not strings.
7a665a14 »
2008-03-06 Added support for line segments and null/NaN values
83
84 If a null is specified as a point or if one of the coordinates is null
f8594bd2 »
2008-09-17 Allow null values in coordinates to have an affect on axis scaling
85 or couldn't be converted to a number, the point is ignored when
86 drawing. As a special case, a null value for lines is interpreted as a
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
87 line segment end, i.e. the points before and after the null value are
cba14862 »
2008-03-06 Convert data coordinates explicitly to numbers
88 not connected.
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
89
c3a34cd6 »
2009-12-07 Support for specifying a bottom for each point for line charts when
90 Lines and points take two coordinates. For filled lines and bars, you
91 can specify a third coordinate which is the bottom of the filled
92 area/bar (defaults to 0).
60689d24 »
2009-03-08 Support for partial bars, this is useful for stacked bars
93
d2a5a632 »
2007-12-04 First draft, options are not documented yet
94 The format of a single series object is as follows:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
95
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
96 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
97 {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
98 color: color or number
99 data: rawdata
100 label: string
101 lines: specific lines options
102 bars: specific bars options
103 points: specific points options
104 xaxis: number
105 yaxis: number
106 clickable: boolean
107 hoverable: boolean
108 shadowSize: number
070fd835 »
2012-07-16 Added docs for the highlightColor option.
109 highlightColor: color or number
633dd824 »
2012-07-15 Cleaned up and standardized markup.
110 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
111 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
112
d2a5a632 »
2007-12-04 First draft, options are not documented yet
113 You don't have to specify any of them except the data, the rest are
114 options that will get default values. Typically you'd only specify
115 label and data, like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
116
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
117 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
118 {
119 label: "y = 3",
120 data: [[0, 3], [10, 3]]
121 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
122 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
123
d2a5a632 »
2007-12-04 First draft, options are not documented yet
124 The label is used for the legend, if you don't specify one, the series
125 will not show up in the legend.
126
127 If you don't specify color, the series will get a color from the
128 auto-generated colors. The color is either a CSS color specification
129 (like "rgb(255, 100, 123)") or an integer that specifies which of
130 auto-generated colors to select, e.g. 0 will get color no. 0, etc.
131
132 The latter is mostly useful if you let the user add and remove series,
133 in which case you can hard-code the color index to prevent the colors
134 from jumping around between the series.
135
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
136 The "xaxis" and "yaxis" options specify which axis to use. The axes
137 are numbered from 1 (default), so { yaxis: 2} means that the series
138 should be plotted against the second y axis.
7c9ff67b »
2008-09-10 Landed dual axis/hover event/finding nearby datapoints patch
139
5587862a »
2008-11-18 Added support for disabling interactivity for specific plots
140 "clickable" and "hoverable" can be set to false to disable
141 interactivity for specific series if interactivity is turned on in
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
142 the plot, see below.
5587862a »
2008-11-18 Added support for disabling interactivity for specific plots
143
d2a5a632 »
2007-12-04 First draft, options are not documented yet
144 The rest of the options are all documented below as they are the same
145 as the default options passed in via the options parameter in the plot
146 commmand. When you specify them for a specific data series, they will
147 override the default options for the plot for that data series.
148
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
149 Here's a complete example of a simple data specification:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
150
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
151 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
152 [ { label: "Foo", data: [ [10, 1], [17, -14], [30, 5] ] },
153 { label: "Bar", data: [ [11, 13], [19, 11], [30, -7] ] }
154 ]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
155 ```
d2a5a632 »
2007-12-04 First draft, options are not documented yet
156
633dd824 »
2012-07-15 Cleaned up and standardized markup.
157
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
158 ## Plot Options ##
d2a5a632 »
2007-12-04 First draft, options are not documented yet
159
19eb7612 »
2007-12-04 Documented more options
160 All options are completely optional. They are documented individually
161 below, to change them you just specify them in an object, e.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
162
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
163 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
164 var options = {
165 series: {
166 lines: { show: true },
167 points: { show: true }
168 }
169 };
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
170
633dd824 »
2012-07-15 Cleaned up and standardized markup.
171 $.plot(placeholder, data, options);
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
172 ```
633dd824 »
2012-07-15 Cleaned up and standardized markup.
173
174
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
175 ## Customizing the legend ##
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
176
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
177 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
178 legend: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
179 show: boolean
180 labelFormatter: null or (fn: string, series object -> string)
181 labelBoxBorderColor: color
182 noColumns: number
183 position: "ne" or "nw" or "se" or "sw"
184 margin: number of pixels or [x margin, y margin]
185 backgroundColor: null or color
186 backgroundOpacity: number between 0 and 1
187 container: null or jQuery object/DOM element/jQuery expression
6bbce446 »
2013-02-12 Updated the API with the legend 'reverse' option.
188 sorted: null/false, true, "ascending", "descending", "reverse", or a comparator
633dd824 »
2012-07-15 Cleaned up and standardized markup.
189 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
190 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
191
19eb7612 »
2007-12-04 Documented more options
192 The legend is generated as a table with the data series labels and
c81f0af7 »
2007-12-07 Added labelFormatter option
193 small label boxes with the color of the series. If you want to format
194 the labels in some way, e.g. make them to links, you can pass in a
195 function for "labelFormatter". Here's an example that makes them
196 clickable:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
197
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
198 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
199 labelFormatter: function(label, series) {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
200 // series is the series object for the label
201 return '<a href="#' + label + '">' + label + '</a>';
633dd824 »
2012-07-15 Cleaned up and standardized markup.
202 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
203 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
204
8760ee77 »
2012-12-12 Added undocumented labelFormatter null behavior.
205 To prevent a series from showing up in the legend, simply have the function
206 return null.
207
c81f0af7 »
2007-12-07 Added labelFormatter option
208 "noColumns" is the number of columns to divide the legend table into.
209 "position" specifies the overall placement of the legend within the
210 plot (top-right, top-left, etc.) and margin the distance to the plot
ab264f6e »
2009-01-19 legend.margin can now specify horizontal and vertical margins
211 edge (this can be either a number or an array of two numbers like [x,
212 y]). "backgroundColor" and "backgroundOpacity" specifies the
c81f0af7 »
2007-12-07 Added labelFormatter option
213 background. The default is a partly transparent auto-detected
214 background.
215
216 If you want the legend to appear somewhere else in the DOM, you can
ab264f6e »
2009-01-19 legend.margin can now specify horizontal and vertical margins
217 specify "container" as a jQuery object/expression to put the legend
218 table into. The "position" and "margin" etc. options will then be
219 ignored. Note that Flot will overwrite the contents of the container.
19eb7612 »
2007-12-04 Documented more options
220
6bbce446 »
2013-02-12 Updated the API with the legend 'reverse' option.
221 Legend entries appear in the same order as their series by default. If "sorted"
222 is "reverse" then they appear in the opposite order from their series. To sort
223 them alphabetically, you can specify true, "ascending" or "descending", where
224 true and "ascending" are equivalent.
633dd824 »
2012-07-15 Cleaned up and standardized markup.
225
226 You can also provide your own comparator function that accepts two
227 objects with "label" and "color" properties, and returns zero if they
228 are equal, a positive value if the first is greater than the second,
229 and a negative value if the first is less than the second.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
230
633dd824 »
2012-07-15 Cleaned up and standardized markup.
231 ```js
232 sorted: function(a, b) {
233 // sort alphabetically in ascending order
234 return a.label == b.label ? 0 : (
235 a.label > b.label ? 1 : -1
236 )
237 }
238 ```
239
19eb7612 »
2007-12-04 Documented more options
240
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
241 ## Customizing the axes ##
633dd824 »
2012-07-15 Cleaned up and standardized markup.
242
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
243 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
244 xaxis, yaxis: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
245 show: null or true/false
246 position: "bottom" or "top" or "left" or "right"
247 mode: null or "time" ("time" requires jquery.flot.time.js plugin)
248 timezone: null, "browser" or timezone (only makes sense for mode: "time")
249
250 color: null or color spec
251 tickColor: null or color spec
252 font: null or font spec object
253
254 min: null or number
255 max: null or number
256 autoscaleMargin: null or number
257
258 transform: null or fn: number -> number
259 inverseTransform: null or fn: number -> number
260
261 ticks: null or number or ticks array or (fn: axis -> ticks array)
262 tickSize: number or array
263 minTickSize: number or array
264 tickFormatter: (fn: number, object -> string) or string
265 tickDecimals: null or number
266
267 labelWidth: null or number
268 labelHeight: null or number
269 reserveSpace: null or true
270
271 tickLength: null or number
19eb7612 »
2007-12-04 Documented more options
272
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
273 alignTicksWithAxis: null or number
633dd824 »
2012-07-15 Cleaned up and standardized markup.
274 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
275 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
276
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
277 All axes have the same kind of options. The following describes how to
278 configure one axis, see below for what to do if you've got more than
279 one x axis or y axis.
280
9dcd530b »
2011-03-15 Reformulate the paragraph about the axis show option slightly
281 If you don't set the "show" option (i.e. it is null), visibility is
282 auto-detected, i.e. the axis will show up if there's data associated
283 with it. You can override this by setting the "show" option to true or
284 false.
47821c71 »
2011-03-11 Refactor the axis dimension calculations slightly to avoid the whole
285
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
286 The "position" option specifies where the axis is placed, bottom or
287 top for x axes, left or right for y axes. The "mode" option determines
288 how the data is interpreted, the default of null means as decimal
85429298 »
2012-05-28 Moved time-series functionality into a separate plug-in and incorporated
289 numbers. Use "time" for time series data; see the time series data
290 section. The time plugin (jquery.flot.time.js) is required for time
291 series support.
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
292
3cd7a510 »
2013-03-06 Axis and tick color options now make more sense.
293 The "color" option determines the color of the line and ticks for the axis, and
294 defaults to the grid color with transparency. For more fine-grained control you
295 can also set the color of the ticks separately with "tickColor".
296
297 You can customize the font and color used to draw the axis tick labels with CSS
298 or directly via the "font" option. When "font" is null - the default - each
299 tick label is given the 'flot-tick-label' class. For compatibility with Flot
300 0.7 and earlier the labels are also given the 'tickLabel' class, but this is
301 deprecated and scheduled to be removed with the release of version 1.0.0.
27c70111 »
2013-03-03 Updated the API docs for axis text changes.
302
303 To enable more granular control over styles, labels are divided between a set
304 of text containers, with each holding the labels for one axis. These containers
df0875e5 »
2013-03-30 Replace the stylesheet hack with inline styles.
305 are given the classes 'flot-[x|y]-axis', and 'flot-[x|y]#-axis', where '#' is
306 the number of the axis when there are multiple axes. For example, the x-axis
307 labels for a simple plot with only a single x-axis might look like this:
27c70111 »
2013-03-03 Updated the API docs for axis text changes.
308
309 ```html
df0875e5 »
2013-03-30 Replace the stylesheet hack with inline styles.
310 <div class='flot-x-axis flot-x1-axis'>
27c70111 »
2013-03-03 Updated the API docs for axis text changes.
311 <div class='flot-tick-label'>January 2013</div>
312 ...
313 </div>
314 ```
315
316 For direct control over label styles you can also provide "font" as an object
317 with this format:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
318
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
319 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
320 {
321 size: 11,
bceb4bfc »
2013-04-02 Added lineHeight to the font-spec object.
322 lineHeight: 13,
633dd824 »
2012-07-15 Cleaned up and standardized markup.
323 style: "italic",
324 weight: "bold",
325 family: "sans-serif",
27c70111 »
2013-03-03 Updated the API docs for axis text changes.
326 variant: "small-caps",
327 color: "#545454"
633dd824 »
2012-07-15 Cleaned up and standardized markup.
328 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
329 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
330
bceb4bfc »
2013-04-02 Added lineHeight to the font-spec object.
331 The size and lineHeight must be expressed in pixels; CSS units such as 'em'
332 or 'smaller' are not allowed.
333
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
334 The options "min"/"max" are the precise minimum/maximum value on the
335 scale. If you don't specify either of them, a value will automatically
d769a5b5 »
2011-03-10 Add note about min/max calculations being based on entire dataset
336 be chosen based on the minimum/maximum data values. Note that Flot
337 always examines all the data values you feed to it, even if a
338 restriction on another axis may make some of them invisible (this
339 makes interactive use more stable).
8cf42618 »
2007-12-19 Cleaned up the scaling algorithm and some of the tick stuff
340
341 The "autoscaleMargin" is a bit esoteric: it's the fraction of margin
342 that the scaling algorithm will add to avoid that the outermost points
947c1663 »
2010-04-28 Support for coloring axes, and automatic tick color selection
343 ends up on the grid border. Note that this margin is only applied when
344 a min or max value is not explicitly set. If a margin is specified,
345 the plot will furthermore extend the axis end-point to the nearest
346 whole tick. The default value is "null" for the x axes and 0.02 for y
347 axes which seems appropriate for most cases.
19eb7612 »
2007-12-04 Documented more options
348
e7a909a6 »
2009-09-08 Added axis transformation support
349 "transform" and "inverseTransform" are callbacks you can put in to
350 change the way the data is drawn. You can design a function to
351 compress or expand certain parts of the axis non-linearly, e.g.
352 suppress weekends or compress far away points with a logarithm or some
353 other means. When Flot draws the plot, each value is first put through
354 the transform function. Here's an example, the x axis can be turned
355 into a natural logarithm axis with the following code:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
356
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
357 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
358 xaxis: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
359 transform: function (v) { return Math.log(v); },
360 inverseTransform: function (v) { return Math.exp(v); }
633dd824 »
2012-07-15 Cleaned up and standardized markup.
361 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
362 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
363
26cf412e »
2011-03-11 Add reverse axis example to API
364 Similarly, for reversing the y axis so the values appear in inverse
365 order:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
366
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
367 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
368 yaxis: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
369 transform: function (v) { return -v; },
370 inverseTransform: function (v) { return -v; }
633dd824 »
2012-07-15 Cleaned up and standardized markup.
371 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
372 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
373
e7a909a6 »
2009-09-08 Added axis transformation support
374 Note that for finding extrema, Flot assumes that the transform
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
375 function does not reorder values (it should be monotone).
e7a909a6 »
2009-09-08 Added axis transformation support
376
377 The inverseTransform is simply the inverse of the transform function
378 (so v == inverseTransform(transform(v)) for all relevant v). It is
379 required for converting from canvas coordinates to data coordinates,
380 e.g. for a mouse interaction where a certain pixel is clicked. If you
381 don't use any interactive features of Flot, you may not need it.
382
383
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
384 The rest of the options deal with the ticks.
385
386 If you don't specify any ticks, a tick generator algorithm will make
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
387 some for you. The algorithm has two passes. It first estimates how
388 many ticks would be reasonable and uses this number to compute a nice
389 round tick interval size. Then it generates the ticks.
8cf42618 »
2007-12-19 Cleaned up the scaling algorithm and some of the tick stuff
390
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
391 You can specify how many ticks the algorithm aims for by setting
392 "ticks" to a number. The algorithm always tries to generate reasonably
393 round tick values so even if you ask for three ticks, you might get
60689d24 »
2009-03-08 Support for partial bars, this is useful for stacked bars
394 five if that fits better with the rounding. If you don't want any
395 ticks at all, set "ticks" to 0 or an empty array.
19eb7612 »
2007-12-04 Documented more options
396
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
397 Another option is to skip the rounding part and directly set the tick
398 interval size with "tickSize". If you set it to 2, you'll get ticks at
399 2, 4, 6, etc. Alternatively, you can specify that you just don't want
400 ticks at a size less than a specific tick size with "minTickSize".
401 Note that for time series, the format is an array like [2, "month"],
402 see the next section.
8cf42618 »
2007-12-19 Cleaned up the scaling algorithm and some of the tick stuff
403
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
404 If you want to completely override the tick algorithm, you can specify
405 an array for "ticks", either like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
406
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
407 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
408 ticks: [0, 1.2, 2.4]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
409 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
410
a4c7fa34 »
2009-04-01 Clarify how to set tick labels (issue 144)
411 Or like this where the labels are also customized:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
412
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
413 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
414 ticks: [[0, "zero"], [1.2, "one mark"], [2.4, "two marks"]]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
415 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
416
a4c7fa34 »
2009-04-01 Clarify how to set tick labels (issue 144)
417 You can mix the two if you like.
418
19eb7612 »
2007-12-04 Documented more options
419 For extra flexibility you can specify a function as the "ticks"
420 parameter. The function will be called with an object with the axis
421 min and max and should return a ticks array. Here's a simplistic tick
422 generator that spits out intervals of pi, suitable for use on the x
423 axis for trigonometric functions:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
424
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
425 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
426 function piTickGenerator(axis) {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
427 var res = [], i = Math.floor(axis.min / Math.PI);
428 do {
633dd824 »
2012-07-15 Cleaned up and standardized markup.
429 var v = i * Math.PI;
430 res.push([v, i + "\u03c0"]);
431 ++i;
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
432 } while (v < axis.max);
433 return res;
633dd824 »
2012-07-15 Cleaned up and standardized markup.
434 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
435 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
436
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
437 You can control how the ticks look like with "tickDecimals", the
438 number of decimals to display (default is auto-detected).
439
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
440 Alternatively, for ultimate control over how ticks are formatted you can
08a5c94f »
2008-09-18 Shuffled the explanation of time series support around a bit
441 provide a function to "tickFormatter". The function is passed two
6e3c674e »
2010-12-21 Little stylistic fix in API.txt
442 parameters, the tick value and an axis object with information, and
08a5c94f »
2008-09-18 Shuffled the explanation of time series support around a bit
443 should return a string. The default formatter looks like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
444
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
445 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
446 function formatter(val, axis) {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
447 return val.toFixed(axis.tickDecimals);
633dd824 »
2012-07-15 Cleaned up and standardized markup.
448 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
449 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
450
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
451 The axis object has "min" and "max" with the range of the axis,
452 "tickDecimals" with the number of decimals to round the value to and
453 "tickSize" with the size of the interval between ticks as calculated
454 by the automatic axis scaling algorithm (or specified by you). Here's
455 an example of a custom formatter:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
456
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
457 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
458 function suffixFormatter(val, axis) {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
459 if (val > 1000000)
633dd824 »
2012-07-15 Cleaned up and standardized markup.
460 return (val / 1000000).toFixed(axis.tickDecimals) + " MB";
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
461 else if (val > 1000)
633dd824 »
2012-07-15 Cleaned up and standardized markup.
462 return (val / 1000).toFixed(axis.tickDecimals) + " kB";
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
463 else
633dd824 »
2012-07-15 Cleaned up and standardized markup.
464 return val.toFixed(axis.tickDecimals) + " B";
465 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
466 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
467
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
468 "labelWidth" and "labelHeight" specifies a fixed size of the tick
469 labels in pixels. They're useful in case you need to align several
47821c71 »
2011-03-11 Refactor the axis dimension calculations slightly to avoid the whole
470 plots. "reserveSpace" means that even if an axis isn't shown, Flot
471 should reserve space for it - it is useful in combination with
472 labelWidth and labelHeight for aligning multi-axis charts.
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
473
474 "tickLength" is the length of the tick lines in pixels. By default, the
475 innermost axes will have ticks that extend all across the plot, while
476 any extra axes use small ticks. A value of null means use the default,
477 while a number means small ticks of that length - set it to 0 to hide
478 the lines completely.
81553910 »
2010-04-29 Some cleanup in tick generation code, added support for aligning axes
479
480 If you set "alignTicksWithAxis" to the number of another axis, e.g.
481 alignTicksWithAxis: 1, Flot will ensure that the autogenerated ticks
482 of this axis are aligned with the ticks of the other axis. This may
483 improve the looks, e.g. if you have one y axis to the left and one to
484 the right, because the grid lines will then match the ticks in both
485 ends. The trade-off is that the forced ticks won't necessarily be at
486 natural places.
487
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
488
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
489 ## Multiple axes ##
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
490
491 If you need more than one x axis or y axis, you need to specify for
492 each data series which axis they are to use, as described under the
493 format of the data series, e.g. { data: [...], yaxis: 2 } specifies
494 that a series should be plotted against the second y axis.
495
496 To actually configure that axis, you can't use the xaxis/yaxis options
497 directly - instead there are two arrays in the options:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
498
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
499 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
500 xaxes: []
501 yaxes: []
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
502 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
503
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
504 Here's an example of configuring a single x axis and two y axes (we
505 can leave options of the first y axis empty as the defaults are fine):
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
506
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
507 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
508 {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
509 xaxes: [ { position: "top" } ],
510 yaxes: [ { }, { position: "right", min: 20 } ]
633dd824 »
2012-07-15 Cleaned up and standardized markup.
511 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
512 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
513
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
514 The arrays get their default values from the xaxis/yaxis settings, so
515 say you want to have all y axes start at zero, you can simply specify
516 yaxis: { min: 0 } instead of adding a min parameter to all the axes.
517
518 Generally, the various interfaces in Flot dealing with data points
519 either accept an xaxis/yaxis parameter to specify which axis number to
520 use (starting from 1), or lets you specify the coordinate directly as
521 x2/x3/... or x2axis/x3axis/... instead of "x" or "xaxis".
522
85429298 »
2012-05-28 Moved time-series functionality into a separate plug-in and incorporated
523
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
524 ## Time series data ##
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
525
85429298 »
2012-05-28 Moved time-series functionality into a separate plug-in and incorporated
526 Please note that it is now required to include the time plugin,
527 jquery.flot.time.js, for time series support.
528
84a7a273 »
2008-04-04 Display dates according to UTC instead of according to the time zone …
529 Time series are a bit more difficult than scalar data because
530 calendars don't follow a simple base 10 system. For many cases, Flot
531 abstracts most of this away, but it can still be a bit difficult to
532 get the data into Flot. So we'll first discuss the data format.
533
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
534 The time series support in Flot is based on Javascript timestamps,
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
535 i.e. everywhere a time value is expected or handed over, a Javascript
84a7a273 »
2008-04-04 Display dates according to UTC instead of according to the time zone …
536 timestamp number is used. This is a number, not a Date object. A
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
537 Javascript timestamp is the number of milliseconds since January 1,
65cae14e »
2008-09-03 Fixed wording
538 1970 00:00:00 UTC. This is almost the same as Unix timestamps, except it's
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
539 in milliseconds, so remember to multiply by 1000!
540
84a7a273 »
2008-04-04 Display dates according to UTC instead of according to the time zone …
541 You can see a timestamp like this
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
542
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
543 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
544 alert((new Date()).getTime())
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
545 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
546
488fbc8d »
2013-07-03 Fix typo in API.md
547 There are different schools of thought when it comes to display of
85429298 »
2012-05-28 Moved time-series functionality into a separate plug-in and incorporated
548 timestamps. Many will want the timestamps to be displayed according to
549 a certain time zone, usually the time zone in which the data has been
550 produced. Some want the localized experience, where the timestamps are
551 displayed according to the local time of the visitor. Flot supports
552 both. Optionally you can include a third-party library to get
553 additional timezone support.
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
554
85429298 »
2012-05-28 Moved time-series functionality into a separate plug-in and incorporated
555 Default behavior is that Flot always displays timestamps according to
556 UTC. The reason being that the core Javascript Date object does not
557 support other fixed time zones. Often your data is at another time
558 zone, so it may take a little bit of tweaking to work around this
559 limitation.
84a7a273 »
2008-04-04 Display dates according to UTC instead of according to the time zone …
560
561 The easiest way to think about it is to pretend that the data
562 production time zone is UTC, even if it isn't. So if you have a
563 datapoint at 2002-02-20 08:00, you can generate a timestamp for eight
08a5c94f »
2008-09-18 Shuffled the explanation of time series support around a bit
564 o'clock UTC even if it really happened eight o'clock UTC+0200.
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
565
633dd824 »
2012-07-15 Cleaned up and standardized markup.
566 In PHP you can get an appropriate timestamp with:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
567
633dd824 »
2012-07-15 Cleaned up and standardized markup.
568 ```php
569 strtotime("2002-02-20 UTC") * 1000
570 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
571
633dd824 »
2012-07-15 Cleaned up and standardized markup.
572 In Python you can get it with something like:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
573
633dd824 »
2012-07-15 Cleaned up and standardized markup.
574 ```python
575 calendar.timegm(datetime_object.timetuple()) * 1000
576 ```
403b9532 »
2013-11-05 Fix line wrapping and grammar.
577 In Ruby you can get it using the `#to_i` method on the
578 [`Time`](http://apidock.com/ruby/Time/to_i) object. If you're using the
579 `active_support` gem (default for Ruby on Rails applications) `#to_i` is also
580 available on the `DateTime` and `ActiveSupport::TimeWithZone` objects. You
581 simply need to multiply the result by 1000:
f79e1064 »
2013-11-04 Add Ruby examples
582
583 ```ruby
584 Time.now.to_i * 1000 # => 1383582043000
585 # ActiveSupport examples:
586 DateTime.now.to_i * 1000 # => 1383582043000
2cc2ab89 »
2013-11-04 typo in ActiveSupport::TimeWithZone example
587 ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 1000
f79e1064 »
2013-11-04 Add Ruby examples
588 # => 1383582043000
589 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
590
633dd824 »
2012-07-15 Cleaned up and standardized markup.
591 In .NET you can get it with something like:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
592
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
593 ```aspx
633dd824 »
2012-07-15 Cleaned up and standardized markup.
594 public static int GetJavascriptTimestamp(System.DateTime input)
595 {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
596 System.TimeSpan span = new System.TimeSpan(System.DateTime.Parse("1/1/1970").Ticks);
597 System.DateTime time = input.Subtract(span);
598 return (long)(time.Ticks / 10000);
633dd824 »
2012-07-15 Cleaned up and standardized markup.
599 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
600 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
601
84a7a273 »
2008-04-04 Display dates according to UTC instead of according to the time zone …
602 Javascript also has some support for parsing date strings, so it is
08a5c94f »
2008-09-18 Shuffled the explanation of time series support around a bit
603 possible to generate the timestamps manually client-side.
604
605 If you've already got the real UTC timestamp, it's too late to use the
606 pretend trick described above. But you can fix up the timestamps by
607 adding the time zone offset, e.g. for UTC+0200 you would add 2 hours
608 to the UTC timestamp you got. Then it'll look right on the plot. Most
609 programming environments have some means of getting the timezone
9b08e820 »
2008-11-21 Added documentation and example for the crosshairs feature
610 offset for a specific date (note that you need to get the offset for
611 each individual timestamp to account for daylight savings).
08a5c94f »
2008-09-18 Shuffled the explanation of time series support around a bit
612
85429298 »
2012-05-28 Moved time-series functionality into a separate plug-in and incorporated
613 The alternative with core Javascript is to interpret the timestamps
614 according to the time zone that the visitor is in, which means that
615 the ticks will shift with the time zone and daylight savings of each
616 visitor. This behavior is enabled by setting the axis option
617 "timezone" to the value "browser".
618
88305db1 »
2012-09-12 Update API.md
619 If you need more time zone functionality than this, there is still
85429298 »
2012-05-28 Moved time-series functionality into a separate plug-in and incorporated
620 another option. If you include the "timezone-js" library
621 <https://github.com/mde/timezone-js> in the page and set axis.timezone
622 to a value recognized by said library, Flot will use timezone-js to
623 interpret the timestamps according to that time zone.
624
60689d24 »
2009-03-08 Support for partial bars, this is useful for stacked bars
625 Once you've gotten the timestamps into the data and specified "time"
626 as the axis mode, Flot will automatically generate relevant ticks and
84a7a273 »
2008-04-04 Display dates according to UTC instead of according to the time zone …
627 format them. As always, you can tweak the ticks via the "ticks" option
08a5c94f »
2008-09-18 Shuffled the explanation of time series support around a bit
628 - just remember that the values should be timestamps (numbers), not
629 Date objects.
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
630
84a7a273 »
2008-04-04 Display dates according to UTC instead of according to the time zone …
631 Tick generation and formatting can also be controlled separately
632 through the following axis options:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
633
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
634 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
635 minTickSize: array
636 timeformat: null or format string
637 monthNames: null or array of size 12 of strings
638 dayNames: null or array of size 7 of strings
639 twelveHourClock: boolean
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
640 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
641
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
642 Here "timeformat" is a format string to use. You might use it like
643 this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
644
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
645 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
646 xaxis: {
e3c45a5a »
2013-04-08 Fixed missing comma in demo code.
647 mode: "time",
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
648 timeformat: "%Y/%m/%d"
633dd824 »
2012-07-15 Cleaned up and standardized markup.
649 }
c0900a1d »
2012-12-11 Updated API.md for %q time-series tick-label option.
650 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
651
c0900a1d »
2012-12-11 Updated API.md for %q time-series tick-label option.
652 This will result in tick labels like "2000/12/24". A subset of the
653 standard strftime specifiers are supported (plus the nonstandard %q):
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
654
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
655 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
656 %a: weekday name (customizable)
657 %b: month name (customizable)
658 %d: day of month, zero-padded (01-31)
659 %e: day of month, space-padded ( 1-31)
660 %H: hours, 24-hour time, zero-padded (00-23)
661 %I: hours, 12-hour time, zero-padded (01-12)
662 %m: month, zero-padded (01-12)
663 %M: minutes, zero-padded (00-59)
c0900a1d »
2012-12-11 Updated API.md for %q time-series tick-label option.
664 %q: quarter (1-4)
633dd824 »
2012-07-15 Cleaned up and standardized markup.
665 %S: seconds, zero-padded (00-59)
666 %y: year (two digits)
667 %Y: year (four digits)
668 %p: am/pm
669 %P: AM/PM (uppercase version of %p)
670 %w: weekday as number (0-6, 0 being Sunday)
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
671 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
672
24f70fc6 »
2013-04-20 Re-introduced the %h specifier for back-compat.
673 Flot 0.8 switched from %h to the standard %H hours specifier. The %h specifier
674 is still available, for backwards-compatibility, but is deprecated and
675 scheduled to be removed permanently with the release of version 1.0.
676
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
677 You can customize the month names with the "monthNames" option. For
678 instance, for Danish you might specify:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
679
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
680 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
681 monthNames: ["jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec"]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
682 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
683
22ac76c0 »
2012-06-15 Updated docs. Removed %u specifier.
684 Similarly you can customize the weekday names with the "dayNames"
685 option. An example in French:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
686
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
687 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
688 dayNames: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
689 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
690
0c54df7f »
2009-10-07 Added support for 12 hour timestamps, patch by Forrest Aldridge
691 If you set "twelveHourClock" to true, the autogenerated timestamps
22ac76c0 »
2012-06-15 Updated docs. Removed %u specifier.
692 will use 12 hour AM/PM timestamps instead of 24 hour. This only
693 applies if you have not set "timeformat". Use the "%I" and "%p" or
694 "%P" options if you want to build your own format string with 12-hour
695 times.
696
697 If the Date object has a strftime property (and it is a function), it
698 will be used instead of the built-in formatter. Thus you can include
699 a strftime library such as http://hacks.bluesmoon.info/strftime/ for
700 more powerful date/time formatting.
d0c96fc0 »
2008-11-24 Added access to the built-in date formatter through $.plot.formatDate
701
dfba9f38 »
2008-02-26 Documented the date support, tweaking the API a bit in the process, d…
702 If everything else fails, you can control the formatting by specifying
703 a custom tick formatter function as usual. Here's a simple example
704 which will format December 24 as 24/12:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
705
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
706 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
707 tickFormatter: function (val, axis) {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
708 var d = new Date(val);
709 return d.getUTCDate() + "/" + (d.getUTCMonth() + 1);
633dd824 »
2012-07-15 Cleaned up and standardized markup.
710 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
711 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
712
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
713 Note that for the time mode "tickSize" and "minTickSize" are a bit
714 special in that they are arrays on the form "[value, unit]" where unit
715 is one of "second", "minute", "hour", "day", "month" and "year". So
716 you can specify
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
717
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
718 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
719 minTickSize: [1, "month"]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
720 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
721
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
722 to get a tick interval size of at least 1 month and correspondingly,
723 if axis.tickSize is [2, "day"] in the tick formatter, the ticks have
724 been produced with two days in-between.
725
19eb7612 »
2007-12-04 Documented more options
726
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
727 ## Customizing the data series ##
633dd824 »
2012-07-15 Cleaned up and standardized markup.
728
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
729 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
730 series: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
731 lines, points, bars: {
633dd824 »
2012-07-15 Cleaned up and standardized markup.
732 show: boolean
733 lineWidth: number
734 fill: boolean or number
735 fillColor: null or color/gradient
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
736 }
19eb7612 »
2007-12-04 Documented more options
737
1e685b04 »
2013-01-10 Documented the zero option for bars and lines.
738 lines, bars: {
739 zero: boolean
740 }
741
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
742 points: {
633dd824 »
2012-07-15 Cleaned up and standardized markup.
743 radius: number
744 symbol: "circle" or function
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
745 }
746
747 bars: {
633dd824 »
2012-07-15 Cleaned up and standardized markup.
748 barWidth: number
749 align: "left", "right" or "center"
750 horizontal: boolean
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
751 }
752
753 lines: {
633dd824 »
2012-07-15 Cleaned up and standardized markup.
754 steps: boolean
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
755 }
f6b08328 »
2009-03-01 Added support for coloring the data points below a certain threshold
756
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
757 shadowSize: number
070fd835 »
2012-07-16 Added docs for the highlightColor option.
758 highlightColor: color or number
633dd824 »
2012-07-15 Cleaned up and standardized markup.
759 }
760
761 colors: [ color1, color2, ... ]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
762 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
763
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
764 The options inside "series: {}" are copied to each of the series. So
765 you can specify that all series should have bars by putting it in the
766 global options, or override it for individual series by specifying
767 bars in a particular the series object in the array of data.
768
19eb7612 »
2007-12-04 Documented more options
769 The most important options are "lines", "points" and "bars" that
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
770 specify whether and how lines, points and bars should be shown for
dd8b499f »
2008-10-29 Clear up a couple of things related to not showing lines
771 each data series. In case you don't specify anything at all, Flot will
772 default to showing lines (you can turn this off with
c3a34cd6 »
2009-12-07 Support for specifying a bottom for each point for line charts when
773 lines: { show: false }). You can specify the various types
dd8b499f »
2008-10-29 Clear up a couple of things related to not showing lines
774 independently of each other, and Flot will happily draw each of them
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
775 in turn (this is probably only useful for lines and points), e.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
776
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
777 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
778 var options = {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
779 series: {
633dd824 »
2012-07-15 Cleaned up and standardized markup.
780 lines: { show: true, fill: true, fillColor: "rgba(255, 255, 255, 0.8)" },
781 points: { show: true, fill: false }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
782 }
633dd824 »
2012-07-15 Cleaned up and standardized markup.
783 };
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
784 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
785
dd8b499f »
2008-10-29 Clear up a couple of things related to not showing lines
786 "lineWidth" is the thickness of the line or outline in pixels. You can
787 set it to 0 to prevent a line or outline from being drawn; this will
788 also hide the shadow.
f28eb70f »
2008-03-13 Make it possible to set the fill opacity by setting fill to a number
789
790 "fill" is whether the shape should be filled. For lines, this produces
791 area graphs. You can use "fillColor" to specify the color of the fill.
792 If "fillColor" evaluates to false (default for everything except
5144848c »
2009-04-15 Clarify that the default fill color of points is white
793 points which are filled with white), the fill color is auto-set to the
794 color of the data series. You can adjust the opacity of the fill by
795 setting fill to a number between 0 (fully transparent) and 1 (fully
796 opaque).
5a14a530 »
2007-12-06 Finished documenting the API
797
3a1d1e7b »
2009-02-01 Added support for gradient bars
798 For bars, fillColor can be a gradient, see the gradient documentation
5081ba4a »
2009-06-22 Clarify that barWidth might also be in unit of the y axis
799 below. "barWidth" is the width of the bars in units of the x axis (or
800 the y axis if "horizontal" is true), contrary to most other measures
801 that are specified in pixels. For instance, for time series the unit
802 is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of
803 a day. "align" specifies whether a bar should be left-aligned
40d886f9 »
2011-05-03 Implemented option to right-align a bar and updated API docs
804 (default), right-aligned or centered on top of the value it represents.
805 When "horizontal" is on, the bars are drawn horizontally, i.e. from the
806 y axis instead of the x axis; note that the bar end points are still
5081ba4a »
2009-06-22 Clarify that barWidth might also be in unit of the y axis
807 defined in the same way so you'll probably want to swap the
808 coordinates if you've been plotting vertical bars first.
19eb7612 »
2007-12-04 Documented more options
809
1e685b04 »
2013-01-10 Documented the zero option for bars and lines.
810 Area and bar charts normally start from zero, regardless of the data's range.
811 This is because they convey information through size, and starting from a
812 different value would distort their meaning. In cases where the fill is purely
813 for decorative purposes, however, "zero" allows you to override this behavior.
814 It defaults to true for filled lines and bars; setting it to false tells the
815 series to use the same automatic scaling as an un-filled line.
816
89ce1ca9 »
2009-03-01 Introduce step-wise line charts, extending the data model to have (po…
817 For lines, "steps" specifies whether two adjacent data points are
818 connected with a straight (possibly diagonal) line or with first a
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
819 horizontal and then a vertical line. Note that this transforms the
820 data by adding extra points.
821
8031f5fd »
2010-07-12 Support for customizing the point type through a callback when plotti…
822 For points, you can specify the radius and the symbol. The only
823 built-in symbol type is circles, for other types you can use a plugin
824 or define them yourself by specifying a callback:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
825
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
826 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
827 function cross(ctx, x, y, radius, shadow) {
828 var size = radius * Math.sqrt(Math.PI) / 2;
829 ctx.moveTo(x - size, y - size);
830 ctx.lineTo(x + size, y + size);
831 ctx.moveTo(x - size, y + size);
832 ctx.lineTo(x + size, y - size);
833 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
834 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
835
8031f5fd »
2010-07-12 Support for customizing the point type through a callback when plotti…
836 The parameters are the drawing context, x and y coordinates of the
837 center of the point, a radius which corresponds to what the circle
838 would have used and whether the call is to draw a shadow (due to
839 limited canvas support, shadows are currently faked through extra
840 draws). It's good practice to ensure that the area covered by the
841 symbol is the same as for the circle with the given radius, this
842 ensures that all symbols have approximately the same visual weight.
843
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
844 "shadowSize" is the default size of shadows in pixels. Set it to 0 to
845 remove shadows.
89ce1ca9 »
2009-03-01 Introduce step-wise line charts, extending the data model to have (po…
846
070fd835 »
2012-07-16 Added docs for the highlightColor option.
847 "highlightColor" is the default color of the translucent overlay used
848 to highlight the series when the mouse hovers over it.
849
19eb7612 »
2007-12-04 Documented more options
850 The "colors" array specifies a default color theme to get colors for
851 the data series from. You can specify as many colors as you like, like
852 this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
853
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
854 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
855 colors: ["#d18b2c", "#dba255", "#919733"]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
856 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
857
19eb7612 »
2007-12-04 Documented more options
858 If there are more data series than colors, Flot will try to generate
859 extra colors by lightening and darkening colors in the theme.
860
861
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
862 ## Customizing the grid ##
633dd824 »
2012-07-15 Cleaned up and standardized markup.
863
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
864 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
865 grid: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
866 show: boolean
867 aboveData: boolean
868 color: color
869 backgroundColor: color/gradient or null
870 margin: number or margin object
871 labelMargin: number
872 axisMargin: number
873 markings: array of markings or (fn: axes -> array of markings)
5fcb64ff »
2012-11-08 Support different border color, widths for each side of the chart
874 borderWidth: number or object with "top", "right", "bottom" and "left" properties with different widths
875 borderColor: color or null or object with "top", "right", "bottom" and "left" properties with different colors
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
876 minBorderMargin: number or null
877 clickable: boolean
878 hoverable: boolean
879 autoHighlight: boolean
880 mouseActiveRadius: number
633dd824 »
2012-07-15 Cleaned up and standardized markup.
881 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
882
633dd824 »
2012-07-15 Cleaned up and standardized markup.
883 interaction: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
884 redrawOverlayInterval: number or -1
633dd824 »
2012-07-15 Cleaned up and standardized markup.
885 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
886 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
887
947c1663 »
2010-04-28 Support for coloring axes, and automatic tick color selection
888 The grid is the thing with the axes and a number of ticks. Many of the
889 things in the grid are configured under the individual axes, but not
890 all. "color" is the color of the grid itself whereas "backgroundColor"
891 specifies the background color inside the grid area, here null means
8a78e8f8 »
2009-01-14 Added support for gradients, currently only used for the grid background
892 that the background is transparent. You can also set a gradient, see
3360d274 »
2009-08-06 Option to have the grid on top of the data, important for image plots…
893 the gradient documentation below.
894
895 You can turn off the whole grid including tick labels by setting
815f80e7 »
2010-02-09 Small documentation fixes
896 "show" to false. "aboveData" determines whether the grid is drawn
3360d274 »
2009-08-06 Option to have the grid on top of the data, important for image plots…
897 above the data or below (below is default).
07598593 »
2012-04-27 Added a grid.margin option
898
899 "margin" is the space in pixels between the canvas edge and the grid,
900 which can be either a number or an object with individual margins for
901 each side, in the form:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
902
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
903 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
904 margin: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
905 top: top margin in pixels
906 left: left margin in pixels
907 bottom: bottom margin in pixels
908 right: right margin in pixels
633dd824 »
2012-07-15 Cleaned up and standardized markup.
909 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
910 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
911
947c1663 »
2010-04-28 Support for coloring axes, and automatic tick color selection
912 "labelMargin" is the space in pixels between tick labels and axis
913 line, and "axisMargin" is the space in pixels between axes when there
89bbfef5 »
2011-04-06 Switch to using canvas text to draw the axis labels, fix a problem wi…
914 are two next to each other.
fbe4273b »
2011-03-15 New options.grid.minBorderMargin for adjusting the minimum margin pro…
915
947c1663 »
2010-04-28 Support for coloring axes, and automatic tick color selection
916 "borderWidth" is the width of the border around the plot. Set it to 0
5fcb64ff »
2012-11-08 Support different border color, widths for each side of the chart
917 to disable the border. Set it to an object with "top", "right",
918 "bottom" and "left" properties to use different widths. You can
919 also set "borderColor" if you want the border to have a different color
920 than the grid lines. Set it to an object with "top", "right", "bottom"
921 and "left" properties to use different colors. "minBorderMargin" controls
922 the default minimum margin around the border - it's used to make sure
923 that points aren't accidentally clipped by the canvas edge so by default
924 the value is computed from the point radius.
19eb7612 »
2007-12-04 Documented more options
925
938928b8 »
2008-09-22 Support for preventing event in setSelection and revamped coloredArea…
926 "markings" is used to draw simple lines and rectangular areas in the
927 background of the plot. You can either specify an array of ranges on
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
928 the form { xaxis: { from, to }, yaxis: { from, to } } (with multiple
929 axes, you can specify coordinates for other axes instead, e.g. as
930 x2axis/x3axis/...) or with a function that returns such an array given
931 the axes for the plot in an object as the first parameter.
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
932
938928b8 »
2008-09-22 Support for preventing event in setSelection and revamped coloredArea…
933 You can set the color of markings by specifying "color" in the ranges
934 object. Here's an example array:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
935
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
936 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
937 markings: [ { xaxis: { from: 0, to: 2 }, yaxis: { from: 10, to: 10 }, color: "#bb0000" }, ... ]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
938 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
939
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
940 If you leave out one of the values, that value is assumed to go to the
938928b8 »
2008-09-22 Support for preventing event in setSelection and revamped coloredArea…
941 border of the plot. So for example if you only specify { xaxis: {
942 from: 0, to: 2 } } it means an area that extends from the top to the
943 bottom of the plot in the x range 0-2.
944
945 A line is drawn if from and to are the same, e.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
946
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
947 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
948 markings: [ { yaxis: { from: 1, to: 1 } }, ... ]
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
949 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
950
938928b8 »
2008-09-22 Support for preventing event in setSelection and revamped coloredArea…
951 would draw a line parallel to the x axis at y = 1. You can control the
e8d764d0 »
2009-06-23 Added "pointOffset" for converting a point in data space to an offset
952 line width with "lineWidth" in the range object.
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
953
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
954 An example function that makes vertical stripes might look like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
955
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
956 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
957 markings: function (axes) {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
958 var markings = [];
959 for (var x = Math.floor(axes.xaxis.min); x < axes.xaxis.max; x += 2)
633dd824 »
2012-07-15 Cleaned up and standardized markup.
960 markings.push({ xaxis: { from: x, to: x + 1 } });
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
961 return markings;
633dd824 »
2012-07-15 Cleaned up and standardized markup.
962 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
963 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
964
f4ffef25 »
2007-12-14 Added support for clicking on the plot, still a bit primitive
965 If you set "clickable" to true, the plot will listen for click events
865688a1 »
2008-02-26 Some further tweaks to time series handling, implemented support for …
966 on the plot area and fire a "plotclick" event on the placeholder with
4bc191f0 »
2008-09-10 Spit out pageX/pageY in "plotclick" and "plothover" events, add primi…
967 a position and a nearby data item object as parameters. The coordinates
968 are available both in the unit of the axes (not in pixels) and in
969 global screen coordinates.
7c9ff67b »
2008-09-10 Landed dual axis/hover event/finding nearby datapoints patch
970
da9023c1 »
2008-09-17 Document highlight and related
971 Likewise, if you set "hoverable" to true, the plot will listen for
972 mouse move events on the plot area and fire a "plothover" event with
973 the same parameters as the "plotclick" event. If "autoHighlight" is
974 true (the default), nearby data items are highlighted automatically.
975 If needed, you can disable highlighting and control it yourself with
976 the highlight/unhighlight plot methods described elsewhere.
7c9ff67b »
2008-09-10 Landed dual axis/hover event/finding nearby datapoints patch
977
978 You can use "plotclick" and "plothover" events like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
979
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
980 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
981 $.plot($("#placeholder"), [ d ], { grid: { clickable: true } });
982
983 $("#placeholder").bind("plotclick", function (event, pos, item) {
984 alert("You clicked at " + pos.x + ", " + pos.y);
985 // axis coordinates for other axes, if present, are in pos.x2, pos.x3, ...
986 // if you need global screen coordinates, they are pos.pageX, pos.pageY
987
988 if (item) {
989 highlight(item.series, item.datapoint);
990 alert("You clicked a point!");
991 }
992 });
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
993 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
994
7c9ff67b »
2008-09-10 Landed dual axis/hover event/finding nearby datapoints patch
995 The item object in this example is either null or a nearby object on the form:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
996
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
997 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
998 item: {
999 datapoint: the point, e.g. [0, 2]
1000 dataIndex: the index of the point in the data array
1001 series: the series object
1002 seriesIndex: the index of the series
1003 pageX, pageY: the global screen coordinates of the point
1004 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1005 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1006
7c9ff67b »
2008-09-10 Landed dual axis/hover event/finding nearby datapoints patch
1007 For instance, if you have specified the data like this
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1008
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1009 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1010 $.plot($("#placeholder"), [ { label: "Foo", data: [[0, 10], [7, 3]] } ], ...);
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1011 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1012
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1013 and the mouse is near the point (7, 3), "datapoint" is [7, 3],
1014 "dataIndex" will be 1, "series" is a normalized series object with
1015 among other things the "Foo" label in series.label and the color in
1016 series.color, and "seriesIndex" is 0. Note that plugins and options
1017 that transform the data can shift the indexes from what you specified
1018 in the original data array.
7c9ff67b »
2008-09-10 Landed dual axis/hover event/finding nearby datapoints patch
1019
da9023c1 »
2008-09-17 Document highlight and related
1020 If you use the above events to update some other information and want
1021 to clear out that info in case the mouse goes away, you'll probably
1022 also need to listen to "mouseout" events on the placeholder div.
1023
1024 "mouseActiveRadius" specifies how far the mouse can be from an item
1025 and still activate it. If there are two or more points within this
20fe8fdb »
2008-09-21 Added special-case for highlighting bars
1026 radius, Flot chooses the closest item. For bars, the top-most bar
1027 (from the latest specified data series) is chosen.
f4ffef25 »
2007-12-14 Added support for clicking on the plot, still a bit primitive
1028
5587862a »
2008-11-18 Added support for disabling interactivity for specific plots
1029 If you want to disable interactivity for a specific data series, you
1030 can set "hoverable" and "clickable" to false in the options for that
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1031 series, like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1032
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1033 ```js
1034 { data: [...], label: "Foo", clickable: false }
1035 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1036
f6cebd3f »
2011-05-13 Update excanvas and remove previous eventholder work-around to fix ho…
1037 "redrawOverlayInterval" specifies the maximum time to delay a redraw
1038 of interactive things (this works as a rate limiting device). The
1039 default is capped to 60 frames per second. You can set it to -1 to
1040 disable the rate limiting.
1041
f4ffef25 »
2007-12-14 Added support for clicking on the plot, still a bit primitive
1042
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
1043 ## Specifying gradients ##
8a78e8f8 »
2009-01-14 Added support for gradients, currently only used for the grid background
1044
1045 A gradient is specified like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1046
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1047 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1048 { colors: [ color1, color2, ... ] }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1049 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1050
8a78e8f8 »
2009-01-14 Added support for gradients, currently only used for the grid background
1051 For instance, you might specify a background on the grid going from
1052 black to gray like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1053
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1054 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1055 grid: {
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1056 backgroundColor: { colors: ["#000", "#999"] }
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1057 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1058 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1059
3a1d1e7b »
2009-02-01 Added support for gradient bars
1060 For the series you can specify the gradient as an object that
1061 specifies the scaling of the brightness and the opacity of the series
1062 color, e.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1063
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1064 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1065 { colors: [{ opacity: 0.8 }, { brightness: 0.6, opacity: 0.8 } ] }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1066 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1067
3a1d1e7b »
2009-02-01 Added support for gradient bars
1068 where the first color simply has its alpha scaled, whereas the second
563349c9 »
2009-10-22 Add example of using gradients with bars
1069 is also darkened. For instance, for bars the following makes the bars
1070 gradually disappear, without outline:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1071
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1072 ```js
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1073 bars: {
1074 show: true,
1075 lineWidth: 0,
1076 fill: true,
1077 fillColor: { colors: [ { opacity: 0.8 }, { opacity: 0.1 } ] }
1078 }
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1079 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1080
8a78e8f8 »
2009-01-14 Added support for gradients, currently only used for the grid background
1081 Flot currently only supports vertical gradients drawn from top to
1082 bottom because that's what works with IE.
1083
1084
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
1085 ## Plot Methods ##
d2a5a632 »
2007-12-04 First draft, options are not documented yet
1086
da9023c1 »
2008-09-17 Document highlight and related
1087 The Plot object returned from the plot function has some methods you
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1088 can call:
d2a5a632 »
2007-12-04 First draft, options are not documented yet
1089
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1090 - highlight(series, datapoint)
da9023c1 »
2008-09-17 Document highlight and related
1091
1092 Highlight a specific datapoint in the data series. You can either
1093 specify the actual objects, e.g. if you got them from a
1094 "plotclick" event, or you can specify the indices, e.g.
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1095 highlight(1, 3) to highlight the fourth point in the second series
1096 (remember, zero-based indexing).
da9023c1 »
2008-09-17 Document highlight and related
1097
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1098 - unhighlight(series, datapoint) or unhighlight()
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1099
1100 Remove the highlighting of the point, same parameters as
1101 highlight.
da9023c1 »
2008-09-17 Document highlight and related
1102
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1103 If you call unhighlight with no parameters, e.g. as
1104 plot.unhighlight(), all current highlights are removed.
da9023c1 »
2008-09-17 Document highlight and related
1105
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1106 - setData(data)
2015ca3a »
2008-03-07 Added more members to the Plot object + a few cleanups
1107
1108 You can use this to reset the data used. Note that axis scaling,
1109 ticks, legend etc. will not be recomputed (use setupGrid() to do
1110 that). You'll probably want to call draw() afterwards.
1111
f1db197e »
2009-06-23 New option grid.show, set to false to disable the grid
1112 You can use this function to speed up redrawing a small plot if
1113 you know that the axes won't change. Put in the new data with
1114 setData(newdata), call draw(), and you're good to go. Note that
1115 for large datasets, almost all the time is consumed in draw()
1116 plotting the data so in this case don't bother.
2015ca3a »
2008-03-07 Added more members to the Plot object + a few cleanups
1117
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1118 - setupGrid()
2015ca3a »
2008-03-07 Added more members to the Plot object + a few cleanups
1119
1120 Recalculate and set axis scaling, ticks, legend etc.
1121
1122 Note that because of the drawing model of the canvas, this
1123 function will immediately redraw (actually reinsert in the DOM)
1124 the labels and the legend, but not the actual tick lines because
1125 they're drawn on the canvas. You need to call draw() to get the
1126 canvas redrawn.
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1127
1128 - draw()
2015ca3a »
2008-03-07 Added more members to the Plot object + a few cleanups
1129
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1130 Redraws the plot canvas.
1131
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1132 - triggerRedrawOverlay()
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1133
1134 Schedules an update of an overlay canvas used for drawing
d54a40c2 »
2009-10-22 Move selection support to a plugin (based on patch from andershol),
1135 interactive things like a selection and point highlights. This
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1136 is mostly useful for writing plugins. The redraw doesn't happen
1137 immediately, instead a timer is set to catch multiple successive
dbc1270b »
2011-03-10 Mention that you can get to the overlay by setting up a drawOverlay hook
1138 redraws (e.g. from a mousemove). You can get to the overlay by
1139 setting up a drawOverlay hook.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1140
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1141 - width()/height()
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1142
1143 Gets the width and height of the plotting area inside the grid.
1144 This is smaller than the canvas or placeholder dimensions as some
1145 extra space is needed (e.g. for labels).
1146
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1147 - offset()
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1148
1149 Returns the offset of the plotting area inside the grid relative
1150 to the document, useful for instance for calculating mouse
1151 positions (event.pageX/Y minus this offset is the pixel position
1152 inside the plot).
e8d764d0 »
2009-06-23 Added "pointOffset" for converting a point in data space to an offset
1153
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1154 - pointOffset({ x: xpos, y: ypos })
e8d764d0 »
2009-06-23 Added "pointOffset" for converting a point in data space to an offset
1155
1156 Returns the calculated offset of the data point at (x, y) in data
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1157 space within the placeholder div. If you are working with multiple
1158 axes, you can specify the x and y axis references, e.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1159
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1160 ```js
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1161 o = pointOffset({ x: xpos, y: ypos, xaxis: 2, yaxis: 3 })
1162 // o.left and o.top now contains the offset within the div
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1163 ````
4e027816 »
2011-03-17 Refactor replot behaviour so Flot tries to reuse the existing canvas,
1164
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1165 - resize()
4e027816 »
2011-03-17 Refactor replot behaviour so Flot tries to reuse the existing canvas,
1166
1167 Tells Flot to resize the drawing canvas to the size of the
1168 placeholder. You need to run setupGrid() and draw() afterwards as
1169 canvas resizing is a destructive operation. This is used
1170 internally by the resize plugin.
1171
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1172 - shutdown()
4e027816 »
2011-03-17 Refactor replot behaviour so Flot tries to reuse the existing canvas,
1173
1174 Cleans up any event handlers Flot has currently registered. This
1175 is used internally.
1176
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1177 There are also some members that let you peek inside the internal
e8d764d0 »
2009-06-23 Added "pointOffset" for converting a point in data space to an offset
1178 workings of Flot which is useful in some cases. Note that if you change
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1179 something in the objects returned, you're changing the objects used by
1180 Flot to keep track of its state, so be careful.
1181
1182 - getData()
1183
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1184 Returns an array of the data series currently used in normalized
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1185 form with missing settings filled in according to the global
1186 options. So for instance to find out what color Flot has assigned
1187 to the data series, you could do this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1188
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1189 ```js
1190 var series = plot.getData();
1191 for (var i = 0; i < series.length; ++i)
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1192 alert(series[i].color);
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1193 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1194
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1195 A notable other interesting field besides color is datapoints
1196 which has a field "points" with the normalized data points in a
f1db197e »
2009-06-23 New option grid.show, set to false to disable the grid
1197 flat array (the field "pointsize" is the increment in the flat
1198 array to get to the next point so for a dataset consisting only of
1199 (x,y) pairs it would be 2).
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1200
1201 - getAxes()
1202
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
1203 Gets an object with the axes. The axes are returned as the
1204 attributes of the object, so for instance getAxes().xaxis is the
1205 x axis.
e8d764d0 »
2009-06-23 Added "pointOffset" for converting a point in data space to an offset
1206
1207 Various things are stuffed inside an axis object, e.g. you could
1208 use getAxes().xaxis.ticks to find out what the ticks are for the
1209 xaxis. Two other useful attributes are p2c and c2p, functions for
1210 transforming from data point space to the canvas plot space and
1211 back. Both returns values that are offset with the plot offset.
bad53abc »
2010-04-15 Revamped internals to add support for extra axes, not just dual (spon…
1212 Check the Flot source code for the complete set of attributes (or
1213 output an axis with console.log() and inspect it).
1214
1215 With multiple axes, the extra axes are returned as x2axis, x3axis,
1216 etc., e.g. getAxes().y2axis is the second y axis. You can check
47821c71 »
2011-03-11 Refactor the axis dimension calculations slightly to avoid the whole
1217 y2axis.used to see whether the axis is associated with any data
1218 points and y2axis.show to see if it is currently shown.
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1219
a7355c21 »
2009-07-05 Added getPlaceholder and renamed internal target to placeholder
1220 - getPlaceholder()
1221
1222 Returns placeholder that the plot was put into. This can be useful
1223 for plugins for adding DOM elements or firing events.
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1224
1225 - getCanvas()
1226
1227 Returns the canvas used for drawing in case you need to hack on it
1228 yourself. You'll probably need to get the plot offset too.
1229
1230 - getPlotOffset()
1231
1232 Gets the offset that the grid has within the canvas as an object
da9023c1 »
2008-09-17 Document highlight and related
1233 with distances from the canvas edges as "left", "right", "top",
1234 "bottom". I.e., if you draw a circle on the canvas with the center
1235 placed at (left, top), its center will be at the top-most, left
1236 corner of the grid.
078f25e5 »
2008-09-13 Fixed description of methods returning internals
1237
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1238 - getOptions()
1239
d2b0d36e »
2010-12-14 Add a note about getOptions() being useful for changing options
1240 Gets the options for the plot, normalized, with default values
1241 filled in. You get a reference to actual values used by Flot, so
1242 if you modify the values in here, Flot will use the new values.
1243 If you change something, you probably have to call draw() or
1244 setupGrid() or triggerRedrawOverlay() to see the change.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1245
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1246
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
1247 ## Hooks ##
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1248
1249 In addition to the public methods, the Plot object also has some hooks
1250 that can be used to modify the plotting process. You can install a
1251 callback function at various points in the process, the function then
1252 gets access to the internal data structures in Flot.
1253
1254 Here's an overview of the phases Flot goes through:
1255
1256 1. Plugin initialization, parsing options
1257
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1258 2. Constructing the canvases used for drawing
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1259
1260 3. Set data: parsing data specification, calculating colors,
1261 copying raw data points into internal format,
1262 normalizing them, finding max/min for axis auto-scaling
1263
1264 4. Grid setup: calculating axis spacing, ticks, inserting tick
1265 labels, the legend
1266
1267 5. Draw: drawing the grid, drawing each of the series in turn
1268
1269 6. Setting up event handling for interactive features
1270
1271 7. Responding to events, if any
1272
4e027816 »
2011-03-17 Refactor replot behaviour so Flot tries to reuse the existing canvas,
1273 8. Shutdown: this mostly happens in case a plot is overwritten
1274
9396ceb4 »
2009-10-21 Added a hooks option to enable scripts to define hooks before doing a…
1275 Each hook is simply a function which is put in the appropriate array.
1276 You can add them through the "hooks" option, and they are also available
1277 after the plot is constructed as the "hooks" attribute on the returned
1278 plot object, e.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1279
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1280 ```js
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1281 // define a simple draw hook
1282 function hellohook(plot, canvascontext) { alert("hello!"); };
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1283
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1284 // pass it in, in an array since we might want to specify several
1285 var plot = $.plot(placeholder, data, { hooks: { draw: [hellohook] } });
9396ceb4 »
2009-10-21 Added a hooks option to enable scripts to define hooks before doing a…
1286
4fa6e380 »
2012-07-16 Correct GitHub Syntax Highlighting in API markdown
1287 // we can now find it again in plot.hooks.draw[0] unless a plugin
1288 // has added other hooks
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1289 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1290
9396ceb4 »
2009-10-21 Added a hooks option to enable scripts to define hooks before doing a…
1291 The available hooks are described below. All hook callbacks get the
1292 plot object as first parameter. You can find some examples of defined
1293 hooks in the plugins bundled with Flot.
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1294
1295 - processOptions [phase 1]
1296
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1297 ```function(plot, options)```
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1298
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1299 Called after Flot has parsed and merged options. Useful in the
1300 instance where customizations beyond simple merging of default
1301 values is needed. A plugin might use it to detect that it has been
1302 enabled and then turn on or off other options.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1303
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1304
1305 - processRawData [phase 3]
1306
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1307 ```function(plot, series, data, datapoints)```
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1308
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1309 Called before Flot copies and normalizes the raw data for the given
1310 series. If the function fills in datapoints.points with normalized
1311 points and sets datapoints.pointsize to the size of the points,
1312 Flot will skip the copying/normalization step for this series.
aebbf14b »
2009-07-04 Generalized the data normalization step so it can be parameterized
1313
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1314 In any case, you might be interested in setting datapoints.format,
1315 an array of objects for specifying how a point is normalized and
151e96fb »
2013-01-10 Expand documentation of the point format options.
1316 how it interferes with axis scaling. It accepts the following options:
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1317
151e96fb »
2013-01-10 Expand documentation of the point format options.
1318 ```js
1319 {
1320 x, y: boolean,
1321 number: boolean,
1322 required: boolean,
1323 defaultValue: value,
1324 autoscale: boolean
1325 }
1326 ```
1327
1328 "x" and "y" specify whether the value is plotted against the x or y axis,
1329 and is currently used only to calculate axis min-max ranges. The default
1330 format array, for example, looks like this:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1331
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1332 ```js
1333 [
1334 { x: true, number: true, required: true },
1335 { y: true, number: true, required: true }
1336 ]
1337 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1338
151e96fb »
2013-01-10 Expand documentation of the point format options.
1339 This indicates that a point, i.e. [0, 25], consists of two values, with the
1340 first being plotted on the x axis and the second on the y axis.
1341
1342 If "number" is true, then the value must be numeric, and is set to null if
1343 it cannot be converted to a number.
1344
1345 "defaultValue" provides a fallback in case the original value is null. This
1346 is for instance handy for bars, where one can omit the third coordinate
1347 (the bottom of the bar), which then defaults to zero.
1348
1349 If "required" is true, then the value must exist (be non-null) for the
1350 point as a whole to be valid. If no value is provided, then the entire
1351 point is cleared out with nulls, turning it into a gap in the series.
1352
1353 "autoscale" determines whether the value is considered when calculating an
1354 automatic min-max range for the axes that the value is plotted against.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1355
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…
1356 - processDatapoints [phase 3]
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1357
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1358 ```function(plot, series, datapoints)```
1359
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1360 Called after normalization of the given series but before finding
1361 min/max of the data points. This hook is useful for implementing data
1362 transformations. "datapoints" contains the normalized data points in
1363 a flat array as datapoints.points with the size of a single point
1364 given in datapoints.pointsize. Here's a simple transform that
1365 multiplies all y coordinates by 2:
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1366
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1367 ```js
1368 function multiply(plot, series, datapoints) {
1369 var points = datapoints.points, ps = datapoints.pointsize;
1370 for (var i = 0; i < points.length; i += ps)
1371 points[i + 1] *= 2;
1372 }
1373 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1374
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1375 Note that you must leave datapoints in a good condition as Flot
1376 doesn't check it or do any normalization on it afterwards.
2ebeb5d4 »
2009-06-23 Added draw hook
1377
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1378 - processOffset [phase 4]
1379
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1380 ```function(plot, offset)```
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1381
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1382 Called after Flot has initialized the plot's offset, but before it
1383 draws any axes or plot elements. This hook is useful for customizing
1384 the margins between the grid and the edge of the canvas. "offset" is
1385 an object with attributes "top", "bottom", "left" and "right",
1386 corresponding to the margins on the four sides of the plot.
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1387
1388 - drawBackground [phase 5]
1389
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1390 ```function(plot, canvascontext)```
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1391
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1392 Called before all other drawing operations. Used to draw backgrounds
1393 or other custom elements before the plot or axes have been drawn.
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1394
c61c120a »
2010-03-22 Added drawSeries hook
1395 - drawSeries [phase 5]
1396
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1397 ```function(plot, canvascontext, series)```
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1398
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1399 Hook for custom drawing of a single series. Called just before the
1400 standard drawing routine has been called in the loop that draws
1401 each series.
4ee1e04e »
2012-04-25 Added processOffset and drawBackground hooks
1402
2ebeb5d4 »
2009-06-23 Added draw hook
1403 - draw [phase 5]
1404
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1405 ```function(plot, canvascontext)```
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1406
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1407 Hook for drawing on the canvas. Called after the grid is drawn
1408 (unless it's disabled or grid.aboveData is set) and the series have
1409 been plotted (in case any points, lines or bars have been turned
1410 on). For examples of how to draw things, look at the source code.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1411
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1412 - bindEvents [phase 6]
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1413
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1414 ```function(plot, eventHolder)```
e448280e »
2010-03-15 Made it clearer that eventHolder is not the one that receives custom
1415
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1416 Called after Flot has setup its event handlers. Should set any
1417 necessary event handlers on eventHolder, a jQuery object with the
1418 canvas, e.g.
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1419
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1420 ```js
1421 function (plot, eventHolder) {
1422 eventHolder.mousedown(function (e) {
1423 alert("You pressed the mouse at " + e.pageX + " " + e.pageY);
1424 });
1425 }
1426 ```
a4de2cab »
2012-07-15 Additional cleanup and markup standardization.
1427
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1428 Interesting events include click, mousemove, mouseup/down. You can
1429 use all jQuery events. Usually, the event handlers will update the
1430 state by drawing something (add a drawOverlay hook and call
1431 triggerRedrawOverlay) or firing an externally visible event for
1432 user code. See the crosshair plugin for an example.
1433
1434 Currently, eventHolder actually contains both the static canvas
1435 used for the plot itself and the overlay canvas used for
1436 interactive features because some versions of IE get the stacking
1437 order wrong. The hook only gets one event, though (either for the
1438 overlay or for the static canvas).
1439
1440 Note that custom plot events generated by Flot are not generated on
1441 eventHolder, but on the div placeholder supplied as the first
1442 argument to the plot call. You can get that with
1443 plot.getPlaceholder() - that's probably also the one you should use
1444 if you need to fire a custom event.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1445
1446 - drawOverlay [phase 7]
1447
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1448 ```function (plot, canvascontext)```
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1449
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1450 The drawOverlay hook is used for interactive things that need a
1451 canvas to draw on. The model currently used by Flot works the way
1452 that an extra overlay canvas is positioned on top of the static
1453 canvas. This overlay is cleared and then completely redrawn
1454 whenever something interesting happens. This hook is called when
1455 the overlay canvas is to be redrawn.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1456
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1457 "canvascontext" is the 2D context of the overlay canvas. You can
1458 use this to draw things. You'll most likely need some of the
1459 metrics computed by Flot, e.g. plot.width()/plot.height(). See the
1460 crosshair plugin for an example.
d3acc16e »
2009-06-02 Removed work-around for slow jQuery mousemove events (closing issue
1461
4e027816 »
2011-03-17 Refactor replot behaviour so Flot tries to reuse the existing canvas,
1462 - shutdown [phase 8]
1463
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1464 ```function (plot, eventHolder)```
4e027816 »
2011-03-17 Refactor replot behaviour so Flot tries to reuse the existing canvas,
1465
633dd824 »
2012-07-15 Cleaned up and standardized markup.
1466 Run when plot.shutdown() is called, which usually only happens in
1467 case a plot is overwritten by a new plot. If you're writing a
1468 plugin that adds extra DOM elements or event handlers, you should
1469 add a callback to clean up after you. Take a look at the section in
4bfa801e »
2013-09-04 Link to PLUGINS.md
1470 the [PLUGINS](PLUGINS.md) document for more info.
4e027816 »
2011-03-17 Refactor replot behaviour so Flot tries to reuse the existing canvas,
1471
3360d274 »
2009-08-06 Option to have the grid on top of the data, important for image plots…
1472
cc974bd0 »
2012-07-16 Additional cleanup and markup standardization.
1473 ## Plugins ##
0d15280a »
2009-05-23 Implemented plugin system, introduced experimental hooks system (thre…