Commit ed791745 authored by David Schnur's avatar David Schnur

Re-styled and cleaned up all the examples.

parent 8e8327f5
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: AJAX</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
<div id="placeholder" style="width:600px;height:300px;"></div>
$(function() {
<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 type="text/javascript">
$(function () {
var options = {
lines: { show: true },
points: { show: true },
xaxis: { tickDecimals: 0, tickSize: 1 }
lines: {
show: true
},
points: {
show: true
},
xaxis: {
tickDecimals: 0,
tickSize: 1
}
};
var data = [];
var placeholder = $("#placeholder");
$.plot(placeholder, data, options);
$.plot("#placeholder", data, options);
// Fetch one series, adding to what we already have
// fetch one series, adding to what we got
var alreadyFetched = {};
$("input.fetchSeries").click(function () {
$("button.fetchSeries").click(function () {
var button = $(this);
// find the URL in the link right next to us
// Find the URL in the link right next to us, then fetch the data
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);
// Extract the first coordinate pair; jQuery has parsed it, so
// the data is now just an ordinary JavaScript object
var firstcoordinate = "(" + series.data[0][0] + ", " + series.data[0][1] + ")";
button.siblings("span").text("Fetched " + series.label + ", first point: " + firstcoordinate);
// Push the new data onto our existing data array
// 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);
$.plot("#placeholder", data, options);
}
$.ajax({
url: dataurl,
type: 'GET',
dataType: 'json',
type: "GET",
dataType: "json",
success: onDataReceived
});
});
// Initiate a recurring data update
$("button.dataUpdate").click(function () {
// initiate a recurring data update
$("input.dataUpdate").click(function () {
// reset data
data = [];
alreadyFetched = {};
$.plot(placeholder, data, options);
$.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);
// Load all the data in one pass; if we only got partial
// data we could merge it with what we already have.
data = [ series ];
$.plot("#placeholder", data, options);
}
// Normally we 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.
$.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",
type: 'GET',
dataType: 'json',
type: "GET",
dataType: "json",
success: onDataReceived
});
if (iteration < 5)
if (iteration < 5) {
setTimeout(fetchData, 1000);
else {
} else {
data = [];
alreadyFetched = {};
}
......@@ -136,8 +111,55 @@ $(function () {
setTimeout(fetchData, 1000);
});
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>AJAX</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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>
<button class="fetchSeries">First dataset</button>
[ <a href="data-eu-gdp-growth.json">see data</a> ]
<span></span>
</p>
<p>
<button class="fetchSeries">Second dataset</button>
[ <a href="data-japan-gdp-growth.json">see data</a> ]
<span></span>
</p>
<p>
<button class="fetchSeries">Third dataset</button>
[ <a href="data-usa-gdp-growth.json">see data</a> ]
<span></span>
</p>
<p>If you combine AJAX with setTimeout, you can poll the server for new data.</p>
<p>
<button class="dataUpdate">Poll for data</button>
</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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 type="text/javascript">
$(function () {
// generate a dataset
<title>Flot Examples: Adding Annotations</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
$(function() {
var d1 = [];
for (var i = 0; i < 20; ++i)
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 } }
{ 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 },
......@@ -46,19 +34,18 @@ $(function () {
grid: { markings: markings }
});
// add labels
var o;
var o = plot.pointOffset({ x: 2, y: -1.2});
// Append it to the placeholder that Flot already uses for positioning
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>');
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>');
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
// 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;
......@@ -68,8 +55,29 @@ $(function () {
ctx.lineTo(o.left, o.top);
ctx.fillStyle = "#000";
ctx.fill();
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Adding Annotations</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Interacting with axes</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
<p id="click"></p>
$(function() {
<script type="text/javascript">
$(function () {
function generate(start, end, fn) {
var res = [];
for (var i = 0; i <= 100; ++i) {
......@@ -38,9 +27,7 @@ $(function () {
{ data: generate(2, 10, function (x) { return Math.tan(x);}), xaxis: 2, yaxis: 4 }
];
var plot = $.plot($("#placeholder"),
data,
{
var plot = $.plot($("#placeholder"), data, {
xaxes: [
{ position: 'bottom' },
{ position: 'top'}
......@@ -73,7 +60,33 @@ $(function () {
$("#click").text("You clicked the " + axis.direction + axis.n + "axis!")
});
});
});
</script>
</body>
});
</script>
</head>
<body>
<div id="header">
<h2>Interacting with axes</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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.</p>
<p>Try clicking an axis.</p>
<p id="click"></p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</html>
This diff is collapsed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flot Example</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.time.js"></script>
<script language="javascript" type="text/javascript" src="../jquery.flot.selection.js"></script>
</head>
<body>
<h1>Timezone Examples</h1>
<table>
<tr><td>UTC</td><td><div id="placeholderUTC" style="width:600px;height:100px;"></div></td></tr>
<tr><td>Browser</td><td><div id="placeholderLocal" style="width:600px;height:100px;"></div></td></tr>
<tr><td>Chicago</td><td><div id="placeholderChicago" style="width:600px;height:100px;"></div></td></tr>
</table>
<title>Flot Examples: Time zones</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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.time.js"></script>
<script language="javascript" type="text/javascript" src="date.js"></script>
<script id="source">
$(function () {
<script type="text/javascript">
$(function() {
timezoneJS.timezone.zoneFileBasePath = "tz";
timezoneJS.timezone.defaultZoneFile = [ ];
timezoneJS.timezone.defaultZoneFile = [];
timezoneJS.timezone.init();
var d = [
[Date.UTC(2011, 2, 12, 14, 0, 0), 28],
[Date.UTC(2011, 2, 12, 15, 0, 0), 27],
......@@ -61,14 +51,60 @@ $(function () {
[Date.UTC(2011, 2, 13, 20, 0, 0), 11],
[Date.UTC(2011, 2, 13, 21, 0, 0), 9],
[Date.UTC(2011, 2, 13, 22, 0, 0), 7.5],
[Date.UTC(2011, 2, 13, 23, 0, 0), 6]];
[Date.UTC(2011, 2, 13, 23, 0, 0), 6]
];
var plot = $.plot("#placeholderUTC", [d], {
xaxis: {
mode: "time"
}
});
var plot = $.plot("#placeholderLocal", [d], {
xaxis: {
mode: "time",
timezone: "browser"
}
});
var plot = $.plot("#placeholderChicago", [d], {
xaxis: {
mode: "time",
timezone: "America/Chicago"
}
});
});
</script>
</head>
<body>
<div id="header">
<h2>Time zones</h2>
</div>
<div id="content">
<h3>UTC</h3>
<div class="demo-container" style="height: 300px;">
<div id="placeholderUTC"></div>
</div>
<h3>Browser</h3>
<div class="demo-container" style="height: 300px;">
<div id="placeholderLocal"></div>
</div>
<h3>Chicago</h3>
<div class="demo-container" style="height: 300px;">
<div id="placeholderChicago"></div>
</div>
var plot = $.plot($("#placeholderUTC"), [d], { xaxis: { mode: "time" } });
var plot = $.plot($("#placeholderLocal"), [d], { xaxis: { mode: "time", timezone: "browser" } });
var plot = $.plot($("#placeholderChicago"), [d], { xaxis: { mode: "time", timezone: "America/Chicago" } });
</div>
});
</script>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
This diff is collapsed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.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">
<!--[if lte IE 8]><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 ticks on the axes, the legend, the graph
type, etc. The idea is that Flot goes to great lengths to provide sensible
defaults so that you don't have to customize much for a good result.</p>
<title>Flot Examples: Basic Options</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
<script type="text/javascript">
$(function () {
$(function () {
var d1 = [];
for ( var i = 0; i < Math.PI * 2; i += 0.25 ) {
d1.push([ i, Math.sin( i ) ]);
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 ) ]);
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 ) ]);
d3.push([i, Math.tan(i)]);
}
$.plot( $("#placeholder"), [
......@@ -69,9 +57,31 @@ $(function () {
}
}
});
});
});
</script>
</head>
<body>
<div id="header">
<h2>Basic Options</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<p>There are plenty of options you can set to control the precise looks of your plot. You can control the ticks on the axes, the legend, the graph type, etc.</p>
<p>Flot goes to great lengths to provide sensible defaults so that you don't have to customize much for a good-looking result.</p>
</div>
</script>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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 type="text/javascript">
$(function () {
<title>Flot Examples: Basic Usage</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
$(function() {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);
......@@ -30,9 +19,32 @@ $(function () {
// 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>
$.plot("#placeholder", [ d1, d2, d3 ]);
});
</script>
</head>
<body>
<div id="header">
<h2>Basic Usage</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<p>You don't have to do much to get an attractive plot. Create a placeholder, make sure it has dimensions (so Flot knows at what size to draw the plot), then call the plot function with your data.</p>
<p>The axes are automatically scaled.</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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.categories.js"></script>
</head>
<body>
<h1>Flot Examples</h1>
<div id="placeholder" style="width:600px;height:300px;"></div>
<p>With the categories plugin you can plot categories/textual data
easily.</p>
<script type="text/javascript">
$(function () {
<title>Flot Examples: Categories</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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.categories.js"></script>
<script type="text/javascript">
$(function() {
var data = [ ["January", 10], ["February", 8], ["March", 4], ["April", 13], ["May", 17], ["June", 9] ];
$.plot($("#placeholder"), [ data ], {
......@@ -26,15 +19,43 @@ $(function () {
bars: {
show: true,
barWidth: 0.6,
align: "center" }
align: "center"
}
},
xaxis: {
mode: "categories",
tickLength: 0
}
});
});
</script>
</body>
});
</script>
</head>
<body>
<div id="header">
<h2>Categories</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<p>With the categories plugin you can plot categories/textual data easily.</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Image Plots</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script type="text/javascript">
<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>
$(function() {
<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>
var data = [[["hs-2004-27-a-large-web.jpg", -10, -10, 10, 10]]];
<script 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 }
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>
});
</script>
</head>
<body>
<div id="header">
<h2>Image Plots</h2>
</div>
<div id="content">
<div class="demo-container" style="width:600px;height:600px;">
<div id="placeholder"></div>
</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 static images against a set of axes. This is for useful for adding ticks to complex prerendered visualizations. Instead of inputting data points, you specify 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>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Interactivity</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
<div id="placeholder" style="width:600px;height:300px"></div>
$(function() {
<p>One of the goals of Flot is to support user interactions. Try
pointing and clicking on the points.</p>
var sin = [],
cos = [];
<p>
<label><input id="enablePosition" type="checkbox">Show mouse position</label>
<span id="hoverdata"></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><label><input id="enableTooltip" type="checkbox">Enable tooltip</label></p>
<script 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)" } ], {
var plot = $.plot($("#placeholder"), [
{ data: sin, label: "sin(x)"},
{ data: cos, label: "cos(x)"}
], {
series: {
lines: { show: true },
points: { show: true }
lines: {
show: true
},
grid: { hoverable: true, clickable: true },
yaxis: { min: -1.2, max: 1.2 }
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',
$("<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',
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) {
if ($("#enablePosition:checked").length > 0) {
var str = "(" + pos.x.toFixed(2) + ", " + pos.y.toFixed(2) + ")";
$("#hoverdata").text(str);
......@@ -68,6 +65,7 @@ $(function () {
if ($("#enableTooltip:checked").length > 0) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
$("#tooltip").remove();
......@@ -77,8 +75,7 @@ $(function () {
showTooltip(item.pageX, item.pageY,
item.series.label + " of " + x + " = " + y);
}
}
else {
} else {
$("#tooltip").remove();
previousPoint = null;
}
......@@ -91,8 +88,39 @@ $(function () {
plot.highlight(item.series, item.datapoint);
}
});
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Interactivity</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<p>One of the goals of Flot is to support user interactions. Try pointing and clicking on the points.</p>
<p>
<label><input id="enablePosition" type="checkbox"></input>Show mouse position</label>
<span id="hoverdata"></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><label><input id="enableTooltip" type="checkbox"></input>Enable tooltip</label></p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Navigation</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<style type="text/css">
#placeholder .button {
position: absolute;
cursor: pointer;
}
#placeholder div.button {
font-size: smaller;
color: #999;
......@@ -23,58 +21,60 @@
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>
</style>
<!--[if lte IE 8]><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>
<script type="text/javascript">
<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>
$(function() {
// generate data set from a parametric function with a fractal look
<script 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)
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)
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 data = [ d1 ],
placeholder = $("#placeholder");
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] },
var plot = $.plot(placeholder, data, {
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) {
placeholder.bind("plotpan", function (event, plot) {
var axes = plot.getAxes();
$(".message").html("Panning to x: " + axes.xaxis.min.toFixed(2)
+ " &ndash; " + axes.xaxis.max.toFixed(2)
......@@ -82,7 +82,7 @@ $(function () {
+ " &ndash; " + axes.yaxis.max.toFixed(2));
});
placeholder.bind('plotzoom', function (event, plot) {
placeholder.bind("plotzoom", function (event, plot) {
var axes = plot.getAxes();
$(".message").html("Zooming to x: " + axes.xaxis.min.toFixed(2)
+ " &ndash; " + axes.xaxis.max.toFixed(2)
......@@ -91,8 +91,11 @@ $(function () {
});
// add zoom out button
$('<div class="button" style="right:20px;top:20px">zoom out</div>').appendTo(placeholder).click(function (e) {
e.preventDefault();
$("<div class='button' style='right:20px;top:20px'>zoom out</div>")
.appendTo(placeholder)
.click(function (event) {
event.preventDefault();
plot.zoomOut();
});
......@@ -100,19 +103,47 @@ $(function () {
// 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) {
$("<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>
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>
</head>
<body>
<div id="header">
<h2>Navigation</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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 type="text/javascript">
$(function () {
<title>Flot Examples: Percentiles</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script 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 = [
......@@ -43,15 +30,46 @@ $(function () {
{ 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' }
xaxis: {
tickDecimals: 0
},
yaxis: {
tickFormatter: function (v) {
return v + " cm";
}
},
legend: {
position: "se"
}
});
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Percentiles</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Real-time updates</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
<div id="placeholder" style="width:600px;height:300px;"></div>
$(function() {
<p>You can update a chart periodically to get a real-time effect
by using a timer to insert the new data in the plot and redraw it.</p>
// We use an inline data source in the example, usually data would
// be fetched from a server
<p>Time between updates: <input id="updateInterval" type="text" value="" style="text-align: right; width:5em"> milliseconds</p>
var data = [],
totalPoints = 300;
<script type="text/javascript">
$(function () {
// we use an inline data source in the example, usually data would
// be fetched from a server
var data = [], totalPoints = 300;
function getRandomData() {
if (data.length > 0)
data = data.slice(1);
// do a random walk
// Do a random walk
while (data.length < totalPoints) {
var prev = data.length > 0 ? data[data.length - 1] : 50;
var y = prev + Math.random() * 10 - 5;
if (y < 0)
var prev = data.length > 0 ? data[data.length - 1] : 50,
y = prev + Math.random() * 10 - 5;
if (y < 0) {
y = 0;
if (y > 100)
} else if (y > 100) {
y = 100;
}
data.push(y);
}
// zip the generated y values with the x values
// Zip the generated y values with the x values
var res = [];
for (var i = 0; i < data.length; ++i)
for (var i = 0; i < data.length; ++i) {
res.push([i, data[i]])
}
return res;
}
// setup control widget
// Set up the control widget
var updateInterval = 30;
$("#updateInterval").val(updateInterval).change(function () {
var v = $(this).val();
if (v && !isNaN(+v)) {
updateInterval = +v;
if (updateInterval < 1)
if (updateInterval < 1) {
updateInterval = 1;
if (updateInterval > 2000)
} else if (updateInterval > 2000) {
updateInterval = 2000;
}
$(this).val("" + updateInterval);
}
});
// setup plot
var options = {
series: { shadowSize: 0 }, // drawing is faster without shadows
yaxis: { min: 0, max: 100 },
xaxis: { show: false }
};
var plot = $.plot($("#placeholder"), [ getRandomData() ], options);
var plot = $.plot($("#placeholder"), [ getRandomData() ], {
series: {
shadowSize: 0 // drawing is faster without shadows
},
yaxis: {
min: 0,
max: 100
},
xaxis: {
show: false
}
});
function update() {
plot.setData([ getRandomData() ]);
// since the axes don't change, we don't need to call plot.setupGrid()
// Since the axes don't change, we don't need to call plot.setupGrid()
plot.draw();
setTimeout(update, updateInterval);
}
update();
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Real-time updates</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<p>You can update a chart periodically to get a real-time effect by using a timer to insert the new data in the plot and redraw it.</p>
<p>Time between updates: <input id="updateInterval" type="text" value="" style="text-align: right; width:5em"> milliseconds</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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.resize.js"></script>
<title>Flot Examples: Resizing</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<style type="text/css">
html, body {
height: 100%; /* make the percentage height on placeholder work */
}
.message {
padding-left: 50px;
font-size: smaller;
}
</style>
</head>
<body>
<h1>Flot Examples</h1>
<div id="placeholder" style="width:80%;height:40%;"></div>
<p class="message"></p>
<p>Sometimes it makes more sense to just let the plot take up the
available space. In that case, we need to redraw the plot each
time the placeholder changes its size. If you include the resize
plugin, this is handled automatically.</p>
<p>Try resizing the window.</p>
</style>
<!--[if lte IE 8]><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.resize.js"></script>
<script type="text/javascript">
$(function() {
<script type="text/javascript">
$(function () {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
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 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
var placeholder = $("#placeholder");
var plot = $.plot(placeholder, [d1, d2, d3]);
// the plugin includes a jQuery plugin for adding resize events to
// any element, let's just add a callback so we can display the
// placeholder size
// The plugin includes a jQuery plugin for adding resize events to any
// element. Add a callback so we can display the placeholder size.
placeholder.resize(function () {
$(".message").text("Placeholder is now "
+ $(this).width() + "x" + $(this).height()
+ " pixels");
});
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Resizing</h2>
</div>
<div id="content" style="width:100%;">
<div class="demo-container" style="width:100%;">
<div id="placeholder"></div>
</div>
<p class="message"></p>
<p>Sometimes it makes more sense to just let the plot take up the available space. In that case, we need to redraw the plot each time the placeholder changes its size. If you include the resize plugin, this is handled automatically.</p>
<!--<p>Drag the handles at the bottom and right of the plot to resize it.</p>-->
<p>Try resizing the window.</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Selection</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script type="text/javascript">
<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>
$(function() {
<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 type="text/javascript">
$(function () {
var data = [
{
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 }
lines: {
show: true
},
points: {
show: true
}
},
legend: { noColumns: 2 },
xaxis: { tickDecimals: 0 },
yaxis: { min: 0 },
selection: { mode: "x" }
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 }
if (zoom) {
plot = $.plot(placeholder, data, $.extend(true, {}, options, {
xaxis: {
min: ranges.xaxis.from,
max: ranges.xaxis.to
}
}));
}
});
placeholder.bind("plotunselected", function (event) {
......@@ -105,10 +87,51 @@ $(function () {
});
$("#setSelection").click(function () {
plot.setSelection({ xaxis: { from: 1994, to: 1995 } });
plot.setSelection({
xaxis: {
from: 1994,
to: 1995
}
});
});
});
});
</script>
</body>
</script>
</head>
<body>
<div id="header">
<h2>Selection</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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>
<button id="clearSelection">Clear selection</button>
<button id="setSelection">Select year 1994</button>
</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"></input>Zoom to selection.</label></p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.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">
<!--[if lte IE 8]><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.errorbars.js"></script>
<script language="javascript" type="text/javascript" src="../jquery.flot.navigate.js"></script>
</head>
<body>
<h1>Flot Examples</h1>
<div id="placeholder" style="width:600px;height:400px;"></div>
<p>With the errorbars plugin you can plot error bars to show standard deviation and other useful statistical properties.</p>
<title>Flot Examples: Error Bars</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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.errorbars.js"></script>
<script language="javascript" type="text/javascript" src="../../jquery.flot.navigate.js"></script>
<script type="text/javascript">
<script type="text/javascript" language="javascript">
$(function () {
$(function() {
function drawArrow(ctx, x, y, radius){
ctx.beginPath();
......@@ -37,10 +29,15 @@ $(function () {
ctx.stroke();
}
//data1
var data1 = [[1,1,.5,.1,.3], [2,2,.3,.5,.2], [3,3,.9,.5,.2],
[1.5,-.05,.5,.1,.3], [3.15,1.,.5,.1,.3],
[2.5,-1.,.5,.1,.3]];
var data1 = [
[1,1,.5,.1,.3],
[2,2,.3,.5,.2],
[3,3,.9,.5,.2],
[1.5,-.05,.5,.1,.3],
[3.15,1.,.5,.1,.3],
[2.5,-1.,.5,.1,.3]
];
var data1_points = {
show: true,
radius: 5,
......@@ -50,8 +47,12 @@ $(function () {
yerr: {show: true, color: "red", upperCap: "-"}
};
//data2
var data2 = [[.7,3,.2,.4], [1.5,2.2,.3,.4], [2.3,1,.5,.2]];
var data2 = [
[.7,3,.2,.4],
[1.5,2.2,.3,.4],
[2.3,1,.5,.2]
];
var data2_points = {
show: true,
radius: 5,
......@@ -59,8 +60,12 @@ $(function () {
yerr: {show:true, asymmetric:true, upperCap: drawArrow, lowerCap: drawSemiCircle}
};
//data3
var data3 = [[1,2,.4], [2,0.5,.3], [2.7,2,.5]];
var data3 = [
[1,2,.4],
[2,0.5,.3],
[2.7,2,.5]
];
var data3_points = {
//do not show points
radius: 0,
......@@ -68,27 +73,74 @@ $(function () {
yerr: {show:true, upperCap: "-", lowerCap: "-", radius: 5}
};
//data4
var data4 = [[1.3, 1], [1.75, 2.5], [2.5, 0.5]];
var data4 = [
[1.3, 1],
[1.75, 2.5],
[2.5, 0.5]
];
var data4_errors = [0.1, 0.4, 0.2];
for (var i=0; i<data4.length; i++)
for (var i = 0; i < data4.length; i++) {
data4_errors[i] = data4[i].concat(data4_errors[i])
}
//plot
var data = [{color: "blue", points: data1_points, data: data1, label: "data1"},
var data = [
{color: "blue", points: data1_points, data: data1, label: "data1"},
{color: "red", points: data2_points, data: data2, label: "data2"},
{color: "green", lines: {show: true}, points: data3_points, data: data3, label: "data3"},
// bars with errors
{color: "orange", bars: {show: true, align: "center", barWidth: 0.25}, data: data4, label: "data4"},
{color: "orange", points: data3_points, data: data4_errors}];
var options = {legend: {position: "sw", show: true}, series: {lines: {show: false}},
xaxis: {min: 0.6, max: 3.1}, yaxis: {min: 0, max: 3.5},
zoom: {interactive: true}, pan: {interactive: true}
};
{color: "orange", points: data3_points, data: data4_errors}
];
$.plot($("#placeholder"), data , {
legend: {
position: "sw",
show: true
},
series: {
lines: {
show: false
}
},
xaxis: {
min: 0.6,
max: 3.1
},
yaxis: {
min: 0,
max: 3.5
},
zoom: {
interactive: true
},
pan: {
interactive: true
}
});
});
</script>
</head>
<body>
<div id="header">
<h2>Error Bars</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<p>With the errorbars plugin you can plot error bars to show standard deviation and other useful statistical properties.</p>
</div>
$.plot($("#placeholder"), data , options);
});
</script>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</html>
This diff is collapsed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Toggling Series</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
<div id="placeholder" style="width:600px;height:300px;"></div>
$(function() {
<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 type="text/javascript">
$(function () {
var datasets = {
"usa": {
label: "USA",
......@@ -57,6 +44,7 @@ $(function () {
// 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;
......@@ -66,33 +54,64 @@ $(function () {
// 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.append("<br/><input type='checkbox' name='" + key +
"' checked='checked' id='id" + key + "'></input>" +
"<label for='id" + key + "'>"
+ val.label + "</label>");
});
choiceContainer.find("input").click(plotAccordingToChoices);
choiceContainer.find("input").click(plotAccordingToChoices);
function plotAccordingToChoices() {
var data = [];
choiceContainer.find("input:checked").each(function () {
var key = $(this).attr("name");
if (key && datasets[key])
if (key && datasets[key]) {
data.push(datasets[key]);
}
});
if (data.length > 0)
if (data.length > 0) {
$.plot($("#placeholder"), data, {
yaxis: { min: 0 },
xaxis: { tickDecimals: 0 }
yaxis: {
min: 0
},
xaxis: {
tickDecimals: 0
}
});
}
}
plotAccordingToChoices();
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Toggling Series</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder" style="float:left; width:725px;"></div>
<p id="choices" style="float:right; width:135px;"></p>
</div>
<p>This example shows 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 and off with the checkboxes next to the plot.</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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 type="text/javascript">
$(function () {
<title>Flot Examples: Series Types</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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 type="text/javascript">
$(function() {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
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)
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)
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)
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())
for (var i = 0; i < 14; i += 0.5 + Math.random()) {
d6.push([i, Math.sqrt(2*i + Math.sin(i) + 5)]);
}
$.plot($("#placeholder"), [
{
$.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>
}]);
});
</script>
</head>
<body>
<div id="header">
<h2>Series Types</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Stacking</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script type="text/javascript">
<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>
$(function() {
<script id="source">
$(function () {
var d1 = [];
for (var i = 0; i <= 10; i += 1)
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)
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)
for (var i = 0; i <= 10; i += 1) {
d3.push([i, parseInt(Math.random() * 30)]);
}
var stack = 0, bars = true, lines = false, steps = false;
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 }
lines: {
show: lines,
fill: true,
steps: steps
},
bars: {
show: bars,
barWidth: 0.6
}
}
});
}
plotWithOptions();
$(".stackControls input").click(function (e) {
$(".stackControls button").click(function (e) {
e.preventDefault();
stack = $(this).val() == "With stacking" ? true : null;
stack = $(this).text() == "With stacking" ? true : null;
plotWithOptions();
});
$(".graphControls input").click(function (e) {
$(".graphControls button").click(function (e) {
e.preventDefault();
bars = $(this).val().indexOf("Bars") != -1;
lines = $(this).val().indexOf("Lines") != -1;
steps = $(this).val().indexOf("steps") != -1;
bars = $(this).text().indexOf("Bars") != -1;
lines = $(this).text().indexOf("Lines") != -1;
steps = $(this).text().indexOf("steps") != -1;
plotWithOptions();
});
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Stacking</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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">
<button>With stacking</button>
<button>Without stacking</button>
</p>
<p class="graphControls">
<button>Bars</button>
<button>Lines</button>
<button>Lines with steps</button>
</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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 type="text/javascript">
$(function () {
<title>Flot Examples: Symbols</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script 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;
}
......@@ -39,11 +34,39 @@ $(function () {
];
$.plot($("#placeholder"), data, {
series: { points: { show: true, radius: 3 } },
grid: { hoverable: true }
series: {
points: {
show: true,
radius: 3
}
},
grid: {
hoverable: true
}
});
});
});
</script>
</body>
</script>
</head>
<body>
<div id="header">
<h2>Symbols</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<p>Points can be marked in several ways, with circles being the built-in default. For other point types, you can define a callback function to draw the symbol. Some common symbols are available in the symbol plugin.</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Thresholds</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script type="text/javascript">
<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>
$(function() {
<script type="text/javascript">
$(function () {
var d1 = [];
for (var i = 0; i <= 60; i += 1)
for (var i = 0; i <= 60; i += 1) {
d1.push([i, parseInt(Math.random() * 30 - 10)]);
}
function plotWithOptions(t) {
$.plot($("#placeholder"), [ {
$.plot($("#placeholder"), [{
data: d1,
color: "rgb(30, 180, 20)",
threshold: { below: t, color: "rgb(200, 20, 30)" },
lines: { steps: true }
} ]);
threshold: {
below: t,
color: "rgb(200, 20, 30)"
},
lines: {
steps: true
}
}]);
}
plotWithOptions(0);
$(".controls input").click(function (e) {
$(".controls button").click(function (e) {
e.preventDefault();
var t = parseFloat($(this).val().replace('Threshold at ', ''));
var t = parseFloat($(this).text().replace("Threshold at ", ""));
plotWithOptions(t);
});
});
</script>
});
</script>
</head>
<body>
<div id="header">
<h2>Thresholds</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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">
<button>Threshold at 5</button>
<button>Threshold at 0</button>
<button>Threshold at -2.5</button>
</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Tracking</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script type="text/javascript">
<div id="placeholder" style="width:600px;height:300px"></div>
$(function() {
<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 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" } ], {
plot = $.plot($("#placeholder"), [
{ data: sin, label: "sin(x) = -0.00"},
{ data: cos, label: "cos(x) = -0.00" }
], {
series: {
lines: { show: true }
lines: {
show: true
}
},
crosshair: {
mode: "x"
},
crosshair: { mode: "x" },
grid: { hoverable: true, autoHighlight: false },
yaxis: { min: -1.2, max: 1.2 }
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());
......@@ -52,32 +51,41 @@ $(function () {
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)
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)
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)
var y,
p1 = series.data[j - 1],
p2 = series.data[j];
if (p1 == null) {
y = p2[1];
else if (p2 == null)
} else if (p2 == null) {
y = p1[1];
else
} 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)));
}
......@@ -85,11 +93,37 @@ $(function () {
$("#placeholder").bind("plothover", function (event, pos, item) {
latestPosition = pos;
if (!updateLegendTimeout)
if (!updateLegendTimeout) {
updateLegendTimeout = setTimeout(updateLegend, 50);
}
});
});
});
</script>
</body>
</script>
</head>
<body>
<div id="header">
<h2>Tracking</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</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>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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.time.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 () {
<title>Flot Examples: Visitors</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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.time.js"></script>
<script language="javascript" type="text/javascript" src="../../jquery.flot.selection.js"></script>
<script type="text/javascript">
$(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)
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);
var markings = [],
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
do {
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
i += 7 * 24 * 60 * 60 * 1000;
} while (i < axes.xaxis.max);
......@@ -51,41 +51,92 @@ $(function () {
}
var options = {
xaxis: { mode: "time", tickLength: 5 },
selection: { mode: "x" },
grid: { markings: weekendAreas }
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 },
lines: {
show: true,
lineWidth: 1
},
shadowSize: 0
},
xaxis: { ticks: [], mode: "time" },
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
selection: { mode: "x" }
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 }
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>
});
</script>
</head>
<body>
<div id="header">
<h2>Visitors</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder"></div>
</div>
<div class="demo-container" style="height:150px;">
<div id="overview"></div>
</div>
<p>This plot shows visitors per day to the Flot homepage, with weekends colored.</p>
<p>The smaller plot is linked to the main plot, so it acts as an overview. Try dragging a selection on either plot, and watch the behavior of the other.</p>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<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">
<!--[if lte IE 8]><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>
<title>Flot Examples: Selection and zooming</title>
<link href="../examples.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><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>
<script type="text/javascript">
<p id="overviewLegend" style="margin-left:10px"></p>
</div>
$(function() {
<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;
......@@ -43,13 +28,23 @@ $(function () {
}
var options = {
legend: { show: false },
legend: {
show: false
},
series: {
lines: { show: true },
points: { show: true }
lines: {
show: true
},
points: {
show: true
}
},
yaxis: {
ticks: 10
},
yaxis: { ticks: 10 },
selection: { mode: "xy" }
selection: {
mode: "xy"
}
};
var startData = getData(0, 3 * Math.PI);
......@@ -57,42 +52,89 @@ $(function () {
var plot = $.plot($("#placeholder"), startData, options);
// setup overview
var overview = $.plot($("#overview"), startData, {
legend: { show: true, container: $("#overviewLegend") },
legend: {
show: false
},
series: {
lines: { show: true, lineWidth: 1 },
lines: {
show: true,
lineWidth: 1
},
shadowSize: 0
},
xaxis: { ticks: 4 },
yaxis: { ticks: 3, min: -2, max: 2 },
grid: { color: "#999" },
selection: { mode: "xy" }
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)
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)
}
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>
});
</script>
</head>
<body>
<div id="header">
<h2>Selection and zooming</h2>
</div>
<div id="content">
<div class="demo-container">
<div id="placeholder" style="float:left; width:700px;"></div>
<div id="overview" style="float:right;width:160px; height:125px;"></div>
</div>
<p>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>
</div>
<div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen
</div>
</body>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment