Skip to content
Browse files

starting file set: version 0.3

  • Loading branch information...
1 parent 02c127f commit c6030db88a9a01e37ec72065fff8ec3dbbe918ed ali asaria committed Mar 15, 2010
Showing with 14,618 additions and 0 deletions.
  1. +5 −0 .buildpath
  2. +3 −0 .gitignore
  3. +22 −0 .project
  4. +3 −0 .settings/org.eclipse.php.core.prefs
  5. +24 −0 ABOUT.txt
  6. +13 −0 README.txt
  7. +12 −0 TODO.txt
  8. +18 −0 config/configure.php
  9. +19 −0 config/metrics.php
  10. +26 −0 config/tests.php
  11. +137 −0 core.php
  12. BIN css/bg_button_a.gif
  13. BIN css/bg_button_span.gif
  14. +126 −0 css/buttons.css
  15. +61 −0 css/report.css
  16. BIN css/secondary-newer.png
  17. BIN css/secondary.png
  18. BIN css/secondary_light.png
  19. +55 −0 example.php
  20. +1,024 −0 js/flot/API.txt
  21. +71 −0 js/flot/FAQ.txt
  22. +22 −0 js/flot/LICENSE.txt
  23. +15 −0 js/flot/Makefile
  24. +340 −0 js/flot/NEWS.txt
  25. +105 −0 js/flot/PLUGINS.txt
  26. +81 −0 js/flot/README.txt
  27. +143 −0 js/flot/examples/ajax.html
  28. +75 −0 js/flot/examples/annotating.html
  29. BIN js/flot/examples/arrow-down.gif
  30. BIN js/flot/examples/arrow-left.gif
  31. BIN js/flot/examples/arrow-right.gif
  32. BIN js/flot/examples/arrow-up.gif
  33. +38 −0 js/flot/examples/basic.html
  34. +4 −0 js/flot/examples/data-eu-gdp-growth-1.json
  35. +4 −0 js/flot/examples/data-eu-gdp-growth-2.json
  36. +4 −0 js/flot/examples/data-eu-gdp-growth-3.json
  37. +4 −0 js/flot/examples/data-eu-gdp-growth-4.json
  38. +4 −0 js/flot/examples/data-eu-gdp-growth-5.json
  39. +4 −0 js/flot/examples/data-eu-gdp-growth.json
  40. +4 −0 js/flot/examples/data-japan-gdp-growth.json
  41. +4 −0 js/flot/examples/data-usa-gdp-growth.json
  42. +39 −0 js/flot/examples/dual-axis.html
  43. +75 −0 js/flot/examples/graph-types.html
  44. BIN js/flot/examples/hs-2004-27-a-large_web.jpg
  45. +45 −0 js/flot/examples/image.html
  46. +43 −0 js/flot/examples/index.html
  47. +93 −0 js/flot/examples/interacting.html
  48. +6 −0 js/flot/examples/layout.css
  49. +118 −0 js/flot/examples/navigate.html
  50. +114 −0 js/flot/examples/selection.html
  51. +65 −0 js/flot/examples/setting-options.html
  52. +77 −0 js/flot/examples/stacking.html
  53. +54 −0 js/flot/examples/thresholding.html
  54. +71 −0 js/flot/examples/time.html
  55. +95 −0 js/flot/examples/tracking.html
  56. +98 −0 js/flot/examples/turning-series.html
  57. +90 −0 js/flot/examples/visitors.html
  58. +98 −0 js/flot/examples/zooming.html
  59. +1,427 −0 js/flot/excanvas.js
  60. +1 −0 js/flot/excanvas.min.js
  61. +174 −0 js/flot/jquery.colorhelpers.js
  62. +1 −0 js/flot/jquery.colorhelpers.min.js
  63. +156 −0 js/flot/jquery.flot.crosshair.js
  64. +1 −0 js/flot/jquery.flot.crosshair.min.js
  65. +237 −0 js/flot/jquery.flot.image.js
  66. +1 −0 js/flot/jquery.flot.image.min.js
  67. +2,119 −0 js/flot/jquery.flot.js
  68. +1 −0 js/flot/jquery.flot.min.js
  69. +272 −0 js/flot/jquery.flot.navigate.js
  70. +1 −0 js/flot/jquery.flot.navigate.min.js
  71. +299 −0 js/flot/jquery.flot.selection.js
  72. +1 −0 js/flot/jquery.flot.selection.min.js
  73. +152 −0 js/flot/jquery.flot.stack.js
  74. +1 −0 js/flot/jquery.flot.stack.min.js
  75. +103 −0 js/flot/jquery.flot.threshold.js
  76. +1 −0 js/flot/jquery.flot.threshold.min.js
  77. +4,376 −0 js/flot/jquery.js
  78. +19 −0 js/flot/jquery.min.js
  79. +154 −0 js/jquery-1.4.2.min.js
  80. +16 −0 lib/common.php
  81. +105 −0 lib/metrics.php
  82. +189 −0 lib/report.php
  83. +226 −0 lib/tests.php
  84. +234 −0 lib/z_scores_table.php
  85. +375 −0 redis/redis.php
  86. +325 −0 report.php
