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