-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.html
105 lines (87 loc) · 3.99 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flot Barnumbers Enhanced Example</title>
<link href="http://www.flotcharts.org/flot/examples/examples.css" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
<script src="http://www.flotcharts.org/flot/jquery.flot.js" type="text/javascript"></script>
<script src="https://rawgit.com/jasonroman/flot-barnumbers-enhanced/master/jquery.flot.barnumbers.enhanced.js" type="text/javascript"></script>
<style>
#left { float: left; }
#right { float: right; }
</style>
<script type="text/javascript">
$(function() {
// simple formatter function to prepend $ to all values
var barnumberFormatter = function(value) {
return '$' + value;
};
var dataVertical = [[0, 1], [1, 9], [2, 7], [3, 14], [4, 10], [5, 2]];
var dataHorizontal = [[1, 0], [9, 1], [7, 2], [14, 3], [10, 4], [2, 5]];
$.plot("#placeholder-vertical", [
{
data: dataVertical,
bars: {
show: true,
barWidth: 0.9,
numbers: {
show: true,
formatter: barnumberFormatter,
font: '14pt Arial',
fontColor: '#FF0000',
// remove the next 3 lines to vertically center the values
threshold: 0.25, // any value < 25% of the maximum data point will display above the bar
yAlign: function(y) { return y; }, // shows numbers at the top of the bar
yOffset: 5 // pixel offset so numbers are not right up on the edge of the top of the bar
}
}
}
]);
$.plot("#placeholder-horizontal", [
{
data: dataHorizontal,
bars: {
show: true,
barWidth: 0.9,
horizontal: true,
numbers: {
show: true,
formatter: barnumberFormatter,
font: '14pt Arial',
fontColor: '#FF0000',
// remove the next 3 lines to horizontally center the values
threshold: 0.25, // any value lower than 25% of the maximum data point will display above the bar
xAlign: function(x) { return x; }, // shows numbers at the top of the bar
xOffset: 5 // pixel offset so numbers are not right up on the edge of the top of the bar
}
}
}
]);
});
</script>
</head>
<body>
<div id="header">
<h2>Flot Barnumbers Enhanced - Basic Usage</h2>
</div>
<div id="content">
<div id="left" class="demo-container" style="width: 375px; height: 450px;">
<div id="placeholder-vertical" class="demo-placeholder"></div>
</div>
<div id="right" class="demo-container" style="width: 375px; height: 450px;">
<div id="placeholder-horizontal" class="demo-placeholder"></div>
</div>
<div style="clear: both"></div>
<p style="text-align: center">Simply include the plugin and the <b>bars: { numbers { ... } }</b> options on the series you want to enable.</p>
</div>
<div id="footer">
Copyright © 2014 Jason Roman
- <a href="https://github.com/jasonroman" target="_blank">GitHub</a>
- <a href="http://www.jayroman.com" target="_blank">Website</a> ;
Daniel Head
- <a href="https://github.com/dr-head" target="_blank">GitHub</a>
<br><a href="https://github.com/jasonroman/flot-barnumbers-enhanced" target="_blank">https://github.com/jasonroman/flot-barnumbers-enhanced</a>
</div>
</body>
</html>