View
5 .buildpath
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<buildpath>
+ <buildpathentry kind="src" path=""/>
+ <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
+</buildpath>
View
3 .gitignore
@@ -0,0 +1,3 @@
+.svn
+.DS_Store
+
View
22 .project
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>php_ab_testing_redis</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.dltk.core.scriptbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.php.core.PHPNature</nature>
+ </natures>
+</projectDescription>
View
3 .settings/org.eclipse.php.core.prefs
@@ -0,0 +1,3 @@
+#Sat Feb 20 14:02:16 EST 2010
+eclipse.preferences.version=1
+include_path=0;/php_ab_testing_redis
View
24 ABOUT.txt
@@ -0,0 +1,24 @@
+Author:
+This project is by Ali Asaria created for Well.ca Inc. 2010. The idea for the program is based on the
+project "Vanity" by Assaf Arkin -- a Rails A/B testing tool.
+
+The philosophy behind this program is
+
+
+About Well.ca:
+Well.ca is Canada's largest online health and beauty store.
+
+
+License:
+
+
+
+Credits:
+
+- Idea and style inspired by Vanity for Rails by Assaf Arkin http://vanity.labnotes.org/
+- See Assaf's credits here: http://vanity.labnotes.org/credits.html
+- Redis client library - Redis PHP Bindings - http://code.google.com/p/redis/ - Copyright 2009 Ludovico Magnocavallo, Copyright 2009 Salvatore Sanfilippo - Released under the same license as Redis.
+- jQuery by John Resig - http://jquery.com/ - MIT License or (GPL) Version 2.
+- Flot copyright of IOLA and Ole Laursen, released under the MIT license.
+- Buttons http://www.halmatferello.com/lab/pure-css-buttons/ Licensed under GPL and MIT.
+
View
13 README.txt
@@ -0,0 +1,13 @@
+A/B TESTING FOR PHP USING REDIS
+
+To set up this project:
+
+1. Start up redis. Specify the host name and db number in config/configure.php
+2. Define things to measure in config/metrics.php following the declaration pattern in the file's example
+3. Define the tests you'd like to perform in config/tests.php following the pattern there. Specify a metric for each test as shown in the example
+4. include core.php in your code.
+5. make sure to set ab_participant_specify_id("a_unique_id_for_this_user") at least once
+6. for every metric, call: ab_track("name_of_your_metric");
+7. every time you need a choice, call: ab_test("name_of_your_ab_test"); and it will return a string represing the alternative to use
+
+that is all.
View
12 TODO.txt
@@ -0,0 +1,12 @@
+
+- Add author and credit information
+- Add notion of statistical significance based on Vanity ala http://20bits.com/articles/statistical-analysis-and-ab-testing/
+- Allow ability to clear the data from a test
+- Add IP restriction on report.php
+- Have metrics that can have size, and related results that would be distributions : E.g. # of Pages viewed. This would be more complicated.
+- Fix date_time issues where I just use unicode time and not proper date math (can't find docs for date match in PHP 5.2)
+
+
+Suggestions
+- Have an option on a metric so that it is only initialized upon request
+- Have a flag where this runs without redis for debugging (e.g. file-based or sqlite)
View
18 config/configure.php
@@ -0,0 +1,18 @@
+<?php
+
+$config['redis_host'] = 'localhost';
+$config['redis_port'] = 6379; //redis's default port is 6379
+$config['redis_db_number'] = 0;
+
+
+$config['USE_AUTHENTICATION'] = true; // Use (internal) authentication - best choice if
+ // no other authentication is available
+ // If set to 0:
+ // There will be no further authentication. You
+ // will have to handle this by yourself!
+ // If set to 1:
+ // You need to change ADMIN_PASSWORD to make
+ // this work!
+$config['ADMIN_USERNAME'] = 'admin'; // Admin Username
+$config['ADMIN_PASSWORD'] = 'elephant'; // Admin Password - CHANGE THIS TO ENABLE!!!
+
View
19 config/metrics.php
@@ -0,0 +1,19 @@
+<?php
+
+//example:
+/*
+$ab_metrics['conversion'] = array(
+ "name" => "conversion", //this must be the same as the key above. Whitespace is not allowed
+ "description" => "When someone completes checkout"
+);
+*/
+
+$ab_metrics['conversion'] = array(
+ "name" => "conversion",
+ "description" => "When someone completes checkout"
+);
+
+$ab_metrics['signup'] = array(
+ "name" => "signup",
+ "description" => "When someone signsup for a newsletter"
+);
View
26 config/tests.php
@@ -0,0 +1,26 @@
+<?php
+//example:
+/*
+$ab_tests['checkout_button_color'] = array(
+ "name" => "checkout_button_color", //must be the same as the key above. Whitespace is not allowed
+ "description" => "What colour should we make the checkout button",
+ "alternatives" => array("green", "red", "blue"), //all possible alternatives
+ //as an array of strings
+ "metrics" => array('conversion') //what metrics refer to a conversion here? this is an array of strings
+ //that correspond to metrics in the config/metrics file
+);
+*/
+
+$ab_tests['checkout_button_color'] = array(
+ "name" => "checkout_button_color",
+ "description" => "What colour should we make the checkout button",
+ "alternatives" => array("green", "red", "blue"),
+ "metrics" => array('conversion', 'signup')
+);
+
+$ab_tests['checkout_button_size'] = array(
+ "name" => "checkout_button_size",
+ "description" => "How big should we make it?",
+ "alternatives" => array("small", "medium", "large"),
+ "metrics" => array('conversion')
+);
View
137 core.php
@@ -0,0 +1,137 @@
+<?php
+
+/*
+ * This is the file you include in order to use the AB testing suite
+ *
+ * Three functions are exposed to the public:
+ * ab_participant_id(...)
+ * ab_test(...)
+ * ab_track(...)
+ *
+ * Run ab_partipant_id before anything else
+ */
+
+/*
+ * INCLUDES
+ */
+//include the redis connector
+include_once('redis/redis.php');
+
+include('config/configure.php');
+
+//bring in the custom defined metrics and tests
+include('config/metrics.php');
+include('config/tests.php');
+
+include('lib/metrics.php');
+include('lib/tests.php');
+
+$ab_participant_id = -1;
+
+/*
+ * Try to connect to redis
+ */
+$r =& new Redis($config['redis_host'],$config['redis_port']);
+$redis_connected = $r->connect();
+
+
+if ($redis_connected)
+{
+ $r->select_db($config['redis_db_number']);
+ //$r->flushdb();
+}
+else
+{
+}
+
+
+/************************************
+ * CORE FUNCTIONS
+ *
+ * The following three functions
+ *
+ * ab_participant_id(...)
+ * ab_test(...)
+ * ab_track(...)
+ *
+ * are the only three functions exposed to the public.
+ *
+ * For documentation on how to use this, read README.txt
+ */
+
+/**
+ *
+ * Sets the unique participant ID for the current visitor
+ * this must be set once and must be done before using any
+ * other of the ab testing functions.
+ * @param $id - the unique ID of the visitor
+ * @return (nothing)
+ */
+function ab_participant_id ($id)
+{
+ global $ab_participant_id;
+ global $redis_connected;
+
+ $ab_participant_id = $id;
+
+ if ($redis_connected)
+ {
+ //set up the metrics (this should loop through them and link them to associated ab tests
+ ab_metrics_initialize();
+ ab_tests_initialize();
+ }
+}
+
+/**
+ * Runs a test.
+ * @param $test is a string that specifieds the test to run
+ * @return a string representing the alternative to run. will return null if the test isn't found
+ */
+function ab_test($test)
+{
+ global $redis_connected;
+ global $ab_tests;
+
+ //test if the test exists, otherwise return null
+ if (!array_key_exists($test, $ab_tests)) return null;
+
+ if ($redis_connected)
+ {
+ return ab_tests_test($test);
+ }
+ else
+ {
+ //the following function will still work, even without
+ //a connection to redis
+ return ab_tests_test($test);
+ }
+}
+
+/**
+ * Track a metric.
+ * @param $metric : a string representing the metric to track
+ * @param $value : (optional) how many conversions happened (e.g. use this
+ * for add to cart if the person adds 10 to the cart) default = 1
+ * @return nothing
+ */
+function ab_track($metric, $value = 1)
+{
+ global $redis_connected;
+
+ if ($redis_connected)
+ {
+ if ($ab_participant_id != -1)
+ {
+ ab_metrics_track($metric, $value = 1);
+ }
+ }
+ else
+ {
+ //do nothing
+ }
+}
+
+
+
+
+
View
BIN css/bg_button_a.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN css/bg_button_span.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
126 css/buttons.css
@@ -0,0 +1,126 @@
+/*
+ Pure CSS Buttons.
+ Learn more ~ http://www.halmatferello.com/lab/pure-css-buttons/
+
+ Licensed under GPL and MIT.
+*/
+
+.pcb, .pcb span {
+ background: url('secondary_light.png') no-repeat;
+ height: 23px;
+ line-height: 23px;
+ padding: 3px 0 7px 0;
+
+ font-family: "Helvetica Neue", Helvetica, Frutiger, "Frutiger Linotype", Univers, Calibri, "Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Arial, sans-serif;
+ xfont-size: 62.5%;
+ color: #333;
+}
+
+.pcb, a.pcb:link, a.pcb:visited {
+ color: #333;
+ font-size: 11px;
+ padding-left: 14px;
+ text-decoration: none !important;
+}
+/* ie 6 hack */
+* html div#frame .pcb {
+ color: #333;
+ padding-top: 0px;
+ padding-bottom: 0px;
+ text-decoration: none;
+}
+/* ie 7 hack */
+*:first-child+html .pcb {
+ color: #333;
+ padding-top: 0px;
+ padding-bottom: 0px;
+ text-decoration: none;
+}
+
+.pcb span {
+ background-position: right -326px;
+ padding-right: 14px;
+}
+
+a.green-button, a.green-button:link, a.green-button:visited, .green-active-button, .green-disabled-button {
+ color: #fff !important;
+ font-size: 12px;
+ font-weight: bold;
+}
+a.green-button:hover {
+ background-position: left -27px;
+}
+a.green-button:hover span {
+ background-position: right -353px;
+}
+a.green-button:active, .green-active-button {
+ background-position: left -54px;
+}
+a.green-button:active span, .green-active-button span {
+ background-position: right -380px;
+}
+body .green-disabled-button {
+ color: #A8BE69 !important;
+ background-position: left -81px !important;
+}
+body .green-disabled-button span {
+ background-position: right -407px;
+}
+
+a.grey-button {
+ background-position: left -219px;
+ padding-top: 3px;
+}
+a.grey-button span {
+ background-position: right -545px;
+ padding-top: 3px;
+}
+a.grey-button:hover {
+ background-position: left -246px;
+}
+a.grey-button:hover span {
+ background-position: right -572px;
+}
+a.grey-button:active, .grey-active-button {
+ background-position: left -273px;
+}
+a.grey-button:active span, .grey-active-button span {
+ background-position: right -599px;
+}
+body .grey-disabled-button {
+ background-position: left -300px;
+ color: #bbb !important;
+}
+body .grey-disabled-button span {
+ background-position: right -626px;
+}
+
+a.red-button, .red-active-button, .red-disabled-button {
+ background-position: left -109px;
+ color: #fff !important;
+ padding-top: 3px;
+ font-weight: bold;
+}
+a.red-button span {
+ background-position: right -435px;
+ padding-top: 3px;
+}
+a.red-button:hover {
+ background-position: left -137px;
+}
+a.red-button:hover span {
+ background-position: right -463px;
+}
+a.red-button:active, .red-active-button {
+ background-position: left -165px;
+}
+a.red-button:active span, .red-active-button span {
+ background-position: right -491px;
+}
+body .red-disabled-button {
+ background-position: left -192px;
+ color: #DC4143 !important;
+}
+body .red-disabled-button span {
+ background-position: right -518px;
+}
View
61 css/report.css
@@ -0,0 +1,61 @@
+@CHARSET "UTF-8";
+
+
+body { xfont-family: Zapfino, cursive; font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif}
+xh1 { padding-left: 0.5em; font-family: 'HelveticaNeue-UltraLight', 'Helvetica Neue UltraLight', 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 24px; font-weight: 100; letter-spacing: 1px; color: #eee; background-color: #333;}
+
+h1 { padding-left: 0.5em; font-family: Zapfino, cursive; font-size: 24px; font-weight: 100; letter-spacing: 1px; color: #eee; background-color: #333;}
+h2 { padding-left: 0px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 50px; font-weight: bold; letter-spacing: -6px; color: #999; margin: 0}
+h3 { margin: 0; padding: 0; padding-top: 20px; font-family: Zapfino, cursive; line-height: 1.1em; font-weight: normal; font-size: 24px;}
+p { margin: 0; padding: 0; padding-top: 5px; font-family: Zapfino, cursive; line-height: 1.1em;}
+
+hr { border: 0px solid white; border-top: 2px dotted #666;
+color: white;
+height: 1px;}
+
+.indent {padding-left: 1em}
+.results { margin: 0; padding: 0; padding-left: 1em; font-family: Gotham, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; font-weight: normal; letter-spacing: -0px; color: #444; line-height: 1.1em}
+.alternative { text-decoration: underline; color: #666; }
+.alternatives { xfloat: left; }
+
+.clear { /* generic container (i.e. div) for floating buttons */
+ overflow: hidden;
+ width: 100%;
+}
+
+a.button {
+ background: transparent url('bg_button_a.gif') no-repeat scroll top right;
+ color: #444;
+ display: block;
+ float: left;
+ font: normal 12px arial, sans-serif;
+ height: 24px;
+ margin-right: 6px;
+ padding-right: 18px; /* sliding doors padding */
+ text-decoration: none;
+}
+
+a.button span {
+ background: transparent url('bg_button_span.gif') no-repeat;
+ display: block;
+ line-height: 14px;
+ padding: 5px 0 5px 18px;
+}
+
+a.button:active {
+ background-position: bottom right;
+ color: #000;
+ outline: none; /* hide dotted outline in Firefox */
+}
+
+a.button:active span {
+ background-position: bottom left;
+ padding: 6px 0 4px 18px; /* push text down 1px */
+}
+
+.forced-text {
+ font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif;
+ font-weight: normal;
+ font-size: 12px;
+ color: #999;
+}
View
BIN css/secondary-newer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN css/secondary.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN css/secondary_light.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
55 example.php
@@ -0,0 +1,55 @@
+<?php
+require_once("core.php");
+
+//we hard code the parcipant ID in this example
+$participant_id = "1017";
+
+//you can provide it in the URL:
+if (isset($_GET['uid']))
+ $participant_id = $_GET['uid'];
+
+//STEP 1: SET THE PARTICIPANT ID
+ab_participant_id($participant_id);
+
+// implement logic based on submission status
+if (isset($_POST['submit_action']))
+{
+ ab_track("conversion");
+
+ echo "<br><br>Success: Conversion Tracked!";
+
+ exit;
+}
+
+
+//STEP 2: DO THE TEST BY CALLING ab_test(..)
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Checkout Button Color Test</title>
+</head>
+<body>
+<form method="post">
+ <p>
+ Hello User #<?php echo $participant_id; ?>,
+ <br />Please press the button if you like its color.
+ </p>
+
+ <?php
+ $size = ab_test('checkout_button_size');
+
+ $font_size = "12pt";
+
+ if ($size == "small")
+ $font_size = "9pt";
+ elseif ($size == "medium")
+ $font_size = "12pt";
+ else //if $size = "large"
+ $font_size = "20pt";
+ ?>
+ <input type="submit" name="submit_action" value="Submit With This Color" style="background-color: <?php echo ab_test('checkout_button_color') ?>; font-size: <?php echo $font_size?>;" />
+</form>
+</body>
+</html>
View
1,024 js/flot/API.txt
@@ -0,0 +1,1024 @@
+Flot Reference
+--------------
+
+Consider a call to the plot function:
+
+ var plot = $.plot(placeholder, data, options)
+
+The placeholder is a jQuery object or DOM element or jQuery expression
+that the plot will be put into. This placeholder needs to have its
+width and height set as explained in the README (go read that now if
+you haven't, it's short). The plot will modify some properties of the
+placeholder so it's recommended you simply pass in a div that you
+don't use for anything else. Make sure you check any fancy styling
+you apply to the div, e.g. background images have been reported to be a
+problem on IE 7.
+
+The format of the data is documented below, as is the available
+options. The "plot" object returned has some methods you can call.
+These are documented separately below.
+
+Note that in general Flot gives no guarantees if you change any of the
+objects you pass in to the plot function or get out of it since
+they're not necessarily deep-copied.
+
+
+Data Format
+-----------
+
+The data is an array of data series:
+
+ [ series1, series2, ... ]
+
+A series can either be raw data or an object with properties. The raw
+data format is an array of points:
+
+ [ [x1, y1], [x2, y2], ... ]
+
+E.g.
+
+ [ [1, 3], [2, 14.01], [3.5, 3.14] ]
+
+Note that to simplify the internal logic in Flot both the x and y
+values must be numbers (even if specifying time series, see below for
+how to do this). This is a common problem because you might retrieve
+data from the database and serialize them directly to JSON without
+noticing the wrong type. If you're getting mysterious errors, double
+check that you're inputting numbers and not strings.
+
+If a null is specified as a point or if one of the coordinates is null
+or couldn't be converted to a number, the point is ignored when
+drawing. As a special case, a null value for lines is interpreted as a
+line segment end, i.e. the points before and after the null value are
+not connected.
+
+Lines and points take two coordinates. For bars, you can specify a
+third coordinate which is the bottom of the bar (defaults to 0).
+
+The format of a single series object is as follows:
+
+ {
+ color: color or number
+ data: rawdata
+ label: string
+ lines: specific lines options
+ bars: specific bars options
+ points: specific points options
+ xaxis: 1 or 2
+ yaxis: 1 or 2
+ clickable: boolean
+ hoverable: boolean
+ shadowSize: number
+ }
+
+You don't have to specify any of them except the data, the rest are
+options that will get default values. Typically you'd only specify
+label and data, like this:
+
+ {
+ label: "y = 3",
+ data: [[0, 3], [10, 3]]
+ }
+
+The label is used for the legend, if you don't specify one, the series
+will not show up in the legend.
+
+If you don't specify color, the series will get a color from the
+auto-generated colors. The color is either a CSS color specification
+(like "rgb(255, 100, 123)") or an integer that specifies which of
+auto-generated colors to select, e.g. 0 will get color no. 0, etc.
+
+The latter is mostly useful if you let the user add and remove series,
+in which case you can hard-code the color index to prevent the colors
+from jumping around between the series.
+
+The "xaxis" and "yaxis" options specify which axis to use, specify 2
+to get the secondary axis (x axis at top or y axis to the right).
+E.g., you can use this to make a dual axis plot by specifying
+{ yaxis: 2 } for one data series.
+
+"clickable" and "hoverable" can be set to false to disable
+interactivity for specific series if interactivity is turned on in
+the plot, see below.
+
+The rest of the options are all documented below as they are the same
+as the default options passed in via the options parameter in the plot
+commmand. When you specify them for a specific data series, they will
+override the default options for the plot for that data series.
+
+Here's a complete example of a simple data specification:
+
+ [ { label: "Foo", data: [ [10, 1], [17, -14], [30, 5] ] },
+ { label: "Bar", data: [ [11, 13], [19, 11], [30, -7] ] } ]
+
+
+Plot Options
+------------
+
+All options are completely optional. They are documented individually
+below, to change them you just specify them in an object, e.g.
+
+ var options = {
+ series: {
+ lines: { show: true },
+ points: { show: true }
+ }
+ };
+
+ $.plot(placeholder, data, options);
+
+
+Customizing the legend
+======================
+
+ legend: {
+ show: boolean
+ labelFormatter: null or (fn: string, series object -> string)
+ labelBoxBorderColor: color
+ noColumns: number
+ position: "ne" or "nw" or "se" or "sw"
+ margin: number of pixels or [x margin, y margin]
+ backgroundColor: null or color
+ backgroundOpacity: number between 0 and 1
+ container: null or jQuery object/DOM element/jQuery expression
+ }
+
+The legend is generated as a table with the data series labels and
+small label boxes with the color of the series. If you want to format
+the labels in some way, e.g. make them to links, you can pass in a
+function for "labelFormatter". Here's an example that makes them
+clickable:
+
+ labelFormatter: function(label, series) {
+ // series is the series object for the label
+ return '<a href="#' + label + '">' + label + '</a>';
+ }
+
+"noColumns" is the number of columns to divide the legend table into.
+"position" specifies the overall placement of the legend within the
+plot (top-right, top-left, etc.) and margin the distance to the plot
+edge (this can be either a number or an array of two numbers like [x,
+y]). "backgroundColor" and "backgroundOpacity" specifies the
+background. The default is a partly transparent auto-detected
+background.
+
+If you want the legend to appear somewhere else in the DOM, you can
+specify "container" as a jQuery object/expression to put the legend
+table into. The "position" and "margin" etc. options will then be
+ignored. Note that Flot will overwrite the contents of the container.
+
+
+Customizing the axes
+====================
+
+ xaxis, yaxis, x2axis, y2axis: {
+ mode: null or "time"
+ min: null or number
+ max: null or number
+ autoscaleMargin: null or number
+
+ labelWidth: null or number
+ labelHeight: null or number
+
+ transform: null or fn: number -> number
+ inverseTransform: null or fn: number -> number
+
+ ticks: null or number or ticks array or (fn: range -> ticks array)
+ tickSize: number or array
+ minTickSize: number or array
+ tickFormatter: (fn: number, object -> string) or string
+ tickDecimals: null or number
+ }
+
+All axes have the same kind of options. The "mode" option
+determines how the data is interpreted, the default of null means as
+decimal numbers. Use "time" for time series data, see the next section.
+
+The options "min"/"max" are the precise minimum/maximum value on the
+scale. If you don't specify either of them, a value will automatically
+be chosen based on the minimum/maximum data values.
+
+The "autoscaleMargin" is a bit esoteric: it's the fraction of margin
+that the scaling algorithm will add to avoid that the outermost points
+ends up on the grid border. Note that this margin is only applied
+when a min or max value is not explicitly set. If a margin is
+specified, the plot will furthermore extend the axis end-point to the
+nearest whole tick. The default value is "null" for the x axis and
+0.02 for the y axis which seems appropriate for most cases.
+
+"labelWidth" and "labelHeight" specifies a fixed size of the tick
+labels in pixels. They're useful in case you need to align several
+plots.
+
+"transform" and "inverseTransform" are callbacks you can put in to
+change the way the data is drawn. You can design a function to
+compress or expand certain parts of the axis non-linearly, e.g.
+suppress weekends or compress far away points with a logarithm or some
+other means. When Flot draws the plot, each value is first put through
+the transform function. Here's an example, the x axis can be turned
+into a natural logarithm axis with the following code:
+
+ xaxis: {
+ transform: function (v) { return Math.log(v); },
+ inverseTransform: function (v) { return Math.exp(v); }
+ }
+
+Note that for finding extrema, Flot assumes that the transform
+function does not reorder values (monotonicity is assumed).
+
+The inverseTransform is simply the inverse of the transform function
+(so v == inverseTransform(transform(v)) for all relevant v). It is
+required for converting from canvas coordinates to data coordinates,
+e.g. for a mouse interaction where a certain pixel is clicked. If you
+don't use any interactive features of Flot, you may not need it.
+
+
+The rest of the options deal with the ticks.
+
+If you don't specify any ticks, a tick generator algorithm will make
+some for you. The algorithm has two passes. It first estimates how
+many ticks would be reasonable and uses this number to compute a nice
+round tick interval size. Then it generates the ticks.
+
+You can specify how many ticks the algorithm aims for by setting
+"ticks" to a number. The algorithm always tries to generate reasonably
+round tick values so even if you ask for three ticks, you might get
+five if that fits better with the rounding. If you don't want any
+ticks at all, set "ticks" to 0 or an empty array.
+
+Another option is to skip the rounding part and directly set the tick
+interval size with "tickSize". If you set it to 2, you'll get ticks at
+2, 4, 6, etc. Alternatively, you can specify that you just don't want
+ticks at a size less than a specific tick size with "minTickSize".
+Note that for time series, the format is an array like [2, "month"],
+see the next section.
+
+If you want to completely override the tick algorithm, you can specify
+an array for "ticks", either like this:
+
+ ticks: [0, 1.2, 2.4]
+
+Or like this where the labels are also customized:
+
+ ticks: [[0, "zero"], [1.2, "one mark"], [2.4, "two marks"]]
+
+You can mix the two if you like.
+
+For extra flexibility you can specify a function as the "ticks"
+parameter. The function will be called with an object with the axis
+min and max and should return a ticks array. Here's a simplistic tick
+generator that spits out intervals of pi, suitable for use on the x
+axis for trigonometric functions:
+
+ function piTickGenerator(axis) {
+ var res = [], i = Math.floor(axis.min / Math.PI);
+ do {
+ var v = i * Math.PI;
+ res.push([v, i + "\u03c0"]);
+ ++i;
+ } while (v < axis.max);
+
+ return res;
+ }
+
+
+You can control how the ticks look like with "tickDecimals", the
+number of decimals to display (default is auto-detected).
+
+Alternatively, for ultimate control over how ticks look like you can
+provide a function to "tickFormatter". The function is passed two
+parameters, the tick value and an "axis" object with information, and
+should return a string. The default formatter looks like this:
+
+ function formatter(val, axis) {
+ return val.toFixed(axis.tickDecimals);
+ }
+
+The axis object has "min" and "max" with the range of the axis,
+"tickDecimals" with the number of decimals to round the value to and
+"tickSize" with the size of the interval between ticks as calculated
+by the automatic axis scaling algorithm (or specified by you). Here's
+an example of a custom formatter:
+
+ function suffixFormatter(val, axis) {
+ if (val > 1000000)
+ return (val / 1000000).toFixed(axis.tickDecimals) + " MB";
+ else if (val > 1000)
+ return (val / 1000).toFixed(axis.tickDecimals) + " kB";
+ else
+ return val.toFixed(axis.tickDecimals) + " B";
+ }
+
+Time series data
+================
+
+Time series are a bit more difficult than scalar data because
+calendars don't follow a simple base 10 system. For many cases, Flot
+abstracts most of this away, but it can still be a bit difficult to
+get the data into Flot. So we'll first discuss the data format.
+
+The time series support in Flot is based on Javascript timestamps,
+i.e. everywhere a time value is expected or handed over, a Javascript
+timestamp number is used. This is a number, not a Date object. A
+Javascript timestamp is the number of milliseconds since January 1,
+1970 00:00:00 UTC. This is almost the same as Unix timestamps, except it's
+in milliseconds, so remember to multiply by 1000!
+
+You can see a timestamp like this
+
+ alert((new Date()).getTime())
+
+Normally you want the timestamps to be displayed according to a
+certain time zone, usually the time zone in which the data has been
+produced. However, Flot always displays timestamps according to UTC.
+It has to as the only alternative with core Javascript is to interpret
+the timestamps according to the time zone that the visitor is in,
+which means that the ticks will shift unpredictably with the time zone
+and daylight savings of each visitor.
+
+So given that there's no good support for custom time zones in
+Javascript, you'll have to take care of this server-side.
+
+The easiest way to think about it is to pretend that the data
+production time zone is UTC, even if it isn't. So if you have a
+datapoint at 2002-02-20 08:00, you can generate a timestamp for eight
+o'clock UTC even if it really happened eight o'clock UTC+0200.
+
+In PHP you can get an appropriate timestamp with
+'strtotime("2002-02-20 UTC") * 1000', in Python with
+'calendar.timegm(datetime_object.timetuple()) * 1000', in .NET with
+something like:
+
+ public static int GetJavascriptTimestamp(System.DateTime input)
+ {
+ System.TimeSpan span = new System.TimeSpan(System.DateTime.Parse("1/1/1970").Ticks);
+ System.DateTime time = input.Subtract(span);
+ return (long)(time.Ticks / 10000);
+ }
+
+Javascript also has some support for parsing date strings, so it is
+possible to generate the timestamps manually client-side.
+
+If you've already got the real UTC timestamp, it's too late to use the
+pretend trick described above. But you can fix up the timestamps by
+adding the time zone offset, e.g. for UTC+0200 you would add 2 hours
+to the UTC timestamp you got. Then it'll look right on the plot. Most
+programming environments have some means of getting the timezone
+offset for a specific date (note that you need to get the offset for
+each individual timestamp to account for daylight savings).
+
+Once you've gotten the timestamps into the data and specified "time"
+as the axis mode, Flot will automatically generate relevant ticks and
+format them. As always, you can tweak the ticks via the "ticks" option
+- just remember that the values should be timestamps (numbers), not
+Date objects.
+
+Tick generation and formatting can also be controlled separately
+through the following axis options:
+
+ minTickSize: array
+ timeformat: null or format string
+ monthNames: null or array of size 12 of strings
+ twelveHourClock: boolean
+
+Here "timeformat" is a format string to use. You might use it like
+this:
+
+ xaxis: {
+ mode: "time"
+ timeformat: "%y/%m/%d"
+ }
+
+This will result in tick labels like "2000/12/24". The following
+specifiers are supported
+
+ %h: hours
+ %H: hours (left-padded with a zero)
+ %M: minutes (left-padded with a zero)
+ %S: seconds (left-padded with a zero)
+ %d: day of month (1-31)
+ %m: month (1-12)
+ %y: year (four digits)
+ %b: month name (customizable)
+ %p: am/pm, additionally switches %h/%H to 12 hour instead of 24
+ %P: AM/PM (uppercase version of %p)
+
+You can customize the month names with the "monthNames" option. For
+instance, for Danish you might specify:
+
+ monthNames: ["jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec"]
+
+If you set "twelveHourClock" to true, the autogenerated timestamps
+will use 12 hour AM/PM timestamps instead of 24 hour.
+
+The format string and month names are used by a very simple built-in
+format function that takes a date object, a format string (and
+optionally an array of month names) and returns the formatted string.
+If needed, you can access it as $.plot.formatDate(date, formatstring,
+monthNames) or even replace it with another more advanced function
+from a date library if you're feeling adventurous.
+
+If everything else fails, you can control the formatting by specifying
+a custom tick formatter function as usual. Here's a simple example
+which will format December 24 as 24/12:
+
+ tickFormatter: function (val, axis) {
+ var d = new Date(val);
+ return d.getUTCDate() + "/" + (d.getUTCMonth() + 1);
+ }
+
+Note that for the time mode "tickSize" and "minTickSize" are a bit
+special in that they are arrays on the form "[value, unit]" where unit
+is one of "second", "minute", "hour", "day", "month" and "year". So
+you can specify
+
+ minTickSize: [1, "month"]
+
+to get a tick interval size of at least 1 month and correspondingly,
+if axis.tickSize is [2, "day"] in the tick formatter, the ticks have
+been produced with two days in-between.
+
+
+
+Customizing the data series
+===========================
+
+ series: {
+ lines, points, bars: {
+ show: boolean
+ lineWidth: number
+ fill: boolean or number
+ fillColor: null or color/gradient
+ }
+
+ points: {
+ radius: number
+ }
+
+ bars: {
+ barWidth: number
+ align: "left" or "center"
+ horizontal: boolean
+ }
+
+ lines: {
+ steps: boolean
+ }
+
+ shadowSize: number
+ }
+
+ colors: [ color1, color2, ... ]
+
+The options inside "series: {}" are copied to each of the series. So
+you can specify that all series should have bars by putting it in the
+global options, or override it for individual series by specifying
+bars in a particular the series object in the array of data.
+
+The most important options are "lines", "points" and "bars" that
+specify whether and how lines, points and bars should be shown for
+each data series. In case you don't specify anything at all, Flot will
+default to showing lines (you can turn this off with
+lines: { show: false}). You can specify the various types
+independently of each other, and Flot will happily draw each of them
+in turn (this is probably only useful for lines and points), e.g.
+
+ var options = {
+ series: {
+ lines: { show: true, fill: true, fillColor: "rgba(255, 255, 255, 0.8)" },
+ points: { show: true, fill: false }
+ }
+ };
+
+"lineWidth" is the thickness of the line or outline in pixels. You can
+set it to 0 to prevent a line or outline from being drawn; this will
+also hide the shadow.
+
+"fill" is whether the shape should be filled. For lines, this produces
+area graphs. You can use "fillColor" to specify the color of the fill.
+If "fillColor" evaluates to false (default for everything except
+points which are filled with white), the fill color is auto-set to the
+color of the data series. You can adjust the opacity of the fill by
+setting fill to a number between 0 (fully transparent) and 1 (fully
+opaque).
+
+For bars, fillColor can be a gradient, see the gradient documentation
+below. "barWidth" is the width of the bars in units of the x axis (or
+the y axis if "horizontal" is true), contrary to most other measures
+that are specified in pixels. For instance, for time series the unit
+is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of
+a day. "align" specifies whether a bar should be left-aligned
+(default) or centered on top of the value it represents. When
+"horizontal" is on, the bars are drawn horizontally, i.e. from the y
+axis instead of the x axis; note that the bar end points are still
+defined in the same way so you'll probably want to swap the
+coordinates if you've been plotting vertical bars first.
+
+For lines, "steps" specifies whether two adjacent data points are
+connected with a straight (possibly diagonal) line or with first a
+horizontal and then a vertical line. Note that this transforms the
+data by adding extra points.
+
+"shadowSize" is the default size of shadows in pixels. Set it to 0 to
+remove shadows.
+
+The "colors" array specifies a default color theme to get colors for
+the data series from. You can specify as many colors as you like, like
+this:
+
+ colors: ["#d18b2c", "#dba255", "#919733"]
+
+If there are more data series than colors, Flot will try to generate
+extra colors by lightening and darkening colors in the theme.
+
+
+Customizing the grid
+====================
+
+ grid: {
+ show: boolean
+ aboveData: boolean
+ color: color
+ backgroundColor: color/gradient or null
+ tickColor: color
+ labelMargin: number
+ markings: array of markings or (fn: axes -> array of markings)
+ borderWidth: number
+ borderColor: color or null
+ clickable: boolean
+ hoverable: boolean
+ autoHighlight: boolean
+ mouseActiveRadius: number
+ }
+
+The grid is the thing with the axes and a number of ticks. "color" is
+the color of the grid itself whereas "backgroundColor" specifies the
+background color inside the grid area. The default value of null means
+that the background is transparent. You can also set a gradient, see
+the gradient documentation below.
+
+You can turn off the whole grid including tick labels by setting
+"show" to false. "aboveData" determines whether the grid is drawn on
+above the data or below (below is default).
+
+"tickColor" is the color of the ticks and "labelMargin" is the spacing
+between tick labels and the grid. Note that you can style the tick
+labels with CSS, e.g. to change the color. They have class "tickLabel".
+"borderWidth" is the width of the border around the plot. Set it to 0
+to disable the border. You can also set "borderColor" if you want the
+border to have a different color than the grid lines.
+
+"markings" is used to draw simple lines and rectangular areas in the
+background of the plot. You can either specify an array of ranges on
+the form { xaxis: { from, to }, yaxis: { from, to } } (secondary axis
+coordinates with x2axis/y2axis) or with a function that returns such
+an array given the axes for the plot in an object as the first
+parameter.
+
+You can set the color of markings by specifying "color" in the ranges
+object. Here's an example array:
+
+ markings: [ { xaxis: { from: 0, to: 2 }, yaxis: { from: 10, to: 10 }, color: "#bb0000" }, ... ]
+
+If you leave out one of the values, that value is assumed to go to the
+border of the plot. So for example if you only specify { xaxis: {
+from: 0, to: 2 } } it means an area that extends from the top to the
+bottom of the plot in the x range 0-2.
+
+A line is drawn if from and to are the same, e.g.
+
+ markings: [ { yaxis: { from: 1, to: 1 } }, ... ]
+
+would draw a line parallel to the x axis at y = 1. You can control the
+line width with "lineWidth" in the range object.
+
+An example function might look like this:
+
+ markings: function (axes) {
+ var markings = [];
+ for (var x = Math.floor(axes.xaxis.min); x < axes.xaxis.max; x += 2)
+ markings.push({ xaxis: { from: x, to: x + 1 } });
+ return markings;
+ }
+
+
+If you set "clickable" to true, the plot will listen for click events
+on the plot area and fire a "plotclick" event on the placeholder with
+a position and a nearby data item object as parameters. The coordinates
+are available both in the unit of the axes (not in pixels) and in
+global screen coordinates.
+
+Likewise, if you set "hoverable" to true, the plot will listen for
+mouse move events on the plot area and fire a "plothover" event with
+the same parameters as the "plotclick" event. If "autoHighlight" is
+true (the default), nearby data items are highlighted automatically.
+If needed, you can disable highlighting and control it yourself with
+the highlight/unhighlight plot methods described elsewhere.
+
+You can use "plotclick" and "plothover" events like this:
+
+ $.plot($("#placeholder"), [ d ], { grid: { clickable: true } });
+
+ $("#placeholder").bind("plotclick", function (event, pos, item) {
+ alert("You clicked at " + pos.x + ", " + pos.y);
+ // secondary axis coordinates if present are in pos.x2, pos.y2,
+ // if you need global screen coordinates, they are pos.pageX, pos.pageY
+
+ if (item) {
+ highlight(item.series, item.datapoint);
+ alert("You clicked a point!");
+ }
+ });
+
+The item object in this example is either null or a nearby object on the form:
+
+ item: {
+ datapoint: the point, e.g. [0, 2]
+ dataIndex: the index of the point in the data array
+ series: the series object
+ seriesIndex: the index of the series
+ pageX, pageY: the global screen coordinates of the point
+ }
+
+For instance, if you have specified the data like this
+
+ $.plot($("#placeholder"), [ { label: "Foo", data: [[0, 10], [7, 3]] } ], ...);
+
+and the mouse is near the point (7, 3), "datapoint" is [7, 3],
+"dataIndex" will be 1, "series" is a normalized series object with
+among other things the "Foo" label in series.label and the color in
+series.color, and "seriesIndex" is 0. Note that plugins and options
+that transform the data can shift the indexes from what you specified
+in the original data array.
+
+If you use the above events to update some other information and want
+to clear out that info in case the mouse goes away, you'll probably
+also need to listen to "mouseout" events on the placeholder div.
+
+"mouseActiveRadius" specifies how far the mouse can be from an item
+and still activate it. If there are two or more points within this
+radius, Flot chooses the closest item. For bars, the top-most bar
+(from the latest specified data series) is chosen.
+
+If you want to disable interactivity for a specific data series, you
+can set "hoverable" and "clickable" to false in the options for that
+series, like this { data: [...], label: "Foo", clickable: false }.
+
+
+Specifying gradients
+====================
+
+A gradient is specified like this:
+
+ { colors: [ color1, color2, ... ] }
+
+For instance, you might specify a background on the grid going from
+black to gray like this:
+
+ grid: {
+ backgroundColor: { colors: ["#000", "#999"] }
+ }
+
+For the series you can specify the gradient as an object that
+specifies the scaling of the brightness and the opacity of the series
+color, e.g.
+
+ { colors: [{ opacity: 0.8 }, { brightness: 0.6, opacity: 0.8 } ] }
+
+where the first color simply has its alpha scaled, whereas the second
+is also darkened. For instance, for bars the following makes the bars
+gradually disappear, without outline:
+
+ bars: {
+ show: true,
+ lineWidth: 0,
+ fill: true,
+ fillColor: { colors: [ { opacity: 0.8 }, { opacity: 0.1 } ] }
+ }
+
+Flot currently only supports vertical gradients drawn from top to
+bottom because that's what works with IE.
+
+
+Plot Methods
+------------
+
+The Plot object returned from the plot function has some methods you
+can call:
+
+ - highlight(series, datapoint)
+
+ Highlight a specific datapoint in the data series. You can either
+ specify the actual objects, e.g. if you got them from a
+ "plotclick" event, or you can specify the indices, e.g.
+ highlight(1, 3) to highlight the fourth point in the second series
+ (remember, zero-based indexing).
+
+
+ - unhighlight(series, datapoint) or unhighlight()
+
+ Remove the highlighting of the point, same parameters as
+ highlight.
+
+ If you call unhighlight with no parameters, e.g. as
+ plot.unhighlight(), all current highlights are removed.
+
+
+ - setData(data)
+
+ You can use this to reset the data used. Note that axis scaling,
+ ticks, legend etc. will not be recomputed (use setupGrid() to do
+ that). You'll probably want to call draw() afterwards.
+
+ You can use this function to speed up redrawing a small plot if
+ you know that the axes won't change. Put in the new data with
+ setData(newdata), call draw(), and you're good to go. Note that
+ for large datasets, almost all the time is consumed in draw()
+ plotting the data so in this case don't bother.
+
+
+ - setupGrid()
+
+ Recalculate and set axis scaling, ticks, legend etc.
+
+ Note that because of the drawing model of the canvas, this
+ function will immediately redraw (actually reinsert in the DOM)
+ the labels and the legend, but not the actual tick lines because
+ they're drawn on the canvas. You need to call draw() to get the
+ canvas redrawn.
+
+ - draw()
+
+ Redraws the plot canvas.
+
+ - triggerRedrawOverlay()
+
+ Schedules an update of an overlay canvas used for drawing
+ interactive things like a selection and point highlights. This
+ is mostly useful for writing plugins. The redraw doesn't happen
+ immediately, instead a timer is set to catch multiple successive
+ redraws (e.g. from a mousemove).
+
+ - width()/height()
+
+ Gets the width and height of the plotting area inside the grid.
+ This is smaller than the canvas or placeholder dimensions as some
+ extra space is needed (e.g. for labels).
+
+ - offset()
+
+ Returns the offset of the plotting area inside the grid relative
+ to the document, useful for instance for calculating mouse
+ positions (event.pageX/Y minus this offset is the pixel position
+ inside the plot).
+
+ - pointOffset({ x: xpos, y: ypos })
+
+ Returns the calculated offset of the data point at (x, y) in data
+ space within the placeholder div. If you are working with dual axes, you
+ can specify the x and y axis references, e.g.
+
+ o = pointOffset({ x: xpos, y: ypos, xaxis: 2, yaxis: 2 })
+ // o.left and o.top now contains the offset within the div
+
+
+There are also some members that let you peek inside the internal
+workings of Flot which is useful in some cases. Note that if you change
+something in the objects returned, you're changing the objects used by
+Flot to keep track of its state, so be careful.
+
+ - getData()
+
+ Returns an array of the data series currently used in normalized
+ form with missing settings filled in according to the global
+ options. So for instance to find out what color Flot has assigned
+ to the data series, you could do this:
+
+ var series = plot.getData();
+ for (var i = 0; i < series.length; ++i)
+ alert(series[i].color);
+
+ A notable other interesting field besides color is datapoints
+ which has a field "points" with the normalized data points in a
+ flat array (the field "pointsize" is the increment in the flat
+ array to get to the next point so for a dataset consisting only of
+ (x,y) pairs it would be 2).
+
+ - getAxes()
+
+ Gets an object with the axes settings as { xaxis, yaxis, x2axis,
+ y2axis }.
+
+ Various things are stuffed inside an axis object, e.g. you could
+ use getAxes().xaxis.ticks to find out what the ticks are for the
+ xaxis. Two other useful attributes are p2c and c2p, functions for
+ transforming from data point space to the canvas plot space and
+ back. Both returns values that are offset with the plot offset.
+
+ - getPlaceholder()
+
+ Returns placeholder that the plot was put into. This can be useful
+ for plugins for adding DOM elements or firing events.
+
+ - getCanvas()
+
+ Returns the canvas used for drawing in case you need to hack on it
+ yourself. You'll probably need to get the plot offset too.
+
+ - getPlotOffset()
+
+ Gets the offset that the grid has within the canvas as an object
+ with distances from the canvas edges as "left", "right", "top",
+ "bottom". I.e., if you draw a circle on the canvas with the center
+ placed at (left, top), its center will be at the top-most, left
+ corner of the grid.
+
+ - getOptions()
+
+ Gets the options for the plot, in a normalized format with default
+ values filled in.
+
+
+Hooks
+=====
+
+In addition to the public methods, the Plot object also has some hooks
+that can be used to modify the plotting process. You can install a
+callback function at various points in the process, the function then
+gets access to the internal data structures in Flot.
+
+Here's an overview of the phases Flot goes through:
+
+ 1. Plugin initialization, parsing options
+
+ 2. Constructing the canvases used for drawing
+
+ 3. Set data: parsing data specification, calculating colors,
+ copying raw data points into internal format,
+ normalizing them, finding max/min for axis auto-scaling
+
+ 4. Grid setup: calculating axis spacing, ticks, inserting tick
+ labels, the legend
+
+ 5. Draw: drawing the grid, drawing each of the series in turn
+
+ 6. Setting up event handling for interactive features
+
+ 7. Responding to events, if any
+
+Each hook is simply a function which is put in the appropriate array.
+You can add them through the "hooks" option, and they are also available
+after the plot is constructed as the "hooks" attribute on the returned
+plot object, e.g.
+
+ // define a simple draw hook
+ function hellohook(plot, canvascontext) { alert("hello!"); };
+
+ // pass it in, in an array since we might want to specify several
+ var plot = $.plot(placeholder, data, { hooks: { draw: [hellohook] } });
+
+ // we can now find it again in plot.hooks.draw[0] unless a plugin
+ // has added other hooks
+
+The available hooks are described below. All hook callbacks get the
+plot object as first parameter. You can find some examples of defined
+hooks in the plugins bundled with Flot.
+
+ - processOptions [phase 1]
+
+ function(plot, options)
+
+ Called after Flot has parsed and merged options. Useful in the
+ instance where customizations beyond simple merging of default
+ values is needed. A plugin might use it to detect that it has been
+ enabled and then turn on or off other options.
+
+
+ - processRawData [phase 3]
+
+ function(plot, series, data, datapoints)
+
+ Called before Flot copies and normalizes the raw data for the given
+ series. If the function fills in datapoints.points with normalized
+ points and sets datapoints.pointsize to the size of the points,
+ Flot will skip the copying/normalization step for this series.
+
+ In any case, you might be interested in setting datapoints.format,
+ an array of objects for specifying how a point is normalized and
+ how it interferes with axis scaling.
+
+ The default format array for points is something along the lines of:
+
+ [
+ { x: true, number: true, required: true },
+ { y: true, number: true, required: true }
+ ]
+
+ The first object means that for the first coordinate it should be
+ taken into account when scaling the x axis, that it must be a
+ number, and that it is required - so if it is null or cannot be
+ converted to a number, the whole point will be zeroed out with
+ nulls. Beyond these you can also specify "defaultValue", a value to
+ use if the coordinate is null. This is for instance handy for bars
+ where one can omit the third coordinate (the bottom of the bar)
+ which then defaults to 0.
+
+
+ - processDatapoints [phase 3]
+
+ function(plot, series, datapoints)
+
+ Called after normalization of the given series but before finding
+ min/max of the data points. This hook is useful for implementing data
+ transformations. "datapoints" contains the normalized data points in
+ a flat array as datapoints.points with the size of a single point
+ given in datapoints.pointsize. Here's a simple transform that
+ multiplies all y coordinates by 2:
+
+ function multiply(plot, series, datapoints) {
+ var points = datapoints.points, ps = datapoints.pointsize;
+ for (var i = 0; i < points.length; i += ps)
+ points[i + 1] *= 2;
+ }
+
+ Note that you must leave datapoints in a good condition as Flot
+ doesn't check it or do any normalization on it afterwards.
+
+
+ - draw [phase 5]
+
+ function(plot, canvascontext)
+
+ Hook for drawing on the canvas. Called after the grid is drawn
+ (unless it's disabled) and the series have been plotted (in case
+ any points, lines or bars have been turned on). For examples of how
+ to draw things, look at the source code.
+
+
+ - bindEvents [phase 6]
+
+ function(plot, eventHolder)
+
+ Called after Flot has setup its event handlers. Should set any
+ necessary event handlers on eventHolder, a jQuery object with the
+ canvas, e.g.
+
+ function (plot, eventHolder) {
+ eventHolder.mousedown(function (e) {
+ alert("You pressed the mouse at " + e.pageX + " " + e.pageY);
+ });
+ }
+
+ Interesting events include click, mousemove, mouseup/down. You can
+ use all jQuery events. Usually, the event handlers will update the
+ state by drawing something (add a drawOverlay hook and call
+ triggerRedrawOverlay) or firing an externally visible event for
+ user code. See the crosshair plugin for an example.
+
+ Currently, eventHolder actually contains both the static canvas
+ used for the plot itself and the overlay canvas used for
+ interactive features because some versions of IE get the stacking
+ order wrong. The hook only gets one event, though (either for the
+ overlay or for the static canvas).
+
+
+ - drawOverlay [phase 7]
+
+ function (plot, canvascontext)
+
+ The drawOverlay hook is used for interactive things that need a
+ canvas to draw on. The model currently used by Flot works the way
+ that an extra overlay canvas is positioned on top of the static
+ canvas. This overlay is cleared and then completely redrawn
+ whenever something interesting happens. This hook is called when
+ the overlay canvas is to be redrawn.
+
+ "canvascontext" is the 2D context of the overlay canvas. You can
+ use this to draw things. You'll most likely need some of the
+ metrics computed by Flot, e.g. plot.width()/plot.height(). See the
+ crosshair plugin for an example.
+
+
+
+Plugins
+-------
+
+Plugins extend the functionality of Flot. To use a plugin, simply
+include its Javascript file after Flot in the HTML page.
+
+If you're worried about download size/latency, you can concatenate all
+the plugins you use, and Flot itself for that matter, into one big file
+(make sure you get the order right), then optionally run it through a
+Javascript minifier such as YUI Compressor.
+
+Here's a brief explanation of how the plugin plumbings work:
+
+Each plugin registers itself in the global array $.plot.plugins. When
+you make a new plot object with $.plot, Flot goes through this array
+calling the "init" function of each plugin and merging default options
+from its "option" attribute. The init function gets a reference to the
+plot object created and uses this to register hooks and add new public
+methods if needed.
+
+See the PLUGINS.txt file for details on how to write a plugin. As the
+above description hints, it's actually pretty easy.
View
71 js/flot/FAQ.txt
@@ -0,0 +1,71 @@
+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 [widget framework xyz]!
+
+A: The problem is most likely within the framework, or your use of the
+framework.
+
+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. As a last resort, you might try replotting and see if it helps.
+
+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 mailing list, but please don't submit a bug report to Flot -
+try the framework instead.
View
22 js/flot/LICENSE.txt
@@ -0,0 +1,22 @@
+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.
View
15 js/flot/Makefile
@@ -0,0 +1,15 @@
+# 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 listing them
+all: $(patsubst %.js,%.min.js,$(filter-out %.min.js,$(wildcard *.js)))
+
+%.min.js: %.js
+ java -jar $(YUICOMPRESSOR_PATH) $< -o $@
View
340 js/flot/NEWS.txt
@@ -0,0 +1,340 @@
+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 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.
View
105 js/flot/PLUGINS.txt
@@ -0,0 +1,105 @@
+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.
View
81 js/flot/README.txt
@@ -0,0 +1,81 @@
+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.
View
143 js/flot/examples/ajax.html
@@ -0,0 +1,143 @@
+<!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