removed flot extras
|
@ -1,131 +0,0 @@
|
|||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 23
|
||||
/svn/!svn/ver/266/trunk
|
||||
END
|
||||
jquery.flot.selection.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 48
|
||||
/svn/!svn/ver/251/trunk/jquery.flot.selection.js
|
||||
END
|
||||
excanvas.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 35
|
||||
/svn/!svn/ver/223/trunk/excanvas.js
|
||||
END
|
||||
FAQ.txt
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 31
|
||||
/svn/!svn/ver/234/trunk/FAQ.txt
|
||||
END
|
||||
API.txt
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 31
|
||||
/svn/!svn/ver/263/trunk/API.txt
|
||||
END
|
||||
jquery.flot.threshold.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 48
|
||||
/svn/!svn/ver/157/trunk/jquery.flot.threshold.js
|
||||
END
|
||||
jquery.flot.crosshair.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 48
|
||||
/svn/!svn/ver/255/trunk/jquery.flot.crosshair.js
|
||||
END
|
||||
jquery.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 33
|
||||
/svn/!svn/ver/180/trunk/jquery.js
|
||||
END
|
||||
NEWS.txt
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 32
|
||||
/svn/!svn/ver/263/trunk/NEWS.txt
|
||||
END
|
||||
jquery.flot.navigate.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 47
|
||||
/svn/!svn/ver/251/trunk/jquery.flot.navigate.js
|
||||
END
|
||||
jquery.colorhelpers.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 46
|
||||
/svn/!svn/ver/219/trunk/jquery.colorhelpers.js
|
||||
END
|
||||
jquery.flot.fillbetween.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 50
|
||||
/svn/!svn/ver/229/trunk/jquery.flot.fillbetween.js
|
||||
END
|
||||
jquery.flot.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 38
|
||||
/svn/!svn/ver/265/trunk/jquery.flot.js
|
||||
END
|
||||
PLUGINS.txt
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 35
|
||||
/svn/!svn/ver/184/trunk/PLUGINS.txt
|
||||
END
|
||||
LICENSE.txt
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 35
|
||||
/svn/!svn/ver/211/trunk/LICENSE.txt
|
||||
END
|
||||
jquery.flot.symbol.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 45
|
||||
/svn/!svn/ver/263/trunk/jquery.flot.symbol.js
|
||||
END
|
||||
jquery.flot.stack.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 44
|
||||
/svn/!svn/ver/231/trunk/jquery.flot.stack.js
|
||||
END
|
||||
excanvas.min.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 39
|
||||
/svn/!svn/ver/223/trunk/excanvas.min.js
|
||||
END
|
||||
jquery.flot.pie.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 42
|
||||
/svn/!svn/ver/228/trunk/jquery.flot.pie.js
|
||||
END
|
||||
README.txt
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 34
|
||||
/svn/!svn/ver/222/trunk/README.txt
|
||||
END
|
||||
Makefile
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 32
|
||||
/svn/!svn/ver/226/trunk/Makefile
|
||||
END
|
||||
jquery.flot.image.js
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 44
|
||||
/svn/!svn/ver/243/trunk/jquery.flot.image.js
|
||||
END
|
|
@ -1,745 +0,0 @@
|
|||
10
|
||||
|
||||
dir
|
||||
266
|
||||
http://flot.googlecode.com/svn/trunk
|
||||
http://flot.googlecode.com/svn
|
||||
|
||||
|
||||
|
||||
2010-09-13T10:27:28.039566Z
|
||||
266
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1e0a6537-2640-0410-bfb7-f154510ff394
|
||||
|
||||
jquery.flot.selection.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
caba4d7c5f3aa02a59d153c188e5c822
|
||||
2010-04-15T17:13:55.862879Z
|
||||
251
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11371
|
||||
|
||||
excanvas.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
5c015eb45975966e2330bb564500e81a
|
||||
2009-10-23T11:08:51.992158Z
|
||||
223
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
41784
|
||||
|
||||
FAQ.txt
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
c2887a84557b19f27935e98dc649255c
|
||||
2010-02-25T21:10:27.314789Z
|
||||
234
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3245
|
||||
|
||||
API.txt
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
bb60d0426d8d8034d0031a3032448a19
|
||||
2010-07-12T20:14:46.959518Z
|
||||
263
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
42958
|
||||
|
||||
jquery.flot.threshold.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
8c5df27b8f30169bdcb5e0972afa7852
|
||||
2009-05-23T22:33:50.910866Z
|
||||
157
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3291
|
||||
|
||||
jquery.flot.crosshair.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
1258fd1f95bd86c2a409db913bd7b17c
|
||||
2010-04-15T17:34:51.701471Z
|
||||
255
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5014
|
||||
|
||||
jquery.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
7b7ece4224616a0eb48bf16057e15e77
|
||||
2009-07-05T11:27:27.624286Z
|
||||
180
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
120763
|
||||
|
||||
NEWS.txt
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
a4beb6d075825e2ce97217942fc54d83
|
||||
2010-07-12T20:14:46.959518Z
|
||||
263
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
18022
|
||||
|
||||
jquery.flot.navigate.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
7340660a4f641febfc4db2e8a6ae6a26
|
||||
2010-04-15T17:13:55.862879Z
|
||||
251
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
12611
|
||||
|
||||
jquery.colorhelpers.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
e41a9f0f0169d9b91fd4febae512aa9d
|
||||
2009-10-22T22:18:40.985869Z
|
||||
219
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5923
|
||||
|
||||
jquery.flot.fillbetween.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
62001e803c55571594a327da3781fbe7
|
||||
2009-12-07T15:24:55.339814Z
|
||||
229
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6771
|
||||
|
||||
jquery.flot.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
8d6503221b6d7658e7d79e34c8e58036
|
||||
2010-08-16T09:30:05.278961Z
|
||||
265
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
103752
|
||||
|
||||
PLUGINS.txt
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
b1c78fd463f59a4072c0681a47b6e2fa
|
||||
2009-07-05T16:28:17.918698Z
|
||||
184
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3249
|
||||
|
||||
LICENSE.txt
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
4df0a17a01e7266c8efecbb9061752de
|
||||
2009-10-21T15:56:49.766903Z
|
||||
211
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1069
|
||||
|
||||
jquery.flot.stack.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
e9af2bfe13e736536572d141050febc4
|
||||
2010-02-09T15:45:53.414299Z
|
||||
231
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6968
|
||||
|
||||
jquery.flot.symbol.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
df5e55902225d675fd9f88aaf5fe6301
|
||||
2010-07-12T20:14:46.959518Z
|
||||
263
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2441
|
||||
|
||||
excanvas.min.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
3682670784157eca627a91ae04f925b8
|
||||
2009-10-23T11:08:51.992158Z
|
||||
223
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
19415
|
||||
|
||||
jquery.flot.pie.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
80de48112de5fb30a9b243baa51da925
|
||||
2009-11-20T23:34:30.607841Z
|
||||
228
|
||||
the.d0rp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
22588
|
||||
|
||||
README.txt
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
a6e85fab934a9e0be57c480fdb8f8320
|
||||
2009-10-22T22:38:51.309593Z
|
||||
222
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2730
|
||||
|
||||
Makefile
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
eb208f50bca4c378a8c8f864560f9807
|
||||
2009-10-28T12:29:29.323123Z
|
||||
226
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
457
|
||||
|
||||
examples
|
||||
dir
|
||||
|
||||
jquery.flot.image.js
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2010-10-03T19:41:44.000000Z
|
||||
a8ac5bc33b9578d6f735efb8963611f9
|
||||
2010-03-22T11:35:33.680078Z
|
||||
243
|
||||
olau@iola.dk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7351
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
Frequently asked questions
|
||||
--------------------------
|
||||
|
||||
Q: How much data can Flot cope with?
|
||||
|
||||
A: Flot will happily draw everything you send to it so the answer
|
||||
depends on the browser. The excanvas emulation used for IE (built with
|
||||
VML) makes IE by far the slowest browser so be sure to test with that
|
||||
if IE users are in your target group.
|
||||
|
||||
1000 points is not a problem, but as soon as you start having more
|
||||
points than the pixel width, you should probably start thinking about
|
||||
downsampling/aggregation as this is near the resolution limit of the
|
||||
chart anyway. If you downsample server-side, you also save bandwidth.
|
||||
|
||||
|
||||
Q: Flot isn't working when I'm using JSON data as source!
|
||||
|
||||
A: Actually, Flot loves JSON data, you just got the format wrong.
|
||||
Double check that you're not inputting strings instead of numbers,
|
||||
like [["0", "-2.13"], ["5", "4.3"]]. This is most common mistake, and
|
||||
the error might not show up immediately because Javascript can do some
|
||||
conversion automatically.
|
||||
|
||||
|
||||
Q: Can I export the graph?
|
||||
|
||||
A: This is a limitation of the canvas technology. There's a hook in
|
||||
the canvas object for getting an image out, but you won't get the tick
|
||||
labels. And it's not likely to be supported by IE. At this point, your
|
||||
best bet is probably taking a screenshot, e.g. with PrtScn.
|
||||
|
||||
|
||||
Q: The bars are all tiny in time mode?
|
||||
|
||||
A: It's not really possible to determine the bar width automatically.
|
||||
So you have to set the width with the barWidth option which is NOT in
|
||||
pixels, but in the units of the x axis (or the y axis for horizontal
|
||||
bars). For time mode that's milliseconds so the default value of 1
|
||||
makes the bars 1 millisecond wide.
|
||||
|
||||
|
||||
Q: Can I use Flot with libraries like Mootools or Prototype?
|
||||
|
||||
A: Yes, Flot supports it out of the box and it's easy! Just use jQuery
|
||||
instead of $, e.g. call jQuery.plot instead of $.plot and use
|
||||
jQuery(something) instead of $(something). As a convenience, you can
|
||||
put in a DOM element for the graph placeholder where the examples and
|
||||
the API documentation are using jQuery objects.
|
||||
|
||||
Depending on how you include jQuery, you may have to add one line of
|
||||
code to prevent jQuery from overwriting functions from the other
|
||||
libraries, see the documentation in jQuery ("Using jQuery with other
|
||||
libraries") for details.
|
||||
|
||||
|
||||
Q: Flot doesn't work with [insert name of Javascript UI framework]!
|
||||
|
||||
A: The only non-standard thing used by Flot is the canvas tag;
|
||||
otherwise it is simply a series of absolute positioned divs within the
|
||||
placeholder tag you put in. If this is not working, it's probably
|
||||
because the framework you're using is doing something weird with the
|
||||
DOM, or you're using it the wrong way.
|
||||
|
||||
A common problem is that there's display:none on a container until the
|
||||
user does something. Many tab widgets work this way, and there's
|
||||
nothing wrong with it - you just can't call Flot inside a display:none
|
||||
container as explained in the README so you need to hold off the Flot
|
||||
call until the container is actually displayed (or use
|
||||
visibility:hidden instead of display:none or move the container
|
||||
off-screen).
|
||||
|
||||
If you find there's a specific thing we can do to Flot to help, feel
|
||||
free to submit a bug report. Otherwise, you're welcome to ask for help
|
||||
on the forum/mailing list, but please don't submit a bug report to
|
||||
Flot.
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 2007-2009 IOLA and Ole Laursen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,15 +0,0 @@
|
|||
# Makefile for generating minified files
|
||||
|
||||
YUICOMPRESSOR_PATH=../yuicompressor-2.3.5.jar
|
||||
|
||||
# if you need another compressor path, just copy the above line to a
|
||||
# file called Makefile.local, customize it and you're good to go
|
||||
-include Makefile.local
|
||||
|
||||
.PHONY: all
|
||||
|
||||
# we cheat and process all .js files instead of an exhaustive list
|
||||
all: $(patsubst %.js,%.min.js,$(filter-out %.min.js,$(wildcard *.js)))
|
||||
|
||||
%.min.js: %.js
|
||||
java -jar $(YUICOMPRESSOR_PATH) $< -o $@
|
|
@ -1,439 +0,0 @@
|
|||
Flot x.x
|
||||
--------
|
||||
|
||||
API changes:
|
||||
|
||||
Multiple axes support. Code using dual axes should be changed from
|
||||
using x2axis/y2axis in the options to using an array (although
|
||||
backwards-compatibility hooks are in place). For instance,
|
||||
|
||||
{
|
||||
xaxis: { ... }, x2axis: { ... },
|
||||
yaxis: { ... }, y2axis: { ... }
|
||||
}
|
||||
|
||||
becomes
|
||||
|
||||
{
|
||||
xaxes: [ { ... }, { ... } ],
|
||||
yaxes: [ { ... }, { ... } ]
|
||||
}
|
||||
|
||||
Note that if you're just using one axis, continue to use the
|
||||
xaxis/yaxis directly (it now sets the default settings for the
|
||||
arrays). Plugins touching the axes must be ported to take the extra
|
||||
axes into account, a couple of helper functions have been added for
|
||||
that purpose, check the source.
|
||||
|
||||
"tickColor" on the grid options is now deprecated in favour of a
|
||||
corresponding option on the axes, so { grid: { tickColor: "#000" }}
|
||||
becomes { xaxis: { tickColor: "#000"}, yaxis: { tickColor: "#000"} },
|
||||
but if you just configure a base color Flot will now autogenerate a
|
||||
tick color by adding transparency. Backwards-compatibility hooks are
|
||||
in place.
|
||||
|
||||
Changes:
|
||||
|
||||
- Support for specifying a bottom for each point for line charts when
|
||||
filling them, this means that an arbitrary bottom can be used
|
||||
instead of just the x axis (based on patches patiently provided by
|
||||
Roman V. Prikhodchenko).
|
||||
- New fillbetween plugin that can compute a bottom for a series from
|
||||
another series, useful for filling areas between lines (see new
|
||||
example percentiles.html for a use case).
|
||||
- More predictable handling of gaps for the stacking plugin, now all
|
||||
undefined ranges are skipped.
|
||||
- Stacking plugin can stack horizontal bar charts.
|
||||
- Navigate plugin now redraws the plot while panning instead of only
|
||||
after the fact (can be disabled by setting the pan.frameRate option
|
||||
to null), raised by lastthemy (issue 235).
|
||||
- Date formatter now accepts %0m and %0d to get a zero-padded month or
|
||||
day (issue raised by Maximillian Dornseif).
|
||||
- Revamped internals to support an unlimited number of axes, not just
|
||||
dual (sponsored by Flight Data Services,
|
||||
www.flightdataservices.com).
|
||||
- New setting on axes, "tickLength", to control the size of ticks or
|
||||
turn them off without turning off the labels.
|
||||
- Axis labels are now put in container divs with classes, for instance
|
||||
labels in the x axes can be reached via ".xAxis .tickLabel".
|
||||
- Support for setting the color of an axis (sponsored by Flight Data
|
||||
Services, www.flightdataservices.com).
|
||||
- Tick color is now auto-generated as the base color with some
|
||||
transparency (unless you override it).
|
||||
- Support for aligning ticks in the axes with "alignTicksWithAxis" to
|
||||
ensure that they appear next to each other rather than in between,
|
||||
at the expense of possibly awkward tick steps (sponsored by Flight
|
||||
Data Services, www.flightdataservices.com).
|
||||
- Support for customizing the point type through a callback when
|
||||
plotting points and new symbol plugin with some predefined point
|
||||
types (sponsored by Utility Data Corporation).
|
||||
|
||||
- New hooks: drawSeries
|
||||
|
||||
Bug fixes:
|
||||
|
||||
- Fixed problem with findNearbyItem and bars on top of each other
|
||||
(reported by ragingchikn, issue 242).
|
||||
- Fixed problem with ticks and the border (based on patch from
|
||||
ultimatehustler69, issue 236).
|
||||
- Fixed problem with plugins adding options to the series objects.
|
||||
- Fixed a problem introduced in 0.6 with specifying a gradient with {
|
||||
brightness: x, opacity: y }.
|
||||
- Don't use $.browser.msie, check for getContext on the created canvas
|
||||
element instead and try to use excanvas if it's not found.
|
||||
- highlight(s, index) was looking up the point in the original s.data
|
||||
instead of in the computed datapoints array, which breaks with
|
||||
plugins that modify the datapoints (such as the stacking plugin).
|
||||
Issue 316 reported by curlypaul924.
|
||||
- More robust handling of axis from data passed in from getData()
|
||||
(problem reported by Morgan).
|
||||
- Fixed problem with turning off bar outline (issue 253, fix by Jordi
|
||||
Castells).
|
||||
- Check the selection passed into setSelection in the selection
|
||||
plugin, to guard against errors when synchronizing plots (fix by Lau
|
||||
Bech Lauritzen).
|
||||
- Fix bug in crosshair code with mouseout resetting the crosshair even
|
||||
if it is locked (fix by Lau Bech Lauritzen).
|
||||
- Fix bug with points plotting using line width from lines rather than
|
||||
points.
|
||||
|
||||
Flot 0.6
|
||||
--------
|
||||
|
||||
API changes:
|
||||
|
||||
1. Selection support has been moved to a plugin. Thus if you're
|
||||
passing selection: { mode: something }, you MUST include the file
|
||||
jquery.flot.selection.js after jquery.flot.js. This reduces the size
|
||||
of base Flot and makes it easier to customize the selection as well as
|
||||
improving code clarity. The change is based on a patch from andershol.
|
||||
|
||||
2. In the global options specified in the $.plot command,
|
||||
"lines", "points", "bars" and "shadowSize" have been moved to a
|
||||
sub-object called "series", i.e.
|
||||
|
||||
$.plot(placeholder, data, { lines: { show: true }})
|
||||
|
||||
should be changed to
|
||||
|
||||
$.plot(placeholder, data, { series: { lines: { show: true }}})
|
||||
|
||||
All future series-specific options will go into this sub-object to
|
||||
simplify plugin writing. Backward-compatibility code is in place, so
|
||||
old code should not break.
|
||||
|
||||
3. "plothover" no longer provides the original data point, but instead
|
||||
a normalized one, since there may be no corresponding original point.
|
||||
|
||||
4. Due to a bug in previous versions of jQuery, you now need at least
|
||||
jQuery 1.2.6. But if you can, try jQuery 1.3.2 as it got some
|
||||
improvements in event handling speed.
|
||||
|
||||
|
||||
Changes:
|
||||
|
||||
- Added support for disabling interactivity for specific data series
|
||||
(request from Ronald Schouten and Steve Upton).
|
||||
|
||||
- Flot now calls $() on the placeholder and optional legend container
|
||||
passed in so you can specify DOM elements or CSS expressions to make
|
||||
it easier to use Flot with libraries like Prototype or Mootools or
|
||||
through raw JSON from Ajax responses.
|
||||
|
||||
- A new "plotselecting" event is now emitted while the user is making
|
||||
a selection.
|
||||
|
||||
- The "plothover" event is now emitted immediately instead of at most
|
||||
10 times per second, you'll have to put in a setTimeout yourself if
|
||||
you're doing something really expensive on this event.
|
||||
|
||||
- The built-in date formatter can now be accessed as
|
||||
$.plot.formatDate(...) (suggestion by Matt Manela) and even
|
||||
replaced.
|
||||
|
||||
- Added "borderColor" option to the grid (patch from Amaury Chamayou
|
||||
and patch from Mike R. Williamson).
|
||||
|
||||
- Added support for gradient backgrounds for the grid, take a look at
|
||||
the "setting options" example (based on patch from Amaury Chamayou,
|
||||
issue 90).
|
||||
|
||||
- Gradient bars (suggestion by stefpet).
|
||||
|
||||
- Added a "plotunselected" event which is triggered when the selection
|
||||
is removed, see "selection" example (suggestion by Meda Ugo);
|
||||
|
||||
- The option legend.margin can now specify horizontal and vertical
|
||||
margins independently (suggestion by someone who's annoyed).
|
||||
|
||||
- Data passed into Flot is now copied to a new canonical format to
|
||||
enable further processing before it hits the drawing routines. As a
|
||||
side-effect, this should make Flot more robust in the face of bad
|
||||
data (and fixes issue 112).
|
||||
|
||||
- Step-wise charting: line charts have a new option "steps" that when
|
||||
set to true connects the points with horizontal/vertical steps
|
||||
instead of diagonal lines.
|
||||
|
||||
- The legend labelFormatter now passes the series in addition to just
|
||||
the label (suggestion by Vincent Lemeltier).
|
||||
|
||||
- Horizontal bars (based on patch by Jason LeBrun).
|
||||
|
||||
- Support for partial bars by specifying a third coordinate, i.e. they
|
||||
don't have to start from the axis. This can be used to make stacked
|
||||
bars.
|
||||
|
||||
- New option to disable the (grid.show).
|
||||
|
||||
- Added pointOffset method for converting a point in data space to an
|
||||
offset within the placeholder.
|
||||
|
||||
- Plugin system: register an init method in the $.flot.plugins array
|
||||
to get started, see PLUGINS.txt for details on how to write plugins
|
||||
(it's easy). There are also some extra methods to enable access to
|
||||
internal state.
|
||||
|
||||
- Hooks: you can register functions that are called while Flot is
|
||||
crunching the data and doing the plot. This can be used to modify
|
||||
Flot without changing the source, useful for writing plugins. Some
|
||||
hooks are defined, more are likely to come.
|
||||
|
||||
- Threshold plugin: you can set a threshold and a color, and the data
|
||||
points below that threshold will then get the color. Useful for
|
||||
marking data below 0, for instance.
|
||||
|
||||
- Stack plugin: you can specify a stack key for each series to have
|
||||
them summed. This is useful for drawing additive/cumulative graphs
|
||||
with bars and (currently unfilled) lines.
|
||||
|
||||
- Crosshairs plugin: trace the mouse position on the axes, enable with
|
||||
crosshair: { mode: "x"} (see the new tracking example for a use).
|
||||
|
||||
- Image plugin: plot prerendered images.
|
||||
|
||||
- Navigation plugin for panning and zooming a plot.
|
||||
|
||||
- More configurable grid.
|
||||
|
||||
- Axis transformation support, useful for non-linear plots, e.g. log
|
||||
axes and compressed time axes (like omitting weekends).
|
||||
|
||||
- Support for twelve-hour date formatting (patch by Forrest Aldridge).
|
||||
|
||||
- The color parsing code in Flot has been cleaned up and split out so
|
||||
it's now available as a separate jQuery plugin. It's included inline
|
||||
in the Flot source to make dependency managing easier. This also
|
||||
makes it really easy to use the color helpers in Flot plugins.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
- Fixed two corner-case bugs when drawing filled curves (report and
|
||||
analysis by Joshua Varner).
|
||||
- Fix auto-adjustment code when setting min to 0 for an axis where the
|
||||
dataset is completely flat on that axis (report by chovy).
|
||||
- Fixed a bug with passing in data from getData to setData when the
|
||||
secondary axes are used (issue 65, reported by nperelman).
|
||||
- Fixed so that it is possible to turn lines off when no other chart
|
||||
type is shown (based on problem reported by Glenn Vanderburg), and
|
||||
fixed so that setting lineWidth to 0 also hides the shadow (based on
|
||||
problem reported by Sergio Nunes).
|
||||
- Updated mousemove position expression to the latest from jQuery (bug
|
||||
reported by meyuchas).
|
||||
- Use CSS borders instead of background in legend (fix printing issue 25
|
||||
and 45).
|
||||
- Explicitly convert axis min/max to numbers.
|
||||
- Fixed a bug with drawing marking lines with different colors
|
||||
(reported by Khurram).
|
||||
- Fixed a bug with returning y2 values in the selection event (fix
|
||||
by exists, issue 75).
|
||||
- Only set position relative on placeholder if it hasn't already a
|
||||
position different from static (reported by kyberneticist, issue 95).
|
||||
- Don't round markings to prevent sub-pixel problems (reported by Dan
|
||||
Lipsitt).
|
||||
- Make the grid border act similarly to a regular CSS border, i.e.
|
||||
prevent it from overlapping the plot itself. This also fixes a
|
||||
problem with anti-aliasing when the width is 1 pixel (reported by
|
||||
Anthony Ettinger).
|
||||
- Imported version 3 of excanvas and fixed two issues with the newer
|
||||
version. Hopefully, this will make Flot work with IE8 (nudge by
|
||||
Fabien Menager, further analysis by Booink, issue 133).
|
||||
- Changed the shadow code for lines to hopefully look a bit better
|
||||
with vertical lines.
|
||||
- Round tick positions to avoid possible problems with fractions
|
||||
(suggestion by Fred, issue 130).
|
||||
- Made the heuristic for determining how many ticks to aim for a bit
|
||||
smarter.
|
||||
- Fix for uneven axis margins (report and patch by Paul Kienzle) and
|
||||
snapping to ticks (concurrent report and patch by lifthrasiir).
|
||||
- Fixed bug with slicing in findNearbyItems (patch by zollman).
|
||||
- Make heuristic for x axis label widths more dynamic (patch by
|
||||
rickinhethuis).
|
||||
- Make sure points on top take precedence when finding nearby points
|
||||
when hovering (reported by didroe, issue 224).
|
||||
|
||||
Flot 0.5
|
||||
--------
|
||||
|
||||
Backwards API change summary: Timestamps are now in UTC. Also
|
||||
"selected" event -> becomes "plotselected" with new data, the
|
||||
parameters for setSelection are now different (but backwards
|
||||
compatibility hooks are in place), coloredAreas becomes markings with
|
||||
a new interface (but backwards compatibility hooks are in place).
|
||||
|
||||
|
||||
Interactivity: added a new "plothover" event and this and the
|
||||
"plotclick" event now returns the closest data item (based on patch by
|
||||
/david, patch by Mark Byers for bar support). See the revamped
|
||||
"interacting with the data" example for some hints on what you can do.
|
||||
|
||||
Highlighting: you can now highlight points and datapoints are
|
||||
autohighlighted when you hover over them (if hovering is turned on).
|
||||
|
||||
Support for dual axis has been added (based on patch by someone who's
|
||||
annoyed and /david). For each data series you can specify which axes
|
||||
it belongs to, and there are two more axes, x2axis and y2axis, to
|
||||
customize. This affects the "selected" event which has been renamed to
|
||||
"plotselected" and spews out { xaxis: { from: -10, to: 20 } ... },
|
||||
setSelection in which the parameters are on a new form (backwards
|
||||
compatible hooks are in place so old code shouldn't break) and
|
||||
markings (formerly coloredAreas).
|
||||
|
||||
Timestamps in time mode are now displayed according to
|
||||
UTC instead of the time zone of the visitor. This affects the way the
|
||||
timestamps should be input; you'll probably have to offset the
|
||||
timestamps according to your local time zone. It also affects any
|
||||
custom date handling code (which basically now should use the
|
||||
equivalent UTC date mehods, e.g. .setUTCMonth() instead of
|
||||
.setMonth().
|
||||
|
||||
Added support for specifying the size of tick labels (axis.labelWidth,
|
||||
axis.labelHeight). Useful for specifying a max label size to keep
|
||||
multiple plots aligned.
|
||||
|
||||
Markings, previously coloredAreas, are now specified as ranges on the
|
||||
axes, like { xaxis: { from: 0, to: 10 }}. Furthermore with markings
|
||||
you can now draw horizontal/vertical lines by setting from and to to
|
||||
the same coordinate (idea from line support patch by by Ryan Funduk).
|
||||
|
||||
The "fill" option can now be a number that specifies the opacity of
|
||||
the fill.
|
||||
|
||||
You can now specify a coordinate as null (like [2, null]) and Flot
|
||||
will take the other coordinate into account when scaling the axes
|
||||
(based on patch by joebno).
|
||||
|
||||
New option for bars "align". Set it to "center" to center the bars on
|
||||
the value they represent.
|
||||
|
||||
setSelection now takes a second parameter which you can use to prevent
|
||||
the method from firing the "plotselected" handler.
|
||||
|
||||
Using the "container" option in legend now overwrites the container
|
||||
element instead of just appending to it (fixes infinite legend bug,
|
||||
reported by several people, fix by Brad Dewey).
|
||||
|
||||
Fixed a bug in calculating spacing around the plot (reported by
|
||||
timothytoe). Fixed a bug in finding max values for all-negative data
|
||||
sets. Prevent the possibility of eternal looping in tick calculations.
|
||||
Fixed a bug when borderWidth is set to 0 (reported by
|
||||
Rob/sanchothefat). Fixed a bug with drawing bars extending below 0
|
||||
(reported by James Hewitt, patch by Ryan Funduk). Fixed a
|
||||
bug with line widths of bars (reported by MikeM). Fixed a bug with
|
||||
'nw' and 'sw' legend positions. Improved the handling of axis
|
||||
auto-scaling with bars. Fixed a bug with multi-line x-axis tick
|
||||
labels (reported by Luca Ciano). IE-fix help by Savage Zhang.
|
||||
|
||||
|
||||
Flot 0.4
|
||||
--------
|
||||
|
||||
API changes: deprecated axis.noTicks in favor of just specifying the
|
||||
number as axis.ticks. So "xaxis: { noTicks: 10 }" becomes
|
||||
"xaxis: { ticks: 10 }"
|
||||
|
||||
Time series support. Specify axis.mode: "time", put in Javascript
|
||||
timestamps as data, and Flot will automatically spit out sensible
|
||||
ticks. Take a look at the two new examples. The format can be
|
||||
customized with axis.timeformat and axis.monthNames, or if that fails
|
||||
with axis.tickFormatter.
|
||||
|
||||
Support for colored background areas via grid.coloredAreas. Specify an
|
||||
array of { x1, y1, x2, y2 } objects or a function that returns these
|
||||
given { xmin, xmax, ymin, ymax }.
|
||||
|
||||
More members on the plot object (report by Chris Davies and others).
|
||||
"getData" for inspecting the assigned settings on data series (e.g.
|
||||
color) and "setData", "setupGrid" and "draw" for updating the contents
|
||||
without a total replot.
|
||||
|
||||
The default number of ticks to aim for is now dependent on the size of
|
||||
the plot in pixels. Support for customizing tick interval sizes
|
||||
directly with axis.minTickSize and axis.tickSize.
|
||||
|
||||
Cleaned up the automatic axis scaling algorithm and fixed how it
|
||||
interacts with ticks. Also fixed a couple of tick-related corner case
|
||||
bugs (one reported by mainstreetmark, another reported by timothytoe).
|
||||
|
||||
The option axis.tickFormatter now takes a function with two
|
||||
parameters, the second parameter is an optional object with
|
||||
information about the axis. It has min, max, tickDecimals, tickSize.
|
||||
|
||||
Added support for segmented lines (based on patch from Michael
|
||||
MacDonald) and for ignoring null and bad values (suggestion from Nick
|
||||
Konidaris and joshwaihi).
|
||||
|
||||
Added support for changing the border width (joebno and safoo).
|
||||
Label colors can be changed via CSS by selecting the tickLabel class.
|
||||
|
||||
Fixed a bug in handling single-item bar series (reported by Emil
|
||||
Filipov). Fixed erratic behaviour when interacting with the plot
|
||||
with IE 7 (reported by Lau Bech Lauritzen). Prevent IE/Safari text
|
||||
selection when selecting stuff on the canvas.
|
||||
|
||||
|
||||
|
||||
Flot 0.3
|
||||
--------
|
||||
|
||||
This is mostly a quick-fix release because jquery.js wasn't included
|
||||
in the previous zip/tarball.
|
||||
|
||||
Support clicking on the plot. Turn it on with grid: { clickable: true },
|
||||
then you get a "plotclick" event on the graph placeholder with the
|
||||
position in units of the plot.
|
||||
|
||||
Fixed a bug in dealing with data where min = max, thanks to Michael
|
||||
Messinides.
|
||||
|
||||
Include jquery.js in the zip/tarball.
|
||||
|
||||
|
||||
Flot 0.2
|
||||
--------
|
||||
|
||||
Added support for putting a background behind the default legend. The
|
||||
default is the partly transparent background color. Added
|
||||
backgroundColor and backgroundOpacity to the legend options to control
|
||||
this.
|
||||
|
||||
The ticks options can now be a callback function that takes one
|
||||
parameter, an object with the attributes min and max. The function
|
||||
should return a ticks array.
|
||||
|
||||
Added labelFormatter option in legend, useful for turning the legend
|
||||
labels into links.
|
||||
|
||||
Fixed a couple of bugs.
|
||||
|
||||
The API should now be fully documented.
|
||||
|
||||
Patch from Guy Fraser to make parts of the code smaller.
|
||||
|
||||
API changes: Moved labelMargin option to grid from x/yaxis.
|
||||
|
||||
|
||||
Flot 0.1
|
||||
--------
|
||||
|
||||
First public release.
|
|
@ -1,105 +0,0 @@
|
|||
Writing plugins
|
||||
---------------
|
||||
|
||||
To make a new plugin, create an init function and a set of options (if
|
||||
needed), stuff it into an object and put it in the $.plot.plugins
|
||||
array. For example:
|
||||
|
||||
function myCoolPluginInit(plot) { plot.coolstring = "Hello!" };
|
||||
var myCoolOptions = { coolstuff: { show: true } }
|
||||
$.plot.plugins.push({ init: myCoolPluginInit, options: myCoolOptions });
|
||||
|
||||
// now when $.plot is called, the returned object will have the
|
||||
// attribute "coolstring"
|
||||
|
||||
Now, given that the plugin might run in many different places, it's
|
||||
a good idea to avoid leaking names. We can avoid this by wrapping the
|
||||
above lines in an anonymous function which we call immediately, like
|
||||
this: (function () { inner code ... })(). To make it even more robust
|
||||
in case $ is not bound to jQuery but some other Javascript library, we
|
||||
can write it as
|
||||
|
||||
(function ($) {
|
||||
// plugin definition
|
||||
// ...
|
||||
})(jQuery);
|
||||
|
||||
Here is a simple debug plugin which alerts each of the series in the
|
||||
plot. It has a single option that control whether it is enabled and
|
||||
how much info to output:
|
||||
|
||||
(function ($) {
|
||||
function init(plot) {
|
||||
var debugLevel = 1;
|
||||
|
||||
function checkDebugEnabled(plot, options) {
|
||||
if (options.debug) {
|
||||
debugLevel = options.debug;
|
||||
|
||||
plot.hooks.processDatapoints.push(alertSeries);
|
||||
}
|
||||
}
|
||||
|
||||
function alertSeries(plot, series, datapoints) {
|
||||
var msg = "series " + series.label;
|
||||
if (debugLevel > 1)
|
||||
msg += " with " + series.data.length + " points";
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
plot.hooks.processOptions.push(checkDebugEnabled);
|
||||
}
|
||||
|
||||
var options = { debug: 0 };
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: "simpledebug",
|
||||
version: "0.1"
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
We also define "name" and "version". It's not used by Flot, but might
|
||||
be helpful for other plugins in resolving dependencies.
|
||||
|
||||
Put the above in a file named "jquery.flot.debug.js", include it in an
|
||||
HTML page and then it can be used with:
|
||||
|
||||
$.plot($("#placeholder"), [...], { debug: 2 });
|
||||
|
||||
This simple plugin illustrates a couple of points:
|
||||
|
||||
- It uses the anonymous function trick to avoid name pollution.
|
||||
- It can be enabled/disabled through an option.
|
||||
- Variables in the init function can be used to store plot-specific
|
||||
state between the hooks.
|
||||
|
||||
|
||||
Options guidelines
|
||||
==================
|
||||
|
||||
Plugins should always support appropriate options to enable/disable
|
||||
them because the plugin user may have several plots on the same page
|
||||
where only one should use the plugin.
|
||||
|
||||
If the plugin needs series-specific options, you can put them in
|
||||
"series" in the options object, e.g.
|
||||
|
||||
var options = {
|
||||
series: {
|
||||
downsample: {
|
||||
algorithm: null,
|
||||
maxpoints: 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Then they will be copied by Flot into each series, providing the
|
||||
defaults in case the plugin user doesn't specify any. Again, in most
|
||||
cases it's probably a good idea if the plugin is turned off rather
|
||||
than on per default, just like most of the powerful features in Flot.
|
||||
|
||||
Think hard and long about naming the options. These names are going to
|
||||
be public API, and code is going to depend on them if the plugin is
|
||||
successful.
|
|
@ -1,81 +0,0 @@
|
|||
About
|
||||
-----
|
||||
|
||||
Flot is a Javascript plotting library for jQuery. Read more at the
|
||||
website:
|
||||
|
||||
http://code.google.com/p/flot/
|
||||
|
||||
Take a look at the examples linked from above, they should give a good
|
||||
impression of what Flot can do and the source code of the examples is
|
||||
probably the fastest way to learn how to use Flot.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Just include the Javascript file after you've included jQuery.
|
||||
|
||||
Note that you need to get a version of Excanvas (e.g. the one bundled
|
||||
with Flot) which is canvas emulation on Internet Explorer. You can
|
||||
include the excanvas script like this:
|
||||
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="excanvas.pack.js"></script><![endif]-->
|
||||
|
||||
If it's not working on your development IE 6.0, check that it has
|
||||
support for VML which excanvas is relying on. It appears that some
|
||||
stripped down versions used for test environments on virtual machines
|
||||
lack the VML support.
|
||||
|
||||
Also note that you need at least jQuery 1.2.6 (but at least jQuery
|
||||
1.3.2 is recommended for interactive charts because of performance
|
||||
improvements in event handling).
|
||||
|
||||
|
||||
Basic usage
|
||||
-----------
|
||||
|
||||
Create a placeholder div to put the graph in:
|
||||
|
||||
<div id="placeholder"></div>
|
||||
|
||||
You need to set the width and height of this div, otherwise the plot
|
||||
library doesn't know how to scale the graph. You can do it inline like
|
||||
this:
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
You can also do it with an external stylesheet. Make sure that the
|
||||
placeholder isn't within something with a display:none CSS property -
|
||||
in that case, Flot has trouble measuring label dimensions which
|
||||
results in garbled looks and might have trouble measuring the
|
||||
placeholder dimensions which is fatal (it'll throw an exception).
|
||||
|
||||
Then when the div is ready in the DOM, which is usually on document
|
||||
ready, run the plot function:
|
||||
|
||||
$.plot($("#placeholder"), data, options);
|
||||
|
||||
Here, data is an array of data series and options is an object with
|
||||
settings if you want to customize the plot. Take a look at the
|
||||
examples for some ideas of what to put in or look at the reference
|
||||
in the file "API.txt". Here's a quick example that'll draw a line from
|
||||
(0, 0) to (1, 1):
|
||||
|
||||
$.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } });
|
||||
|
||||
The plot function immediately draws the chart and then returns a plot
|
||||
object with a couple of methods.
|
||||
|
||||
|
||||
What's with the name?
|
||||
---------------------
|
||||
|
||||
First: it's pronounced with a short o, like "plot". Not like "flawed".
|
||||
|
||||
So "Flot" rhymes with "plot".
|
||||
|
||||
And if you look up "flot" in a Danish-to-English dictionary, some up
|
||||
the words that come up are "good-looking", "attractive", "stylish",
|
||||
"smart", "impressive", "extravagant". One of the main goals with Flot
|
||||
is pretty looks.
|
|
@ -1,174 +0,0 @@
|
|||
/* Plugin for jQuery for working with colors.
|
||||
*
|
||||
* Version 1.0.
|
||||
*
|
||||
* Inspiration from jQuery color animation plugin by John Resig.
|
||||
*
|
||||
* Released under the MIT license by Ole Laursen, October 2009.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
|
||||
* var c = $.color.extract($("#mydiv"), 'background-color');
|
||||
* console.log(c.r, c.g, c.b, c.a);
|
||||
* $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
|
||||
*
|
||||
* Note that .scale() and .add() work in-place instead of returning
|
||||
* new objects.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
jQuery.color = {};
|
||||
|
||||
// construct color object with some convenient chainable helpers
|
||||
jQuery.color.make = function (r, g, b, a) {
|
||||
var o = {};
|
||||
o.r = r || 0;
|
||||
o.g = g || 0;
|
||||
o.b = b || 0;
|
||||
o.a = a != null ? a : 1;
|
||||
|
||||
o.add = function (c, d) {
|
||||
for (var i = 0; i < c.length; ++i)
|
||||
o[c.charAt(i)] += d;
|
||||
return o.normalize();
|
||||
};
|
||||
|
||||
o.scale = function (c, f) {
|
||||
for (var i = 0; i < c.length; ++i)
|
||||
o[c.charAt(i)] *= f;
|
||||
return o.normalize();
|
||||
};
|
||||
|
||||
o.toString = function () {
|
||||
if (o.a >= 1.0) {
|
||||
return "rgb("+[o.r, o.g, o.b].join(",")+")";
|
||||
} else {
|
||||
return "rgba("+[o.r, o.g, o.b, o.a].join(",")+")";
|
||||
}
|
||||
};
|
||||
|
||||
o.normalize = function () {
|
||||
function clamp(min, value, max) {
|
||||
return value < min ? min: (value > max ? max: value);
|
||||
}
|
||||
|
||||
o.r = clamp(0, parseInt(o.r), 255);
|
||||
o.g = clamp(0, parseInt(o.g), 255);
|
||||
o.b = clamp(0, parseInt(o.b), 255);
|
||||
o.a = clamp(0, o.a, 1);
|
||||
return o;
|
||||
};
|
||||
|
||||
o.clone = function () {
|
||||
return jQuery.color.make(o.r, o.b, o.g, o.a);
|
||||
};
|
||||
|
||||
return o.normalize();
|
||||
}
|
||||
|
||||
// extract CSS color property from element, going up in the DOM
|
||||
// if it's "transparent"
|
||||
jQuery.color.extract = function (elem, css) {
|
||||
var c;
|
||||
do {
|
||||
c = elem.css(css).toLowerCase();
|
||||
// keep going until we find an element that has color, or
|
||||
// we hit the body
|
||||
if (c != '' && c != 'transparent')
|
||||
break;
|
||||
elem = elem.parent();
|
||||
} while (!jQuery.nodeName(elem.get(0), "body"));
|
||||
|
||||
// catch Safari's way of signalling transparent
|
||||
if (c == "rgba(0, 0, 0, 0)")
|
||||
c = "transparent";
|
||||
|
||||
return jQuery.color.parse(c);
|
||||
}
|
||||
|
||||
// parse CSS color string (like "rgb(10, 32, 43)" or "#fff"),
|
||||
// returns color object
|
||||
jQuery.color.parse = function (str) {
|
||||
var res, m = jQuery.color.make;
|
||||
|
||||
// Look for rgb(num,num,num)
|
||||
if (res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))
|
||||
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10));
|
||||
|
||||
// Look for rgba(num,num,num,num)
|
||||
if (res = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
|
||||
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4]));
|
||||
|
||||
// Look for rgb(num%,num%,num%)
|
||||
if (res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))
|
||||
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55);
|
||||
|
||||
// Look for rgba(num%,num%,num%,num)
|
||||
if (res = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
|
||||
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55, parseFloat(res[4]));
|
||||
|
||||
// Look for #a0b1c2
|
||||
if (res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))
|
||||
return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16));
|
||||
|
||||
// Look for #fff
|
||||
if (res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))
|
||||
return m(parseInt(res[1]+res[1], 16), parseInt(res[2]+res[2], 16), parseInt(res[3]+res[3], 16));
|
||||
|
||||
// Otherwise, we're most likely dealing with a named color
|
||||
var name = jQuery.trim(str).toLowerCase();
|
||||
if (name == "transparent")
|
||||
return m(255, 255, 255, 0);
|
||||
else {
|
||||
res = lookupColors[name];
|
||||
return m(res[0], res[1], res[2]);
|
||||
}
|
||||
}
|
||||
|
||||
var lookupColors = {
|
||||
aqua:[0,255,255],
|
||||
azure:[240,255,255],
|
||||
beige:[245,245,220],
|
||||
black:[0,0,0],
|
||||
blue:[0,0,255],
|
||||
brown:[165,42,42],
|
||||
cyan:[0,255,255],
|
||||
darkblue:[0,0,139],
|
||||
darkcyan:[0,139,139],
|
||||
darkgrey:[169,169,169],
|
||||
darkgreen:[0,100,0],
|
||||
darkkhaki:[189,183,107],
|
||||
darkmagenta:[139,0,139],
|
||||
darkolivegreen:[85,107,47],
|
||||
darkorange:[255,140,0],
|
||||
darkorchid:[153,50,204],
|
||||
darkred:[139,0,0],
|
||||
darksalmon:[233,150,122],
|
||||
darkviolet:[148,0,211],
|
||||
fuchsia:[255,0,255],
|
||||
gold:[255,215,0],
|
||||
green:[0,128,0],
|
||||
indigo:[75,0,130],
|
||||
khaki:[240,230,140],
|
||||
lightblue:[173,216,230],
|
||||
lightcyan:[224,255,255],
|
||||
lightgreen:[144,238,144],
|
||||
lightgrey:[211,211,211],
|
||||
lightpink:[255,182,193],
|
||||
lightyellow:[255,255,224],
|
||||
lime:[0,255,0],
|
||||
magenta:[255,0,255],
|
||||
maroon:[128,0,0],
|
||||
navy:[0,0,128],
|
||||
olive:[128,128,0],
|
||||
orange:[255,165,0],
|
||||
pink:[255,192,203],
|
||||
purple:[128,0,128],
|
||||
violet:[128,0,128],
|
||||
red:[255,0,0],
|
||||
silver:[192,192,192],
|
||||
white:[255,255,255],
|
||||
yellow:[255,255,0]
|
||||
};
|
||||
})();
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
Flot plugin for showing crosshairs, thin lines, when the mouse hovers
|
||||
over the plot.
|
||||
|
||||
crosshair: {
|
||||
mode: null or "x" or "y" or "xy"
|
||||
color: color
|
||||
lineWidth: number
|
||||
}
|
||||
|
||||
Set the mode to one of "x", "y" or "xy". The "x" mode enables a
|
||||
vertical crosshair that lets you trace the values on the x axis, "y"
|
||||
enables a horizontal crosshair and "xy" enables them both. "color" is
|
||||
the color of the crosshair (default is "rgba(170, 0, 0, 0.80)"),
|
||||
"lineWidth" is the width of the drawn lines (default is 1).
|
||||
|
||||
The plugin also adds four public methods:
|
||||
|
||||
- setCrosshair(pos)
|
||||
|
||||
Set the position of the crosshair. Note that this is cleared if
|
||||
the user moves the mouse. "pos" is in coordinates of the plot and
|
||||
should be on the form { x: xpos, y: ypos } (you can use x2/x3/...
|
||||
if you're using multiple axes), which is coincidentally the same
|
||||
format as what you get from a "plothover" event. If "pos" is null,
|
||||
the crosshair is cleared.
|
||||
|
||||
- clearCrosshair()
|
||||
|
||||
Clear the crosshair.
|
||||
|
||||
- lockCrosshair(pos)
|
||||
|
||||
Cause the crosshair to lock to the current location, no longer
|
||||
updating if the user moves the mouse. Optionally supply a position
|
||||
(passed on to setCrosshair()) to move it to.
|
||||
|
||||
Example usage:
|
||||
var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
|
||||
$("#graph").bind("plothover", function (evt, position, item) {
|
||||
if (item) {
|
||||
// Lock the crosshair to the data point being hovered
|
||||
myFlot.lockCrosshair({ x: item.datapoint[0], y: item.datapoint[1] });
|
||||
}
|
||||
else {
|
||||
// Return normal crosshair operation
|
||||
myFlot.unlockCrosshair();
|
||||
}
|
||||
});
|
||||
|
||||
- unlockCrosshair()
|
||||
|
||||
Free the crosshair to move again after locking it.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
var options = {
|
||||
crosshair: {
|
||||
mode: null, // one of null, "x", "y" or "xy",
|
||||
color: "rgba(170, 0, 0, 0.80)",
|
||||
lineWidth: 1
|
||||
}
|
||||
};
|
||||
|
||||
function init(plot) {
|
||||
// position of crosshair in pixels
|
||||
var crosshair = { x: -1, y: -1, locked: false };
|
||||
|
||||
plot.setCrosshair = function setCrosshair(pos) {
|
||||
if (!pos)
|
||||
crosshair.x = -1;
|
||||
else {
|
||||
var o = plot.p2c(pos);
|
||||
crosshair.x = Math.max(0, Math.min(o.left, plot.width()));
|
||||
crosshair.y = Math.max(0, Math.min(o.top, plot.height()));
|
||||
}
|
||||
|
||||
plot.triggerRedrawOverlay();
|
||||
};
|
||||
|
||||
plot.clearCrosshair = plot.setCrosshair; // passes null for pos
|
||||
|
||||
plot.lockCrosshair = function lockCrosshair(pos) {
|
||||
if (pos)
|
||||
plot.setCrosshair(pos);
|
||||
crosshair.locked = true;
|
||||
}
|
||||
|
||||
plot.unlockCrosshair = function unlockCrosshair() {
|
||||
crosshair.locked = false;
|
||||
}
|
||||
|
||||
plot.hooks.bindEvents.push(function (plot, eventHolder) {
|
||||
if (!plot.getOptions().crosshair.mode)
|
||||
return;
|
||||
|
||||
eventHolder.mouseout(function () {
|
||||
if (crosshair.locked)
|
||||
return;
|
||||
|
||||
if (crosshair.x != -1) {
|
||||
crosshair.x = -1;
|
||||
plot.triggerRedrawOverlay();
|
||||
}
|
||||
});
|
||||
|
||||
eventHolder.mousemove(function (e) {
|
||||
if (crosshair.locked)
|
||||
return;
|
||||
|
||||
if (plot.getSelection && plot.getSelection()) {
|
||||
crosshair.x = -1; // hide the crosshair while selecting
|
||||
return;
|
||||
}
|
||||
|
||||
var offset = plot.offset();
|
||||
crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
|
||||
crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
|
||||
plot.triggerRedrawOverlay();
|
||||
});
|
||||
});
|
||||
|
||||
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
||||
var c = plot.getOptions().crosshair;
|
||||
if (!c.mode)
|
||||
return;
|
||||
|
||||
var plotOffset = plot.getPlotOffset();
|
||||
|
||||
ctx.save();
|
||||
ctx.translate(plotOffset.left, plotOffset.top);
|
||||
|
||||
if (crosshair.x != -1) {
|
||||
ctx.strokeStyle = c.color;
|
||||
ctx.lineWidth = c.lineWidth;
|
||||
ctx.lineJoin = "round";
|
||||
|
||||
ctx.beginPath();
|
||||
if (c.mode.indexOf("x") != -1) {
|
||||
ctx.moveTo(crosshair.x, 0);
|
||||
ctx.lineTo(crosshair.x, plot.height());
|
||||
}
|
||||
if (c.mode.indexOf("y") != -1) {
|
||||
ctx.moveTo(0, crosshair.y);
|
||||
ctx.lineTo(plot.width(), crosshair.y);
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.restore();
|
||||
});
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'crosshair',
|
||||
version: '1.0'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
Flot plugin for computing bottoms for filled line and bar charts.
|
||||
|
||||
The case: you've got two series that you want to fill the area
|
||||
between. In Flot terms, you need to use one as the fill bottom of the
|
||||
other. You can specify the bottom of each data point as the third
|
||||
coordinate manually, or you can use this plugin to compute it for you.
|
||||
|
||||
In order to name the other series, you need to give it an id, like this
|
||||
|
||||
var dataset = [
|
||||
{ data: [ ... ], id: "foo" } , // use default bottom
|
||||
{ data: [ ... ], fillBetween: "foo" }, // use first dataset as bottom
|
||||
];
|
||||
|
||||
$.plot($("#placeholder"), dataset, { line: { show: true, fill: true }});
|
||||
|
||||
As a convenience, if the id given is a number that doesn't appear as
|
||||
an id in the series, it is interpreted as the index in the array
|
||||
instead (so fillBetween: 0 can also mean the first series).
|
||||
|
||||
Internally, the plugin modifies the datapoints in each series. For
|
||||
line series, extra data points might be inserted through
|
||||
interpolation. Note that at points where the bottom line is not
|
||||
defined (due to a null point or start/end of line), the current line
|
||||
will show a gap too. The algorithm comes from the jquery.flot.stack.js
|
||||
plugin, possibly some code could be shared.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
var options = {
|
||||
series: { fillBetween: null } // or number
|
||||
};
|
||||
|
||||
function init(plot) {
|
||||
function findBottomSeries(s, allseries) {
|
||||
var i;
|
||||
for (i = 0; i < allseries.length; ++i) {
|
||||
if (allseries[i].id == s.fillBetween)
|
||||
return allseries[i];
|
||||
}
|
||||
|
||||
if (typeof s.fillBetween == "number") {
|
||||
i = s.fillBetween;
|
||||
|
||||
if (i < 0 || i >= allseries.length)
|
||||
return null;
|
||||
|
||||
return allseries[i];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function computeFillBottoms(plot, s, datapoints) {
|
||||
if (s.fillBetween == null)
|
||||
return;
|
||||
|
||||
var other = findBottomSeries(s, plot.getData());
|
||||
if (!other)
|
||||
return;
|
||||
|
||||
var ps = datapoints.pointsize,
|
||||
points = datapoints.points,
|
||||
otherps = other.datapoints.pointsize,
|
||||
otherpoints = other.datapoints.points,
|
||||
newpoints = [],
|
||||
px, py, intery, qx, qy, bottom,
|
||||
withlines = s.lines.show,
|
||||
withbottom = ps > 2 && datapoints.format[2].y,
|
||||
withsteps = withlines && s.lines.steps,
|
||||
fromgap = true,
|
||||
i = 0, j = 0, l;
|
||||
|
||||
while (true) {
|
||||
if (i >= points.length)
|
||||
break;
|
||||
|
||||
l = newpoints.length;
|
||||
|
||||
if (points[i] == null) {
|
||||
// copy gaps
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
i += ps;
|
||||
}
|
||||
else if (j >= otherpoints.length) {
|
||||
// for lines, we can't use the rest of the points
|
||||
if (!withlines) {
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
}
|
||||
i += ps;
|
||||
}
|
||||
else if (otherpoints[j] == null) {
|
||||
// oops, got a gap
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(null);
|
||||
fromgap = true;
|
||||
j += otherps;
|
||||
}
|
||||
else {
|
||||
// cases where we actually got two points
|
||||
px = points[i];
|
||||
py = points[i + 1];
|
||||
qx = otherpoints[j];
|
||||
qy = otherpoints[j + 1];
|
||||
bottom = 0;
|
||||
|
||||
if (px == qx) {
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
|
||||
//newpoints[l + 1] += qy;
|
||||
bottom = qy;
|
||||
|
||||
i += ps;
|
||||
j += otherps;
|
||||
}
|
||||
else if (px > qx) {
|
||||
// we got past point below, might need to
|
||||
// insert interpolated extra point
|
||||
if (withlines && i > 0 && points[i - ps] != null) {
|
||||
intery = py + (points[i - ps + 1] - py) * (qx - px) / (points[i - ps] - px);
|
||||
newpoints.push(qx);
|
||||
newpoints.push(intery)
|
||||
for (m = 2; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
bottom = qy;
|
||||
}
|
||||
|
||||
j += otherps;
|
||||
}
|
||||
else { // px < qx
|
||||
if (fromgap && withlines) {
|
||||
// if we come from a gap, we just skip this point
|
||||
i += ps;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
|
||||
// we might be able to interpolate a point below,
|
||||
// this can give us a better y
|
||||
if (withlines && j > 0 && otherpoints[j - otherps] != null)
|
||||
bottom = qy + (otherpoints[j - otherps + 1] - qy) * (px - qx) / (otherpoints[j - otherps] - qx);
|
||||
|
||||
//newpoints[l + 1] += bottom;
|
||||
|
||||
i += ps;
|
||||
}
|
||||
|
||||
fromgap = false;
|
||||
|
||||
if (l != newpoints.length && withbottom)
|
||||
newpoints[l + 2] = bottom;
|
||||
}
|
||||
|
||||
// maintain the line steps invariant
|
||||
if (withsteps && l != newpoints.length && l > 0
|
||||
&& newpoints[l] != null
|
||||
&& newpoints[l] != newpoints[l - ps]
|
||||
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints[l + ps + m] = newpoints[l + m];
|
||||
newpoints[l + 1] = newpoints[l - ps + 1];
|
||||
}
|
||||
}
|
||||
|
||||
datapoints.points = newpoints;
|
||||
}
|
||||
|
||||
plot.hooks.processDatapoints.push(computeFillBottoms);
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'fillbetween',
|
||||
version: '1.0'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,238 +0,0 @@
|
|||
/*
|
||||
Flot plugin for plotting images, e.g. useful for putting ticks on a
|
||||
prerendered complex visualization.
|
||||
|
||||
The data syntax is [[image, x1, y1, x2, y2], ...] where (x1, y1) and
|
||||
(x2, y2) are where you intend the two opposite corners of the image to
|
||||
end up in the plot. Image must be a fully loaded Javascript image (you
|
||||
can make one with new Image()). If the image is not complete, it's
|
||||
skipped when plotting.
|
||||
|
||||
There are two helpers included for retrieving images. The easiest work
|
||||
the way that you put in URLs instead of images in the data (like
|
||||
["myimage.png", 0, 0, 10, 10]), then call $.plot.image.loadData(data,
|
||||
options, callback) where data and options are the same as you pass in
|
||||
to $.plot. This loads the images, replaces the URLs in the data with
|
||||
the corresponding images and calls "callback" when all images are
|
||||
loaded (or failed loading). In the callback, you can then call $.plot
|
||||
with the data set. See the included example.
|
||||
|
||||
A more low-level helper, $.plot.image.load(urls, callback) is also
|
||||
included. Given a list of URLs, it calls callback with an object
|
||||
mapping from URL to Image object when all images are loaded or have
|
||||
failed loading.
|
||||
|
||||
Options for the plugin are
|
||||
|
||||
series: {
|
||||
images: {
|
||||
show: boolean
|
||||
anchor: "corner" or "center"
|
||||
alpha: [0,1]
|
||||
}
|
||||
}
|
||||
|
||||
which can be specified for a specific series
|
||||
|
||||
$.plot($("#placeholder"), [{ data: [ ... ], images: { ... } ])
|
||||
|
||||
Note that because the data format is different from usual data points,
|
||||
you can't use images with anything else in a specific data series.
|
||||
|
||||
Setting "anchor" to "center" causes the pixels in the image to be
|
||||
anchored at the corner pixel centers inside of at the pixel corners,
|
||||
effectively letting half a pixel stick out to each side in the plot.
|
||||
|
||||
|
||||
A possible future direction could be support for tiling for large
|
||||
images (like Google Maps).
|
||||
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
var options = {
|
||||
series: {
|
||||
images: {
|
||||
show: false,
|
||||
alpha: 1,
|
||||
anchor: "corner" // or "center"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.plot.image = {};
|
||||
|
||||
$.plot.image.loadDataImages = function (series, options, callback) {
|
||||
var urls = [], points = [];
|
||||
|
||||
var defaultShow = options.series.images.show;
|
||||
|
||||
$.each(series, function (i, s) {
|
||||
if (!(defaultShow || s.images.show))
|
||||
return;
|
||||
|
||||
if (s.data)
|
||||
s = s.data;
|
||||
|
||||
$.each(s, function (i, p) {
|
||||
if (typeof p[0] == "string") {
|
||||
urls.push(p[0]);
|
||||
points.push(p);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$.plot.image.load(urls, function (loadedImages) {
|
||||
$.each(points, function (i, p) {
|
||||
var url = p[0];
|
||||
if (loadedImages[url])
|
||||
p[0] = loadedImages[url];
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
$.plot.image.load = function (urls, callback) {
|
||||
var missing = urls.length, loaded = {};
|
||||
if (missing == 0)
|
||||
callback({});
|
||||
|
||||
$.each(urls, function (i, url) {
|
||||
var handler = function () {
|
||||
--missing;
|
||||
|
||||
loaded[url] = this;
|
||||
|
||||
if (missing == 0)
|
||||
callback(loaded);
|
||||
};
|
||||
|
||||
$('<img />').load(handler).error(handler).attr('src', url);
|
||||
});
|
||||
}
|
||||
|
||||
function drawSeries(plot, ctx, series) {
|
||||
var plotOffset = plot.getPlotOffset();
|
||||
|
||||
if (!series.images || !series.images.show)
|
||||
return;
|
||||
|
||||
var points = series.datapoints.points,
|
||||
ps = series.datapoints.pointsize;
|
||||
|
||||
for (var i = 0; i < points.length; i += ps) {
|
||||
var img = points[i],
|
||||
x1 = points[i + 1], y1 = points[i + 2],
|
||||
x2 = points[i + 3], y2 = points[i + 4],
|
||||
xaxis = series.xaxis, yaxis = series.yaxis,
|
||||
tmp;
|
||||
|
||||
// actually we should check img.complete, but it
|
||||
// appears to be a somewhat unreliable indicator in
|
||||
// IE6 (false even after load event)
|
||||
if (!img || img.width <= 0 || img.height <= 0)
|
||||
continue;
|
||||
|
||||
if (x1 > x2) {
|
||||
tmp = x2;
|
||||
x2 = x1;
|
||||
x1 = tmp;
|
||||
}
|
||||
if (y1 > y2) {
|
||||
tmp = y2;
|
||||
y2 = y1;
|
||||
y1 = tmp;
|
||||
}
|
||||
|
||||
// if the anchor is at the center of the pixel, expand the
|
||||
// image by 1/2 pixel in each direction
|
||||
if (series.images.anchor == "center") {
|
||||
tmp = 0.5 * (x2-x1) / (img.width - 1);
|
||||
x1 -= tmp;
|
||||
x2 += tmp;
|
||||
tmp = 0.5 * (y2-y1) / (img.height - 1);
|
||||
y1 -= tmp;
|
||||
y2 += tmp;
|
||||
}
|
||||
|
||||
// clip
|
||||
if (x1 == x2 || y1 == y2 ||
|
||||
x1 >= xaxis.max || x2 <= xaxis.min ||
|
||||
y1 >= yaxis.max || y2 <= yaxis.min)
|
||||
continue;
|
||||
|
||||
var sx1 = 0, sy1 = 0, sx2 = img.width, sy2 = img.height;
|
||||
if (x1 < xaxis.min) {
|
||||
sx1 += (sx2 - sx1) * (xaxis.min - x1) / (x2 - x1);
|
||||
x1 = xaxis.min;
|
||||
}
|
||||
|
||||
if (x2 > xaxis.max) {
|
||||
sx2 += (sx2 - sx1) * (xaxis.max - x2) / (x2 - x1);
|
||||
x2 = xaxis.max;
|
||||
}
|
||||
|
||||
if (y1 < yaxis.min) {
|
||||
sy2 += (sy1 - sy2) * (yaxis.min - y1) / (y2 - y1);
|
||||
y1 = yaxis.min;
|
||||
}
|
||||
|
||||
if (y2 > yaxis.max) {
|
||||
sy1 += (sy1 - sy2) * (yaxis.max - y2) / (y2 - y1);
|
||||
y2 = yaxis.max;
|
||||
}
|
||||
|
||||
x1 = xaxis.p2c(x1);
|
||||
x2 = xaxis.p2c(x2);
|
||||
y1 = yaxis.p2c(y1);
|
||||
y2 = yaxis.p2c(y2);
|
||||
|
||||
// the transformation may have swapped us
|
||||
if (x1 > x2) {
|
||||
tmp = x2;
|
||||
x2 = x1;
|
||||
x1 = tmp;
|
||||
}
|
||||
if (y1 > y2) {
|
||||
tmp = y2;
|
||||
y2 = y1;
|
||||
y1 = tmp;
|
||||
}
|
||||
|
||||
tmp = ctx.globalAlpha;
|
||||
ctx.globalAlpha *= series.images.alpha;
|
||||
ctx.drawImage(img,
|
||||
sx1, sy1, sx2 - sx1, sy2 - sy1,
|
||||
x1 + plotOffset.left, y1 + plotOffset.top,
|
||||
x2 - x1, y2 - y1);
|
||||
ctx.globalAlpha = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
function processRawData(plot, series, data, datapoints) {
|
||||
if (!series.images.show)
|
||||
return;
|
||||
|
||||
// format is Image, x1, y1, x2, y2 (opposite corners)
|
||||
datapoints.format = [
|
||||
{ required: true },
|
||||
{ x: true, number: true, required: true },
|
||||
{ y: true, number: true, required: true },
|
||||
{ x: true, number: true, required: true },
|
||||
{ y: true, number: true, required: true }
|
||||
];
|
||||
}
|
||||
|
||||
function init(plot) {
|
||||
plot.hooks.processRawData.push(processRawData);
|
||||
plot.hooks.drawSeries.push(drawSeries);
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'image',
|
||||
version: '1.1'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,300 +0,0 @@
|
|||
/*
|
||||
Flot plugin for adding panning and zooming capabilities to a plot.
|
||||
|
||||
The default behaviour is double click and scrollwheel up/down to zoom
|
||||
in, drag to pan. The plugin defines plot.zoom({ center }),
|
||||
plot.zoomOut() and plot.pan(offset) so you easily can add custom
|
||||
controls. It also fires a "plotpan" and "plotzoom" event when
|
||||
something happens, useful for synchronizing plots.
|
||||
|
||||
Options:
|
||||
|
||||
zoom: {
|
||||
interactive: false
|
||||
trigger: "dblclick" // or "click" for single click
|
||||
amount: 1.5 // 2 = 200% (zoom in), 0.5 = 50% (zoom out)
|
||||
}
|
||||
|
||||
pan: {
|
||||
interactive: false
|
||||
frameRate: 20
|
||||
}
|
||||
|
||||
xaxis, yaxis, x2axis, y2axis: {
|
||||
zoomRange: null // or [number, number] (min range, max range)
|
||||
panRange: null // or [number, number] (min, max)
|
||||
}
|
||||
|
||||
"interactive" enables the built-in drag/click behaviour. If you enable
|
||||
interactive for pan, then you'll have a basic plot that supports
|
||||
moving around; the same for zoom.
|
||||
|
||||
"amount" specifies the default amount to zoom in (so 1.5 = 150%)
|
||||
relative to the current viewport.
|
||||
|
||||
"frameRate" specifies the maximum number of times per second the plot
|
||||
will update itself while the user is panning around on it (set to null
|
||||
to disable intermediate pans, the plot will then not update until the
|
||||
mouse button is released).
|
||||
|
||||
"zoomRange" is the interval in which zooming can happen, e.g. with
|
||||
zoomRange: [1, 100] the zoom will never scale the axis so that the
|
||||
difference between min and max is smaller than 1 or larger than 100.
|
||||
You can set either end to null to ignore, e.g. [1, null].
|
||||
|
||||
"panRange" confines the panning to stay within a range, e.g. with
|
||||
panRange: [-10, 20] panning stops at -10 in one end and at 20 in the
|
||||
other. Either can be null, e.g. [-10, null].
|
||||
|
||||
Example API usage:
|
||||
|
||||
plot = $.plot(...);
|
||||
|
||||
// zoom default amount in on the pixel (10, 20)
|
||||
plot.zoom({ center: { left: 10, top: 20 } });
|
||||
|
||||
// zoom out again
|
||||
plot.zoomOut({ center: { left: 10, top: 20 } });
|
||||
|
||||
// zoom 200% in on the pixel (10, 20)
|
||||
plot.zoom({ amount: 2, center: { left: 10, top: 20 } });
|
||||
|
||||
// pan 100 pixels to the left and 20 down
|
||||
plot.pan({ left: -100, top: 20 })
|
||||
|
||||
Here, "center" specifies where the center of the zooming should
|
||||
happen. Note that this is defined in pixel space, not the space of the
|
||||
data points (you can use the p2c helpers on the axes in Flot to help
|
||||
you convert between these).
|
||||
|
||||
"amount" is the amount to zoom the viewport relative to the current
|
||||
range, so 1 is 100% (i.e. no change), 1.5 is 150% (zoom in), 0.7 is
|
||||
70% (zoom out). You can set the default in the options.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// First two dependencies, jquery.event.drag.js and
|
||||
// jquery.mousewheel.js, we put them inline here to save people the
|
||||
// effort of downloading them.
|
||||
|
||||
/*
|
||||
jquery.event.drag.js ~ v1.5 ~ Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
|
||||
Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-LICENSE.txt
|
||||
*/
|
||||
(function(E){E.fn.drag=function(L,K,J){if(K){this.bind("dragstart",L)}if(J){this.bind("dragend",J)}return !L?this.trigger("drag"):this.bind("drag",K?K:L)};var A=E.event,B=A.special,F=B.drag={not:":input",distance:0,which:1,dragging:false,setup:function(J){J=E.extend({distance:F.distance,which:F.which,not:F.not},J||{});J.distance=I(J.distance);A.add(this,"mousedown",H,J);if(this.attachEvent){this.attachEvent("ondragstart",D)}},teardown:function(){A.remove(this,"mousedown",H);if(this===F.dragging){F.dragging=F.proxy=false}G(this,true);if(this.detachEvent){this.detachEvent("ondragstart",D)}}};B.dragstart=B.dragend={setup:function(){},teardown:function(){}};function H(L){var K=this,J,M=L.data||{};if(M.elem){K=L.dragTarget=M.elem;L.dragProxy=F.proxy||K;L.cursorOffsetX=M.pageX-M.left;L.cursorOffsetY=M.pageY-M.top;L.offsetX=L.pageX-L.cursorOffsetX;L.offsetY=L.pageY-L.cursorOffsetY}else{if(F.dragging||(M.which>0&&L.which!=M.which)||E(L.target).is(M.not)){return }}switch(L.type){case"mousedown":E.extend(M,E(K).offset(),{elem:K,target:L.target,pageX:L.pageX,pageY:L.pageY});A.add(document,"mousemove mouseup",H,M);G(K,false);F.dragging=null;return false;case !F.dragging&&"mousemove":if(I(L.pageX-M.pageX)+I(L.pageY-M.pageY)<M.distance){break}L.target=M.target;J=C(L,"dragstart",K);if(J!==false){F.dragging=K;F.proxy=L.dragProxy=E(J||K)[0]}case"mousemove":if(F.dragging){J=C(L,"drag",K);if(B.drop){B.drop.allowed=(J!==false);B.drop.handler(L)}if(J!==false){break}L.type="mouseup"}case"mouseup":A.remove(document,"mousemove mouseup",H);if(F.dragging){if(B.drop){B.drop.handler(L)}C(L,"dragend",K)}G(K,true);F.dragging=F.proxy=M.elem=false;break}return true}function C(M,K,L){M.type=K;var J=E.event.handle.call(L,M);return J===false?false:J||M.result}function I(J){return Math.pow(J,2)}function D(){return(F.dragging===false)}function G(K,J){if(!K){return }K.unselectable=J?"off":"on";K.onselectstart=function(){return J};if(K.style){K.style.MozUserSelect=J?"":"none"}}})(jQuery);
|
||||
|
||||
|
||||
/* jquery.mousewheel.min.js
|
||||
* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
|
||||
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||
*
|
||||
* Version: 3.0.2
|
||||
*
|
||||
* Requires: 1.2.2+
|
||||
*/
|
||||
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);
|
||||
|
||||
|
||||
|
||||
|
||||
(function ($) {
|
||||
var options = {
|
||||
xaxis: {
|
||||
zoomRange: null, // or [number, number] (min range, max range)
|
||||
panRange: null // or [number, number] (min, max)
|
||||
},
|
||||
zoom: {
|
||||
interactive: false,
|
||||
trigger: "dblclick", // or "click" for single click
|
||||
amount: 1.5 // how much to zoom relative to current position, 2 = 200% (zoom in), 0.5 = 50% (zoom out)
|
||||
},
|
||||
pan: {
|
||||
interactive: false,
|
||||
frameRate: 20
|
||||
}
|
||||
};
|
||||
|
||||
function init(plot) {
|
||||
function bindEvents(plot, eventHolder) {
|
||||
var o = plot.getOptions();
|
||||
if (o.zoom.interactive) {
|
||||
function clickHandler(e, zoomOut) {
|
||||
var c = plot.offset();
|
||||
c.left = e.pageX - c.left;
|
||||
c.top = e.pageY - c.top;
|
||||
if (zoomOut)
|
||||
plot.zoomOut({ center: c });
|
||||
else
|
||||
plot.zoom({ center: c });
|
||||
}
|
||||
|
||||
eventHolder[o.zoom.trigger](clickHandler);
|
||||
|
||||
eventHolder.mousewheel(function (e, delta) {
|
||||
clickHandler(e, delta < 0);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (o.pan.interactive) {
|
||||
var prevCursor = 'default', pageX = 0, pageY = 0,
|
||||
panTimeout = null;
|
||||
|
||||
eventHolder.bind("dragstart", { distance: 10 }, function (e) {
|
||||
if (e.which != 1) // only accept left-click
|
||||
return false;
|
||||
eventHolderCursor = eventHolder.css('cursor');
|
||||
eventHolder.css('cursor', 'move');
|
||||
pageX = e.pageX;
|
||||
pageY = e.pageY;
|
||||
});
|
||||
eventHolder.bind("drag", function (e) {
|
||||
if (panTimeout || !o.pan.frameRate)
|
||||
return;
|
||||
|
||||
panTimeout = setTimeout(function () {
|
||||
plot.pan({ left: pageX - e.pageX,
|
||||
top: pageY - e.pageY });
|
||||
pageX = e.pageX;
|
||||
pageY = e.pageY;
|
||||
|
||||
panTimeout = null;
|
||||
}, 1/o.pan.frameRate * 1000);
|
||||
});
|
||||
eventHolder.bind("dragend", function (e) {
|
||||
if (panTimeout) {
|
||||
clearTimeout(panTimeout);
|
||||
panTimeout = null;
|
||||
}
|
||||
|
||||
eventHolder.css('cursor', prevCursor);
|
||||
plot.pan({ left: pageX - e.pageX,
|
||||
top: pageY - e.pageY });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
plot.zoomOut = function (args) {
|
||||
if (!args)
|
||||
args = {};
|
||||
|
||||
if (!args.amount)
|
||||
args.amount = plot.getOptions().zoom.amount
|
||||
|
||||
args.amount = 1 / args.amount;
|
||||
plot.zoom(args);
|
||||
}
|
||||
|
||||
plot.zoom = function (args) {
|
||||
if (!args)
|
||||
args = {};
|
||||
|
||||
var c = args.center,
|
||||
amount = args.amount || plot.getOptions().zoom.amount,
|
||||
w = plot.width(), h = plot.height();
|
||||
|
||||
if (!c)
|
||||
c = { left: w / 2, top: h / 2 };
|
||||
|
||||
var xf = c.left / w,
|
||||
yf = c.top / h,
|
||||
minmax = {
|
||||
x: {
|
||||
min: c.left - xf * w / amount,
|
||||
max: c.left + (1 - xf) * w / amount
|
||||
},
|
||||
y: {
|
||||
min: c.top - yf * h / amount,
|
||||
max: c.top + (1 - yf) * h / amount
|
||||
}
|
||||
};
|
||||
|
||||
$.each(plot.getUsedAxes(), function(i, axis) {
|
||||
var opts = axis.options,
|
||||
min = minmax[axis.direction].min,
|
||||
max = minmax[axis.direction].max
|
||||
|
||||
min = axis.c2p(min);
|
||||
max = axis.c2p(max);
|
||||
if (min > max) {
|
||||
// make sure min < max
|
||||
var tmp = min;
|
||||
min = max;
|
||||
max = tmp;
|
||||
}
|
||||
|
||||
var range = max - min, zr = opts.zoomRange;
|
||||
if (zr &&
|
||||
((zr[0] != null && range < zr[0]) ||
|
||||
(zr[1] != null && range > zr[1])))
|
||||
return;
|
||||
|
||||
opts.min = min;
|
||||
opts.max = max;
|
||||
});
|
||||
|
||||
plot.setupGrid();
|
||||
plot.draw();
|
||||
|
||||
if (!args.preventEvent)
|
||||
plot.getPlaceholder().trigger("plotzoom", [ plot ]);
|
||||
}
|
||||
|
||||
plot.pan = function (args) {
|
||||
var delta = {
|
||||
x: +args.left,
|
||||
y: +args.top
|
||||
};
|
||||
|
||||
if (isNaN(delta.x))
|
||||
delta.x = 0;
|
||||
if (isNaN(delta.y))
|
||||
delta.y = 0;
|
||||
|
||||
$.each(plot.getUsedAxes(), function (i, axis) {
|
||||
var opts = axis.options,
|
||||
min, max, d = delta[axis.direction];
|
||||
|
||||
min = axis.c2p(axis.p2c(axis.min) + d),
|
||||
max = axis.c2p(axis.p2c(axis.max) + d);
|
||||
|
||||
var pr = opts.panRange;
|
||||
if (pr) {
|
||||
// check whether we hit the wall
|
||||
if (pr[0] != null && pr[0] > min) {
|
||||
d = pr[0] - min;
|
||||
min += d;
|
||||
max += d;
|
||||
}
|
||||
|
||||
if (pr[1] != null && pr[1] < max) {
|
||||
d = pr[1] - max;
|
||||
min += d;
|
||||
max += d;
|
||||
}
|
||||
}
|
||||
|
||||
opts.min = min;
|
||||
opts.max = max;
|
||||
});
|
||||
|
||||
plot.setupGrid();
|
||||
plot.draw();
|
||||
|
||||
if (!args.preventEvent)
|
||||
plot.getPlaceholder().trigger("plotpan", [ plot ]);
|
||||
}
|
||||
|
||||
plot.hooks.bindEvents.push(bindEvents);
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'navigate',
|
||||
version: '1.2'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,753 +0,0 @@
|
|||
/*
|
||||
Flot plugin for rendering pie charts. The plugin assumes the data is
|
||||
coming is as a single data value for each series, and each of those
|
||||
values is a positive value or zero (negative numbers don't make
|
||||
any sense and will cause strange effects). The data values do
|
||||
NOT need to be passed in as percentage values because it
|
||||
internally calculates the total and percentages.
|
||||
|
||||
* Created by Brian Medendorp, June 2009
|
||||
* Updated November 2009 with contributions from: btburnett3, Anthony Aragues and Xavi Ivars
|
||||
|
||||
* Changes:
|
||||
2009-10-22: lineJoin set to round
|
||||
2009-10-23: IE full circle fix, donut
|
||||
2009-11-11: Added basic hover from btburnett3 - does not work in IE, and center is off in Chrome and Opera
|
||||
2009-11-17: Added IE hover capability submitted by Anthony Aragues
|
||||
2009-11-18: Added bug fix submitted by Xavi Ivars (issues with arrays when other JS libraries are included as well)
|
||||
|
||||
|
||||
Available options are:
|
||||
series: {
|
||||
pie: {
|
||||
show: true/false
|
||||
radius: 0-1 for percentage of fullsize, or a specified pixel length, or 'auto'
|
||||
innerRadius: 0-1 for percentage of fullsize or a specified pixel length, for creating a donut effect
|
||||
startAngle: 0-2 factor of PI used for starting angle (in radians) i.e 3/2 starts at the top, 0 and 2 have the same result
|
||||
tilt: 0-1 for percentage to tilt the pie, where 1 is no tilt, and 0 is completely flat (nothing will show)
|
||||
offset: {
|
||||
top: integer value to move the pie up or down
|
||||
left: integer value to move the pie left or right, or 'auto'
|
||||
},
|
||||
stroke: {
|
||||
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#FFF')
|
||||
width: integer pixel width of the stroke
|
||||
},
|
||||
label: {
|
||||
show: true/false, or 'auto'
|
||||
formatter: a user-defined function that modifies the text/style of the label text
|
||||
radius: 0-1 for percentage of fullsize, or a specified pixel length
|
||||
background: {
|
||||
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#000')
|
||||
opacity: 0-1
|
||||
},
|
||||
threshold: 0-1 for the percentage value at which to hide labels (if they're too small)
|
||||
},
|
||||
combine: {
|
||||
threshold: 0-1 for the percentage value at which to combine slices (if they're too small)
|
||||
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#CCC'), if null, the plugin will automatically use the color of the first slice to be combined
|
||||
label: any text value of what the combined slice should be labeled
|
||||
}
|
||||
highlight: {
|
||||
opacity: 0-1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
More detail and specific examples can be found in the included HTML file.
|
||||
|
||||
*/
|
||||
|
||||
(function ($)
|
||||
{
|
||||
function init(plot) // this is the "body" of the plugin
|
||||
{
|
||||
var canvas = null;
|
||||
var target = null;
|
||||
var maxRadius = null;
|
||||
var centerLeft = null;
|
||||
var centerTop = null;
|
||||
var total = 0;
|
||||
var redraw = true;
|
||||
var redrawAttempts = 10;
|
||||
var shrink = 0.95;
|
||||
var legendWidth = 0;
|
||||
var processed = false;
|
||||
var raw = false;
|
||||
|
||||
// interactive variables
|
||||
var highlights = [];
|
||||
|
||||
// add hook to determine if pie plugin in enabled, and then perform necessary operations
|
||||
plot.hooks.processOptions.push(checkPieEnabled);
|
||||
plot.hooks.bindEvents.push(bindEvents);
|
||||
|
||||
// check to see if the pie plugin is enabled
|
||||
function checkPieEnabled(plot, options)
|
||||
{
|
||||
if (options.series.pie.show)
|
||||
{
|
||||
//disable grid
|
||||
options.grid.show = false;
|
||||
|
||||
// set labels.show
|
||||
if (options.series.pie.label.show=='auto')
|
||||
if (options.legend.show)
|
||||
options.series.pie.label.show = false;
|
||||
else
|
||||
options.series.pie.label.show = true;
|
||||
|
||||
// set radius
|
||||
if (options.series.pie.radius=='auto')
|
||||
if (options.series.pie.label.show)
|
||||
options.series.pie.radius = 3/4;
|
||||
else
|
||||
options.series.pie.radius = 1;
|
||||
|
||||
// ensure sane tilt
|
||||
if (options.series.pie.tilt>1)
|
||||
options.series.pie.tilt=1;
|
||||
if (options.series.pie.tilt<0)
|
||||
options.series.pie.tilt=0;
|
||||
|
||||
// add processData hook to do transformations on the data
|
||||
plot.hooks.processDatapoints.push(processDatapoints);
|
||||
plot.hooks.drawOverlay.push(drawOverlay);
|
||||
|
||||
// add draw hook
|
||||
plot.hooks.draw.push(draw);
|
||||
}
|
||||
}
|
||||
|
||||
// bind hoverable events
|
||||
function bindEvents(plot, eventHolder)
|
||||
{
|
||||
var options = plot.getOptions();
|
||||
|
||||
if (options.series.pie.show && options.grid.hoverable)
|
||||
eventHolder.unbind('mousemove').mousemove(onMouseMove);
|
||||
|
||||
if (options.series.pie.show && options.grid.clickable)
|
||||
eventHolder.unbind('click').click(onClick);
|
||||
}
|
||||
|
||||
|
||||
// debugging function that prints out an object
|
||||
function alertObject(obj)
|
||||
{
|
||||
var msg = '';
|
||||
function traverse(obj, depth)
|
||||
{
|
||||
if (!depth)
|
||||
depth = 0;
|
||||
for (var i = 0; i < obj.length; ++i)
|
||||
{
|
||||
for (var j=0; j<depth; j++)
|
||||
msg += '\t';
|
||||
|
||||
if( typeof obj[i] == "object")
|
||||
{ // its an object
|
||||
msg += ''+i+':\n';
|
||||
traverse(obj[i], depth+1);
|
||||
}
|
||||
else
|
||||
{ // its a value
|
||||
msg += ''+i+': '+obj[i]+'\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
traverse(obj);
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
function calcTotal(data)
|
||||
{
|
||||
for (var i = 0; i < data.length; ++i)
|
||||
{
|
||||
var item = parseFloat(data[i].data[0][1]);
|
||||
if (item)
|
||||
total += item;
|
||||
}
|
||||
}
|
||||
|
||||
function processDatapoints(plot, series, data, datapoints)
|
||||
{
|
||||
if (!processed)
|
||||
{
|
||||
processed = true;
|
||||
|
||||
canvas = plot.getCanvas();
|
||||
target = $(canvas).parent();
|
||||
options = plot.getOptions();
|
||||
|
||||
plot.setData(combine(plot.getData()));
|
||||
}
|
||||
}
|
||||
|
||||
function setupPie()
|
||||
{
|
||||
legendWidth = target.children().filter('.legend').children().width();
|
||||
|
||||
// calculate maximum radius and center point
|
||||
maxRadius = Math.min(canvas.width,(canvas.height/options.series.pie.tilt))/2;
|
||||
centerTop = (canvas.height/2)+options.series.pie.offset.top;
|
||||
centerLeft = (canvas.width/2);
|
||||
|
||||
if (options.series.pie.offset.left=='auto')
|
||||
if (options.legend.position.match('w'))
|
||||
centerLeft += legendWidth/2;
|
||||
else
|
||||
centerLeft -= legendWidth/2;
|
||||
else
|
||||
centerLeft += options.series.pie.offset.left;
|
||||
|
||||
if (centerLeft<maxRadius)
|
||||
centerLeft = maxRadius;
|
||||
else if (centerLeft>canvas.width-maxRadius)
|
||||
centerLeft = canvas.width-maxRadius;
|
||||
}
|
||||
|
||||
function fixData(data)
|
||||
{
|
||||
for (var i = 0; i < data.length; ++i)
|
||||
{
|
||||
if (typeof(data[i].data)=='number')
|
||||
data[i].data = [[1,data[i].data]];
|
||||
else if (typeof(data[i].data)=='undefined' || typeof(data[i].data[0])=='undefined')
|
||||
{
|
||||
if (typeof(data[i].data)!='undefined' && typeof(data[i].data.label)!='undefined')
|
||||
data[i].label = data[i].data.label; // fix weirdness coming from flot
|
||||
data[i].data = [[1,0]];
|
||||
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function combine(data)
|
||||
{
|
||||
data = fixData(data);
|
||||
calcTotal(data);
|
||||
var combined = 0;
|
||||
var numCombined = 0;
|
||||
var color = options.series.pie.combine.color;
|
||||
|
||||
var newdata = [];
|
||||
for (var i = 0; i < data.length; ++i)
|
||||
{
|
||||
// make sure its a number
|
||||
data[i].data[0][1] = parseFloat(data[i].data[0][1]);
|
||||
if (!data[i].data[0][1])
|
||||
data[i].data[0][1] = 0;
|
||||
|
||||
if (data[i].data[0][1]/total<=options.series.pie.combine.threshold)
|
||||
{
|
||||
combined += data[i].data[0][1];
|
||||
numCombined++;
|
||||
if (!color)
|
||||
color = data[i].color;
|
||||
}
|
||||
else
|
||||
{
|
||||
newdata.push({
|
||||
data: [[1,data[i].data[0][1]]],
|
||||
color: data[i].color,
|
||||
label: data[i].label,
|
||||
angle: (data[i].data[0][1]*(Math.PI*2))/total,
|
||||
percent: (data[i].data[0][1]/total*100)
|
||||
});
|
||||
}
|
||||
}
|
||||
if (numCombined>0)
|
||||
newdata.push({
|
||||
data: [[1,combined]],
|
||||
color: color,
|
||||
label: options.series.pie.combine.label,
|
||||
angle: (combined*(Math.PI*2))/total,
|
||||
percent: (combined/total*100)
|
||||
});
|
||||
return newdata;
|
||||
}
|
||||
|
||||
function draw(plot, newCtx)
|
||||
{
|
||||
if (!target) return; // if no series were passed
|
||||
ctx = newCtx;
|
||||
|
||||
setupPie();
|
||||
var slices = plot.getData();
|
||||
|
||||
var attempts = 0;
|
||||
while (redraw && attempts<redrawAttempts)
|
||||
{
|
||||
redraw = false;
|
||||
if (attempts>0)
|
||||
maxRadius *= shrink;
|
||||
attempts += 1;
|
||||
clear();
|
||||
if (options.series.pie.tilt<=0.8)
|
||||
drawShadow();
|
||||
drawPie();
|
||||
}
|
||||
if (attempts >= redrawAttempts) {
|
||||
clear();
|
||||
target.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>');
|
||||
}
|
||||
|
||||
if ( plot.setSeries && plot.insertLegend )
|
||||
{
|
||||
plot.setSeries(slices);
|
||||
plot.insertLegend();
|
||||
}
|
||||
|
||||
// we're actually done at this point, just defining internal functions at this point
|
||||
|
||||
function clear()
|
||||
{
|
||||
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||
target.children().filter('.pieLabel, .pieLabelBackground').remove();
|
||||
}
|
||||
|
||||
function drawShadow()
|
||||
{
|
||||
var shadowLeft = 5;
|
||||
var shadowTop = 15;
|
||||
var edge = 10;
|
||||
var alpha = 0.02;
|
||||
|
||||
// set radius
|
||||
if (options.series.pie.radius>1)
|
||||
var radius = options.series.pie.radius;
|
||||
else
|
||||
var radius = maxRadius * options.series.pie.radius;
|
||||
|
||||
if (radius>=(canvas.width/2)-shadowLeft || radius*options.series.pie.tilt>=(canvas.height/2)-shadowTop || radius<=edge)
|
||||
return; // shadow would be outside canvas, so don't draw it
|
||||
|
||||
ctx.save();
|
||||
ctx.translate(shadowLeft,shadowTop);
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.fillStyle = '#000';
|
||||
|
||||
// center and rotate to starting position
|
||||
ctx.translate(centerLeft,centerTop);
|
||||
ctx.scale(1, options.series.pie.tilt);
|
||||
|
||||
//radius -= edge;
|
||||
for (var i=1; i<=edge; i++)
|
||||
{
|
||||
ctx.beginPath();
|
||||
ctx.arc(0,0,radius,0,Math.PI*2,false);
|
||||
ctx.fill();
|
||||
radius -= i;
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function drawPie()
|
||||
{
|
||||
startAngle = Math.PI*options.series.pie.startAngle;
|
||||
|
||||
// set radius
|
||||
if (options.series.pie.radius>1)
|
||||
var radius = options.series.pie.radius;
|
||||
else
|
||||
var radius = maxRadius * options.series.pie.radius;
|
||||
|
||||
// center and rotate to starting position
|
||||
ctx.save();
|
||||
ctx.translate(centerLeft,centerTop);
|
||||
ctx.scale(1, options.series.pie.tilt);
|
||||
//ctx.rotate(startAngle); // start at top; -- This doesn't work properly in Opera
|
||||
|
||||
// draw slices
|
||||
ctx.save();
|
||||
var currentAngle = startAngle;
|
||||
for (var i = 0; i < slices.length; ++i)
|
||||
{
|
||||
slices[i].startAngle = currentAngle;
|
||||
drawSlice(slices[i].angle, slices[i].color, true);
|
||||
}
|
||||
ctx.restore();
|
||||
|
||||
// draw slice outlines
|
||||
ctx.save();
|
||||
ctx.lineWidth = options.series.pie.stroke.width;
|
||||
currentAngle = startAngle;
|
||||
for (var i = 0; i < slices.length; ++i)
|
||||
drawSlice(slices[i].angle, options.series.pie.stroke.color, false);
|
||||
ctx.restore();
|
||||
|
||||
// draw donut hole
|
||||
drawDonutHole(ctx);
|
||||
|
||||
// draw labels
|
||||
if (options.series.pie.label.show)
|
||||
drawLabels();
|
||||
|
||||
// restore to original state
|
||||
ctx.restore();
|
||||
|
||||
function drawSlice(angle, color, fill)
|
||||
{
|
||||
if (angle<=0)
|
||||
return;
|
||||
|
||||
if (fill)
|
||||
ctx.fillStyle = color;
|
||||
else
|
||||
{
|
||||
ctx.strokeStyle = color;
|
||||
ctx.lineJoin = 'round';
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
if (angle!=Math.PI*2)
|
||||
ctx.moveTo(0,0); // Center of the pie
|
||||
else if ($.browser.msie)
|
||||
angle -= 0.0001;
|
||||
//ctx.arc(0,0,radius,0,angle,false); // This doesn't work properly in Opera
|
||||
ctx.arc(0,0,radius,currentAngle,currentAngle+angle,false);
|
||||
ctx.closePath();
|
||||
//ctx.rotate(angle); // This doesn't work properly in Opera
|
||||
currentAngle += angle;
|
||||
|
||||
if (fill)
|
||||
ctx.fill();
|
||||
else
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
function drawLabels()
|
||||
{
|
||||
var currentAngle = startAngle;
|
||||
|
||||
// set radius
|
||||
if (options.series.pie.label.radius>1)
|
||||
var radius = options.series.pie.label.radius;
|
||||
else
|
||||
var radius = maxRadius * options.series.pie.label.radius;
|
||||
|
||||
for (var i = 0; i < slices.length; ++i)
|
||||
{
|
||||
if (slices[i].percent >= options.series.pie.label.threshold*100)
|
||||
drawLabel(slices[i], currentAngle, i);
|
||||
currentAngle += slices[i].angle;
|
||||
}
|
||||
|
||||
function drawLabel(slice, startAngle, index)
|
||||
{
|
||||
if (slice.data[0][1]==0)
|
||||
return;
|
||||
|
||||
// format label text
|
||||
var lf = options.legend.labelFormatter, text, plf = options.series.pie.label.formatter;
|
||||
if (lf)
|
||||
text = lf(slice.label, slice);
|
||||
else
|
||||
text = slice.label;
|
||||
if (plf)
|
||||
text = plf(text, slice);
|
||||
|
||||
var halfAngle = ((startAngle+slice.angle) + startAngle)/2;
|
||||
var x = centerLeft + Math.round(Math.cos(halfAngle) * radius);
|
||||
var y = centerTop + Math.round(Math.sin(halfAngle) * radius) * options.series.pie.tilt;
|
||||
|
||||
var html = '<span class="pieLabel" id="pieLabel'+index+'" style="position:absolute;top:' + y + 'px;left:' + x + 'px;">' + text + "</span>";
|
||||
target.append(html);
|
||||
var label = target.children('#pieLabel'+index);
|
||||
var labelTop = (y - label.height()/2);
|
||||
var labelLeft = (x - label.width()/2);
|
||||
label.css('top', labelTop);
|
||||
label.css('left', labelLeft);
|
||||
|
||||
// check to make sure that the label is not outside the canvas
|
||||
if (0-labelTop>0 || 0-labelLeft>0 || canvas.height-(labelTop+label.height())<0 || canvas.width-(labelLeft+label.width())<0)
|
||||
redraw = true;
|
||||
|
||||
if (options.series.pie.label.background.opacity != 0) {
|
||||
// put in the transparent background separately to avoid blended labels and label boxes
|
||||
var c = options.series.pie.label.background.color;
|
||||
if (c == null) {
|
||||
c = slice.color;
|
||||
}
|
||||
var pos = 'top:'+labelTop+'px;left:'+labelLeft+'px;';
|
||||
$('<div class="pieLabelBackground" style="position:absolute;width:' + label.width() + 'px;height:' + label.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').insertBefore(label).css('opacity', options.series.pie.label.background.opacity);
|
||||
}
|
||||
} // end individual label function
|
||||
} // end drawLabels function
|
||||
} // end drawPie function
|
||||
} // end draw function
|
||||
|
||||
// Placed here because it needs to be accessed from multiple locations
|
||||
function drawDonutHole(layer)
|
||||
{
|
||||
// draw donut hole
|
||||
if(options.series.pie.innerRadius > 0)
|
||||
{
|
||||
// subtract the center
|
||||
layer.save();
|
||||
innerRadius = options.series.pie.innerRadius > 1 ? options.series.pie.innerRadius : maxRadius * options.series.pie.innerRadius;
|
||||
layer.globalCompositeOperation = 'destination-out'; // this does not work with excanvas, but it will fall back to using the stroke color
|
||||
layer.beginPath();
|
||||
layer.fillStyle = options.series.pie.stroke.color;
|
||||
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||
layer.fill();
|
||||
layer.closePath();
|
||||
layer.restore();
|
||||
|
||||
// add inner stroke
|
||||
layer.save();
|
||||
layer.beginPath();
|
||||
layer.strokeStyle = options.series.pie.stroke.color;
|
||||
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||
layer.stroke();
|
||||
layer.closePath();
|
||||
layer.restore();
|
||||
// TODO: add extra shadow inside hole (with a mask) if the pie is tilted.
|
||||
}
|
||||
}
|
||||
|
||||
//-- Additional Interactive related functions --
|
||||
|
||||
function isPointInPoly(poly, pt)
|
||||
{
|
||||
for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
|
||||
((poly[i][1] <= pt[1] && pt[1] < poly[j][1]) || (poly[j][1] <= pt[1] && pt[1]< poly[i][1]))
|
||||
&& (pt[0] < (poly[j][0] - poly[i][0]) * (pt[1] - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0])
|
||||
&& (c = !c);
|
||||
return c;
|
||||
}
|
||||
|
||||
function findNearbySlice(mouseX, mouseY)
|
||||
{
|
||||
var slices = plot.getData(),
|
||||
options = plot.getOptions(),
|
||||
radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||
|
||||
for (var i = 0; i < slices.length; ++i)
|
||||
{
|
||||
var s = slices[i];
|
||||
|
||||
if(s.pie.show)
|
||||
{
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0,0); // Center of the pie
|
||||
//ctx.scale(1, options.series.pie.tilt); // this actually seems to break everything when here.
|
||||
ctx.arc(0,0,radius,s.startAngle,s.startAngle+s.angle,false);
|
||||
ctx.closePath();
|
||||
x = mouseX-centerLeft;
|
||||
y = mouseY-centerTop;
|
||||
if(ctx.isPointInPath)
|
||||
{
|
||||
if (ctx.isPointInPath(mouseX-centerLeft, mouseY-centerTop))
|
||||
{
|
||||
//alert('found slice!');
|
||||
ctx.restore();
|
||||
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// excanvas for IE doesn;t support isPointInPath, this is a workaround.
|
||||
p1X = (radius * Math.cos(s.startAngle));
|
||||
p1Y = (radius * Math.sin(s.startAngle));
|
||||
p2X = (radius * Math.cos(s.startAngle+(s.angle/4)));
|
||||
p2Y = (radius * Math.sin(s.startAngle+(s.angle/4)));
|
||||
p3X = (radius * Math.cos(s.startAngle+(s.angle/2)));
|
||||
p3Y = (radius * Math.sin(s.startAngle+(s.angle/2)));
|
||||
p4X = (radius * Math.cos(s.startAngle+(s.angle/1.5)));
|
||||
p4Y = (radius * Math.sin(s.startAngle+(s.angle/1.5)));
|
||||
p5X = (radius * Math.cos(s.startAngle+s.angle));
|
||||
p5Y = (radius * Math.sin(s.startAngle+s.angle));
|
||||
arrPoly = [[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]];
|
||||
arrPoint = [x,y];
|
||||
// TODO: perhaps do some mathmatical trickery here with the Y-coordinate to compensate for pie tilt?
|
||||
if(isPointInPoly(arrPoly, arrPoint))
|
||||
{
|
||||
ctx.restore();
|
||||
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||
}
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function onMouseMove(e)
|
||||
{
|
||||
triggerClickHoverEvent('plothover', e);
|
||||
}
|
||||
|
||||
function onClick(e)
|
||||
{
|
||||
triggerClickHoverEvent('plotclick', e);
|
||||
}
|
||||
|
||||
// trigger click or hover event (they send the same parameters so we share their code)
|
||||
function triggerClickHoverEvent(eventname, e)
|
||||
{
|
||||
var offset = plot.offset(),
|
||||
canvasX = parseInt(e.pageX - offset.left),
|
||||
canvasY = parseInt(e.pageY - offset.top),
|
||||
item = findNearbySlice(canvasX, canvasY);
|
||||
|
||||
if (options.grid.autoHighlight)
|
||||
{
|
||||
// clear auto-highlights
|
||||
for (var i = 0; i < highlights.length; ++i)
|
||||
{
|
||||
var h = highlights[i];
|
||||
if (h.auto == eventname && !(item && h.series == item.series))
|
||||
unhighlight(h.series);
|
||||
}
|
||||
}
|
||||
|
||||
// if no slice was found, quit
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
// highlight the slice
|
||||
highlight(item.series, eventname);
|
||||
|
||||
// trigger any hover bind events
|
||||
var pos = { pageX: e.pageX, pageY: e.pageY };
|
||||
target.trigger(eventname, [ pos, item ]);
|
||||
}
|
||||
|
||||
function highlight(s, auto)
|
||||
{
|
||||
if (typeof s == "number")
|
||||
s = series[s];
|
||||
|
||||
var i = indexOfHighlight(s);
|
||||
if (i == -1)
|
||||
{
|
||||
highlights.push({ series: s, auto: auto });
|
||||
plot.triggerRedrawOverlay();
|
||||
}
|
||||
else if (!auto)
|
||||
highlights[i].auto = false;
|
||||
}
|
||||
|
||||
function unhighlight(s)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
highlights = [];
|
||||
plot.triggerRedrawOverlay();
|
||||
}
|
||||
|
||||
if (typeof s == "number")
|
||||
s = series[s];
|
||||
|
||||
var i = indexOfHighlight(s);
|
||||
if (i != -1)
|
||||
{
|
||||
highlights.splice(i, 1);
|
||||
plot.triggerRedrawOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
function indexOfHighlight(s)
|
||||
{
|
||||
for (var i = 0; i < highlights.length; ++i)
|
||||
{
|
||||
var h = highlights[i];
|
||||
if (h.series == s)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function drawOverlay(plot, octx)
|
||||
{
|
||||
//alert(options.series.pie.radius);
|
||||
var options = plot.getOptions();
|
||||
//alert(options.series.pie.radius);
|
||||
|
||||
var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||
|
||||
octx.save();
|
||||
octx.translate(centerLeft, centerTop);
|
||||
octx.scale(1, options.series.pie.tilt);
|
||||
|
||||
for (i = 0; i < highlights.length; ++i)
|
||||
drawHighlight(highlights[i].series);
|
||||
|
||||
drawDonutHole(octx);
|
||||
|
||||
octx.restore();
|
||||
|
||||
function drawHighlight(series)
|
||||
{
|
||||
if (series.angle < 0) return;
|
||||
|
||||
//octx.fillStyle = parseColor(options.series.pie.highlight.color).scale(null, null, null, options.series.pie.highlight.opacity).toString();
|
||||
octx.fillStyle = "rgba(255, 255, 255, "+options.series.pie.highlight.opacity+")"; // this is temporary until we have access to parseColor
|
||||
|
||||
octx.beginPath();
|
||||
if (series.angle!=Math.PI*2)
|
||||
octx.moveTo(0,0); // Center of the pie
|
||||
octx.arc(0,0,radius,series.startAngle,series.startAngle+series.angle,false);
|
||||
octx.closePath();
|
||||
octx.fill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // end init (plugin body)
|
||||
|
||||
// define pie specific options and their default values
|
||||
var options = {
|
||||
series: {
|
||||
pie: {
|
||||
show: false,
|
||||
radius: 'auto', // actual radius of the visible pie (based on full calculated radius if <=1, or hard pixel value)
|
||||
innerRadius:0, /* for donut */
|
||||
startAngle: 3/2,
|
||||
tilt: 1,
|
||||
offset: {
|
||||
top: 0,
|
||||
left: 'auto'
|
||||
},
|
||||
stroke: {
|
||||
color: '#FFF',
|
||||
width: 1
|
||||
},
|
||||
label: {
|
||||
show: 'auto',
|
||||
formatter: function(label, slice){
|
||||
return '<div style="font-size:x-small;text-align:center;padding:2px;color:'+slice.color+';">'+label+'<br/>'+Math.round(slice.percent)+'%</div>';
|
||||
}, // formatter function
|
||||
radius: 1, // radius at which to place the labels (based on full calculated radius if <=1, or hard pixel value)
|
||||
background: {
|
||||
color: null,
|
||||
opacity: 0
|
||||
},
|
||||
threshold: 0 // percentage at which to hide the label (i.e. the slice is too narrow)
|
||||
},
|
||||
combine: {
|
||||
threshold: -1, // percentage at which to combine little slices into one larger slice
|
||||
color: null, // color to give the new slice (auto-generated if null)
|
||||
label: 'Other' // label to give the new slice
|
||||
},
|
||||
highlight: {
|
||||
//color: '#FFF', // will add this functionality once parseColor is available
|
||||
opacity: 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: "pie",
|
||||
version: "1.0"
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,328 +0,0 @@
|
|||
/*
|
||||
Flot plugin for selecting regions.
|
||||
|
||||
The plugin defines the following options:
|
||||
|
||||
selection: {
|
||||
mode: null or "x" or "y" or "xy",
|
||||
color: color
|
||||
}
|
||||
|
||||
Selection support is enabled by setting the mode to one of "x", "y" or
|
||||
"xy". In "x" mode, the user will only be able to specify the x range,
|
||||
similarly for "y" mode. For "xy", the selection becomes a rectangle
|
||||
where both ranges can be specified. "color" is color of the selection.
|
||||
|
||||
When selection support is enabled, a "plotselected" event will be
|
||||
emitted on the DOM element you passed into the plot function. The
|
||||
event handler gets a parameter with the ranges selected on the axes,
|
||||
like this:
|
||||
|
||||
placeholder.bind("plotselected", function(event, ranges) {
|
||||
alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
|
||||
// similar for yaxis - with multiple axes, the extra ones are in
|
||||
// x2axis, x3axis, ...
|
||||
});
|
||||
|
||||
The "plotselected" event is only fired when the user has finished
|
||||
making the selection. A "plotselecting" event is fired during the
|
||||
process with the same parameters as the "plotselected" event, in case
|
||||
you want to know what's happening while it's happening,
|
||||
|
||||
A "plotunselected" event with no arguments is emitted when the user
|
||||
clicks the mouse to remove the selection.
|
||||
|
||||
The plugin allso adds the following methods to the plot object:
|
||||
|
||||
- setSelection(ranges, preventEvent)
|
||||
|
||||
Set the selection rectangle. The passed in ranges is on the same
|
||||
form as returned in the "plotselected" event. If the selection mode
|
||||
is "x", you should put in either an xaxis range, if the mode is "y"
|
||||
you need to put in an yaxis range and both xaxis and yaxis if the
|
||||
selection mode is "xy", like this:
|
||||
|
||||
setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
|
||||
|
||||
setSelection will trigger the "plotselected" event when called. If
|
||||
you don't want that to happen, e.g. if you're inside a
|
||||
"plotselected" handler, pass true as the second parameter. If you
|
||||
are using multiple axes, you can specify the ranges on any of those,
|
||||
e.g. as x2axis/x3axis/... instead of xaxis, the plugin picks the
|
||||
first one it sees.
|
||||
|
||||
- clearSelection(preventEvent)
|
||||
|
||||
Clear the selection rectangle. Pass in true to avoid getting a
|
||||
"plotunselected" event.
|
||||
|
||||
- getSelection()
|
||||
|
||||
Returns the current selection in the same format as the
|
||||
"plotselected" event. If there's currently no selection, the
|
||||
function returns null.
|
||||
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
function init(plot) {
|
||||
var selection = {
|
||||
first: { x: -1, y: -1}, second: { x: -1, y: -1},
|
||||
show: false,
|
||||
active: false
|
||||
};
|
||||
|
||||
// FIXME: The drag handling implemented here should be
|
||||
// abstracted out, there's some similar code from a library in
|
||||
// the navigation plugin, this should be massaged a bit to fit
|
||||
// the Flot cases here better and reused. Doing this would
|
||||
// make this plugin much slimmer.
|
||||
var savedhandlers = {};
|
||||
|
||||
function onMouseMove(e) {
|
||||
if (selection.active) {
|
||||
plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
|
||||
|
||||
updateSelection(e);
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseDown(e) {
|
||||
if (e.which != 1) // only accept left-click
|
||||
return;
|
||||
|
||||
// cancel out any text selections
|
||||
document.body.focus();
|
||||
|
||||
// prevent text selection and drag in old-school browsers
|
||||
if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
|
||||
savedhandlers.onselectstart = document.onselectstart;
|
||||
document.onselectstart = function () { return false; };
|
||||
}
|
||||
if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
|
||||
savedhandlers.ondrag = document.ondrag;
|
||||
document.ondrag = function () { return false; };
|
||||
}
|
||||
|
||||
setSelectionPos(selection.first, e);
|
||||
|
||||
selection.active = true;
|
||||
|
||||
$(document).one("mouseup", onMouseUp);
|
||||
}
|
||||
|
||||
function onMouseUp(e) {
|
||||
// revert drag stuff for old-school browsers
|
||||
if (document.onselectstart !== undefined)
|
||||
document.onselectstart = savedhandlers.onselectstart;
|
||||
if (document.ondrag !== undefined)
|
||||
document.ondrag = savedhandlers.ondrag;
|
||||
|
||||
// no more draggy-dee-drag
|
||||
selection.active = false;
|
||||
updateSelection(e);
|
||||
|
||||
if (selectionIsSane())
|
||||
triggerSelectedEvent();
|
||||
else {
|
||||
// this counts as a clear
|
||||
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
||||
plot.getPlaceholder().trigger("plotselecting", [ null ]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getSelection() {
|
||||
if (!selectionIsSane())
|
||||
return null;
|
||||
|
||||
var r = {}, c1 = selection.first, c2 = selection.second;
|
||||
$.each(plot.getAxes(), function (name, axis) {
|
||||
if (axis.used) {
|
||||
var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
|
||||
r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
|
||||
}
|
||||
});
|
||||
return r;
|
||||
}
|
||||
|
||||
function triggerSelectedEvent() {
|
||||
var r = getSelection();
|
||||
|
||||
plot.getPlaceholder().trigger("plotselected", [ r ]);
|
||||
|
||||
// backwards-compat stuff, to be removed in future
|
||||
if (r.xaxis && r.yaxis)
|
||||
plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
|
||||
}
|
||||
|
||||
function clamp(min, value, max) {
|
||||
return value < min ? min: (value > max ? max: value);
|
||||
}
|
||||
|
||||
function setSelectionPos(pos, e) {
|
||||
var o = plot.getOptions();
|
||||
var offset = plot.getPlaceholder().offset();
|
||||
var plotOffset = plot.getPlotOffset();
|
||||
pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
|
||||
pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
|
||||
|
||||
if (o.selection.mode == "y")
|
||||
pos.x = pos == selection.first ? 0 : plot.width();
|
||||
|
||||
if (o.selection.mode == "x")
|
||||
pos.y = pos == selection.first ? 0 : plot.height();
|
||||
}
|
||||
|
||||
function updateSelection(pos) {
|
||||
if (pos.pageX == null)
|
||||
return;
|
||||
|
||||
setSelectionPos(selection.second, pos);
|
||||
if (selectionIsSane()) {
|
||||
selection.show = true;
|
||||
plot.triggerRedrawOverlay();
|
||||
}
|
||||
else
|
||||
clearSelection(true);
|
||||
}
|
||||
|
||||
function clearSelection(preventEvent) {
|
||||
if (selection.show) {
|
||||
selection.show = false;
|
||||
plot.triggerRedrawOverlay();
|
||||
if (!preventEvent)
|
||||
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
||||
}
|
||||
}
|
||||
|
||||
// taken from markings support
|
||||
function extractRange(ranges, coord) {
|
||||
var axis, from, to, axes, key;
|
||||
|
||||
axes = plot.getUsedAxes();
|
||||
for (i = 0; i < axes.length; ++i) {
|
||||
axis = axes[i];
|
||||
if (axis.direction == coord) {
|
||||
key = coord + axis.n + "axis";
|
||||
if (!ranges[key] && axis.n == 1)
|
||||
key = coord + "axis"; // support x1axis as xaxis
|
||||
if (ranges[key]) {
|
||||
from = ranges[key].from;
|
||||
to = ranges[key].to;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// backwards-compat stuff - to be removed in future
|
||||
if (!ranges[key]) {
|
||||
axis = coord == "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
|
||||
from = ranges[coord + "1"];
|
||||
to = ranges[coord + "2"];
|
||||
}
|
||||
|
||||
// auto-reverse as an added bonus
|
||||
if (from != null && to != null && from > to) {
|
||||
var tmp = from;
|
||||
from = to;
|
||||
to = tmp;
|
||||
}
|
||||
|
||||
return { from: from, to: to, axis: axis };
|
||||
}
|
||||
|
||||
|
||||
function setSelection(ranges, preventEvent) {
|
||||
var axis, range, o = plot.getOptions();
|
||||
|
||||
if (o.selection.mode == "y") {
|
||||
selection.first.x = 0;
|
||||
selection.second.x = plot.width();
|
||||
}
|
||||
else {
|
||||
range = extractRange(ranges, "x");
|
||||
|
||||
selection.first.x = range.axis.p2c(range.from);
|
||||
selection.second.x = range.axis.p2c(range.to);
|
||||
}
|
||||
|
||||
if (o.selection.mode == "x") {
|
||||
selection.first.y = 0;
|
||||
selection.second.y = plot.height();
|
||||
}
|
||||
else {
|
||||
range = extractRange(ranges, "y");
|
||||
|
||||
selection.first.y = range.axis.p2c(range.from);
|
||||
selection.second.y = range.axis.p2c(range.to);
|
||||
}
|
||||
|
||||
selection.show = true;
|
||||
plot.triggerRedrawOverlay();
|
||||
if (!preventEvent && selectionIsSane())
|
||||
triggerSelectedEvent();
|
||||
}
|
||||
|
||||
function selectionIsSane() {
|
||||
var minSize = 5;
|
||||
return Math.abs(selection.second.x - selection.first.x) >= minSize &&
|
||||
Math.abs(selection.second.y - selection.first.y) >= minSize;
|
||||
}
|
||||
|
||||
plot.clearSelection = clearSelection;
|
||||
plot.setSelection = setSelection;
|
||||
plot.getSelection = getSelection;
|
||||
|
||||
plot.hooks.bindEvents.push(function(plot, eventHolder) {
|
||||
var o = plot.getOptions();
|
||||
if (o.selection.mode != null)
|
||||
eventHolder.mousemove(onMouseMove);
|
||||
|
||||
if (o.selection.mode != null)
|
||||
eventHolder.mousedown(onMouseDown);
|
||||
});
|
||||
|
||||
|
||||
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
||||
// draw selection
|
||||
if (selection.show && selectionIsSane()) {
|
||||
var plotOffset = plot.getPlotOffset();
|
||||
var o = plot.getOptions();
|
||||
|
||||
ctx.save();
|
||||
ctx.translate(plotOffset.left, plotOffset.top);
|
||||
|
||||
var c = $.color.parse(o.selection.color);
|
||||
|
||||
ctx.strokeStyle = c.scale('a', 0.8).toString();
|
||||
ctx.lineWidth = 1;
|
||||
ctx.lineJoin = "round";
|
||||
ctx.fillStyle = c.scale('a', 0.4).toString();
|
||||
|
||||
var x = Math.min(selection.first.x, selection.second.x),
|
||||
y = Math.min(selection.first.y, selection.second.y),
|
||||
w = Math.abs(selection.second.x - selection.first.x),
|
||||
h = Math.abs(selection.second.y - selection.first.y);
|
||||
|
||||
ctx.fillRect(x, y, w, h);
|
||||
ctx.strokeRect(x, y, w, h);
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: {
|
||||
selection: {
|
||||
mode: null, // one of null, "x", "y" or "xy"
|
||||
color: "#e8cfac"
|
||||
}
|
||||
},
|
||||
name: 'selection',
|
||||
version: '1.0'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,184 +0,0 @@
|
|||
/*
|
||||
Flot plugin for stacking data sets, i.e. putting them on top of each
|
||||
other, for accumulative graphs.
|
||||
|
||||
The plugin assumes the data is sorted on x (or y if stacking
|
||||
horizontally). For line charts, it is assumed that if a line has an
|
||||
undefined gap (from a null point), then the line above it should have
|
||||
the same gap - insert zeros instead of "null" if you want another
|
||||
behaviour. This also holds for the start and end of the chart. Note
|
||||
that stacking a mix of positive and negative values in most instances
|
||||
doesn't make sense (so it looks weird).
|
||||
|
||||
Two or more series are stacked when their "stack" attribute is set to
|
||||
the same key (which can be any number or string or just "true"). To
|
||||
specify the default stack, you can set
|
||||
|
||||
series: {
|
||||
stack: null or true or key (number/string)
|
||||
}
|
||||
|
||||
or specify it for a specific series
|
||||
|
||||
$.plot($("#placeholder"), [{ data: [ ... ], stack: true }])
|
||||
|
||||
The stacking order is determined by the order of the data series in
|
||||
the array (later series end up on top of the previous).
|
||||
|
||||
Internally, the plugin modifies the datapoints in each series, adding
|
||||
an offset to the y value. For line series, extra data points are
|
||||
inserted through interpolation. If there's a second y value, it's also
|
||||
adjusted (e.g for bar charts or filled areas).
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
var options = {
|
||||
series: { stack: null } // or number/string
|
||||
};
|
||||
|
||||
function init(plot) {
|
||||
function findMatchingSeries(s, allseries) {
|
||||
var res = null
|
||||
for (var i = 0; i < allseries.length; ++i) {
|
||||
if (s == allseries[i])
|
||||
break;
|
||||
|
||||
if (allseries[i].stack == s.stack)
|
||||
res = allseries[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function stackData(plot, s, datapoints) {
|
||||
if (s.stack == null)
|
||||
return;
|
||||
|
||||
var other = findMatchingSeries(s, plot.getData());
|
||||
if (!other)
|
||||
return;
|
||||
|
||||
var ps = datapoints.pointsize,
|
||||
points = datapoints.points,
|
||||
otherps = other.datapoints.pointsize,
|
||||
otherpoints = other.datapoints.points,
|
||||
newpoints = [],
|
||||
px, py, intery, qx, qy, bottom,
|
||||
withlines = s.lines.show,
|
||||
horizontal = s.bars.horizontal,
|
||||
withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
|
||||
withsteps = withlines && s.lines.steps,
|
||||
fromgap = true,
|
||||
keyOffset = horizontal ? 1 : 0,
|
||||
accumulateOffset = horizontal ? 0 : 1,
|
||||
i = 0, j = 0, l;
|
||||
|
||||
while (true) {
|
||||
if (i >= points.length)
|
||||
break;
|
||||
|
||||
l = newpoints.length;
|
||||
|
||||
if (points[i] == null) {
|
||||
// copy gaps
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
i += ps;
|
||||
}
|
||||
else if (j >= otherpoints.length) {
|
||||
// for lines, we can't use the rest of the points
|
||||
if (!withlines) {
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
}
|
||||
i += ps;
|
||||
}
|
||||
else if (otherpoints[j] == null) {
|
||||
// oops, got a gap
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(null);
|
||||
fromgap = true;
|
||||
j += otherps;
|
||||
}
|
||||
else {
|
||||
// cases where we actually got two points
|
||||
px = points[i + keyOffset];
|
||||
py = points[i + accumulateOffset];
|
||||
qx = otherpoints[j + keyOffset];
|
||||
qy = otherpoints[j + accumulateOffset];
|
||||
bottom = 0;
|
||||
|
||||
if (px == qx) {
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
|
||||
newpoints[l + accumulateOffset] += qy;
|
||||
bottom = qy;
|
||||
|
||||
i += ps;
|
||||
j += otherps;
|
||||
}
|
||||
else if (px > qx) {
|
||||
// we got past point below, might need to
|
||||
// insert interpolated extra point
|
||||
if (withlines && i > 0 && points[i - ps] != null) {
|
||||
intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
|
||||
newpoints.push(qx);
|
||||
newpoints.push(intery + qy);
|
||||
for (m = 2; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
bottom = qy;
|
||||
}
|
||||
|
||||
j += otherps;
|
||||
}
|
||||
else { // px < qx
|
||||
if (fromgap && withlines) {
|
||||
// if we come from a gap, we just skip this point
|
||||
i += ps;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints.push(points[i + m]);
|
||||
|
||||
// we might be able to interpolate a point below,
|
||||
// this can give us a better y
|
||||
if (withlines && j > 0 && otherpoints[j - otherps] != null)
|
||||
bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
|
||||
|
||||
newpoints[l + accumulateOffset] += bottom;
|
||||
|
||||
i += ps;
|
||||
}
|
||||
|
||||
fromgap = false;
|
||||
|
||||
if (l != newpoints.length && withbottom)
|
||||
newpoints[l + 2] += bottom;
|
||||
}
|
||||
|
||||
// maintain the line steps invariant
|
||||
if (withsteps && l != newpoints.length && l > 0
|
||||
&& newpoints[l] != null
|
||||
&& newpoints[l] != newpoints[l - ps]
|
||||
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
|
||||
for (m = 0; m < ps; ++m)
|
||||
newpoints[l + ps + m] = newpoints[l + m];
|
||||
newpoints[l + 1] = newpoints[l - ps + 1];
|
||||
}
|
||||
}
|
||||
|
||||
datapoints.points = newpoints;
|
||||
}
|
||||
|
||||
plot.hooks.processDatapoints.push(stackData);
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'stack',
|
||||
version: '1.2'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
Flot plugin that adds some extra symbols for plotting points.
|
||||
|
||||
The symbols are accessed as strings through the standard symbol
|
||||
choice:
|
||||
|
||||
series: {
|
||||
points: {
|
||||
symbol: "square" // or "diamond", "triangle", "cross"
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
function processRawData(plot, series, datapoints) {
|
||||
// we normalize the area of each symbol so it is approximately the
|
||||
// same as a circle of the given radius
|
||||
|
||||
var handlers = {
|
||||
square: function (ctx, x, y, radius, shadow) {
|
||||
// pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
|
||||
var size = radius * Math.sqrt(Math.PI) / 2;
|
||||
ctx.rect(x - size, y - size, size + size, size + size);
|
||||
},
|
||||
diamond: function (ctx, x, y, radius, shadow) {
|
||||
// pi * r^2 = 2s^2 => s = r * sqrt(pi/2)
|
||||
var size = radius * Math.sqrt(Math.PI / 2);
|
||||
ctx.moveTo(x - size, y);
|
||||
ctx.lineTo(x, y - size);
|
||||
ctx.lineTo(x + size, y);
|
||||
ctx.lineTo(x, y + size);
|
||||
ctx.lineTo(x - size, y);
|
||||
},
|
||||
triangle: function (ctx, x, y, radius, shadow) {
|
||||
// pi * r^2 = 1/2 * s^2 * sin (pi / 3) => s = r * sqrt(2 * pi / sin(pi / 3))
|
||||
var size = radius * Math.sqrt(2 * Math.PI / Math.sin(Math.PI / 3));
|
||||
var height = size * Math.sin(Math.PI / 3);
|
||||
ctx.moveTo(x - size/2, y + height/2);
|
||||
ctx.lineTo(x + size/2, y + height/2);
|
||||
if (!shadow) {
|
||||
ctx.lineTo(x, y - height/2);
|
||||
ctx.lineTo(x - size/2, y + height/2);
|
||||
}
|
||||
},
|
||||
cross: function (ctx, x, y, radius, shadow) {
|
||||
// pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
|
||||
var size = radius * Math.sqrt(Math.PI) / 2;
|
||||
ctx.moveTo(x - size, y - size);
|
||||
ctx.lineTo(x + size, y + size);
|
||||
ctx.moveTo(x - size, y + size);
|
||||
ctx.lineTo(x + size, y - size);
|
||||
}
|
||||
}
|
||||
|
||||
var s = series.points.symbol;
|
||||
if (handlers[s])
|
||||
series.points.symbol = handlers[s];
|
||||
}
|
||||
|
||||
function init(plot) {
|
||||
plot.hooks.processDatapoints.push(processRawData);
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
name: 'symbols',
|
||||
version: '1.0'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
Flot plugin for thresholding data. Controlled through the option
|
||||
"threshold" in either the global series options
|
||||
|
||||
series: {
|
||||
threshold: {
|
||||
below: number
|
||||
color: colorspec
|
||||
}
|
||||
}
|
||||
|
||||
or in a specific series
|
||||
|
||||
$.plot($("#placeholder"), [{ data: [ ... ], threshold: { ... }}])
|
||||
|
||||
The data points below "below" are drawn with the specified color. This
|
||||
makes it easy to mark points below 0, e.g. for budget data.
|
||||
|
||||
Internally, the plugin works by splitting the data into two series,
|
||||
above and below the threshold. The extra series below the threshold
|
||||
will have its label cleared and the special "originSeries" attribute
|
||||
set to the original series. You may need to check for this in hover
|
||||
events.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
var options = {
|
||||
series: { threshold: null } // or { below: number, color: color spec}
|
||||
};
|
||||
|
||||
function init(plot) {
|
||||
function thresholdData(plot, s, datapoints) {
|
||||
if (!s.threshold)
|
||||
return;
|
||||
|
||||
var ps = datapoints.pointsize, i, x, y, p, prevp,
|
||||
thresholded = $.extend({}, s); // note: shallow copy
|
||||
|
||||
thresholded.datapoints = { points: [], pointsize: ps };
|
||||
thresholded.label = null;
|
||||
thresholded.color = s.threshold.color;
|
||||
thresholded.threshold = null;
|
||||
thresholded.originSeries = s;
|
||||
thresholded.data = [];
|
||||
|
||||
var below = s.threshold.below,
|
||||
origpoints = datapoints.points,
|
||||
addCrossingPoints = s.lines.show;
|
||||
|
||||
threspoints = [];
|
||||
newpoints = [];
|
||||
|
||||
for (i = 0; i < origpoints.length; i += ps) {
|
||||
x = origpoints[i]
|
||||
y = origpoints[i + 1];
|
||||
|
||||
prevp = p;
|
||||
if (y < below)
|
||||
p = threspoints;
|
||||
else
|
||||
p = newpoints;
|
||||
|
||||
if (addCrossingPoints && prevp != p && x != null
|
||||
&& i > 0 && origpoints[i - ps] != null) {
|
||||
var interx = (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]) * (below - y) + x;
|
||||
prevp.push(interx);
|
||||
prevp.push(below);
|
||||
for (m = 2; m < ps; ++m)
|
||||
prevp.push(origpoints[i + m]);
|
||||
|
||||
p.push(null); // start new segment
|
||||
p.push(null);
|
||||
for (m = 2; m < ps; ++m)
|
||||
p.push(origpoints[i + m]);
|
||||
p.push(interx);
|
||||
p.push(below);
|
||||
for (m = 2; m < ps; ++m)
|
||||
p.push(origpoints[i + m]);
|
||||
}
|
||||
|
||||
p.push(x);
|
||||
p.push(y);
|
||||
}
|
||||
|
||||
datapoints.points = newpoints;
|
||||
thresholded.datapoints.points = threspoints;
|
||||
|
||||
if (thresholded.datapoints.points.length > 0)
|
||||
plot.getData().push(thresholded);
|
||||
|
||||
// FIXME: there are probably some edge cases left in bars
|
||||
}
|
||||
|
||||
plot.hooks.processDatapoints.push(thresholdData);
|
||||
}
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: 'threshold',
|
||||
version: '1.0'
|
||||
});
|
||||
})(jQuery);
|
|
@ -1,76 +0,0 @@
|
|||
Frequently asked questions
|
||||
--------------------------
|
||||
|
||||
Q: How much data can Flot cope with?
|
||||
|
||||
A: Flot will happily draw everything you send to it so the answer
|
||||
depends on the browser. The excanvas emulation used for IE (built with
|
||||
VML) makes IE by far the slowest browser so be sure to test with that
|
||||
if IE users are in your target group.
|
||||
|
||||
1000 points is not a problem, but as soon as you start having more
|
||||
points than the pixel width, you should probably start thinking about
|
||||
downsampling/aggregation as this is near the resolution limit of the
|
||||
chart anyway. If you downsample server-side, you also save bandwidth.
|
||||
|
||||
|
||||
Q: Flot isn't working when I'm using JSON data as source!
|
||||
|
||||
A: Actually, Flot loves JSON data, you just got the format wrong.
|
||||
Double check that you're not inputting strings instead of numbers,
|
||||
like [["0", "-2.13"], ["5", "4.3"]]. This is most common mistake, and
|
||||
the error might not show up immediately because Javascript can do some
|
||||
conversion automatically.
|
||||
|
||||
|
||||
Q: Can I export the graph?
|
||||
|
||||
A: This is a limitation of the canvas technology. There's a hook in
|
||||
the canvas object for getting an image out, but you won't get the tick
|
||||
labels. And it's not likely to be supported by IE. At this point, your
|
||||
best bet is probably taking a screenshot, e.g. with PrtScn.
|
||||
|
||||
|
||||
Q: The bars are all tiny in time mode?
|
||||
|
||||
A: It's not really possible to determine the bar width automatically.
|
||||
So you have to set the width with the barWidth option which is NOT in
|
||||
pixels, but in the units of the x axis (or the y axis for horizontal
|
||||
bars). For time mode that's milliseconds so the default value of 1
|
||||
makes the bars 1 millisecond wide.
|
||||
|
||||
|
||||
Q: Can I use Flot with libraries like Mootools or Prototype?
|
||||
|
||||
A: Yes, Flot supports it out of the box and it's easy! Just use jQuery
|
||||
instead of $, e.g. call jQuery.plot instead of $.plot and use
|
||||
jQuery(something) instead of $(something). As a convenience, you can
|
||||
put in a DOM element for the graph placeholder where the examples and
|
||||
the API documentation are using jQuery objects.
|
||||
|
||||
Depending on how you include jQuery, you may have to add one line of
|
||||
code to prevent jQuery from overwriting functions from the other
|
||||
libraries, see the documentation in jQuery ("Using jQuery with other
|
||||
libraries") for details.
|
||||
|
||||
|
||||
Q: Flot doesn't work with [insert name of Javascript UI framework]!
|
||||
|
||||
A: The only non-standard thing used by Flot is the canvas tag;
|
||||
otherwise it is simply a series of absolute positioned divs within the
|
||||
placeholder tag you put in. If this is not working, it's probably
|
||||
because the framework you're using is doing something weird with the
|
||||
DOM, or you're using it the wrong way.
|
||||
|
||||
A common problem is that there's display:none on a container until the
|
||||
user does something. Many tab widgets work this way, and there's
|
||||
nothing wrong with it - you just can't call Flot inside a display:none
|
||||
container as explained in the README so you need to hold off the Flot
|
||||
call until the container is actually displayed (or use
|
||||
visibility:hidden instead of display:none or move the container
|
||||
off-screen).
|
||||
|
||||
If you find there's a specific thing we can do to Flot to help, feel
|
||||
free to submit a bug report. Otherwise, you're welcome to ask for help
|
||||
on the forum/mailing list, but please don't submit a bug report to
|
||||
Flot.
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 2007-2009 IOLA and Ole Laursen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,15 +0,0 @@
|
|||
# Makefile for generating minified files
|
||||
|
||||
YUICOMPRESSOR_PATH=../yuicompressor-2.3.5.jar
|
||||
|
||||
# if you need another compressor path, just copy the above line to a
|
||||
# file called Makefile.local, customize it and you're good to go
|
||||
-include Makefile.local
|
||||
|
||||
.PHONY: all
|
||||
|
||||
# we cheat and process all .js files instead of an exhaustive list
|
||||
all: $(patsubst %.js,%.min.js,$(filter-out %.min.js,$(wildcard *.js)))
|
||||
|
||||
%.min.js: %.js
|
||||
java -jar $(YUICOMPRESSOR_PATH) $< -o $@
|
|
@ -1,439 +0,0 @@
|
|||
Flot x.x
|
||||
--------
|
||||
|
||||
API changes:
|
||||
|
||||
Multiple axes support. Code using dual axes should be changed from
|
||||
using x2axis/y2axis in the options to using an array (although
|
||||
backwards-compatibility hooks are in place). For instance,
|
||||
|
||||
{
|
||||
xaxis: { ... }, x2axis: { ... },
|
||||
yaxis: { ... }, y2axis: { ... }
|
||||
}
|
||||
|
||||
becomes
|
||||
|
||||
{
|
||||
xaxes: [ { ... }, { ... } ],
|
||||
yaxes: [ { ... }, { ... } ]
|
||||
}
|
||||
|
||||
Note that if you're just using one axis, continue to use the
|
||||
xaxis/yaxis directly (it now sets the default settings for the
|
||||
arrays). Plugins touching the axes must be ported to take the extra
|
||||
axes into account, a couple of helper functions have been added for
|
||||
that purpose, check the source.
|
||||
|
||||
"tickColor" on the grid options is now deprecated in favour of a
|
||||
corresponding option on the axes, so { grid: { tickColor: "#000" }}
|
||||
becomes { xaxis: { tickColor: "#000"}, yaxis: { tickColor: "#000"} },
|
||||
but if you just configure a base color Flot will now autogenerate a
|
||||
tick color by adding transparency. Backwards-compatibility hooks are
|
||||
in place.
|
||||
|
||||
Changes:
|
||||
|
||||
- Support for specifying a bottom for each point for line charts when
|
||||
filling them, this means that an arbitrary bottom can be used
|
||||
instead of just the x axis (based on patches patiently provided by
|
||||
Roman V. Prikhodchenko).
|
||||
- New fillbetween plugin that can compute a bottom for a series from
|
||||
another series, useful for filling areas between lines (see new
|
||||
example percentiles.html for a use case).
|
||||
- More predictable handling of gaps for the stacking plugin, now all
|
||||
undefined ranges are skipped.
|
||||
- Stacking plugin can stack horizontal bar charts.
|
||||
- Navigate plugin now redraws the plot while panning instead of only
|
||||
after the fact (can be disabled by setting the pan.frameRate option
|
||||
to null), raised by lastthemy (issue 235).
|
||||
- Date formatter now accepts %0m and %0d to get a zero-padded month or
|
||||
day (issue raised by Maximillian Dornseif).
|
||||
- Revamped internals to support an unlimited number of axes, not just
|
||||
dual (sponsored by Flight Data Services,
|
||||
www.flightdataservices.com).
|
||||
- New setting on axes, "tickLength", to control the size of ticks or
|
||||
turn them off without turning off the labels.
|
||||
- Axis labels are now put in container divs with classes, for instance
|
||||
labels in the x axes can be reached via ".xAxis .tickLabel".
|
||||
- Support for setting the color of an axis (sponsored by Flight Data
|
||||
Services, www.flightdataservices.com).
|
||||
- Tick color is now auto-generated as the base color with some
|
||||
transparency (unless you override it).
|
||||
- Support for aligning ticks in the axes with "alignTicksWithAxis" to
|
||||
ensure that they appear next to each other rather than in between,
|
||||
at the expense of possibly awkward tick steps (sponsored by Flight
|
||||
Data Services, www.flightdataservices.com).
|
||||
- Support for customizing the point type through a callback when
|
||||
plotting points and new symbol plugin with some predefined point
|
||||
types (sponsored by Utility Data Corporation).
|
||||
|
||||
- New hooks: drawSeries
|
||||
|
||||
Bug fixes:
|
||||
|
||||
- Fixed problem with findNearbyItem and bars on top of each other
|
||||
(reported by ragingchikn, issue 242).
|
||||
- Fixed problem with ticks and the border (based on patch from
|
||||
ultimatehustler69, issue 236).
|
||||
- Fixed problem with plugins adding options to the series objects.
|
||||
- Fixed a problem introduced in 0.6 with specifying a gradient with {
|
||||
brightness: x, opacity: y }.
|
||||
- Don't use $.browser.msie, check for getContext on the created canvas
|
||||
element instead and try to use excanvas if it's not found.
|
||||
- highlight(s, index) was looking up the point in the original s.data
|
||||
instead of in the computed datapoints array, which breaks with
|
||||
plugins that modify the datapoints (such as the stacking plugin).
|
||||
Issue 316 reported by curlypaul924.
|
||||
- More robust handling of axis from data passed in from getData()
|
||||
(problem reported by Morgan).
|
||||
- Fixed problem with turning off bar outline (issue 253, fix by Jordi
|
||||
Castells).
|
||||
- Check the selection passed into setSelection in the selection
|
||||
plugin, to guard against errors when synchronizing plots (fix by Lau
|
||||
Bech Lauritzen).
|
||||
- Fix bug in crosshair code with mouseout resetting the crosshair even
|
||||
if it is locked (fix by Lau Bech Lauritzen).
|
||||
- Fix bug with points plotting using line width from lines rather than
|
||||
points.
|
||||
|
||||
Flot 0.6
|
||||
--------
|
||||
|
||||
API changes:
|
||||
|
||||
1. Selection support has been moved to a plugin. Thus if you're
|
||||
passing selection: { mode: something }, you MUST include the file
|
||||
jquery.flot.selection.js after jquery.flot.js. This reduces the size
|
||||
of base Flot and makes it easier to customize the selection as well as
|
||||
improving code clarity. The change is based on a patch from andershol.
|
||||
|
||||
2. In the global options specified in the $.plot command,
|
||||
"lines", "points", "bars" and "shadowSize" have been moved to a
|
||||
sub-object called "series", i.e.
|
||||
|
||||
$.plot(placeholder, data, { lines: { show: true }})
|
||||
|
||||
should be changed to
|
||||
|
||||
$.plot(placeholder, data, { series: { lines: { show: true }}})
|
||||
|
||||
All future series-specific options will go into this sub-object to
|
||||
simplify plugin writing. Backward-compatibility code is in place, so
|
||||
old code should not break.
|
||||
|
||||
3. "plothover" no longer provides the original data point, but instead
|
||||
a normalized one, since there may be no corresponding original point.
|
||||
|
||||
4. Due to a bug in previous versions of jQuery, you now need at least
|
||||
jQuery 1.2.6. But if you can, try jQuery 1.3.2 as it got some
|
||||
improvements in event handling speed.
|
||||
|
||||
|
||||
Changes:
|
||||
|
||||
- Added support for disabling interactivity for specific data series
|
||||
(request from Ronald Schouten and Steve Upton).
|
||||
|
||||
- Flot now calls $() on the placeholder and optional legend container
|
||||
passed in so you can specify DOM elements or CSS expressions to make
|
||||
it easier to use Flot with libraries like Prototype or Mootools or
|
||||
through raw JSON from Ajax responses.
|
||||
|
||||
- A new "plotselecting" event is now emitted while the user is making
|
||||
a selection.
|
||||
|
||||
- The "plothover" event is now emitted immediately instead of at most
|
||||
10 times per second, you'll have to put in a setTimeout yourself if
|
||||
you're doing something really expensive on this event.
|
||||
|
||||
- The built-in date formatter can now be accessed as
|
||||
$.plot.formatDate(...) (suggestion by Matt Manela) and even
|
||||
replaced.
|
||||
|
||||
- Added "borderColor" option to the grid (patch from Amaury Chamayou
|
||||
and patch from Mike R. Williamson).
|
||||
|
||||
- Added support for gradient backgrounds for the grid, take a look at
|
||||
the "setting options" example (based on patch from Amaury Chamayou,
|
||||
issue 90).
|
||||
|
||||
- Gradient bars (suggestion by stefpet).
|
||||
|
||||
- Added a "plotunselected" event which is triggered when the selection
|
||||
is removed, see "selection" example (suggestion by Meda Ugo);
|
||||
|
||||
- The option legend.margin can now specify horizontal and vertical
|
||||
margins independently (suggestion by someone who's annoyed).
|
||||
|
||||
- Data passed into Flot is now copied to a new canonical format to
|
||||
enable further processing before it hits the drawing routines. As a
|
||||
side-effect, this should make Flot more robust in the face of bad
|
||||
data (and fixes issue 112).
|
||||
|
||||
- Step-wise charting: line charts have a new option "steps" that when
|
||||
set to true connects the points with horizontal/vertical steps
|
||||
instead of diagonal lines.
|
||||
|
||||
- The legend labelFormatter now passes the series in addition to just
|
||||
the label (suggestion by Vincent Lemeltier).
|
||||
|
||||
- Horizontal bars (based on patch by Jason LeBrun).
|
||||
|
||||
- Support for partial bars by specifying a third coordinate, i.e. they
|
||||
don't have to start from the axis. This can be used to make stacked
|
||||
bars.
|
||||
|
||||
- New option to disable the (grid.show).
|
||||
|
||||
- Added pointOffset method for converting a point in data space to an
|
||||
offset within the placeholder.
|
||||
|
||||
- Plugin system: register an init method in the $.flot.plugins array
|
||||
to get started, see PLUGINS.txt for details on how to write plugins
|
||||
(it's easy). There are also some extra methods to enable access to
|
||||
internal state.
|
||||
|
||||
- Hooks: you can register functions that are called while Flot is
|
||||
crunching the data and doing the plot. This can be used to modify
|
||||
Flot without changing the source, useful for writing plugins. Some
|
||||
hooks are defined, more are likely to come.
|
||||
|
||||
- Threshold plugin: you can set a threshold and a color, and the data
|
||||
points below that threshold will then get the color. Useful for
|
||||
marking data below 0, for instance.
|
||||
|
||||
- Stack plugin: you can specify a stack key for each series to have
|
||||
them summed. This is useful for drawing additive/cumulative graphs
|
||||
with bars and (currently unfilled) lines.
|
||||
|
||||
- Crosshairs plugin: trace the mouse position on the axes, enable with
|
||||
crosshair: { mode: "x"} (see the new tracking example for a use).
|
||||
|
||||
- Image plugin: plot prerendered images.
|
||||
|
||||
- Navigation plugin for panning and zooming a plot.
|
||||
|
||||
- More configurable grid.
|
||||
|
||||
- Axis transformation support, useful for non-linear plots, e.g. log
|
||||
axes and compressed time axes (like omitting weekends).
|
||||
|
||||
- Support for twelve-hour date formatting (patch by Forrest Aldridge).
|
||||
|
||||
- The color parsing code in Flot has been cleaned up and split out so
|
||||
it's now available as a separate jQuery plugin. It's included inline
|
||||
in the Flot source to make dependency managing easier. This also
|
||||
makes it really easy to use the color helpers in Flot plugins.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
- Fixed two corner-case bugs when drawing filled curves (report and
|
||||
analysis by Joshua Varner).
|
||||
- Fix auto-adjustment code when setting min to 0 for an axis where the
|
||||
dataset is completely flat on that axis (report by chovy).
|
||||
- Fixed a bug with passing in data from getData to setData when the
|
||||
secondary axes are used (issue 65, reported by nperelman).
|
||||
- Fixed so that it is possible to turn lines off when no other chart
|
||||
type is shown (based on problem reported by Glenn Vanderburg), and
|
||||
fixed so that setting lineWidth to 0 also hides the shadow (based on
|
||||
problem reported by Sergio Nunes).
|
||||
- Updated mousemove position expression to the latest from jQuery (bug
|
||||
reported by meyuchas).
|
||||
- Use CSS borders instead of background in legend (fix printing issue 25
|
||||
and 45).
|
||||
- Explicitly convert axis min/max to numbers.
|
||||
- Fixed a bug with drawing marking lines with different colors
|
||||
(reported by Khurram).
|
||||
- Fixed a bug with returning y2 values in the selection event (fix
|
||||
by exists, issue 75).
|
||||
- Only set position relative on placeholder if it hasn't already a
|
||||
position different from static (reported by kyberneticist, issue 95).
|
||||
- Don't round markings to prevent sub-pixel problems (reported by Dan
|
||||
Lipsitt).
|
||||
- Make the grid border act similarly to a regular CSS border, i.e.
|
||||
prevent it from overlapping the plot itself. This also fixes a
|
||||
problem with anti-aliasing when the width is 1 pixel (reported by
|
||||
Anthony Ettinger).
|
||||
- Imported version 3 of excanvas and fixed two issues with the newer
|
||||
version. Hopefully, this will make Flot work with IE8 (nudge by
|
||||
Fabien Menager, further analysis by Booink, issue 133).
|
||||
- Changed the shadow code for lines to hopefully look a bit better
|
||||
with vertical lines.
|
||||
- Round tick positions to avoid possible problems with fractions
|
||||
(suggestion by Fred, issue 130).
|
||||
- Made the heuristic for determining how many ticks to aim for a bit
|
||||
smarter.
|
||||
- Fix for uneven axis margins (report and patch by Paul Kienzle) and
|
||||
snapping to ticks (concurrent report and patch by lifthrasiir).
|
||||
- Fixed bug with slicing in findNearbyItems (patch by zollman).
|
||||
- Make heuristic for x axis label widths more dynamic (patch by
|
||||
rickinhethuis).
|
||||
- Make sure points on top take precedence when finding nearby points
|
||||
when hovering (reported by didroe, issue 224).
|
||||
|
||||
Flot 0.5
|
||||
--------
|
||||
|
||||
Backwards API change summary: Timestamps are now in UTC. Also
|
||||
"selected" event -> becomes "plotselected" with new data, the
|
||||
parameters for setSelection are now different (but backwards
|
||||
compatibility hooks are in place), coloredAreas becomes markings with
|
||||
a new interface (but backwards compatibility hooks are in place).
|
||||
|
||||
|
||||
Interactivity: added a new "plothover" event and this and the
|
||||
"plotclick" event now returns the closest data item (based on patch by
|
||||
/david, patch by Mark Byers for bar support). See the revamped
|
||||
"interacting with the data" example for some hints on what you can do.
|
||||
|
||||
Highlighting: you can now highlight points and datapoints are
|
||||
autohighlighted when you hover over them (if hovering is turned on).
|
||||
|
||||
Support for dual axis has been added (based on patch by someone who's
|
||||
annoyed and /david). For each data series you can specify which axes
|
||||
it belongs to, and there are two more axes, x2axis and y2axis, to
|
||||
customize. This affects the "selected" event which has been renamed to
|
||||
"plotselected" and spews out { xaxis: { from: -10, to: 20 } ... },
|
||||
setSelection in which the parameters are on a new form (backwards
|
||||
compatible hooks are in place so old code shouldn't break) and
|
||||
markings (formerly coloredAreas).
|
||||
|
||||
Timestamps in time mode are now displayed according to
|
||||
UTC instead of the time zone of the visitor. This affects the way the
|
||||
timestamps should be input; you'll probably have to offset the
|
||||
timestamps according to your local time zone. It also affects any
|
||||
custom date handling code (which basically now should use the
|
||||
equivalent UTC date mehods, e.g. .setUTCMonth() instead of
|
||||
.setMonth().
|
||||
|
||||
Added support for specifying the size of tick labels (axis.labelWidth,
|
||||
axis.labelHeight). Useful for specifying a max label size to keep
|
||||
multiple plots aligned.
|
||||
|
||||
Markings, previously coloredAreas, are now specified as ranges on the
|
||||
axes, like { xaxis: { from: 0, to: 10 }}. Furthermore with markings
|
||||
you can now draw horizontal/vertical lines by setting from and to to
|
||||
the same coordinate (idea from line support patch by by Ryan Funduk).
|
||||
|
||||
The "fill" option can now be a number that specifies the opacity of
|
||||
the fill.
|
||||
|
||||
You can now specify a coordinate as null (like [2, null]) and Flot
|
||||
will take the other coordinate into account when scaling the axes
|
||||
(based on patch by joebno).
|
||||
|
||||
New option for bars "align". Set it to "center" to center the bars on
|
||||
the value they represent.
|
||||
|
||||
setSelection now takes a second parameter which you can use to prevent
|
||||
the method from firing the "plotselected" handler.
|
||||
|
||||
Using the "container" option in legend now overwrites the container
|
||||
element instead of just appending to it (fixes infinite legend bug,
|
||||
reported by several people, fix by Brad Dewey).
|
||||
|
||||
Fixed a bug in calculating spacing around the plot (reported by
|
||||
timothytoe). Fixed a bug in finding max values for all-negative data
|
||||
sets. Prevent the possibility of eternal looping in tick calculations.
|
||||
Fixed a bug when borderWidth is set to 0 (reported by
|
||||
Rob/sanchothefat). Fixed a bug with drawing bars extending below 0
|
||||
(reported by James Hewitt, patch by Ryan Funduk). Fixed a
|
||||
bug with line widths of bars (reported by MikeM). Fixed a bug with
|
||||
'nw' and 'sw' legend positions. Improved the handling of axis
|
||||
auto-scaling with bars. Fixed a bug with multi-line x-axis tick
|
||||
labels (reported by Luca Ciano). IE-fix help by Savage Zhang.
|
||||
|
||||
|
||||
Flot 0.4
|
||||
--------
|
||||
|
||||
API changes: deprecated axis.noTicks in favor of just specifying the
|
||||
number as axis.ticks. So "xaxis: { noTicks: 10 }" becomes
|
||||
"xaxis: { ticks: 10 }"
|
||||
|
||||
Time series support. Specify axis.mode: "time", put in Javascript
|
||||
timestamps as data, and Flot will automatically spit out sensible
|
||||
ticks. Take a look at the two new examples. The format can be
|
||||
customized with axis.timeformat and axis.monthNames, or if that fails
|
||||
with axis.tickFormatter.
|
||||
|
||||
Support for colored background areas via grid.coloredAreas. Specify an
|
||||
array of { x1, y1, x2, y2 } objects or a function that returns these
|
||||
given { xmin, xmax, ymin, ymax }.
|
||||
|
||||
More members on the plot object (report by Chris Davies and others).
|
||||
"getData" for inspecting the assigned settings on data series (e.g.
|
||||
color) and "setData", "setupGrid" and "draw" for updating the contents
|
||||
without a total replot.
|
||||
|
||||
The default number of ticks to aim for is now dependent on the size of
|
||||
the plot in pixels. Support for customizing tick interval sizes
|
||||
directly with axis.minTickSize and axis.tickSize.
|
||||
|
||||
Cleaned up the automatic axis scaling algorithm and fixed how it
|
||||
interacts with ticks. Also fixed a couple of tick-related corner case
|
||||
bugs (one reported by mainstreetmark, another reported by timothytoe).
|
||||
|
||||
The option axis.tickFormatter now takes a function with two
|
||||
parameters, the second parameter is an optional object with
|
||||
information about the axis. It has min, max, tickDecimals, tickSize.
|
||||
|
||||
Added support for segmented lines (based on patch from Michael
|
||||
MacDonald) and for ignoring null and bad values (suggestion from Nick
|
||||
Konidaris and joshwaihi).
|
||||
|
||||
Added support for changing the border width (joebno and safoo).
|
||||
Label colors can be changed via CSS by selecting the tickLabel class.
|
||||
|
||||
Fixed a bug in handling single-item bar series (reported by Emil
|
||||
Filipov). Fixed erratic behaviour when interacting with the plot
|
||||
with IE 7 (reported by Lau Bech Lauritzen). Prevent IE/Safari text
|
||||
selection when selecting stuff on the canvas.
|
||||
|
||||
|
||||
|
||||
Flot 0.3
|
||||
--------
|
||||
|
||||
This is mostly a quick-fix release because jquery.js wasn't included
|
||||
in the previous zip/tarball.
|
||||
|
||||
Support clicking on the plot. Turn it on with grid: { clickable: true },
|
||||
then you get a "plotclick" event on the graph placeholder with the
|
||||
position in units of the plot.
|
||||
|
||||
Fixed a bug in dealing with data where min = max, thanks to Michael
|
||||
Messinides.
|
||||
|
||||
Include jquery.js in the zip/tarball.
|
||||
|
||||
|
||||
Flot 0.2
|
||||
--------
|
||||
|
||||
Added support for putting a background behind the default legend. The
|
||||
default is the partly transparent background color. Added
|
||||
backgroundColor and backgroundOpacity to the legend options to control
|
||||
this.
|
||||
|
||||
The ticks options can now be a callback function that takes one
|
||||
parameter, an object with the attributes min and max. The function
|
||||
should return a ticks array.
|
||||
|
||||
Added labelFormatter option in legend, useful for turning the legend
|
||||
labels into links.
|
||||
|
||||
Fixed a couple of bugs.
|
||||
|
||||
The API should now be fully documented.
|
||||
|
||||
Patch from Guy Fraser to make parts of the code smaller.
|
||||
|
||||
API changes: Moved labelMargin option to grid from x/yaxis.
|
||||
|
||||
|
||||
Flot 0.1
|
||||
--------
|
||||
|
||||
First public release.
|
|
@ -1,105 +0,0 @@
|
|||
Writing plugins
|
||||
---------------
|
||||
|
||||
To make a new plugin, create an init function and a set of options (if
|
||||
needed), stuff it into an object and put it in the $.plot.plugins
|
||||
array. For example:
|
||||
|
||||
function myCoolPluginInit(plot) { plot.coolstring = "Hello!" };
|
||||
var myCoolOptions = { coolstuff: { show: true } }
|
||||
$.plot.plugins.push({ init: myCoolPluginInit, options: myCoolOptions });
|
||||
|
||||
// now when $.plot is called, the returned object will have the
|
||||
// attribute "coolstring"
|
||||
|
||||
Now, given that the plugin might run in many different places, it's
|
||||
a good idea to avoid leaking names. We can avoid this by wrapping the
|
||||
above lines in an anonymous function which we call immediately, like
|
||||
this: (function () { inner code ... })(). To make it even more robust
|
||||
in case $ is not bound to jQuery but some other Javascript library, we
|
||||
can write it as
|
||||
|
||||
(function ($) {
|
||||
// plugin definition
|
||||
// ...
|
||||
})(jQuery);
|
||||
|
||||
Here is a simple debug plugin which alerts each of the series in the
|
||||
plot. It has a single option that control whether it is enabled and
|
||||
how much info to output:
|
||||
|
||||
(function ($) {
|
||||
function init(plot) {
|
||||
var debugLevel = 1;
|
||||
|
||||
function checkDebugEnabled(plot, options) {
|
||||
if (options.debug) {
|
||||
debugLevel = options.debug;
|
||||
|
||||
plot.hooks.processDatapoints.push(alertSeries);
|
||||
}
|
||||
}
|
||||
|
||||
function alertSeries(plot, series, datapoints) {
|
||||
var msg = "series " + series.label;
|
||||
if (debugLevel > 1)
|
||||
msg += " with " + series.data.length + " points";
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
plot.hooks.processOptions.push(checkDebugEnabled);
|
||||
}
|
||||
|
||||
var options = { debug: 0 };
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: options,
|
||||
name: "simpledebug",
|
||||
version: "0.1"
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
We also define "name" and "version". It's not used by Flot, but might
|
||||
be helpful for other plugins in resolving dependencies.
|
||||
|
||||
Put the above in a file named "jquery.flot.debug.js", include it in an
|
||||
HTML page and then it can be used with:
|
||||
|
||||
$.plot($("#placeholder"), [...], { debug: 2 });
|
||||
|
||||
This simple plugin illustrates a couple of points:
|
||||
|
||||
- It uses the anonymous function trick to avoid name pollution.
|
||||
- It can be enabled/disabled through an option.
|
||||
- Variables in the init function can be used to store plot-specific
|
||||
state between the hooks.
|
||||
|
||||
|
||||
Options guidelines
|
||||
==================
|
||||
|
||||
Plugins should always support appropriate options to enable/disable
|
||||
them because the plugin user may have several plots on the same page
|
||||
where only one should use the plugin.
|
||||
|
||||
If the plugin needs series-specific options, you can put them in
|
||||
"series" in the options object, e.g.
|
||||
|
||||
var options = {
|
||||
series: {
|
||||
downsample: {
|
||||
algorithm: null,
|
||||
maxpoints: 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Then they will be copied by Flot into each series, providing the
|
||||
defaults in case the plugin user doesn't specify any. Again, in most
|
||||
cases it's probably a good idea if the plugin is turned off rather
|
||||
than on per default, just like most of the powerful features in Flot.
|
||||
|
||||
Think hard and long about naming the options. These names are going to
|
||||
be public API, and code is going to depend on them if the plugin is
|
||||
successful.
|
|
@ -1,81 +0,0 @@
|
|||
About
|
||||
-----
|
||||
|
||||
Flot is a Javascript plotting library for jQuery. Read more at the
|
||||
website:
|
||||
|
||||
http://code.google.com/p/flot/
|
||||
|
||||
Take a look at the examples linked from above, they should give a good
|
||||
impression of what Flot can do and the source code of the examples is
|
||||
probably the fastest way to learn how to use Flot.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Just include the Javascript file after you've included jQuery.
|
||||
|
||||
Note that you need to get a version of Excanvas (e.g. the one bundled
|
||||
with Flot) which is canvas emulation on Internet Explorer. You can
|
||||
include the excanvas script like this:
|
||||
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="excanvas.pack.js"></script><![endif]-->
|
||||
|
||||
If it's not working on your development IE 6.0, check that it has
|
||||
support for VML which excanvas is relying on. It appears that some
|
||||
stripped down versions used for test environments on virtual machines
|
||||
lack the VML support.
|
||||
|
||||
Also note that you need at least jQuery 1.2.6 (but at least jQuery
|
||||
1.3.2 is recommended for interactive charts because of performance
|
||||
improvements in event handling).
|
||||
|
||||
|
||||
Basic usage
|
||||
-----------
|
||||
|
||||
Create a placeholder div to put the graph in:
|
||||
|
||||
<div id="placeholder"></div>
|
||||
|
||||
You need to set the width and height of this div, otherwise the plot
|
||||
library doesn't know how to scale the graph. You can do it inline like
|
||||
this:
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
You can also do it with an external stylesheet. Make sure that the
|
||||
placeholder isn't within something with a display:none CSS property -
|
||||
in that case, Flot has trouble measuring label dimensions which
|
||||
results in garbled looks and might have trouble measuring the
|
||||
placeholder dimensions which is fatal (it'll throw an exception).
|
||||
|
||||
Then when the div is ready in the DOM, which is usually on document
|
||||
ready, run the plot function:
|
||||
|
||||
$.plot($("#placeholder"), data, options);
|
||||
|
||||
Here, data is an array of data series and options is an object with
|
||||
settings if you want to customize the plot. Take a look at the
|
||||
examples for some ideas of what to put in or look at the reference
|
||||
in the file "API.txt". Here's a quick example that'll draw a line from
|
||||
(0, 0) to (1, 1):
|
||||
|
||||
$.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } });
|
||||
|
||||
The plot function immediately draws the chart and then returns a plot
|
||||
object with a couple of methods.
|
||||
|
||||
|
||||
What's with the name?
|
||||
---------------------
|
||||
|
||||
First: it's pronounced with a short o, like "plot". Not like "flawed".
|
||||
|
||||
So "Flot" rhymes with "plot".
|
||||
|
||||
And if you look up "flot" in a Danish-to-English dictionary, some up
|
||||
the words that come up are "good-looking", "attractive", "stylish",
|
||||
"smart", "impressive", "extravagant". One of the main goals with Flot
|
||||
is pretty looks.
|
|
@ -1,221 +0,0 @@
|
|||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 32
|
||||
/svn/!svn/ver/266/trunk/examples
|
||||
END
|
||||
basic.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 43
|
||||
/svn/!svn/ver/264/trunk/examples/basic.html
|
||||
END
|
||||
visitors.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 46
|
||||
/svn/!svn/ver/264/trunk/examples/visitors.html
|
||||
END
|
||||
arrow-left.gif
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 47
|
||||
/svn/!svn/ver/187/trunk/examples/arrow-left.gif
|
||||
END
|
||||
data-japan-gdp-growth.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 59
|
||||
/svn/!svn/ver/174/trunk/examples/data-japan-gdp-growth.json
|
||||
END
|
||||
symbols.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 45
|
||||
/svn/!svn/ver/264/trunk/examples/symbols.html
|
||||
END
|
||||
multiple-axes.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 51
|
||||
/svn/!svn/ver/264/trunk/examples/multiple-axes.html
|
||||
END
|
||||
navigate.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 46
|
||||
/svn/!svn/ver/264/trunk/examples/navigate.html
|
||||
END
|
||||
hs-2004-27-a-large_web.jpg
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 59
|
||||
/svn/!svn/ver/177/trunk/examples/hs-2004-27-a-large_web.jpg
|
||||
END
|
||||
graph-types.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 49
|
||||
/svn/!svn/ver/264/trunk/examples/graph-types.html
|
||||
END
|
||||
data-eu-gdp-growth-1.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 58
|
||||
/svn/!svn/ver/175/trunk/examples/data-eu-gdp-growth-1.json
|
||||
END
|
||||
data-eu-gdp-growth-3.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 58
|
||||
/svn/!svn/ver/175/trunk/examples/data-eu-gdp-growth-3.json
|
||||
END
|
||||
data-eu-gdp-growth.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 56
|
||||
/svn/!svn/ver/174/trunk/examples/data-eu-gdp-growth.json
|
||||
END
|
||||
arrow-right.gif
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 48
|
||||
/svn/!svn/ver/187/trunk/examples/arrow-right.gif
|
||||
END
|
||||
interacting.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 49
|
||||
/svn/!svn/ver/264/trunk/examples/interacting.html
|
||||
END
|
||||
data-eu-gdp-growth-5.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 58
|
||||
/svn/!svn/ver/175/trunk/examples/data-eu-gdp-growth-5.json
|
||||
END
|
||||
arrow-up.gif
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 45
|
||||
/svn/!svn/ver/187/trunk/examples/arrow-up.gif
|
||||
END
|
||||
pie.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 41
|
||||
/svn/!svn/ver/264/trunk/examples/pie.html
|
||||
END
|
||||
percentiles.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 49
|
||||
/svn/!svn/ver/264/trunk/examples/percentiles.html
|
||||
END
|
||||
turning-series.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 52
|
||||
/svn/!svn/ver/264/trunk/examples/turning-series.html
|
||||
END
|
||||
image.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 43
|
||||
/svn/!svn/ver/264/trunk/examples/image.html
|
||||
END
|
||||
zooming.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 45
|
||||
/svn/!svn/ver/264/trunk/examples/zooming.html
|
||||
END
|
||||
ajax.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 42
|
||||
/svn/!svn/ver/264/trunk/examples/ajax.html
|
||||
END
|
||||
data-usa-gdp-growth.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 57
|
||||
/svn/!svn/ver/174/trunk/examples/data-usa-gdp-growth.json
|
||||
END
|
||||
selection.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 47
|
||||
/svn/!svn/ver/264/trunk/examples/selection.html
|
||||
END
|
||||
thresholding.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 50
|
||||
/svn/!svn/ver/264/trunk/examples/thresholding.html
|
||||
END
|
||||
time.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 42
|
||||
/svn/!svn/ver/264/trunk/examples/time.html
|
||||
END
|
||||
arrow-down.gif
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 47
|
||||
/svn/!svn/ver/187/trunk/examples/arrow-down.gif
|
||||
END
|
||||
layout.css
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 43
|
||||
/svn/!svn/ver/266/trunk/examples/layout.css
|
||||
END
|
||||
annotating.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 48
|
||||
/svn/!svn/ver/264/trunk/examples/annotating.html
|
||||
END
|
||||
tracking.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 46
|
||||
/svn/!svn/ver/264/trunk/examples/tracking.html
|
||||
END
|
||||
stacking.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 46
|
||||
/svn/!svn/ver/264/trunk/examples/stacking.html
|
||||
END
|
||||
data-eu-gdp-growth-2.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 58
|
||||
/svn/!svn/ver/175/trunk/examples/data-eu-gdp-growth-2.json
|
||||
END
|
||||
interacting-axes.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 54
|
||||
/svn/!svn/ver/264/trunk/examples/interacting-axes.html
|
||||
END
|
||||
data-eu-gdp-growth-4.json
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 58
|
||||
/svn/!svn/ver/175/trunk/examples/data-eu-gdp-growth-4.json
|
||||
END
|
||||
setting-options.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 53
|
||||
/svn/!svn/ver/264/trunk/examples/setting-options.html
|
||||
END
|
||||
index.html
|
||||
K 25
|
||||
svn:wc:ra_dav:version-url
|
||||
V 43
|
||||
/svn/!svn/ver/264/trunk/examples/index.html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 8
|
||||
text/css
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,5 +0,0 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 9
|
||||
text/html
|
||||
END
|
|
@ -1,143 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>Example of loading data dynamically with AJAX. Percentage change in GDP (source: <a href="http://epp.eurostat.ec.europa.eu/tgm/table.do?tab=table&init=1&plugin=1&language=en&pcode=tsieb020">Eurostat</a>). Click the buttons below.</p>
|
||||
|
||||
<p>The data is fetched over HTTP, in this case directly from text
|
||||
files. Usually the URL would point to some web server handler
|
||||
(e.g. a PHP page or Java/.NET/Python/Ruby on Rails handler) that
|
||||
extracts it from a database and serializes it to JSON.</p>
|
||||
|
||||
<p>
|
||||
<input class="fetchSeries" type="button" value="First dataset"> -
|
||||
<a href="data-eu-gdp-growth.json">data</a> -
|
||||
<span></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input class="fetchSeries" type="button" value="Second dataset"> -
|
||||
<a href="data-japan-gdp-growth.json">data</a> -
|
||||
<span></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input class="fetchSeries" type="button" value="Third dataset"> -
|
||||
<a href="data-usa-gdp-growth.json">data</a> -
|
||||
<span></span>
|
||||
</p>
|
||||
|
||||
<p>If you combine AJAX with setTimeout, you can poll the server
|
||||
for new data.</p>
|
||||
|
||||
<p>
|
||||
<input class="dataUpdate" type="button" value="Poll for data">
|
||||
</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var options = {
|
||||
lines: { show: true },
|
||||
points: { show: true },
|
||||
xaxis: { tickDecimals: 0, tickSize: 1 }
|
||||
};
|
||||
var data = [];
|
||||
var placeholder = $("#placeholder");
|
||||
|
||||
$.plot(placeholder, data, options);
|
||||
|
||||
|
||||
// fetch one series, adding to what we got
|
||||
var alreadyFetched = {};
|
||||
|
||||
$("input.fetchSeries").click(function () {
|
||||
var button = $(this);
|
||||
|
||||
// find the URL in the link right next to us
|
||||
var dataurl = button.siblings('a').attr('href');
|
||||
|
||||
// then fetch the data with jQuery
|
||||
function onDataReceived(series) {
|
||||
// extract the first coordinate pair so you can see that
|
||||
// data is now an ordinary Javascript object
|
||||
var firstcoordinate = '(' + series.data[0][0] + ', ' + series.data[0][1] + ')';
|
||||
|
||||
button.siblings('span').text('Fetched ' + series.label + ', first point: ' + firstcoordinate);
|
||||
|
||||
// let's add it to our current data
|
||||
if (!alreadyFetched[series.label]) {
|
||||
alreadyFetched[series.label] = true;
|
||||
data.push(series);
|
||||
}
|
||||
|
||||
// and plot all we got
|
||||
$.plot(placeholder, data, options);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: dataurl,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: onDataReceived
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// initiate a recurring data update
|
||||
$("input.dataUpdate").click(function () {
|
||||
// reset data
|
||||
data = [];
|
||||
alreadyFetched = {};
|
||||
|
||||
$.plot(placeholder, data, options);
|
||||
|
||||
var iteration = 0;
|
||||
|
||||
function fetchData() {
|
||||
++iteration;
|
||||
|
||||
function onDataReceived(series) {
|
||||
// we get all the data in one go, if we only got partial
|
||||
// data, we could merge it with what we already got
|
||||
data = [ series ];
|
||||
|
||||
$.plot($("#placeholder"), data, options);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
// usually, we'll just call the same URL, a script
|
||||
// connected to a database, but in this case we only
|
||||
// have static example files so we need to modify the
|
||||
// URL
|
||||
url: "data-eu-gdp-growth-" + iteration + ".json",
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: onDataReceived
|
||||
});
|
||||
|
||||
if (iteration < 5)
|
||||
setTimeout(fetchData, 1000);
|
||||
else {
|
||||
data = [];
|
||||
alreadyFetched = {};
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(fetchData, 1000);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,75 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>Flot has support for simple background decorations such as
|
||||
lines and rectangles. They can be useful for marking up certain
|
||||
areas. You can easily add any HTML you need with standard DOM
|
||||
manipulation, e.g. for labels. For drawing custom shapes there is
|
||||
also direct access to the canvas.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
// generate a dataset
|
||||
var d1 = [];
|
||||
for (var i = 0; i < 20; ++i)
|
||||
d1.push([i, Math.sin(i)]);
|
||||
|
||||
var data = [{ data: d1, label: "Pressure", color: "#333" }];
|
||||
|
||||
// setup background areas
|
||||
var markings = [
|
||||
{ color: '#f6f6f6', yaxis: { from: 1 } },
|
||||
{ color: '#f6f6f6', yaxis: { to: -1 } },
|
||||
{ color: '#000', lineWidth: 1, xaxis: { from: 2, to: 2 } },
|
||||
{ color: '#000', lineWidth: 1, xaxis: { from: 8, to: 8 } }
|
||||
];
|
||||
|
||||
var placeholder = $("#placeholder");
|
||||
|
||||
// plot it
|
||||
var plot = $.plot(placeholder, data, {
|
||||
bars: { show: true, barWidth: 0.5, fill: 0.9 },
|
||||
xaxis: { ticks: [], autoscaleMargin: 0.02 },
|
||||
yaxis: { min: -2, max: 2 },
|
||||
grid: { markings: markings }
|
||||
});
|
||||
|
||||
// add labels
|
||||
var o;
|
||||
|
||||
o = plot.pointOffset({ x: 2, y: -1.2});
|
||||
// we just append it to the placeholder which Flot already uses
|
||||
// for positioning
|
||||
placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Warming up</div>');
|
||||
|
||||
o = plot.pointOffset({ x: 8, y: -1.2});
|
||||
placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Actual measurements</div>');
|
||||
|
||||
// draw a little arrow on top of the last label to demonstrate
|
||||
// canvas drawing
|
||||
var ctx = plot.getCanvas().getContext("2d");
|
||||
ctx.beginPath();
|
||||
o.left += 4;
|
||||
ctx.moveTo(o.left, o.top);
|
||||
ctx.lineTo(o.left, o.top - 10);
|
||||
ctx.lineTo(o.left + 10, o.top - 5);
|
||||
ctx.lineTo(o.left, o.top);
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.fill();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 916 B |
Before Width: | Height: | Size: 891 B |
Before Width: | Height: | Size: 897 B |
Before Width: | Height: | Size: 916 B |
|
@ -1,38 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>Simple example. You don't need to specify much to get an
|
||||
attractive look. Put in a placeholder, make sure you set its
|
||||
dimensions (otherwise the plot library will barf) and call the
|
||||
plot function with the data. The axes are automatically
|
||||
scaled.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var d1 = [];
|
||||
for (var i = 0; i < 14; i += 0.5)
|
||||
d1.push([i, Math.sin(i)]);
|
||||
|
||||
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
|
||||
|
||||
// a null signifies separate line segments
|
||||
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
|
||||
|
||||
$.plot($("#placeholder"), [ d1, d2, d3 ]);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'Europe (EU27)',
|
||||
data: [[1999, 3.0], [2000, 3.9]]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'Europe (EU27)',
|
||||
data: [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2]]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'Europe (EU27)',
|
||||
data: [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5]]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'Europe (EU27)',
|
||||
data: [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1]]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'Europe (EU27)',
|
||||
data: [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1], [2007, 2.9], [2008, 0.9]]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'Europe (EU27)',
|
||||
data: [[1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1], [2007, 2.9], [2008, 0.9]]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'Japan',
|
||||
data: [[1999, -0.1], [2000, 2.9], [2001, 0.2], [2002, 0.3], [2003, 1.4], [2004, 2.7], [2005, 1.9], [2006, 2.0], [2007, 2.3], [2008, -0.7]]
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
label: 'USA',
|
||||
data: [[1999, 4.4], [2000, 3.7], [2001, 0.8], [2002, 1.6], [2003, 2.5], [2004, 3.6], [2005, 2.9], [2006, 2.8], [2007, 2.0], [2008, 1.1]]
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
<p>Flot supports lines, points, filled areas, bars and any
|
||||
combinations of these, in the same plot and even on the same data
|
||||
series.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var d1 = [];
|
||||
for (var i = 0; i < 14; i += 0.5)
|
||||
d1.push([i, Math.sin(i)]);
|
||||
|
||||
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
|
||||
|
||||
var d3 = [];
|
||||
for (var i = 0; i < 14; i += 0.5)
|
||||
d3.push([i, Math.cos(i)]);
|
||||
|
||||
var d4 = [];
|
||||
for (var i = 0; i < 14; i += 0.1)
|
||||
d4.push([i, Math.sqrt(i * 10)]);
|
||||
|
||||
var d5 = [];
|
||||
for (var i = 0; i < 14; i += 0.5)
|
||||
d5.push([i, Math.sqrt(i)]);
|
||||
|
||||
var d6 = [];
|
||||
for (var i = 0; i < 14; i += 0.5 + Math.random())
|
||||
d6.push([i, Math.sqrt(2*i + Math.sin(i) + 5)]);
|
||||
|
||||
$.plot($("#placeholder"), [
|
||||
{
|
||||
data: d1,
|
||||
lines: { show: true, fill: true }
|
||||
},
|
||||
{
|
||||
data: d2,
|
||||
bars: { show: true }
|
||||
},
|
||||
{
|
||||
data: d3,
|
||||
points: { show: true }
|
||||
},
|
||||
{
|
||||
data: d4,
|
||||
lines: { show: true }
|
||||
},
|
||||
{
|
||||
data: d5,
|
||||
lines: { show: true },
|
||||
points: { show: true }
|
||||
},
|
||||
{
|
||||
data: d6,
|
||||
lines: { show: true, steps: true }
|
||||
}
|
||||
]);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 34 KiB |
|
@ -1,45 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.image.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:400px;height:400px;"></div>
|
||||
|
||||
<p>The Cat's Eye Nebula (<a href="http://hubblesite.org/gallery/album/nebula/pr2004027a/">picture from Hubble</a>).</p>
|
||||
|
||||
<p>With the image plugin, you can plot images. This is for example
|
||||
useful for getting ticks on complex prerendered visualizations.
|
||||
Instead of inputting data points, you put in the images and where
|
||||
their two opposite corners are supposed to be in plot space.</p>
|
||||
|
||||
<p>Images represent a little further complication because you need
|
||||
to make sure they are loaded before you can use them (Flot skips
|
||||
incomplete images). The plugin comes with a couple of helpers
|
||||
for doing that.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var data = [ [ ["hs-2004-27-a-large_web.jpg", -10, -10, 10, 10] ] ];
|
||||
var options = {
|
||||
series: { images: { show: true } },
|
||||
xaxis: { min: -8, max: 4 },
|
||||
yaxis: { min: -8, max: 4 }
|
||||
};
|
||||
|
||||
$.plot.image.loadDataImages(data, options, function () {
|
||||
$.plot($("#placeholder"), data, options);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,46 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<p>Here are some examples for <a href="http://code.google.com/p/flot/">Flot</a>, the Javascript charting library for jQuery:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="basic.html">Basic example</a></li>
|
||||
<li><a href="graph-types.html">Different graph types</a></li>
|
||||
<li><a href="setting-options.html">Setting various options</a> and <a href="annotating.html">annotating a chart</a></li>
|
||||
<li><a href="ajax.html">Updating graphs with AJAX</a></li>
|
||||
</ul>
|
||||
|
||||
<p>Being interactive:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="turning-series.html">Turning series on/off</a></li>
|
||||
<li><a href="selection.html">Rectangular selection support and zooming</a> and <a href="zooming.html">zooming with overview</a></li> (both with selection plugin)
|
||||
<li><a href="interacting.html">Interacting with the data points</a></li>
|
||||
<li><a href="navigate.html">Panning and zooming</a> (with navigation plugin)</li>
|
||||
</ul>
|
||||
|
||||
<p>Various features:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="symbols.html">Using other symbols than circles for points</a> (with symbol plugin)</li>
|
||||
<li><a href="time.html">Plotting time series</a> and <a href="visitors.html">visitors per day with zooming and weekends</a> (with selection plugin)</li>
|
||||
<li><a href="multiple-axes.html">Multiple axes</a> and <a href="interacting-axes.html">interacting with the axes</a></li>
|
||||
<li><a href="thresholding.html">Thresholding the data</a> (with threshold plugin)</li>
|
||||
<li><a href="stacking.html">Stacked charts</a> (with stacking plugin)</li>
|
||||
<li><a href="percentiles.html">Using filled areas to plot percentiles</a> (with fillbetween plugin)</li>
|
||||
<li><a href="tracking.html">Tracking curves with crosshair</a> (with crosshair plugin)</li>
|
||||
<li><a href="image.html">Plotting prerendered images</a> (with image plugin)</li>
|
||||
<li><a href="pie.html">Pie charts</a> (with pie plugin)</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,94 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>With multiple axes, you sometimes need to interact with them. A
|
||||
simple way to do this is to draw the plot, deduce the axis
|
||||
placements and insert a couple of divs on top to catch events.
|
||||
Try clicking an axis.</p>
|
||||
|
||||
<p id="click"></p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
function generate(start, end, fn) {
|
||||
var res = [];
|
||||
for (var i = 0; i <= 100; ++i) {
|
||||
var x = start + i / 100 * (end - start);
|
||||
res.push([x, fn(x)]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
var data = [
|
||||
{ data: generate(0, 10, function (x) { return Math.sqrt(x)}), xaxis: 1, yaxis:1 },
|
||||
{ data: generate(0, 10, function (x) { return Math.sin(x)}), xaxis: 1, yaxis:2 },
|
||||
{ data: generate(0, 10, function (x) { return Math.cos(x)}), xaxis: 1, yaxis:3 },
|
||||
{ data: generate(2, 10, function (x) { return Math.tan(x)}), xaxis: 2, yaxis: 4 }
|
||||
];
|
||||
|
||||
var plot = $.plot($("#placeholder"),
|
||||
data,
|
||||
{
|
||||
xaxes: [
|
||||
{ position: 'bottom' },
|
||||
{ position: 'top'}
|
||||
],
|
||||
yaxes: [
|
||||
{ position: 'left' },
|
||||
{ position: 'left' },
|
||||
{ position: 'right' },
|
||||
{ position: 'left' }
|
||||
]
|
||||
});
|
||||
|
||||
// now for each axis, create a div
|
||||
|
||||
function getBoundingBoxForAxis(plot, axis) {
|
||||
var left = axis.box.left, top = axis.box.top,
|
||||
right = left + axis.box.width, bottom = top + axis.box.height;
|
||||
|
||||
// some ticks may stick out, enlarge the box to encompass all ticks
|
||||
var cls = axis.direction + axis.n + 'Axis';
|
||||
plot.getPlaceholder().find('.' + cls + ' .tickLabel').each(function () {
|
||||
var pos = $(this).position();
|
||||
left = Math.min(pos.left, left);
|
||||
top = Math.min(pos.top, top);
|
||||
right = Math.max(Math.round(pos.left) + $(this).outerWidth(), right);
|
||||
bottom = Math.max(Math.round(pos.top) + $(this).outerHeight(), bottom);
|
||||
});
|
||||
|
||||
return { left: left, top: top, width: right - left, height: bottom - top };
|
||||
}
|
||||
|
||||
$.each(plot.getXAxes().concat(plot.getYAxes()), function (i, axis) {
|
||||
var box = getBoundingBoxForAxis(plot, axis);
|
||||
|
||||
$('<div class="axisTarget" style="position:absolute;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>')
|
||||
.data('axis.direction', axis.direction)
|
||||
.data('axis.n', axis.n)
|
||||
.css({ backgroundColor: "#f00", opacity: 0, cursor: "pointer" })
|
||||
.appendTo(plot.getPlaceholder())
|
||||
.hover(
|
||||
function () { $(this).css({ opacity: 0.10 }) },
|
||||
function () { $(this).css({ opacity: 0 }) }
|
||||
)
|
||||
.click(function () {
|
||||
$("#click").text("You clicked the " + axis.direction + axis.n + "axis!")
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,93 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
<p>One of the goals of Flot is to support user interactions. Try
|
||||
pointing and clicking on the points.</p>
|
||||
|
||||
<p id="hoverdata">Mouse hovers at
|
||||
(<span id="x">0</span>, <span id="y">0</span>). <span id="clickdata"></span></p>
|
||||
|
||||
<p>A tooltip is easy to build with a bit of jQuery code and the
|
||||
data returned from the plot.</p>
|
||||
|
||||
<p><input id="enableTooltip" type="checkbox">Enable tooltip</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var sin = [], cos = [];
|
||||
for (var i = 0; i < 14; i += 0.5) {
|
||||
sin.push([i, Math.sin(i)]);
|
||||
cos.push([i, Math.cos(i)]);
|
||||
}
|
||||
|
||||
var plot = $.plot($("#placeholder"),
|
||||
[ { data: sin, label: "sin(x)"}, { data: cos, label: "cos(x)" } ], {
|
||||
series: {
|
||||
lines: { show: true },
|
||||
points: { show: true }
|
||||
},
|
||||
grid: { hoverable: true, clickable: true },
|
||||
yaxis: { min: -1.2, max: 1.2 }
|
||||
});
|
||||
|
||||
function showTooltip(x, y, contents) {
|
||||
$('<div id="tooltip">' + contents + '</div>').css( {
|
||||
position: 'absolute',
|
||||
display: 'none',
|
||||
top: y + 5,
|
||||
left: x + 5,
|
||||
border: '1px solid #fdd',
|
||||
padding: '2px',
|
||||
'background-color': '#fee',
|
||||
opacity: 0.80
|
||||
}).appendTo("body").fadeIn(200);
|
||||
}
|
||||
|
||||
var previousPoint = null;
|
||||
$("#placeholder").bind("plothover", function (event, pos, item) {
|
||||
$("#x").text(pos.x.toFixed(2));
|
||||
$("#y").text(pos.y.toFixed(2));
|
||||
|
||||
if ($("#enableTooltip:checked").length > 0) {
|
||||
if (item) {
|
||||
if (previousPoint != item.datapoint) {
|
||||
previousPoint = item.datapoint;
|
||||
|
||||
$("#tooltip").remove();
|
||||
var x = item.datapoint[0].toFixed(2),
|
||||
y = item.datapoint[1].toFixed(2);
|
||||
|
||||
showTooltip(item.pageX, item.pageY,
|
||||
item.series.label + " of " + x + " = " + y);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$("#tooltip").remove();
|
||||
previousPoint = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("#placeholder").bind("plotclick", function (event, pos, item) {
|
||||
if (item) {
|
||||
$("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + ".");
|
||||
plot.highlight(item.series, item.datapoint);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,6 +0,0 @@
|
|||
body {
|
||||
font-family: sans-serif;
|
||||
font-size: 16px;
|
||||
margin: 50px;
|
||||
max-width: 800px;
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.navigate.js"></script>
|
||||
<style>
|
||||
#placeholder .button {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
}
|
||||
#placeholder div.button {
|
||||
font-size: smaller;
|
||||
color: #999;
|
||||
background-color: #eee;
|
||||
padding: 2px;
|
||||
}
|
||||
.message {
|
||||
padding-left: 50px;
|
||||
font-size: smaller;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p class="message"></p>
|
||||
|
||||
<p>With the navigate plugin it is easy to add panning and zooming.
|
||||
Drag to pan, double click to zoom (or use the mouse scrollwheel).</p>
|
||||
|
||||
<p>The plugin fires events (useful for synchronizing several
|
||||
plots) and adds a couple of public methods so you can easily build
|
||||
a little user interface around it, like the little buttons at the
|
||||
top right in the plot.</p>
|
||||
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
// generate data set from a parametric function with a fractal
|
||||
// look
|
||||
function sumf(f, t, m) {
|
||||
var res = 0;
|
||||
for (var i = 1; i < m; ++i)
|
||||
res += f(i * i * t) / (i * i);
|
||||
return res;
|
||||
}
|
||||
|
||||
var d1 = [];
|
||||
for (var t = 0; t <= 2 * Math.PI; t += 0.01)
|
||||
d1.push([sumf(Math.cos, t, 10), sumf(Math.sin, t, 10)]);
|
||||
var data = [ d1 ];
|
||||
|
||||
|
||||
var placeholder = $("#placeholder");
|
||||
var options = {
|
||||
series: { lines: { show: true }, shadowSize: 0 },
|
||||
xaxis: { zoomRange: [0.1, 10], panRange: [-10, 10] },
|
||||
yaxis: { zoomRange: [0.1, 10], panRange: [-10, 10] },
|
||||
zoom: {
|
||||
interactive: true
|
||||
},
|
||||
pan: {
|
||||
interactive: true
|
||||
}
|
||||
};
|
||||
|
||||
var plot = $.plot(placeholder, data, options);
|
||||
|
||||
// show pan/zoom messages to illustrate events
|
||||
placeholder.bind('plotpan', function (event, plot) {
|
||||
var axes = plot.getAxes();
|
||||
$(".message").html("Panning to x: " + axes.xaxis.min.toFixed(2)
|
||||
+ " – " + axes.xaxis.max.toFixed(2)
|
||||
+ " and y: " + axes.yaxis.min.toFixed(2)
|
||||
+ " – " + axes.yaxis.max.toFixed(2));
|
||||
});
|
||||
|
||||
placeholder.bind('plotzoom', function (event, plot) {
|
||||
var axes = plot.getAxes();
|
||||
$(".message").html("Zooming to x: " + axes.xaxis.min.toFixed(2)
|
||||
+ " – " + axes.xaxis.max.toFixed(2)
|
||||
+ " and y: " + axes.yaxis.min.toFixed(2)
|
||||
+ " – " + axes.yaxis.max.toFixed(2));
|
||||
});
|
||||
|
||||
// add zoom out button
|
||||
$('<div class="button" style="right:20px;top:20px">zoom out</div>').appendTo(placeholder).click(function (e) {
|
||||
e.preventDefault();
|
||||
plot.zoomOut();
|
||||
});
|
||||
|
||||
// and add panning buttons
|
||||
|
||||
// little helper for taking the repetitive work out of placing
|
||||
// panning arrows
|
||||
function addArrow(dir, right, top, offset) {
|
||||
$('<img class="button" src="arrow-' + dir + '.gif" style="right:' + right + 'px;top:' + top + 'px">').appendTo(placeholder).click(function (e) {
|
||||
e.preventDefault();
|
||||
plot.pan(offset);
|
||||
});
|
||||
}
|
||||
|
||||
addArrow('left', 55, 60, { left: -100 });
|
||||
addArrow('right', 25, 60, { left: 100 });
|
||||
addArrow('up', 40, 45, { top: -100 });
|
||||
addArrow('down', 40, 75, { top: 100 });
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,57 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.fillbetween.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:400px;"></div>
|
||||
|
||||
<p>Height in centimeters of individuals from the US (2003-2006) as function of
|
||||
age in years (source: <a href="http://www.cdc.gov/nchs/data/nhsr/nhsr010.pdf">CDC</a>).
|
||||
The 15%-85%, 25%-75% and 50% percentiles are indicated.</p>
|
||||
|
||||
<p>For each point of a filled curve, you can specify an arbitrary
|
||||
bottom. As this example illustrates, this can be useful for
|
||||
plotting percentiles. If you have the data sets available without
|
||||
appropriate fill bottoms, you can use the fillbetween plugin to
|
||||
compute the data point bottoms automatically.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var males = {'15%': [[2, 88.0], [3, 93.3], [4, 102.0], [5, 108.5], [6, 115.7], [7, 115.6], [8, 124.6], [9, 130.3], [10, 134.3], [11, 141.4], [12, 146.5], [13, 151.7], [14, 159.9], [15, 165.4], [16, 167.8], [17, 168.7], [18, 169.5], [19, 168.0]], '90%': [[2, 96.8], [3, 105.2], [4, 113.9], [5, 120.8], [6, 127.0], [7, 133.1], [8, 139.1], [9, 143.9], [10, 151.3], [11, 161.1], [12, 164.8], [13, 173.5], [14, 179.0], [15, 182.0], [16, 186.9], [17, 185.2], [18, 186.3], [19, 186.6]], '25%': [[2, 89.2], [3, 94.9], [4, 104.4], [5, 111.4], [6, 117.5], [7, 120.2], [8, 127.1], [9, 132.9], [10, 136.8], [11, 144.4], [12, 149.5], [13, 154.1], [14, 163.1], [15, 169.2], [16, 170.4], [17, 171.2], [18, 172.4], [19, 170.8]], '10%': [[2, 86.9], [3, 92.6], [4, 99.9], [5, 107.0], [6, 114.0], [7, 113.5], [8, 123.6], [9, 129.2], [10, 133.0], [11, 140.6], [12, 145.2], [13, 149.7], [14, 158.4], [15, 163.5], [16, 166.9], [17, 167.5], [18, 167.1], [19, 165.3]], 'mean': [[2, 91.9], [3, 98.5], [4, 107.1], [5, 114.4], [6, 120.6], [7, 124.7], [8, 131.1], [9, 136.8], [10, 142.3], [11, 150.0], [12, 154.7], [13, 161.9], [14, 168.7], [15, 173.6], [16, 175.9], [17, 176.6], [18, 176.8], [19, 176.7]], '75%': [[2, 94.5], [3, 102.1], [4, 110.8], [5, 117.9], [6, 124.0], [7, 129.3], [8, 134.6], [9, 141.4], [10, 147.0], [11, 156.1], [12, 160.3], [13, 168.3], [14, 174.7], [15, 178.0], [16, 180.2], [17, 181.7], [18, 181.3], [19, 182.5]], '85%': [[2, 96.2], [3, 103.8], [4, 111.8], [5, 119.6], [6, 125.6], [7, 131.5], [8, 138.0], [9, 143.3], [10, 149.3], [11, 159.8], [12, 162.5], [13, 171.3], [14, 177.5], [15, 180.2], [16, 183.8], [17, 183.4], [18, 183.5], [19, 185.5]], '50%': [[2, 91.9], [3, 98.2], [4, 106.8], [5, 114.6], [6, 120.8], [7, 125.2], [8, 130.3], [9, 137.1], [10, 141.5], [11, 149.4], [12, 153.9], [13, 162.2], [14, 169.0], [15, 174.8], [16, 176.0], [17, 176.8], [18, 176.4], [19, 177.4]]};
|
||||
var females = {'15%': [[2, 84.8], [3, 93.7], [4, 100.6], [5, 105.8], [6, 113.3], [7, 119.3], [8, 124.3], [9, 131.4], [10, 136.9], [11, 143.8], [12, 149.4], [13, 151.2], [14, 152.3], [15, 155.9], [16, 154.7], [17, 157.0], [18, 156.1], [19, 155.4]], '90%': [[2, 95.6], [3, 104.1], [4, 111.9], [5, 119.6], [6, 127.6], [7, 133.1], [8, 138.7], [9, 147.1], [10, 152.8], [11, 161.3], [12, 166.6], [13, 167.9], [14, 169.3], [15, 170.1], [16, 172.4], [17, 169.2], [18, 171.1], [19, 172.4]], '25%': [[2, 87.2], [3, 95.9], [4, 101.9], [5, 107.4], [6, 114.8], [7, 121.4], [8, 126.8], [9, 133.4], [10, 138.6], [11, 146.2], [12, 152.0], [13, 153.8], [14, 155.7], [15, 158.4], [16, 157.0], [17, 158.5], [18, 158.4], [19, 158.1]], '10%': [[2, 84.0], [3, 91.9], [4, 99.2], [5, 105.2], [6, 112.7], [7, 118.0], [8, 123.3], [9, 130.2], [10, 135.0], [11, 141.1], [12, 148.3], [13, 150.0], [14, 150.7], [15, 154.3], [16, 153.6], [17, 155.6], [18, 154.7], [19, 153.1]], 'mean': [[2, 90.2], [3, 98.3], [4, 105.2], [5, 112.2], [6, 119.0], [7, 125.8], [8, 131.3], [9, 138.6], [10, 144.2], [11, 151.3], [12, 156.7], [13, 158.6], [14, 160.5], [15, 162.1], [16, 162.9], [17, 162.2], [18, 163.0], [19, 163.1]], '75%': [[2, 93.2], [3, 101.5], [4, 107.9], [5, 116.6], [6, 122.8], [7, 129.3], [8, 135.2], [9, 143.7], [10, 148.7], [11, 156.9], [12, 160.8], [13, 163.0], [14, 165.0], [15, 165.8], [16, 168.7], [17, 166.2], [18, 167.6], [19, 168.0]], '85%': [[2, 94.5], [3, 102.8], [4, 110.4], [5, 119.0], [6, 125.7], [7, 131.5], [8, 137.9], [9, 146.0], [10, 151.3], [11, 159.9], [12, 164.0], [13, 166.5], [14, 167.5], [15, 168.5], [16, 171.5], [17, 168.0], [18, 169.8], [19, 170.3]], '50%': [[2, 90.2], [3, 98.1], [4, 105.2], [5, 111.7], [6, 118.2], [7, 125.6], [8, 130.5], [9, 138.3], [10, 143.7], [11, 151.4], [12, 156.7], [13, 157.7], [14, 161.0], [15, 162.0], [16, 162.8], [17, 162.2], [18, 162.8], [19, 163.3]]};
|
||||
|
||||
var dataset = [
|
||||
{ label: 'Female mean', data: females['mean'], lines: { show: true }, color: "rgb(255,50,50)" },
|
||||
{ id: 'f15%', data: females['15%'], lines: { show: true, lineWidth: 0, fill: false }, color: "rgb(255,50,50)" },
|
||||
{ id: 'f25%', data: females['25%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(255,50,50)", fillBetween: 'f15%' },
|
||||
{ id: 'f50%', data: females['50%'], lines: { show: true, lineWidth: 0.5, fill: 0.4, shadowSize: 0 }, color: "rgb(255,50,50)", fillBetween: 'f25%' },
|
||||
{ id: 'f75%', data: females['75%'], lines: { show: true, lineWidth: 0, fill: 0.4 }, color: "rgb(255,50,50)", fillBetween: 'f50%' },
|
||||
{ id: 'f85%', data: females['85%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(255,50,50)", fillBetween: 'f75%' },
|
||||
|
||||
{ label: 'Male mean', data: males['mean'], lines: { show: true }, color: "rgb(50,50,255)" },
|
||||
{ id: 'm15%', data: males['15%'], lines: { show: true, lineWidth: 0, fill: false }, color: "rgb(50,50,255)" },
|
||||
{ id: 'm25%', data: males['25%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(50,50,255)", fillBetween: 'm15%' },
|
||||
{ id: 'm50%', data: males['50%'], lines: { show: true, lineWidth: 0.5, fill: 0.4, shadowSize: 0 }, color: "rgb(50,50,255)", fillBetween: 'm25%' },
|
||||
{ id: 'm75%', data: males['75%'], lines: { show: true, lineWidth: 0, fill: 0.4 }, color: "rgb(50,50,255)", fillBetween: 'm50%' },
|
||||
{ id: 'm85%', data: males['85%'], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(50,50,255)", fillBetween: 'm75%' }
|
||||
]
|
||||
|
||||
$.plot($("#placeholder"), dataset, {
|
||||
xaxis: { tickDecimals: 0 },
|
||||
yaxis: { tickFormatter: function (v) { return v + " cm"; } },
|
||||
legend: { position: 'se' }
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,752 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Pie Examples</title>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.pie.js"></script>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
// data
|
||||
/*var data = [
|
||||
{ label: "Series1", data: 10},
|
||||
{ label: "Series2", data: 30},
|
||||
{ label: "Series3", data: 90},
|
||||
{ label: "Series4", data: 70},
|
||||
{ label: "Series5", data: 80},
|
||||
{ label: "Series6", data: 110}
|
||||
];*/
|
||||
/*var data = [
|
||||
{ label: "Series1", data: [[1,10]]},
|
||||
{ label: "Series2", data: [[1,30]]},
|
||||
{ label: "Series3", data: [[1,90]]},
|
||||
{ label: "Series4", data: [[1,70]]},
|
||||
{ label: "Series5", data: [[1,80]]},
|
||||
{ label: "Series6", data: [[1,0]]}
|
||||
];*/
|
||||
var data = [];
|
||||
var series = Math.floor(Math.random()*10)+1;
|
||||
for( var i = 0; i<series; i++)
|
||||
{
|
||||
data[i] = { label: "Series"+(i+1), data: Math.floor(Math.random()*100)+1 }
|
||||
}
|
||||
|
||||
// DEFAULT
|
||||
$.plot($("#default"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 1
|
||||
$.plot($("#graph1"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 2
|
||||
$.plot($("#graph2"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius: 1,
|
||||
label: {
|
||||
show: true,
|
||||
radius: 1,
|
||||
formatter: function(label, series){
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||
},
|
||||
background: { opacity: 0.8 }
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 3
|
||||
$.plot($("#graph3"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius: 1,
|
||||
label: {
|
||||
show: true,
|
||||
radius: 3/4,
|
||||
formatter: function(label, series){
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||
},
|
||||
background: { opacity: 0.5 }
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 4
|
||||
$.plot($("#graph4"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius: 1,
|
||||
label: {
|
||||
show: true,
|
||||
radius: 3/4,
|
||||
formatter: function(label, series){
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||
},
|
||||
background: {
|
||||
opacity: 0.5,
|
||||
color: '#000'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 5
|
||||
$.plot($("#graph5"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius: 3/4,
|
||||
label: {
|
||||
show: true,
|
||||
radius: 3/4,
|
||||
formatter: function(label, series){
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||
},
|
||||
background: {
|
||||
opacity: 0.5,
|
||||
color: '#000'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 6
|
||||
$.plot($("#graph6"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius: 1,
|
||||
label: {
|
||||
show: true,
|
||||
radius: 2/3,
|
||||
formatter: function(label, series){
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||
},
|
||||
threshold: 0.1
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 7
|
||||
$.plot($("#graph7"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
combine: {
|
||||
color: '#999',
|
||||
threshold: 0.1
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 8
|
||||
$.plot($("#graph8"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius:300,
|
||||
label: {
|
||||
show: true,
|
||||
formatter: function(label, series){
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||
},
|
||||
threshold: 0.1
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// GRAPH 9
|
||||
$.plot($("#graph9"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius: 1,
|
||||
tilt: 0.5,
|
||||
label: {
|
||||
show: true,
|
||||
radius: 1,
|
||||
formatter: function(label, series){
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||
},
|
||||
background: { opacity: 0.8 }
|
||||
},
|
||||
combine: {
|
||||
color: '#999',
|
||||
threshold: 0.1
|
||||
}
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
});
|
||||
|
||||
// DONUT
|
||||
$.plot($("#donut"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
innerRadius: 0.5,
|
||||
show: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// INTERACTIVE
|
||||
$.plot($("#interactive"), data,
|
||||
{
|
||||
series: {
|
||||
pie: {
|
||||
show: true
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
hoverable: true,
|
||||
clickable: true
|
||||
}
|
||||
});
|
||||
$("#interactive").bind("plothover", pieHover);
|
||||
$("#interactive").bind("plotclick", pieClick);
|
||||
|
||||
});
|
||||
|
||||
function pieHover(event, pos, obj)
|
||||
{
|
||||
percent = parseFloat(obj.series.percent).toFixed(2);
|
||||
$("#hover").html('<span style="font-weight: bold; color: '+obj.series.color+'">'+obj.series.label+' ('+percent+'%)</span>');
|
||||
}
|
||||
|
||||
function pieClick(event, pos, obj)
|
||||
{
|
||||
percent = parseFloat(obj.series.percent).toFixed(2);
|
||||
alert(''+obj.series.label+': '+percent+'%');
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
* {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
padding: 0 1em 1em 1em;
|
||||
}
|
||||
|
||||
div.graph
|
||||
{
|
||||
width: 400px;
|
||||
height: 300px;
|
||||
float: left;
|
||||
border: 1px dashed gainsboro;
|
||||
}
|
||||
|
||||
label
|
||||
{
|
||||
display: block;
|
||||
margin-left: 400px;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
h2
|
||||
{
|
||||
padding-top: 1em;
|
||||
margin-bottom: 0;
|
||||
clear: both;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
code
|
||||
{
|
||||
display: block;
|
||||
background-color: #eee;
|
||||
border: 1px dashed #999;
|
||||
padding: 0.5em;
|
||||
margin: 0.5em;
|
||||
color: #666;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
code b
|
||||
{
|
||||
color: black;
|
||||
}
|
||||
|
||||
ul
|
||||
{
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
ul li
|
||||
{
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
ul.options li
|
||||
{
|
||||
list-style: none;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
ul li i
|
||||
{
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Pie Examples</h1>
|
||||
|
||||
<h2>Default with Legend</h2>
|
||||
<div id="default" class="graph"></div>
|
||||
<label for="default">
|
||||
Default pie graph with no options set.
|
||||
<code>
|
||||
$.plot($("#default"), data,<br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true<br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Default without Legend</h2>
|
||||
<div id="graph1" class="graph"></div>
|
||||
<label for="graph1">
|
||||
Default pie graph when legend is disabled. Since the labels would normally be outside the container, the graph is resized to fit.
|
||||
<code>
|
||||
$.plot($("#graph1"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
<b>legend: {<br/>
|
||||
show: false<br/>
|
||||
}</b><br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph2</h2>
|
||||
<div id="graph2" class="graph"></div>
|
||||
<label for="graph2">
|
||||
Added a semi-transparent background to the labels and a custom labelFormatter function.
|
||||
<code>
|
||||
$.plot($("#graph2"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
radius: 1,<br/>
|
||||
<b>label: {<br/>
|
||||
show: true,<br/>
|
||||
radius: 1,<br/>
|
||||
formatter: function(label, series){<br/>
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||
},<br/>
|
||||
background: { opacity: 0.8 }<br/>
|
||||
}</b><br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph3</h2>
|
||||
<div id="graph3" class="graph"></div>
|
||||
<label for="graph3">
|
||||
Slightly more transparent label backgrounds and adjusted the radius values to place them within the pie.
|
||||
<code>
|
||||
$.plot($("#graph3"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
radius: 1,<br/>
|
||||
label: {<br/>
|
||||
show: true,<br/>
|
||||
<b>radius: 3/4,</b><br/>
|
||||
formatter: function(label, series){<br/>
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||
},<br/>
|
||||
<b>background: { opacity: 0.5 }</b><br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph4</h2>
|
||||
<div id="graph4" class="graph"></div>
|
||||
<label for="graph4">
|
||||
Semi-transparent, black-colored label background.
|
||||
<code>
|
||||
$.plot($("#graph4"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
radius: 1,<br/>
|
||||
label: {<br/>
|
||||
show: true,<br/>
|
||||
radius: 3/4,<br/>
|
||||
formatter: function(label, series){<br/>
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||
},<br/>
|
||||
background: { <br/>
|
||||
opacity: 0.5,<br/>
|
||||
<b>color: '#000'</b><br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph5</h2>
|
||||
<div id="graph5" class="graph"></div>
|
||||
<label for="graph5">
|
||||
Semi-transparent, black-colored label background placed at pie edge.
|
||||
<code>
|
||||
$.plot($("#graph5"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
<b>radius: 3/4,</b><br/>
|
||||
label: {<br/>
|
||||
show: true,<br/>
|
||||
radius: 3/4,<br/>
|
||||
formatter: function(label, series){<br/>
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||
},<br/>
|
||||
background: { <br/>
|
||||
opacity: 0.5,<br/>
|
||||
color: '#000'<br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph6</h2>
|
||||
<div id="graph6" class="graph"></div>
|
||||
<label for="graph6">
|
||||
Labels can be hidden if the slice is less than a given percentage of the pie (10% in this case).
|
||||
<br><span style="color: red">Note: you may need to refresh the page to see this effect.</span>
|
||||
<code>
|
||||
$.plot($("#graph6"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
<b>radius: 1,</b><br/>
|
||||
label: {<br/>
|
||||
show: true,<br/>
|
||||
<b>radius: 2/3,</b><br/>
|
||||
formatter: function(label, series){<br/>
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||
},<br/>
|
||||
<b>threshold: 0.1</b><br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph7</h2>
|
||||
<div id="graph7" class="graph"></div>
|
||||
<label for="graph7">
|
||||
All slices less than a given percentage of the pie can be combined into a single, larger slice (10% in this case).
|
||||
<br><span style="color: red">Note: you may need to refresh the page to see this effect.</span>
|
||||
<code>
|
||||
$.plot($("#graph7"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
<b>combine: {<br/>
|
||||
color: '#999',<br/>
|
||||
threshold: 0.1<br/>
|
||||
}</b><br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph8</h2>
|
||||
<div id="graph8" class="graph"></div>
|
||||
<label for="graph8">
|
||||
The radius can also be set to a specific size (even larger than the container itself).
|
||||
<code>
|
||||
$.plot($("#graph8"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
<b>radius:300,</b><br/>
|
||||
label: {<br/>
|
||||
show: true,<br/>
|
||||
formatter: function(label, series){<br/>
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||
},<br/>
|
||||
threshold: 0.1<br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Graph9</h2>
|
||||
<div id="graph9" class="graph" style="height: 250px;"></div>
|
||||
<label for="graph9">
|
||||
The pie can be tilted at an angle.
|
||||
<code>
|
||||
$.plot($("#graph9"), data, <br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true,<br/>
|
||||
radius: 1,<br/>
|
||||
<b>tilt: 0.5,</b><br/>
|
||||
label: {<br/>
|
||||
show: true,<br/>
|
||||
radius: 1,<br/>
|
||||
formatter: function(label, series){<br/>
|
||||
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';<br/>
|
||||
},<br/>
|
||||
background: { opacity: 0.8 }<br/>
|
||||
},<br/>
|
||||
combine: {<br/>
|
||||
color: '#999',<br/>
|
||||
threshold: 0.1<br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
legend: {<br/>
|
||||
show: false<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Donut</h2>
|
||||
<div id="donut" class="graph"></div>
|
||||
<label for="donut">
|
||||
A donut hole can be added.
|
||||
<code>
|
||||
$.plot($("#donut"), data,<br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
<b>innerRadius: 0.5,</b><br/>
|
||||
show: true<br/>
|
||||
}<br/>
|
||||
}<br/>
|
||||
});<br/>
|
||||
</code>
|
||||
</label>
|
||||
|
||||
<h2>Interactive</h2>
|
||||
<div id="interactive" class="graph"></div>
|
||||
<label for="interactive">
|
||||
The pie can be made interactive with hover and click events.
|
||||
<code>
|
||||
$.plot($("#interactive"), data,<br/>
|
||||
{<br/>
|
||||
series: {<br/>
|
||||
pie: { <br/>
|
||||
show: true<br/>
|
||||
}<br/>
|
||||
},<br/>
|
||||
<b>grid: {<br/>
|
||||
hoverable: true,<br/>
|
||||
clickable: true<br/>
|
||||
}</b><br/>
|
||||
});<br/>
|
||||
<b>$("#interactive").bind("plothover", pieHover);<br/>
|
||||
$("#interactive").bind("plotclick", pieClick);</b><br/>
|
||||
</code>
|
||||
<div id="hover"></div>
|
||||
</label>
|
||||
|
||||
<h2>Pie Options</h2>
|
||||
<ul class="options">
|
||||
<li style="border-bottom: 1px dotted #ccc;"><b>option:</b> <i>default value</i> - Description of option</li>
|
||||
<li><b>show:</b> <i>false</i> - Enable the plugin and draw as a pie.</li>
|
||||
<li><b>radius:</b> <i>'auto'</i> - Sets the radius of the pie. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the available space (size of the container), otherwise it will use the value as a direct pixel length. If set to 'auto', it will be set to 1 if the legend is enabled and 3/4 if not.</li>
|
||||
<li><b>innerRadius:</b> <i>0</i> - Sets the radius of the donut hole. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the radius, otherwise it will use the value as a direct pixel length.</li>
|
||||
<li><b>startAngle:</b> <i>3/2</i> - Factor of PI used for the starting angle (in radians) It can range between 0 and 2 (where 0 and 2 have the same result).</li>
|
||||
<li><b>tilt:</b> <i>1</i> - Percentage of tilt ranging from 0 and 1, where 1 has no change (fully vertical) and 0 is completely flat (fully horizontal -- in which case nothing actually gets drawn).</li>
|
||||
<li><b>offset:</b> <ul>
|
||||
<li><b>top:</b> <i>0</i> - Pixel distance to move the pie up and down (relative to the center).</li>
|
||||
<li><b>left:</b> <i>'auto'</i> - Pixel distance to move the pie left and right (relative to the center).</li>
|
||||
</ul>
|
||||
<li><b>stroke:</b> <ul>
|
||||
<li><b>color:</b> <i>'#FFF'</i> - Color of the border of each slice. Hexadecimal color definitions are prefered (other formats may or may not work).</li>
|
||||
<li><b>width:</b> <i>1</i> - Pixel width of the border of each slice.</li>
|
||||
</ul>
|
||||
<li><b>label:</b> <ul>
|
||||
<li><b>show:</b> <i>'auto'</i> - Enable/Disable the labels. This can be set to true, false, or 'auto'. When set to 'auto', it will be set to false if the legend is enabled and true if not.</li>
|
||||
<li><b>radius:</b> <i>1</i> - Sets the radius at which to place the labels. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the available space (size of the container), otherwise it will use the value as a direct pixel length.</li>
|
||||
<li><b>threshold:</b> <i>0</i> - Hides the labels of any pie slice that is smaller than the specified percentage (ranging from 0 to 1) i.e. a value of '0.03' will hide all slices 3% or less of the total.</li>
|
||||
<li><b>formatter:</b> <i>[function]</i> - This function specifies how the positioned labels should be formatted, and is applied after the legend's labelFormatter function. The labels can also still be styled using the class "pieLabel" (i.e. ".pieLabel" or "#graph1 .pieLabel").</li>
|
||||
<li><b>radius:</b> <i>1</i> - Sets the radius at which to place the labels. If value is between 0 and 1 (inclusive) then it will use that as a percentage of the available space (size of the container), otherwise it will use the value as a direct pixel length.</li>
|
||||
<li><b>background:</b> <ul>
|
||||
<li><b>color:</b> <i>null</i> - Backgound color of the positioned labels. If null, the plugin will automatically use the color of the slice.</li>
|
||||
<li><b>opacity:</b> <i>0</i> - Opacity of the background for the positioned labels. Acceptable values range from 0 to 1, where 0 is completely transparent and 1 is completely opaque.</li>
|
||||
</ul>
|
||||
</ul>
|
||||
<li><b>combine:</b> <ul>
|
||||
<li><b>threshold:</b> <i>0</i> - Combines all slices that are smaller than the specified percentage (ranging from 0 to 1) i.e. a value of '0.03' will combine all slices 3% or less into one slice).</li>
|
||||
<li><b>color:</b> <i>null</i> - Backgound color of the positioned labels. If null, the plugin will automatically use the color of the first slice to be combined.</li>
|
||||
<li><b>label:</b> <i>'Other'</i> - Label text for the combined slice.</li>
|
||||
</ul>
|
||||
<li><b>highlight:</b> <ul>
|
||||
<li><b>opacity:</b> <i>0.5</i> - Opacity of the highlight overlay on top of the current pie slice. Currently this just uses a white overlay, but support for changing the color of the overlay will also be added at a later date.
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
<h2>Changes/Features</h2>
|
||||
<ul>
|
||||
<li style="list-style: none;"><i>v1.0 - November 20th, 2009 - Brian Medendorp</i></li>
|
||||
<li>The pie plug-in is now part of the Flot repository! This should make it a lot easier to deal with.</li>
|
||||
<li>Added a new option (innerRadius) to add a "donut hole" to the center of the pie, based on comtributions from Anthony Aragues. I was a little reluctant to add this feature because it doesn't work very well with the shadow created for the tilted pie, but figured it was worthwhile for non-tilted pies. Also, excanvas apparently doesn't support compositing, so it will fall back to using the stroke color to fill in the center (but I recommend setting the stroke color to the background color anyway).</li>
|
||||
<li>Changed the lineJoin for the border of the pie slices to use the 'round' option. This should make the center of the pie look better, particularly when there are numerous thin slices.</li>
|
||||
<li>Included a bug fix submitted by btburnett3 to display a slightly smaller slice in the event that the slice is 100% and being rendered with Internet Explorer. I haven't experienced this bug myself, but it doesn't seem to hurt anything so I've included it.</li>
|
||||
<li>The tilt value is now used when calculating the maximum radius of the pie in relation to the height of the container. This should prevent the pie from being smaller than it needed to in some cases, as well as reducing the amount of extra white space generated above and below the pie.</li>
|
||||
<li><b>Hover and Click functionality are now availabe!</b><ul>
|
||||
<li>Thanks to btburnett3 for the original hover functionality and Anthony Aragues for the modification that makes it compatable with excanvas, this was a huge help!</li>
|
||||
<li>Added a new option (highlight opacity) to modify the highlight created when mousing over a slice. Currently this just uses a white overlay, but an option to change the hightlight color will be added when the appropriate functionality becomes available.
|
||||
<li>I had a major setback that required me to practically rebuild the hover/click events from scratch one piece at a time (I discovered that it only worked with a single pie on a page at a time), but the end result ended up being virtually identical to the original, so I'm not quite sure what exactly made it work.</li>
|
||||
<li><span style="color: red;">Warning:</span> There are some minor issues with using this functionality in conjuction with some of the other more advanced features (tilt and donut). When using a donut hole, the inner portion still triggers the events even though that portion of the pie is no longer visible. When tilted, the interactive portions still use the original, untilted version of the pie when determining mouse position (this is because the isPointInPath function apparently doesn't work with transformations), however hover and click both work this way, so the appropriate slice is still highlighted when clicking, and it isn't as noticable of a problem.</li>
|
||||
</ul></li>
|
||||
<li>Included a bug fix submitted by Xavi Ivars to fix array issues when other javascript libraries are included in addition to jQuery</li>
|
||||
<br/>
|
||||
<li style="list-style: none;"><i>v0.4 - July 1st, 2009 - Brian Medendorp</i></li>
|
||||
<li>Each series will now be shown in the legend, even if it's value is zero. The series will not get a positioned label because it will overlap with the other labels present and often makes them unreadable.</li>
|
||||
<li>Data can now be passed in using the standard Flot method using an array of datapoints, the pie plugin will simply use the first y-value that it finds for each series in this case. The plugin uses this datastructure internally, but you can still use the old method of passing in a single numerical value for each series (the plugin will convert it as necessary). This should make it easier to transition from other types of graphs (such as a stacked bar graph) to a pie.</li>
|
||||
<li>The pie can now be tilted at an angle with a new "tilt" option. Acceptable values range from 0-1, where 1 has no change (fully vertical) and 0 is completely flat (fully horizontal -- in which case nothing actually gets drawn). If the plugin determines that it will fit within the canvas, a drop shadow will be drawn under the tilted pie (this also requires a tilt value of 0.8 or less).</li>
|
||||
<br/>
|
||||
<li style="list-style: none;"><i>v0.3.2 - June 25th, 2009 - Brian Medendorp</i></li>
|
||||
<li>Fixed a bug that was causing the pie to be shifted too far left or right when the legend is showing in some cases.</li>
|
||||
<br/>
|
||||
<li style="list-style: none;"><i>v0.3.1 - June 24th, 2009 - Brian Medendorp</i></li>
|
||||
<li>Fixed a bug that was causing nothing to be drawn and generating a javascript error if any of the data values were set to zero.</li>
|
||||
<br/>
|
||||
<li style="list-style: none;"><i>v0.3 - June 23rd, 2009 - Brian Medendorp</i></li>
|
||||
<li>The legend now works without any modifications! Because of changes made to flot and the plugin system (thanks Ole Laursen!) I was able to simplify a number of things and am now able to use the legend without the direct access hack that was required in the previous version.</li>
|
||||
<br/>
|
||||
<li style="list-style: none;"><i>v0.2 - June 22nd, 2009 - Brian Medendorp</i></li>
|
||||
<li>The legend now works but only if you make the necessary changes to jquery.flot.js. Because of this, I changed the default values for pie.radius and pie.label.show to new 'auto' settings that change the default behavior of the size and labels depending on whether the legend functionality is available or not.</li>
|
||||
<br/>
|
||||
<li style="list-style: none;"><i>v0.1 - June 18th, 2009 - Brian Medendorp</i></li>
|
||||
<li>Rewrote the entire pie code into a flot plugin (since that is now an option), so it should be much easier to use and the code is cleaned up a bit. However, the (standard flot) legend is no longer available because the only way to prevent the grid lines from being displayed also prevents the legend from being displayed. Hopefully this can be fixed at a later date.</li>
|
||||
<li>Restructured and combined some of the options. It should be much easier to deal with now.</li>
|
||||
<li>Added the ability to change the starting point of the pie (still defaults to the top).</li>
|
||||
<li>Modified the default options to show the labels to compensate for the lack of a legend.</li>
|
||||
<li>Modified this page to use a random dataset. <span style="color: red">Note: you may need to refresh the page to see the effects of some of the examples.</span></li>
|
||||
<br/>
|
||||
<li style="list-style: none;"><i>May 21st, 2009 - Brian Medendorp</i></li>
|
||||
<li>Merged original pie modifications by Sergey Nosenko into the latest SVN version <i>(as of May 15th, 2009)</i> so that it will work with ie8.</li>
|
||||
<li>Pie graph will now be centered in the canvas unless moved because of the legend or manually via the options. Additionally it prevents the pie from being moved beyond the edge of the canvas.</li>
|
||||
<li>Modified the code related to the labelFormatter option to apply flot's legend labelFormatter first. This is so that the labels will be consistent, but still provide extra formatting for the positioned labels (such as adding the percentage value).</li>
|
||||
<li>Positioned labels now have their backgrounds applied as a seperate element (much like the legend background) so that the opacity value can be set independently from the label itself (foreground). Additionally, the background color defaults to that of the matching slice.</li>
|
||||
<li>As long as the labelOffset and radiusLimit are not set to hard values, the pie will be shrunk if the labels will extend outside the edge of the canvas</li>
|
||||
<li>Added new options "radiusLimitFactor" and "radiusLimit" which limits how large the (visual) radius of the pie is in relation to the full radius (as calculated from the canvas dimensions) or a hard-pixel value (respectively). This allows for pushing the labels "outside" the pie.</li>
|
||||
<li>Added a new option "labelHidePercent" that does not show the positioned labels of slices smaller than the specified percentage. This is to help prevent a bunch of overlapping labels from small slices.</li>
|
||||
<li>Added a new option "sliceCombinePercent" that combines all slices smaller than the specified percentage into one larger slice. This is to help make the pie more attractive when there are a number of tiny slices. The options "sliceCombineColor" and "sliceCombineLabel" have also been added to change the color and name of the new slice if desired.</li>
|
||||
<li>Tested in Firefox (3.0.10, 3.5b4), Internet Explorer (6.0.2900, 7.0.5730, 8.0.6001), Chrome (1.0.154), Opera (9.64), and Safari (3.1.1, 4 beta 5528.16).
|
||||
</ul>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.selection.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
<p>1000 kg. CO<sub>2</sub> emissions per year per capita for various countries (source: <a href="http://en.wikipedia.org/wiki/List_of_countries_by_carbon_dioxide_emissions_per_capita">Wikipedia</a>).</p>
|
||||
|
||||
<p>Flot supports selections through the selection plugin.
|
||||
You can enable rectangular selection
|
||||
or one-dimensional selection if the user should only be able to
|
||||
select on one axis. Try left-click and drag on the plot above
|
||||
where selection on the x axis is enabled.</p>
|
||||
|
||||
<p>You selected: <span id="selection"></span></p>
|
||||
|
||||
<p>The plot command returns a plot object you can use to control
|
||||
the selection. Click the buttons below.</p>
|
||||
|
||||
<p><input id="clearSelection" type="button" value="Clear selection" />
|
||||
<input id="setSelection" type="button" value="Select year 1994" /></p>
|
||||
|
||||
<p>Selections are really useful for zooming. Just replot the
|
||||
chart with min and max values for the axes set to the values
|
||||
in the "plotselected" event triggered. Enable the checkbox
|
||||
below and select a region again.</p>
|
||||
|
||||
<p><label><input id="zoom" type="checkbox" />Zoom to selection.</label></p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var data = [
|
||||
{
|
||||
label: "United States",
|
||||
data: [[1990, 18.9], [1991, 18.7], [1992, 18.4], [1993, 19.3], [1994, 19.5], [1995, 19.3], [1996, 19.4], [1997, 20.2], [1998, 19.8], [1999, 19.9], [2000, 20.4], [2001, 20.1], [2002, 20.0], [2003, 19.8], [2004, 20.4]]
|
||||
},
|
||||
{
|
||||
label: "Russia",
|
||||
data: [[1992, 13.4], [1993, 12.2], [1994, 10.6], [1995, 10.2], [1996, 10.1], [1997, 9.7], [1998, 9.5], [1999, 9.7], [2000, 9.9], [2001, 9.9], [2002, 9.9], [2003, 10.3], [2004, 10.5]]
|
||||
},
|
||||
{
|
||||
label: "United Kingdom",
|
||||
data: [[1990, 10.0], [1991, 11.3], [1992, 9.9], [1993, 9.6], [1994, 9.5], [1995, 9.5], [1996, 9.9], [1997, 9.3], [1998, 9.2], [1999, 9.2], [2000, 9.5], [2001, 9.6], [2002, 9.3], [2003, 9.4], [2004, 9.79]]
|
||||
},
|
||||
{
|
||||
label: "Germany",
|
||||
data: [[1990, 12.4], [1991, 11.2], [1992, 10.8], [1993, 10.5], [1994, 10.4], [1995, 10.2], [1996, 10.5], [1997, 10.2], [1998, 10.1], [1999, 9.6], [2000, 9.7], [2001, 10.0], [2002, 9.7], [2003, 9.8], [2004, 9.79]]
|
||||
},
|
||||
{
|
||||
label: "Denmark",
|
||||
data: [[1990, 9.7], [1991, 12.1], [1992, 10.3], [1993, 11.3], [1994, 11.7], [1995, 10.6], [1996, 12.8], [1997, 10.8], [1998, 10.3], [1999, 9.4], [2000, 8.7], [2001, 9.0], [2002, 8.9], [2003, 10.1], [2004, 9.80]]
|
||||
},
|
||||
{
|
||||
label: "Sweden",
|
||||
data: [[1990, 5.8], [1991, 6.0], [1992, 5.9], [1993, 5.5], [1994, 5.7], [1995, 5.3], [1996, 6.1], [1997, 5.4], [1998, 5.4], [1999, 5.1], [2000, 5.2], [2001, 5.4], [2002, 6.2], [2003, 5.9], [2004, 5.89]]
|
||||
},
|
||||
{
|
||||
label: "Norway",
|
||||
data: [[1990, 8.3], [1991, 8.3], [1992, 7.8], [1993, 8.3], [1994, 8.4], [1995, 5.9], [1996, 6.4], [1997, 6.7], [1998, 6.9], [1999, 7.6], [2000, 7.4], [2001, 8.1], [2002, 12.5], [2003, 9.9], [2004, 19.0]]
|
||||
}
|
||||
];
|
||||
|
||||
var options = {
|
||||
series: {
|
||||
lines: { show: true },
|
||||
points: { show: true }
|
||||
},
|
||||
legend: { noColumns: 2 },
|
||||
xaxis: { tickDecimals: 0 },
|
||||
yaxis: { min: 0 },
|
||||
selection: { mode: "x" }
|
||||
};
|
||||
|
||||
var placeholder = $("#placeholder");
|
||||
|
||||
placeholder.bind("plotselected", function (event, ranges) {
|
||||
$("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1));
|
||||
|
||||
var zoom = $("#zoom").attr("checked");
|
||||
if (zoom)
|
||||
plot = $.plot(placeholder, data,
|
||||
$.extend(true, {}, options, {
|
||||
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
|
||||
}));
|
||||
});
|
||||
|
||||
placeholder.bind("plotunselected", function (event) {
|
||||
$("#selection").text("");
|
||||
});
|
||||
|
||||
var plot = $.plot(placeholder, data, options);
|
||||
|
||||
$("#clearSelection").click(function () {
|
||||
plot.clearSelection();
|
||||
});
|
||||
|
||||
$("#setSelection").click(function () {
|
||||
plot.setSelection({ xaxis: { from: 1994, to: 1995 } });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,65 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
<p>There are plenty of options you can set to control the precise
|
||||
looks of your plot. You can control the axes, the legend, the
|
||||
default graph type, the look of grid, etc.</p>
|
||||
|
||||
<p>The idea is that Flot goes to great lengths to provide <b>sensible
|
||||
defaults</b> which you can then customize as needed for your
|
||||
particular application. If you've found a use case where the
|
||||
defaults can be improved, please don't hesitate to give your
|
||||
feedback.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var d1 = [];
|
||||
for (var i = 0; i < Math.PI * 2; i += 0.25)
|
||||
d1.push([i, Math.sin(i)]);
|
||||
|
||||
var d2 = [];
|
||||
for (var i = 0; i < Math.PI * 2; i += 0.25)
|
||||
d2.push([i, Math.cos(i)]);
|
||||
|
||||
var d3 = [];
|
||||
for (var i = 0; i < Math.PI * 2; i += 0.1)
|
||||
d3.push([i, Math.tan(i)]);
|
||||
|
||||
$.plot($("#placeholder"), [
|
||||
{ label: "sin(x)", data: d1},
|
||||
{ label: "cos(x)", data: d2},
|
||||
{ label: "tan(x)", data: d3}
|
||||
], {
|
||||
series: {
|
||||
lines: { show: true },
|
||||
points: { show: true }
|
||||
},
|
||||
xaxis: {
|
||||
ticks: [0, [Math.PI/2, "\u03c0/2"], [Math.PI, "\u03c0"], [Math.PI * 3/2, "3\u03c0/2"], [Math.PI * 2, "2\u03c0"]]
|
||||
},
|
||||
yaxis: {
|
||||
ticks: 10,
|
||||
min: -2,
|
||||
max: 2
|
||||
},
|
||||
grid: {
|
||||
backgroundColor: { colors: ["#fff", "#eee"] }
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,77 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.stack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>With the stack plugin, you can have Flot stack the
|
||||
series. This is useful if you wish to display both a total and the
|
||||
constituents it is made of. The only requirement is that you provide
|
||||
the input sorted on x.</p>
|
||||
|
||||
<p class="stackControls">
|
||||
<input type="button" value="With stacking">
|
||||
<input type="button" value="Without stacking">
|
||||
</p>
|
||||
|
||||
<p class="graphControls">
|
||||
<input type="button" value="Bars">
|
||||
<input type="button" value="Lines">
|
||||
<input type="button" value="Lines with steps">
|
||||
</p>
|
||||
|
||||
<script id="source">
|
||||
$(function () {
|
||||
var d1 = [];
|
||||
for (var i = 0; i <= 10; i += 1)
|
||||
d1.push([i, parseInt(Math.random() * 30)]);
|
||||
|
||||
var d2 = [];
|
||||
for (var i = 0; i <= 10; i += 1)
|
||||
d2.push([i, parseInt(Math.random() * 30)]);
|
||||
|
||||
var d3 = [];
|
||||
for (var i = 0; i <= 10; i += 1)
|
||||
d3.push([i, parseInt(Math.random() * 30)]);
|
||||
|
||||
var stack = 0, bars = true, lines = false, steps = false;
|
||||
|
||||
function plotWithOptions() {
|
||||
$.plot($("#placeholder"), [ d1, d2, d3 ], {
|
||||
series: {
|
||||
stack: stack,
|
||||
lines: { show: lines, fill: true, steps: steps },
|
||||
bars: { show: bars, barWidth: 0.6 }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
plotWithOptions();
|
||||
|
||||
$(".stackControls input").click(function (e) {
|
||||
e.preventDefault();
|
||||
stack = $(this).val() == "With stacking" ? true : null;
|
||||
plotWithOptions();
|
||||
});
|
||||
$(".graphControls input").click(function (e) {
|
||||
e.preventDefault();
|
||||
bars = $(this).val().indexOf("Bars") != -1;
|
||||
lines = $(this).val().indexOf("Lines") != -1;
|
||||
steps = $(this).val().indexOf("steps") != -1;
|
||||
plotWithOptions();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,49 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.symbol.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
<p>Various point types. Circles are built-in. For other
|
||||
point types, you can define a little callback function to draw the
|
||||
symbol; some common ones are available in the symbol plugin.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
function generate(offset, amplitude) {
|
||||
var res = [];
|
||||
var start = 0, end = 10;
|
||||
for (var i = 0; i <= 50; ++i) {
|
||||
var x = start + i / 50 * (end - start);
|
||||
res.push([x, amplitude * Math.sin(x + offset)]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
var data = [
|
||||
{ data: generate(2, 1.8), points: { symbol: "circle" } },
|
||||
{ data: generate(3, 1.5), points: { symbol: "square" } },
|
||||
{ data: generate(4, 0.9), points: { symbol: "diamond" } },
|
||||
{ data: generate(6, 1.4), points: { symbol: "triangle" } },
|
||||
{ data: generate(7, 1.1), points: { symbol: "cross" } }
|
||||
];
|
||||
|
||||
$.plot($("#placeholder"), data, {
|
||||
series: { points: { show: true, radius: 3 } },
|
||||
grid: { hoverable: true }
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,54 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.threshold.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>With the threshold plugin, you can apply a specific color to
|
||||
the part of a data series below a threshold. This is can be useful
|
||||
for highlighting negative values, e.g. when displaying net results
|
||||
or what's in stock.</p>
|
||||
|
||||
<p class="controls">
|
||||
<input type="button" value="Threshold at 5">
|
||||
<input type="button" value="Threshold at 0">
|
||||
<input type="button" value="Threshold at -2.5">
|
||||
</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var d1 = [];
|
||||
for (var i = 0; i <= 60; i += 1)
|
||||
d1.push([i, parseInt(Math.random() * 30 - 10)]);
|
||||
|
||||
function plotWithOptions(t) {
|
||||
$.plot($("#placeholder"), [ {
|
||||
data: d1,
|
||||
color: "rgb(30, 180, 20)",
|
||||
threshold: { below: t, color: "rgb(200, 20, 30)" },
|
||||
lines: { steps: true }
|
||||
} ]);
|
||||
}
|
||||
|
||||
plotWithOptions(0);
|
||||
|
||||
$(".controls input").click(function (e) {
|
||||
e.preventDefault();
|
||||
var t = parseFloat($(this).val().replace('Threshold at ', ''));
|
||||
plotWithOptions(t);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,95 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.crosshair.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||
|
||||
<p>You can add crosshairs that'll track the mouse position, either
|
||||
on both axes or as here on only one.</p>
|
||||
|
||||
<p>If you combine it with listening on hover events, you can use
|
||||
it to track the intersection on the curves by interpolating
|
||||
the data points (look at the legend).</p>
|
||||
|
||||
<p id="hoverdata"></p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
var plot;
|
||||
$(function () {
|
||||
var sin = [], cos = [];
|
||||
for (var i = 0; i < 14; i += 0.1) {
|
||||
sin.push([i, Math.sin(i)]);
|
||||
cos.push([i, Math.cos(i)]);
|
||||
}
|
||||
|
||||
plot = $.plot($("#placeholder"),
|
||||
[ { data: sin, label: "sin(x) = -0.00"},
|
||||
{ data: cos, label: "cos(x) = -0.00" } ], {
|
||||
series: {
|
||||
lines: { show: true }
|
||||
},
|
||||
crosshair: { mode: "x" },
|
||||
grid: { hoverable: true, autoHighlight: false },
|
||||
yaxis: { min: -1.2, max: 1.2 }
|
||||
});
|
||||
var legends = $("#placeholder .legendLabel");
|
||||
legends.each(function () {
|
||||
// fix the widths so they don't jump around
|
||||
$(this).css('width', $(this).width());
|
||||
});
|
||||
|
||||
var updateLegendTimeout = null;
|
||||
var latestPosition = null;
|
||||
|
||||
function updateLegend() {
|
||||
updateLegendTimeout = null;
|
||||
|
||||
var pos = latestPosition;
|
||||
|
||||
var axes = plot.getAxes();
|
||||
if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max ||
|
||||
pos.y < axes.yaxis.min || pos.y > axes.yaxis.max)
|
||||
return;
|
||||
|
||||
var i, j, dataset = plot.getData();
|
||||
for (i = 0; i < dataset.length; ++i) {
|
||||
var series = dataset[i];
|
||||
|
||||
// find the nearest points, x-wise
|
||||
for (j = 0; j < series.data.length; ++j)
|
||||
if (series.data[j][0] > pos.x)
|
||||
break;
|
||||
|
||||
// now interpolate
|
||||
var y, p1 = series.data[j - 1], p2 = series.data[j];
|
||||
if (p1 == null)
|
||||
y = p2[1];
|
||||
else if (p2 == null)
|
||||
y = p1[1];
|
||||
else
|
||||
y = p1[1] + (p2[1] - p1[1]) * (pos.x - p1[0]) / (p2[0] - p1[0]);
|
||||
|
||||
legends.eq(i).text(series.label.replace(/=.*/, "= " + y.toFixed(2)));
|
||||
}
|
||||
}
|
||||
|
||||
$("#placeholder").bind("plothover", function (event, pos, item) {
|
||||
latestPosition = pos;
|
||||
if (!updateLegendTimeout)
|
||||
updateLegendTimeout = setTimeout(updateLegend, 50);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,98 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>Here is an example with real data: military budgets for
|
||||
various countries in constant (2005) million US dollars (source: <a href="http://www.sipri.org/">SIPRI</a>).</p>
|
||||
|
||||
<p>Since all data is available client-side, it's pretty easy to
|
||||
make the plot interactive. Try turning countries on/off with the
|
||||
checkboxes below.</p>
|
||||
|
||||
<p id="choices">Show:</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var datasets = {
|
||||
"usa": {
|
||||
label: "USA",
|
||||
data: [[1988, 483994], [1989, 479060], [1990, 457648], [1991, 401949], [1992, 424705], [1993, 402375], [1994, 377867], [1995, 357382], [1996, 337946], [1997, 336185], [1998, 328611], [1999, 329421], [2000, 342172], [2001, 344932], [2002, 387303], [2003, 440813], [2004, 480451], [2005, 504638], [2006, 528692]]
|
||||
},
|
||||
"russia": {
|
||||
label: "Russia",
|
||||
data: [[1988, 218000], [1989, 203000], [1990, 171000], [1992, 42500], [1993, 37600], [1994, 36600], [1995, 21700], [1996, 19200], [1997, 21300], [1998, 13600], [1999, 14000], [2000, 19100], [2001, 21300], [2002, 23600], [2003, 25100], [2004, 26100], [2005, 31100], [2006, 34700]]
|
||||
},
|
||||
"uk": {
|
||||
label: "UK",
|
||||
data: [[1988, 62982], [1989, 62027], [1990, 60696], [1991, 62348], [1992, 58560], [1993, 56393], [1994, 54579], [1995, 50818], [1996, 50554], [1997, 48276], [1998, 47691], [1999, 47529], [2000, 47778], [2001, 48760], [2002, 50949], [2003, 57452], [2004, 60234], [2005, 60076], [2006, 59213]]
|
||||
},
|
||||
"germany": {
|
||||
label: "Germany",
|
||||
data: [[1988, 55627], [1989, 55475], [1990, 58464], [1991, 55134], [1992, 52436], [1993, 47139], [1994, 43962], [1995, 43238], [1996, 42395], [1997, 40854], [1998, 40993], [1999, 41822], [2000, 41147], [2001, 40474], [2002, 40604], [2003, 40044], [2004, 38816], [2005, 38060], [2006, 36984]]
|
||||
},
|
||||
"denmark": {
|
||||
label: "Denmark",
|
||||
data: [[1988, 3813], [1989, 3719], [1990, 3722], [1991, 3789], [1992, 3720], [1993, 3730], [1994, 3636], [1995, 3598], [1996, 3610], [1997, 3655], [1998, 3695], [1999, 3673], [2000, 3553], [2001, 3774], [2002, 3728], [2003, 3618], [2004, 3638], [2005, 3467], [2006, 3770]]
|
||||
},
|
||||
"sweden": {
|
||||
label: "Sweden",
|
||||
data: [[1988, 6402], [1989, 6474], [1990, 6605], [1991, 6209], [1992, 6035], [1993, 6020], [1994, 6000], [1995, 6018], [1996, 3958], [1997, 5780], [1998, 5954], [1999, 6178], [2000, 6411], [2001, 5993], [2002, 5833], [2003, 5791], [2004, 5450], [2005, 5521], [2006, 5271]]
|
||||
},
|
||||
"norway": {
|
||||
label: "Norway",
|
||||
data: [[1988, 4382], [1989, 4498], [1990, 4535], [1991, 4398], [1992, 4766], [1993, 4441], [1994, 4670], [1995, 4217], [1996, 4275], [1997, 4203], [1998, 4482], [1999, 4506], [2000, 4358], [2001, 4385], [2002, 5269], [2003, 5066], [2004, 5194], [2005, 4887], [2006, 4891]]
|
||||
}
|
||||
};
|
||||
|
||||
// hard-code color indices to prevent them from shifting as
|
||||
// countries are turned on/off
|
||||
var i = 0;
|
||||
$.each(datasets, function(key, val) {
|
||||
val.color = i;
|
||||
++i;
|
||||
});
|
||||
|
||||
// insert checkboxes
|
||||
var choiceContainer = $("#choices");
|
||||
$.each(datasets, function(key, val) {
|
||||
choiceContainer.append('<br/><input type="checkbox" name="' + key +
|
||||
'" checked="checked" id="id' + key + '">' +
|
||||
'<label for="id' + key + '">'
|
||||
+ val.label + '</label>');
|
||||
});
|
||||
choiceContainer.find("input").click(plotAccordingToChoices);
|
||||
|
||||
|
||||
function plotAccordingToChoices() {
|
||||
var data = [];
|
||||
|
||||
choiceContainer.find("input:checked").each(function () {
|
||||
var key = $(this).attr("name");
|
||||
if (key && datasets[key])
|
||||
data.push(datasets[key]);
|
||||
});
|
||||
|
||||
if (data.length > 0)
|
||||
$.plot($("#placeholder"), data, {
|
||||
yaxis: { min: 0 },
|
||||
xaxis: { tickDecimals: 0 }
|
||||
});
|
||||
}
|
||||
|
||||
plotAccordingToChoices();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,90 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.selection.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>Visitors per day to the Flot homepage. Weekends are colored. Try zooming.
|
||||
The plot below shows an overview.</p>
|
||||
|
||||
<div id="overview" style="margin-left:50px;margin-top:20px;width:400px;height:50px"></div>
|
||||
|
||||
<script id="source">
|
||||
$(function () {
|
||||
var d = [[1196463600000, 0], [1196550000000, 0], [1196636400000, 0], [1196722800000, 77], [1196809200000, 3636], [1196895600000, 3575], [1196982000000, 2736], [1197068400000, 1086], [1197154800000, 676], [1197241200000, 1205], [1197327600000, 906], [1197414000000, 710], [1197500400000, 639], [1197586800000, 540], [1197673200000, 435], [1197759600000, 301], [1197846000000, 575], [1197932400000, 481], [1198018800000, 591], [1198105200000, 608], [1198191600000, 459], [1198278000000, 234], [1198364400000, 1352], [1198450800000, 686], [1198537200000, 279], [1198623600000, 449], [1198710000000, 468], [1198796400000, 392], [1198882800000, 282], [1198969200000, 208], [1199055600000, 229], [1199142000000, 177], [1199228400000, 374], [1199314800000, 436], [1199401200000, 404], [1199487600000, 253], [1199574000000, 218], [1199660400000, 476], [1199746800000, 462], [1199833200000, 448], [1199919600000, 442], [1200006000000, 403], [1200092400000, 204], [1200178800000, 194], [1200265200000, 327], [1200351600000, 374], [1200438000000, 507], [1200524400000, 546], [1200610800000, 482], [1200697200000, 283], [1200783600000, 221], [1200870000000, 483], [1200956400000, 523], [1201042800000, 528], [1201129200000, 483], [1201215600000, 452], [1201302000000, 270], [1201388400000, 222], [1201474800000, 439], [1201561200000, 559], [1201647600000, 521], [1201734000000, 477], [1201820400000, 442], [1201906800000, 252], [1201993200000, 236], [1202079600000, 525], [1202166000000, 477], [1202252400000, 386], [1202338800000, 409], [1202425200000, 408], [1202511600000, 237], [1202598000000, 193], [1202684400000, 357], [1202770800000, 414], [1202857200000, 393], [1202943600000, 353], [1203030000000, 364], [1203116400000, 215], [1203202800000, 214], [1203289200000, 356], [1203375600000, 399], [1203462000000, 334], [1203548400000, 348], [1203634800000, 243], [1203721200000, 126], [1203807600000, 157], [1203894000000, 288]];
|
||||
|
||||
// first correct the timestamps - they are recorded as the daily
|
||||
// midnights in UTC+0100, but Flot always displays dates in UTC
|
||||
// so we have to add one hour to hit the midnights in the plot
|
||||
for (var i = 0; i < d.length; ++i)
|
||||
d[i][0] += 60 * 60 * 1000;
|
||||
|
||||
// helper for returning the weekends in a period
|
||||
function weekendAreas(axes) {
|
||||
var markings = [];
|
||||
var d = new Date(axes.xaxis.min);
|
||||
// go to the first Saturday
|
||||
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7))
|
||||
d.setUTCSeconds(0);
|
||||
d.setUTCMinutes(0);
|
||||
d.setUTCHours(0);
|
||||
var i = d.getTime();
|
||||
do {
|
||||
// when we don't set yaxis, the rectangle automatically
|
||||
// extends to infinity upwards and downwards
|
||||
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
|
||||
i += 7 * 24 * 60 * 60 * 1000;
|
||||
} while (i < axes.xaxis.max);
|
||||
|
||||
return markings;
|
||||
}
|
||||
|
||||
var options = {
|
||||
xaxis: { mode: "time", tickLength: 5 },
|
||||
selection: { mode: "x" },
|
||||
grid: { markings: weekendAreas }
|
||||
};
|
||||
|
||||
var plot = $.plot($("#placeholder"), [d], options);
|
||||
|
||||
var overview = $.plot($("#overview"), [d], {
|
||||
series: {
|
||||
lines: { show: true, lineWidth: 1 },
|
||||
shadowSize: 0
|
||||
},
|
||||
xaxis: { ticks: [], mode: "time" },
|
||||
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
|
||||
selection: { mode: "x" }
|
||||
});
|
||||
|
||||
// now connect the two
|
||||
|
||||
$("#placeholder").bind("plotselected", function (event, ranges) {
|
||||
// do the zooming
|
||||
plot = $.plot($("#placeholder"), [d],
|
||||
$.extend(true, {}, options, {
|
||||
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
|
||||
}));
|
||||
|
||||
// don't fire event on the overview to prevent eternal loop
|
||||
overview.setSelection(ranges, true);
|
||||
});
|
||||
|
||||
$("#overview").bind("plotselected", function (event, ranges) {
|
||||
plot.setSelection(ranges);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,98 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.selection.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div style="float:left">
|
||||
<div id="placeholder" style="width:500px;height:300px"></div>
|
||||
</div>
|
||||
|
||||
<div id="miniature" style="float:left;margin-left:20px">
|
||||
<div id="overview" style="width:166px;height:100px"></div>
|
||||
|
||||
<p id="overviewLegend" style="margin-left:10px"></p>
|
||||
</div>
|
||||
|
||||
<p style="clear:left">The selection support makes it easy to
|
||||
construct flexible zooming schemes. With a few lines of code, the
|
||||
small overview plot to the right has been connected to the large
|
||||
plot. Try selecting a rectangle on either of them.</p>
|
||||
|
||||
<script id="source">
|
||||
$(function () {
|
||||
// setup plot
|
||||
function getData(x1, x2) {
|
||||
var d = [];
|
||||
for (var i = 0; i <= 100; ++i) {
|
||||
var x = x1 + i * (x2 - x1) / 100;
|
||||
d.push([x, Math.sin(x * Math.sin(x))]);
|
||||
}
|
||||
|
||||
return [
|
||||
{ label: "sin(x sin(x))", data: d }
|
||||
];
|
||||
}
|
||||
|
||||
var options = {
|
||||
legend: { show: false },
|
||||
series: {
|
||||
lines: { show: true },
|
||||
points: { show: true }
|
||||
},
|
||||
yaxis: { ticks: 10 },
|
||||
selection: { mode: "xy" }
|
||||
};
|
||||
|
||||
var startData = getData(0, 3 * Math.PI);
|
||||
|
||||
var plot = $.plot($("#placeholder"), startData, options);
|
||||
|
||||
// setup overview
|
||||
var overview = $.plot($("#overview"), startData, {
|
||||
legend: { show: true, container: $("#overviewLegend") },
|
||||
series: {
|
||||
lines: { show: true, lineWidth: 1 },
|
||||
shadowSize: 0
|
||||
},
|
||||
xaxis: { ticks: 4 },
|
||||
yaxis: { ticks: 3, min: -2, max: 2 },
|
||||
grid: { color: "#999" },
|
||||
selection: { mode: "xy" }
|
||||
});
|
||||
|
||||
// now connect the two
|
||||
|
||||
$("#placeholder").bind("plotselected", function (event, ranges) {
|
||||
// clamp the zooming to prevent eternal zoom
|
||||
if (ranges.xaxis.to - ranges.xaxis.from < 0.00001)
|
||||
ranges.xaxis.to = ranges.xaxis.from + 0.00001;
|
||||
if (ranges.yaxis.to - ranges.yaxis.from < 0.00001)
|
||||
ranges.yaxis.to = ranges.yaxis.from + 0.00001;
|
||||
|
||||
// do the zooming
|
||||
plot = $.plot($("#placeholder"), getData(ranges.xaxis.from, ranges.xaxis.to),
|
||||
$.extend(true, {}, options, {
|
||||
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
|
||||
yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
|
||||
}));
|
||||
|
||||
// don't fire event on the overview to prevent eternal loop
|
||||
overview.setSelection(ranges, true);
|
||||
});
|
||||
$("#overview").bind("plotselected", function (event, ranges) {
|
||||
plot.setSelection(ranges);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,143 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>Example of loading data dynamically with AJAX. Percentage change in GDP (source: <a href="http://epp.eurostat.ec.europa.eu/tgm/table.do?tab=table&init=1&plugin=1&language=en&pcode=tsieb020">Eurostat</a>). Click the buttons below.</p>
|
||||
|
||||
<p>The data is fetched over HTTP, in this case directly from text
|
||||
files. Usually the URL would point to some web server handler
|
||||
(e.g. a PHP page or Java/.NET/Python/Ruby on Rails handler) that
|
||||
extracts it from a database and serializes it to JSON.</p>
|
||||
|
||||
<p>
|
||||
<input class="fetchSeries" type="button" value="First dataset"> -
|
||||
<a href="data-eu-gdp-growth.json">data</a> -
|
||||
<span></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input class="fetchSeries" type="button" value="Second dataset"> -
|
||||
<a href="data-japan-gdp-growth.json">data</a> -
|
||||
<span></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<input class="fetchSeries" type="button" value="Third dataset"> -
|
||||
<a href="data-usa-gdp-growth.json">data</a> -
|
||||
<span></span>
|
||||
</p>
|
||||
|
||||
<p>If you combine AJAX with setTimeout, you can poll the server
|
||||
for new data.</p>
|
||||
|
||||
<p>
|
||||
<input class="dataUpdate" type="button" value="Poll for data">
|
||||
</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
var options = {
|
||||
lines: { show: true },
|
||||
points: { show: true },
|
||||
xaxis: { tickDecimals: 0, tickSize: 1 }
|
||||
};
|
||||
var data = [];
|
||||
var placeholder = $("#placeholder");
|
||||
|
||||
$.plot(placeholder, data, options);
|
||||
|
||||
|
||||
// fetch one series, adding to what we got
|
||||
var alreadyFetched = {};
|
||||
|
||||
$("input.fetchSeries").click(function () {
|
||||
var button = $(this);
|
||||
|
||||
// find the URL in the link right next to us
|
||||
var dataurl = button.siblings('a').attr('href');
|
||||
|
||||
// then fetch the data with jQuery
|
||||
function onDataReceived(series) {
|
||||
// extract the first coordinate pair so you can see that
|
||||
// data is now an ordinary Javascript object
|
||||
var firstcoordinate = '(' + series.data[0][0] + ', ' + series.data[0][1] + ')';
|
||||
|
||||
button.siblings('span').text('Fetched ' + series.label + ', first point: ' + firstcoordinate);
|
||||
|
||||
// let's add it to our current data
|
||||
if (!alreadyFetched[series.label]) {
|
||||
alreadyFetched[series.label] = true;
|
||||
data.push(series);
|
||||
}
|
||||
|
||||
// and plot all we got
|
||||
$.plot(placeholder, data, options);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: dataurl,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: onDataReceived
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// initiate a recurring data update
|
||||
$("input.dataUpdate").click(function () {
|
||||
// reset data
|
||||
data = [];
|
||||
alreadyFetched = {};
|
||||
|
||||
$.plot(placeholder, data, options);
|
||||
|
||||
var iteration = 0;
|
||||
|
||||
function fetchData() {
|
||||
++iteration;
|
||||
|
||||
function onDataReceived(series) {
|
||||
// we get all the data in one go, if we only got partial
|
||||
// data, we could merge it with what we already got
|
||||
data = [ series ];
|
||||
|
||||
$.plot($("#placeholder"), data, options);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
// usually, we'll just call the same URL, a script
|
||||
// connected to a database, but in this case we only
|
||||
// have static example files so we need to modify the
|
||||
// URL
|
||||
url: "data-eu-gdp-growth-" + iteration + ".json",
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: onDataReceived
|
||||
});
|
||||
|
||||
if (iteration < 5)
|
||||
setTimeout(fetchData, 1000);
|
||||
else {
|
||||
data = [];
|
||||
alreadyFetched = {};
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(fetchData, 1000);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,75 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Flot Examples</title>
|
||||
<link href="layout.css" rel="stylesheet" type="text/css"></link>
|
||||
<!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><![endif]-->
|
||||
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../jquery.flot.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Flot Examples</h1>
|
||||
|
||||
<div id="placeholder" style="width:600px;height:300px;"></div>
|
||||
|
||||
<p>Flot has support for simple background decorations such as
|
||||
lines and rectangles. They can be useful for marking up certain
|
||||
areas. You can easily add any HTML you need with standard DOM
|
||||
manipulation, e.g. for labels. For drawing custom shapes there is
|
||||
also direct access to the canvas.</p>
|
||||
|
||||
<script id="source" language="javascript" type="text/javascript">
|
||||
$(function () {
|
||||
// generate a dataset
|
||||
var d1 = [];
|
||||
for (var i = 0; i < 20; ++i)
|
||||
d1.push([i, Math.sin(i)]);
|
||||
|
||||
var data = [{ data: d1, label: "Pressure", color: "#333" }];
|
||||
|
||||
// setup background areas
|
||||
var markings = [
|
||||
{ color: '#f6f6f6', yaxis: { from: 1 } },
|
||||
{ color: '#f6f6f6', yaxis: { to: -1 } },
|
||||
{ color: '#000', lineWidth: 1, xaxis: { from: 2, to: 2 } },
|
||||
{ color: '#000', lineWidth: 1, xaxis: { from: 8, to: 8 } }
|
||||
];
|
||||
|
||||
var placeholder = $("#placeholder");
|
||||
|
||||
// plot it
|
||||
var plot = $.plot(placeholder, data, {
|
||||
bars: { show: true, barWidth: 0.5, fill: 0.9 },
|
||||
xaxis: { ticks: [], autoscaleMargin: 0.02 },
|
||||
yaxis: { min: -2, max: 2 },
|
||||
grid: { markings: markings }
|
||||
});
|
||||
|
||||
// add labels
|
||||
var o;
|
||||
|
||||
o = plot.pointOffset({ x: 2, y: -1.2});
|
||||
// we just append it to the placeholder which Flot already uses
|
||||
// for positioning
|
||||
placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Warming up</div>');
|
||||
|
||||
o = plot.pointOffset({ x: 8, y: -1.2});
|
||||
placeholder.append('<div style="position:absolute;left:' + (o.left + 4) + 'px;top:' + o.top + 'px;color:#666;font-size:smaller">Actual measurements</div>');
|
||||
|
||||
// draw a little arrow on top of the last label to demonstrate
|
||||
// canvas drawing
|
||||
var ctx = plot.getCanvas().getContext("2d");
|
||||
ctx.beginPath();
|
||||
o.left += 4;
|
||||
ctx.moveTo(o.left, o.top);
|
||||
ctx.lineTo(o.left, o.top - 10);
|
||||
ctx.lineTo(o.left + 10, o.top - 5);
|
||||
ctx.lineTo(o.left, o.top);
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.fill();
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 916 B |
Before Width: | Height: | Size: 891 B |