flot-graph-rails 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ /* Flot plugin for automatically redrawing plots as the placeholder resizes.
2
+
3
+ Copyright (c) 2007-2012 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ It works by listening for changes on the placeholder div (through the jQuery
7
+ resize event plugin) - if the size changes, it will redraw the plot.
8
+
9
+ There are no options. If you need to disable the plugin for some plots, you
10
+ can just fix the size of their placeholders.
11
+
12
+ */
13
+
14
+ /* Inline dependency:
15
+ * jQuery resize event - v1.1 - 3/14/2010
16
+ * http://benalman.com/projects/jquery-resize-plugin/
17
+ *
18
+ * Copyright (c) 2010 "Cowboy" Ben Alman
19
+ * Dual licensed under the MIT and GPL licenses.
20
+ * http://benalman.com/about/license/
21
+ */
22
+
23
+ (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
24
+
25
+ (function ($) {
26
+ var options = { }; // no options
27
+
28
+ function init(plot) {
29
+ function onResize() {
30
+ var placeholder = plot.getPlaceholder();
31
+
32
+ // somebody might have hidden us and we can't plot
33
+ // when we don't have the dimensions
34
+ if (placeholder.width() == 0 || placeholder.height() == 0)
35
+ return;
36
+
37
+ plot.resize();
38
+ plot.setupGrid();
39
+ plot.draw();
40
+ }
41
+
42
+ function bindEvents(plot, eventHolder) {
43
+ plot.getPlaceholder().resize(onResize);
44
+ }
45
+
46
+ function shutdown(plot, eventHolder) {
47
+ plot.getPlaceholder().unbind("resize", onResize);
48
+ }
49
+
50
+ plot.hooks.bindEvents.push(bindEvents);
51
+ plot.hooks.shutdown.push(shutdown);
52
+ }
53
+
54
+ $.plot.plugins.push({
55
+ init: init,
56
+ options: options,
57
+ name: 'resize',
58
+ version: '1.0'
59
+ });
60
+ })(jQuery);
@@ -0,0 +1,344 @@
1
+ /* Flot plugin for selecting regions of a plot.
2
+
3
+ Copyright (c) 2007-2012 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The plugin supports these options:
7
+
8
+ selection: {
9
+ mode: null or "x" or "y" or "xy",
10
+ color: color
11
+ }
12
+
13
+ Selection support is enabled by setting the mode to one of "x", "y" or "xy".
14
+ In "x" mode, the user will only be able to specify the x range, similarly for
15
+ "y" mode. For "xy", the selection becomes a rectangle where both ranges can be
16
+ specified. "color" is color of the selection (if you need to change the color
17
+ later on, you can get to it with plot.getOptions().selection.color).
18
+
19
+ When selection support is enabled, a "plotselected" event will be emitted on
20
+ the DOM element you passed into the plot function. The event handler gets a
21
+ parameter with the ranges selected on the axes, like this:
22
+
23
+ placeholder.bind( "plotselected", function( event, ranges ) {
24
+ alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
25
+ // similar for yaxis - with multiple axes, the extra ones are in
26
+ // x2axis, x3axis, ...
27
+ });
28
+
29
+ The "plotselected" event is only fired when the user has finished making the
30
+ selection. A "plotselecting" event is fired during the process with the same
31
+ parameters as the "plotselected" event, in case you want to know what's
32
+ happening while it's happening,
33
+
34
+ A "plotunselected" event with no arguments is emitted when the user clicks the
35
+ mouse to remove the selection.
36
+
37
+ The plugin allso adds the following methods to the plot object:
38
+
39
+ - setSelection( ranges, preventEvent )
40
+
41
+ Set the selection rectangle. The passed in ranges is on the same form as
42
+ returned in the "plotselected" event. If the selection mode is "x", you
43
+ should put in either an xaxis range, if the mode is "y" you need to put in
44
+ an yaxis range and both xaxis and yaxis if the selection mode is "xy", like
45
+ this:
46
+
47
+ setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
48
+
49
+ setSelection will trigger the "plotselected" event when called. If you don't
50
+ want that to happen, e.g. if you're inside a "plotselected" handler, pass
51
+ true as the second parameter. If you are using multiple axes, you can
52
+ specify the ranges on any of those, e.g. as x2axis/x3axis/... instead of
53
+ xaxis, the plugin picks the first one it sees.
54
+
55
+ - clearSelection( preventEvent )
56
+
57
+ Clear the selection rectangle. Pass in true to avoid getting a
58
+ "plotunselected" event.
59
+
60
+ - getSelection()
61
+
62
+ Returns the current selection in the same format as the "plotselected"
63
+ event. If there's currently no selection, the function returns null.
64
+
65
+ */
66
+
67
+ (function ($) {
68
+ function init(plot) {
69
+ var selection = {
70
+ first: { x: -1, y: -1}, second: { x: -1, y: -1},
71
+ show: false,
72
+ active: false
73
+ };
74
+
75
+ // FIXME: The drag handling implemented here should be
76
+ // abstracted out, there's some similar code from a library in
77
+ // the navigation plugin, this should be massaged a bit to fit
78
+ // the Flot cases here better and reused. Doing this would
79
+ // make this plugin much slimmer.
80
+ var savedhandlers = {};
81
+
82
+ var mouseUpHandler = null;
83
+
84
+ function onMouseMove(e) {
85
+ if (selection.active) {
86
+ updateSelection(e);
87
+
88
+ plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
89
+ }
90
+ }
91
+
92
+ function onMouseDown(e) {
93
+ if (e.which != 1) // only accept left-click
94
+ return;
95
+
96
+ // cancel out any text selections
97
+ document.body.focus();
98
+
99
+ // prevent text selection and drag in old-school browsers
100
+ if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
101
+ savedhandlers.onselectstart = document.onselectstart;
102
+ document.onselectstart = function () { return false; };
103
+ }
104
+ if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
105
+ savedhandlers.ondrag = document.ondrag;
106
+ document.ondrag = function () { return false; };
107
+ }
108
+
109
+ setSelectionPos(selection.first, e);
110
+
111
+ selection.active = true;
112
+
113
+ // this is a bit silly, but we have to use a closure to be
114
+ // able to whack the same handler again
115
+ mouseUpHandler = function (e) { onMouseUp(e); };
116
+
117
+ $(document).one("mouseup", mouseUpHandler);
118
+ }
119
+
120
+ function onMouseUp(e) {
121
+ mouseUpHandler = null;
122
+
123
+ // revert drag stuff for old-school browsers
124
+ if (document.onselectstart !== undefined)
125
+ document.onselectstart = savedhandlers.onselectstart;
126
+ if (document.ondrag !== undefined)
127
+ document.ondrag = savedhandlers.ondrag;
128
+
129
+ // no more dragging
130
+ selection.active = false;
131
+ updateSelection(e);
132
+
133
+ if (selectionIsSane())
134
+ triggerSelectedEvent();
135
+ else {
136
+ // this counts as a clear
137
+ plot.getPlaceholder().trigger("plotunselected", [ ]);
138
+ plot.getPlaceholder().trigger("plotselecting", [ null ]);
139
+ }
140
+
141
+ return false;
142
+ }
143
+
144
+ function getSelection() {
145
+ if (!selectionIsSane())
146
+ return null;
147
+
148
+ if (!selection.show) return null;
149
+
150
+ var r = {}, c1 = selection.first, c2 = selection.second;
151
+ $.each(plot.getAxes(), function (name, axis) {
152
+ if (axis.used) {
153
+ var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
154
+ r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
155
+ }
156
+ });
157
+ return r;
158
+ }
159
+
160
+ function triggerSelectedEvent() {
161
+ var r = getSelection();
162
+
163
+ plot.getPlaceholder().trigger("plotselected", [ r ]);
164
+
165
+ // backwards-compat stuff, to be removed in future
166
+ if (r.xaxis && r.yaxis)
167
+ plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
168
+ }
169
+
170
+ function clamp(min, value, max) {
171
+ return value < min ? min: (value > max ? max: value);
172
+ }
173
+
174
+ function setSelectionPos(pos, e) {
175
+ var o = plot.getOptions();
176
+ var offset = plot.getPlaceholder().offset();
177
+ var plotOffset = plot.getPlotOffset();
178
+ pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
179
+ pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
180
+
181
+ if (o.selection.mode == "y")
182
+ pos.x = pos == selection.first ? 0 : plot.width();
183
+
184
+ if (o.selection.mode == "x")
185
+ pos.y = pos == selection.first ? 0 : plot.height();
186
+ }
187
+
188
+ function updateSelection(pos) {
189
+ if (pos.pageX == null)
190
+ return;
191
+
192
+ setSelectionPos(selection.second, pos);
193
+ if (selectionIsSane()) {
194
+ selection.show = true;
195
+ plot.triggerRedrawOverlay();
196
+ }
197
+ else
198
+ clearSelection(true);
199
+ }
200
+
201
+ function clearSelection(preventEvent) {
202
+ if (selection.show) {
203
+ selection.show = false;
204
+ plot.triggerRedrawOverlay();
205
+ if (!preventEvent)
206
+ plot.getPlaceholder().trigger("plotunselected", [ ]);
207
+ }
208
+ }
209
+
210
+ // function taken from markings support in Flot
211
+ function extractRange(ranges, coord) {
212
+ var axis, from, to, key, axes = plot.getAxes();
213
+
214
+ for (var k in axes) {
215
+ axis = axes[k];
216
+ if (axis.direction == coord) {
217
+ key = coord + axis.n + "axis";
218
+ if (!ranges[key] && axis.n == 1)
219
+ key = coord + "axis"; // support x1axis as xaxis
220
+ if (ranges[key]) {
221
+ from = ranges[key].from;
222
+ to = ranges[key].to;
223
+ break;
224
+ }
225
+ }
226
+ }
227
+
228
+ // backwards-compat stuff - to be removed in future
229
+ if (!ranges[key]) {
230
+ axis = coord == "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
231
+ from = ranges[coord + "1"];
232
+ to = ranges[coord + "2"];
233
+ }
234
+
235
+ // auto-reverse as an added bonus
236
+ if (from != null && to != null && from > to) {
237
+ var tmp = from;
238
+ from = to;
239
+ to = tmp;
240
+ }
241
+
242
+ return { from: from, to: to, axis: axis };
243
+ }
244
+
245
+ function setSelection(ranges, preventEvent) {
246
+ var axis, range, o = plot.getOptions();
247
+
248
+ if (o.selection.mode == "y") {
249
+ selection.first.x = 0;
250
+ selection.second.x = plot.width();
251
+ }
252
+ else {
253
+ range = extractRange(ranges, "x");
254
+
255
+ selection.first.x = range.axis.p2c(range.from);
256
+ selection.second.x = range.axis.p2c(range.to);
257
+ }
258
+
259
+ if (o.selection.mode == "x") {
260
+ selection.first.y = 0;
261
+ selection.second.y = plot.height();
262
+ }
263
+ else {
264
+ range = extractRange(ranges, "y");
265
+
266
+ selection.first.y = range.axis.p2c(range.from);
267
+ selection.second.y = range.axis.p2c(range.to);
268
+ }
269
+
270
+ selection.show = true;
271
+ plot.triggerRedrawOverlay();
272
+ if (!preventEvent && selectionIsSane())
273
+ triggerSelectedEvent();
274
+ }
275
+
276
+ function selectionIsSane() {
277
+ var minSize = 5;
278
+ return Math.abs(selection.second.x - selection.first.x) >= minSize &&
279
+ Math.abs(selection.second.y - selection.first.y) >= minSize;
280
+ }
281
+
282
+ plot.clearSelection = clearSelection;
283
+ plot.setSelection = setSelection;
284
+ plot.getSelection = getSelection;
285
+
286
+ plot.hooks.bindEvents.push(function(plot, eventHolder) {
287
+ var o = plot.getOptions();
288
+ if (o.selection.mode != null) {
289
+ eventHolder.mousemove(onMouseMove);
290
+ eventHolder.mousedown(onMouseDown);
291
+ }
292
+ });
293
+
294
+
295
+ plot.hooks.drawOverlay.push(function (plot, ctx) {
296
+ // draw selection
297
+ if (selection.show && selectionIsSane()) {
298
+ var plotOffset = plot.getPlotOffset();
299
+ var o = plot.getOptions();
300
+
301
+ ctx.save();
302
+ ctx.translate(plotOffset.left, plotOffset.top);
303
+
304
+ var c = $.color.parse(o.selection.color);
305
+
306
+ ctx.strokeStyle = c.scale('a', 0.8).toString();
307
+ ctx.lineWidth = 1;
308
+ ctx.lineJoin = "round";
309
+ ctx.fillStyle = c.scale('a', 0.4).toString();
310
+
311
+ var x = Math.min(selection.first.x, selection.second.x) + 0.5,
312
+ y = Math.min(selection.first.y, selection.second.y) + 0.5,
313
+ w = Math.abs(selection.second.x - selection.first.x) - 1,
314
+ h = Math.abs(selection.second.y - selection.first.y) - 1;
315
+
316
+ ctx.fillRect(x, y, w, h);
317
+ ctx.strokeRect(x, y, w, h);
318
+
319
+ ctx.restore();
320
+ }
321
+ });
322
+
323
+ plot.hooks.shutdown.push(function (plot, eventHolder) {
324
+ eventHolder.unbind("mousemove", onMouseMove);
325
+ eventHolder.unbind("mousedown", onMouseDown);
326
+
327
+ if (mouseUpHandler)
328
+ $(document).unbind("mouseup", mouseUpHandler);
329
+ });
330
+
331
+ }
332
+
333
+ $.plot.plugins.push({
334
+ init: init,
335
+ options: {
336
+ selection: {
337
+ mode: null, // one of null, "x", "y" or "xy"
338
+ color: "#e8cfac"
339
+ }
340
+ },
341
+ name: 'selection',
342
+ version: '1.1'
343
+ });
344
+ })(jQuery);
@@ -0,0 +1,188 @@
1
+ /* Flot plugin for stacking data sets rather than overlyaing them.
2
+
3
+ Copyright (c) 2007-2012 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The plugin assumes the data is sorted on x (or y if stacking horizontally).
7
+ For line charts, it is assumed that if a line has an undefined gap (from a
8
+ null point), then the line above it should have the same gap - insert zeros
9
+ instead of "null" if you want another behaviour. This also holds for the start
10
+ and end of the chart. Note that stacking a mix of positive and negative values
11
+ in most instances doesn't make sense (so it looks weird).
12
+
13
+ Two or more series are stacked when their "stack" attribute is set to the same
14
+ key (which can be any number or string or just "true"). To specify the default
15
+ stack, you can set the stack option like this:
16
+
17
+ series: {
18
+ stack: null or true or key (number/string)
19
+ }
20
+
21
+ You can also specify it for a single series, like this:
22
+
23
+ $.plot( $("#placeholder"), [{
24
+ data: [ ... ],
25
+ stack: true
26
+ }])
27
+
28
+ The stacking order is determined by the order of the data series in the array
29
+ (later series end up on top of the previous).
30
+
31
+ Internally, the plugin modifies the datapoints in each series, adding an
32
+ offset to the y value. For line series, extra data points are inserted through
33
+ interpolation. If there's a second y value, it's also adjusted (e.g for bar
34
+ charts or filled areas).
35
+
36
+ */
37
+
38
+ (function ($) {
39
+ var options = {
40
+ series: { stack: null } // or number/string
41
+ };
42
+
43
+ function init(plot) {
44
+ function findMatchingSeries(s, allseries) {
45
+ var res = null;
46
+ for (var i = 0; i < allseries.length; ++i) {
47
+ if (s == allseries[i])
48
+ break;
49
+
50
+ if (allseries[i].stack == s.stack)
51
+ res = allseries[i];
52
+ }
53
+
54
+ return res;
55
+ }
56
+
57
+ function stackData(plot, s, datapoints) {
58
+ if (s.stack == null)
59
+ return;
60
+
61
+ var other = findMatchingSeries(s, plot.getData());
62
+ if (!other)
63
+ return;
64
+
65
+ var ps = datapoints.pointsize,
66
+ points = datapoints.points,
67
+ otherps = other.datapoints.pointsize,
68
+ otherpoints = other.datapoints.points,
69
+ newpoints = [],
70
+ px, py, intery, qx, qy, bottom,
71
+ withlines = s.lines.show,
72
+ horizontal = s.bars.horizontal,
73
+ withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
74
+ withsteps = withlines && s.lines.steps,
75
+ fromgap = true,
76
+ keyOffset = horizontal ? 1 : 0,
77
+ accumulateOffset = horizontal ? 0 : 1,
78
+ i = 0, j = 0, l, m;
79
+
80
+ while (true) {
81
+ if (i >= points.length)
82
+ break;
83
+
84
+ l = newpoints.length;
85
+
86
+ if (points[i] == null) {
87
+ // copy gaps
88
+ for (m = 0; m < ps; ++m)
89
+ newpoints.push(points[i + m]);
90
+ i += ps;
91
+ }
92
+ else if (j >= otherpoints.length) {
93
+ // for lines, we can't use the rest of the points
94
+ if (!withlines) {
95
+ for (m = 0; m < ps; ++m)
96
+ newpoints.push(points[i + m]);
97
+ }
98
+ i += ps;
99
+ }
100
+ else if (otherpoints[j] == null) {
101
+ // oops, got a gap
102
+ for (m = 0; m < ps; ++m)
103
+ newpoints.push(null);
104
+ fromgap = true;
105
+ j += otherps;
106
+ }
107
+ else {
108
+ // cases where we actually got two points
109
+ px = points[i + keyOffset];
110
+ py = points[i + accumulateOffset];
111
+ qx = otherpoints[j + keyOffset];
112
+ qy = otherpoints[j + accumulateOffset];
113
+ bottom = 0;
114
+
115
+ if (px == qx) {
116
+ for (m = 0; m < ps; ++m)
117
+ newpoints.push(points[i + m]);
118
+
119
+ newpoints[l + accumulateOffset] += qy;
120
+ bottom = qy;
121
+
122
+ i += ps;
123
+ j += otherps;
124
+ }
125
+ else if (px > qx) {
126
+ // we got past point below, might need to
127
+ // insert interpolated extra point
128
+ if (withlines && i > 0 && points[i - ps] != null) {
129
+ intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
130
+ newpoints.push(qx);
131
+ newpoints.push(intery + qy);
132
+ for (m = 2; m < ps; ++m)
133
+ newpoints.push(points[i + m]);
134
+ bottom = qy;
135
+ }
136
+
137
+ j += otherps;
138
+ }
139
+ else { // px < qx
140
+ if (fromgap && withlines) {
141
+ // if we come from a gap, we just skip this point
142
+ i += ps;
143
+ continue;
144
+ }
145
+
146
+ for (m = 0; m < ps; ++m)
147
+ newpoints.push(points[i + m]);
148
+
149
+ // we might be able to interpolate a point below,
150
+ // this can give us a better y
151
+ if (withlines && j > 0 && otherpoints[j - otherps] != null)
152
+ bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
153
+
154
+ newpoints[l + accumulateOffset] += bottom;
155
+
156
+ i += ps;
157
+ }
158
+
159
+ fromgap = false;
160
+
161
+ if (l != newpoints.length && withbottom)
162
+ newpoints[l + 2] += bottom;
163
+ }
164
+
165
+ // maintain the line steps invariant
166
+ if (withsteps && l != newpoints.length && l > 0
167
+ && newpoints[l] != null
168
+ && newpoints[l] != newpoints[l - ps]
169
+ && newpoints[l + 1] != newpoints[l - ps + 1]) {
170
+ for (m = 0; m < ps; ++m)
171
+ newpoints[l + ps + m] = newpoints[l + m];
172
+ newpoints[l + 1] = newpoints[l - ps + 1];
173
+ }
174
+ }
175
+
176
+ datapoints.points = newpoints;
177
+ }
178
+
179
+ plot.hooks.processDatapoints.push(stackData);
180
+ }
181
+
182
+ $.plot.plugins.push({
183
+ init: init,
184
+ options: options,
185
+ name: 'stack',
186
+ version: '1.2'
187
+ });
188
+ })(jQuery);
@@ -0,0 +1,71 @@
1
+ /* Flot plugin that adds some extra symbols for plotting points.
2
+
3
+ Copyright (c) 2007-2012 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The symbols are accessed as strings through the standard symbol options:
7
+
8
+ series: {
9
+ points: {
10
+ symbol: "square" // or "diamond", "triangle", "cross"
11
+ }
12
+ }
13
+
14
+ */
15
+
16
+ (function ($) {
17
+ function processRawData(plot, series, datapoints) {
18
+ // we normalize the area of each symbol so it is approximately the
19
+ // same as a circle of the given radius
20
+
21
+ var handlers = {
22
+ square: function (ctx, x, y, radius, shadow) {
23
+ // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
24
+ var size = radius * Math.sqrt(Math.PI) / 2;
25
+ ctx.rect(x - size, y - size, size + size, size + size);
26
+ },
27
+ diamond: function (ctx, x, y, radius, shadow) {
28
+ // pi * r^2 = 2s^2 => s = r * sqrt(pi/2)
29
+ var size = radius * Math.sqrt(Math.PI / 2);
30
+ ctx.moveTo(x - size, y);
31
+ ctx.lineTo(x, y - size);
32
+ ctx.lineTo(x + size, y);
33
+ ctx.lineTo(x, y + size);
34
+ ctx.lineTo(x - size, y);
35
+ },
36
+ triangle: function (ctx, x, y, radius, shadow) {
37
+ // pi * r^2 = 1/2 * s^2 * sin (pi / 3) => s = r * sqrt(2 * pi / sin(pi / 3))
38
+ var size = radius * Math.sqrt(2 * Math.PI / Math.sin(Math.PI / 3));
39
+ var height = size * Math.sin(Math.PI / 3);
40
+ ctx.moveTo(x - size/2, y + height/2);
41
+ ctx.lineTo(x + size/2, y + height/2);
42
+ if (!shadow) {
43
+ ctx.lineTo(x, y - height/2);
44
+ ctx.lineTo(x - size/2, y + height/2);
45
+ }
46
+ },
47
+ cross: function (ctx, x, y, radius, shadow) {
48
+ // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
49
+ var size = radius * Math.sqrt(Math.PI) / 2;
50
+ ctx.moveTo(x - size, y - size);
51
+ ctx.lineTo(x + size, y + size);
52
+ ctx.moveTo(x - size, y + size);
53
+ ctx.lineTo(x + size, y - size);
54
+ }
55
+ };
56
+
57
+ var s = series.points.symbol;
58
+ if (handlers[s])
59
+ series.points.symbol = handlers[s];
60
+ }
61
+
62
+ function init(plot) {
63
+ plot.hooks.processDatapoints.push(processRawData);
64
+ }
65
+
66
+ $.plot.plugins.push({
67
+ init: init,
68
+ name: 'symbols',
69
+ version: '1.0'
70
+ });
71
+ })(jQuery);