1# Flot [![Build status](https://travis-ci.org/flot/flot.png)](https://travis-ci.org/flot/flot) 2 3## About ## 4 5Flot is a Javascript plotting library for jQuery. 6Read more at the website: <http://www.flotcharts.org/> 7 8Take a look at the the examples in examples/index.html; they should give a good 9impression of what Flot can do, and the source code of the examples is probably 10the fastest way to learn how to use Flot. 11 12 13## Installation ## 14 15Just include the Javascript file after you've included jQuery. 16 17Generally, all browsers that support the HTML5 canvas tag are 18supported. 19 20For support for Internet Explorer < 9, you can use [Excanvas] 21[excanvas], a canvas emulator; this is used in the examples bundled 22with Flot. You just include the excanvas script like this: 23 24```html 25<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]--> 26``` 27 28If it's not working on your development IE 6.0, check that it has 29support for VML which Excanvas is relying on. It appears that some 30stripped down versions used for test environments on virtual machines 31lack the VML support. 32 33You can also try using [Flashcanvas][flashcanvas], which uses Flash to 34do the emulation. Although Flash can be a bit slower to load than VML, 35if you've got a lot of points, the Flash version can be much faster 36overall. Flot contains some wrapper code for activating Excanvas which 37Flashcanvas is compatible with. 38 39You need at least jQuery 1.2.6, but try at least 1.3.2 for interactive 40charts because of performance improvements in event handling. 41 42 43## Basic usage ## 44 45Create a placeholder div to put the graph in: 46 47```html 48<div id="placeholder"></div> 49``` 50 51You need to set the width and height of this div, otherwise the plot 52library doesn't know how to scale the graph. You can do it inline like 53this: 54 55```html 56<div id="placeholder" style="width:600px;height:300px"></div> 57``` 58 59You can also do it with an external stylesheet. Make sure that the 60placeholder isn't within something with a display:none CSS property - 61in that case, Flot has trouble measuring label dimensions which 62results in garbled looks and might have trouble measuring the 63placeholder dimensions which is fatal (it'll throw an exception). 64 65Then when the div is ready in the DOM, which is usually on document 66ready, run the plot function: 67 68```js 69$.plot($("#placeholder"), data, options); 70``` 71 72Here, data is an array of data series and options is an object with 73settings if you want to customize the plot. Take a look at the 74examples for some ideas of what to put in or look at the 75[API reference](API.md). Here's a quick example that'll draw a line 76from (0, 0) to (1, 1): 77 78```js 79$.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } }); 80``` 81 82The plot function immediately draws the chart and then returns a plot 83object with a couple of methods. 84 85 86## What's with the name? ## 87 88First: it's pronounced with a short o, like "plot". Not like "flawed". 89 90So "Flot" rhymes with "plot". 91 92And if you look up "flot" in a Danish-to-English dictionary, some of 93the words that come up are "good-looking", "attractive", "stylish", 94"smart", "impressive", "extravagant". One of the main goals with Flot 95is pretty looks. 96 97 98## Notes about the examples ## 99 100In order to have a useful, functional example of time-series plots using time 101zones, date.js from [timezone-js][timezone-js] (released under the Apache 2.0 102license) and the [Olson][olson] time zone database (released to the public 103domain) have been included in the examples directory. They are used in 104examples/axes-time-zones/index.html. 105 106 107[excanvas]: http://code.google.com/p/explorercanvas/ 108[flashcanvas]: http://code.google.com/p/flashcanvas/ 109[timezone-js]: https://github.com/mde/timezone-js 110[olson]: http://ftp.iana.org/time-zones 111