@kevinburke/flot 5.0.0

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +1814 -0
  2. package/LICENSE.txt +22 -0
  3. package/README.md +119 -0
  4. package/dist/flot.js +9830 -0
  5. package/dist/flot.min.js +2 -0
  6. package/dist/flot.min.js.map +1 -0
  7. package/dist/flot.mjs +9805 -0
  8. package/dist/jquery.flot.js +9869 -0
  9. package/dist/jquery.flot.min.js +2 -0
  10. package/dist/jquery.flot.min.js.map +1 -0
  11. package/dist/plugins/jquery.flot.crosshair.js +207 -0
  12. package/dist/plugins/jquery.flot.crosshair.min.js +2 -0
  13. package/dist/plugins/jquery.flot.crosshair.min.js.map +1 -0
  14. package/dist/plugins/jquery.flot.image.js +261 -0
  15. package/dist/plugins/jquery.flot.image.min.js +2 -0
  16. package/dist/plugins/jquery.flot.image.min.js.map +1 -0
  17. package/dist/plugins/jquery.flot.pie.js +815 -0
  18. package/dist/plugins/jquery.flot.pie.min.js +2 -0
  19. package/dist/plugins/jquery.flot.pie.min.js.map +1 -0
  20. package/dist/plugins/jquery.flot.resize.js +62 -0
  21. package/dist/plugins/jquery.flot.resize.min.js +2 -0
  22. package/dist/plugins/jquery.flot.resize.min.js.map +1 -0
  23. package/dist/plugins/jquery.flot.threshold.js +148 -0
  24. package/dist/plugins/jquery.flot.threshold.min.js +2 -0
  25. package/dist/plugins/jquery.flot.threshold.min.js.map +1 -0
  26. package/docs/API.md +1767 -0
  27. package/docs/PLUGINS.md +143 -0
  28. package/docs/absRelTime.md +42 -0
  29. package/docs/browser.md +24 -0
  30. package/docs/canvaswrapper.md +116 -0
  31. package/docs/composeImages.md +32 -0
  32. package/docs/drawSeries.md +35 -0
  33. package/docs/hover.md +21 -0
  34. package/docs/interactions.md +57 -0
  35. package/docs/logaxis.md +27 -0
  36. package/docs/navigate.md +110 -0
  37. package/package.json +53 -0
  38. package/source/helpers.js +168 -0
  39. package/source/index.js +70 -0
  40. package/source/jquery-adapter.js +83 -0
  41. package/source/jquery.canvaswrapper.js +546 -0
  42. package/source/jquery.colorhelpers.js +198 -0
  43. package/source/jquery.flot.axislabels.js +214 -0
  44. package/source/jquery.flot.browser.js +53 -0
  45. package/source/jquery.flot.categories.js +202 -0
  46. package/source/jquery.flot.composeImages.js +327 -0
  47. package/source/jquery.flot.crosshair.js +203 -0
  48. package/source/jquery.flot.drawSeries.js +699 -0
  49. package/source/jquery.flot.errorbars.js +375 -0
  50. package/source/jquery.flot.fillbetween.js +254 -0
  51. package/source/jquery.flot.flatdata.js +47 -0
  52. package/source/jquery.flot.hover.js +354 -0
  53. package/source/jquery.flot.image.js +252 -0
  54. package/source/jquery.flot.js +2814 -0
  55. package/source/jquery.flot.legend.js +444 -0
  56. package/source/jquery.flot.logaxis.js +299 -0
  57. package/source/jquery.flot.navigate.js +842 -0
  58. package/source/jquery.flot.pie.js +811 -0
  59. package/source/jquery.flot.resize.js +57 -0
  60. package/source/jquery.flot.saturated.js +40 -0
  61. package/source/jquery.flot.selection.js +552 -0
  62. package/source/jquery.flot.stack.js +220 -0
  63. package/source/jquery.flot.symbol.js +98 -0
  64. package/source/jquery.flot.threshold.js +144 -0
  65. package/source/jquery.flot.time.js +584 -0
  66. package/source/jquery.flot.touch.js +320 -0
  67. package/source/jquery.flot.touchNavigate.js +357 -0
  68. package/source/jquery.flot.uiConstants.js +9 -0
  69. package/source/jquery.js +9473 -0
@@ -0,0 +1,375 @@
1
+ /* Flot plugin for plotting error bars.
2
+
3
+ Copyright (c) 2007-2014 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ Error bars are used to show standard deviation and other statistical
7
+ properties in a plot.
8
+
9
+ * Created by Rui Pereira - rui (dot) pereira (at) gmail (dot) com
10
+
11
+ This plugin allows you to plot error-bars over points. Set "errorbars" inside
12
+ the points series to the axis name over which there will be error values in
13
+ your data array (*even* if you do not intend to plot them later, by setting
14
+ "show: null" on xerr/yerr).
15
+
16
+ The plugin supports these options:
17
+
18
+ series: {
19
+ points: {
20
+ errorbars: "x" or "y" or "xy",
21
+ xerr: {
22
+ show: null/false or true,
23
+ asymmetric: null/false or true,
24
+ upperCap: null or "-" or function,
25
+ lowerCap: null or "-" or function,
26
+ color: null or color,
27
+ radius: null or number
28
+ },
29
+ yerr: { same options as xerr }
30
+ }
31
+ }
32
+
33
+ Each data point array is expected to be of the type:
34
+
35
+ "x" [ x, y, xerr ]
36
+ "y" [ x, y, yerr ]
37
+ "xy" [ x, y, xerr, yerr ]
38
+
39
+ Where xerr becomes xerr_lower,xerr_upper for the asymmetric error case, and
40
+ equivalently for yerr. Eg., a datapoint for the "xy" case with symmetric
41
+ error-bars on X and asymmetric on Y would be:
42
+
43
+ [ x, y, xerr, yerr_lower, yerr_upper ]
44
+
45
+ By default no end caps are drawn. Setting upperCap and/or lowerCap to "-" will
46
+ draw a small cap perpendicular to the error bar. They can also be set to a
47
+ user-defined drawing function, with (ctx, x, y, radius) as parameters, as eg.
48
+
49
+ function drawSemiCircle( ctx, x, y, radius ) {
50
+ ctx.beginPath();
51
+ ctx.arc( x, y, radius, 0, Math.PI, false );
52
+ ctx.moveTo( x - radius, y );
53
+ ctx.lineTo( x + radius, y );
54
+ ctx.stroke();
55
+ }
56
+
57
+ Color and radius both default to the same ones of the points series if not
58
+ set. The independent radius parameter on xerr/yerr is useful for the case when
59
+ we may want to add error-bars to a line, without showing the interconnecting
60
+ points (with radius: 0), and still showing end caps on the error-bars.
61
+ shadowSize and lineWidth are derived as well from the points series.
62
+
63
+ */
64
+
65
+ import { plugins } from './jquery.flot.js';
66
+
67
+ var options = {
68
+ series: {
69
+ points: {
70
+ errorbars: null, //should be 'x', 'y' or 'xy'
71
+ xerr: {err: 'x', show: null, asymmetric: null, upperCap: null, lowerCap: null, color: null, radius: null},
72
+ yerr: {err: 'y', show: null, asymmetric: null, upperCap: null, lowerCap: null, color: null, radius: null}
73
+ }
74
+ }
75
+ };
76
+
77
+ function processRawData(plot, series, data, datapoints) {
78
+ if (!series.points.errorbars) {
79
+ return;
80
+ }
81
+
82
+ // x,y values
83
+ var format = [
84
+ { x: true, number: true, required: true },
85
+ { y: true, number: true, required: true }
86
+ ];
87
+
88
+ var errors = series.points.errorbars;
89
+ // error bars - first X then Y
90
+ if (errors === 'x' || errors === 'xy') {
91
+ // lower / upper error
92
+ if (series.points.xerr.asymmetric) {
93
+ format.push({ x: true, number: true, required: true });
94
+ format.push({ x: true, number: true, required: true });
95
+ } else {
96
+ format.push({ x: true, number: true, required: true });
97
+ }
98
+ }
99
+ if (errors === 'y' || errors === 'xy') {
100
+ // lower / upper error
101
+ if (series.points.yerr.asymmetric) {
102
+ format.push({ y: true, number: true, required: true });
103
+ format.push({ y: true, number: true, required: true });
104
+ } else {
105
+ format.push({ y: true, number: true, required: true });
106
+ }
107
+ }
108
+ datapoints.format = format;
109
+ }
110
+
111
+ function parseErrors(series, i) {
112
+ var points = series.datapoints.points;
113
+
114
+ // read errors from points array
115
+ var exl = null,
116
+ exu = null,
117
+ eyl = null,
118
+ eyu = null;
119
+ var xerr = series.points.xerr,
120
+ yerr = series.points.yerr;
121
+
122
+ var eb = series.points.errorbars;
123
+ // error bars - first X
124
+ if (eb === 'x' || eb === 'xy') {
125
+ if (xerr.asymmetric) {
126
+ exl = points[i + 2];
127
+ exu = points[i + 3];
128
+ if (eb === 'xy') {
129
+ if (yerr.asymmetric) {
130
+ eyl = points[i + 4];
131
+ eyu = points[i + 5];
132
+ } else {
133
+ eyl = points[i + 4];
134
+ }
135
+ }
136
+ } else {
137
+ exl = points[i + 2];
138
+ if (eb === 'xy') {
139
+ if (yerr.asymmetric) {
140
+ eyl = points[i + 3];
141
+ eyu = points[i + 4];
142
+ } else {
143
+ eyl = points[i + 3];
144
+ }
145
+ }
146
+ }
147
+ // only Y
148
+ } else {
149
+ if (eb === 'y') {
150
+ if (yerr.asymmetric) {
151
+ eyl = points[i + 2];
152
+ eyu = points[i + 3];
153
+ } else {
154
+ eyl = points[i + 2];
155
+ }
156
+ }
157
+ }
158
+
159
+ // symmetric errors?
160
+ if (exu == null) exu = exl;
161
+ if (eyu == null) eyu = eyl;
162
+
163
+ var errRanges = [exl, exu, eyl, eyu];
164
+ // nullify if not showing
165
+ if (!xerr.show) {
166
+ errRanges[0] = null;
167
+ errRanges[1] = null;
168
+ }
169
+ if (!yerr.show) {
170
+ errRanges[2] = null;
171
+ errRanges[3] = null;
172
+ }
173
+ return errRanges;
174
+ }
175
+
176
+ function drawSeriesErrors(plot, ctx, s) {
177
+ var points = s.datapoints.points,
178
+ ps = s.datapoints.pointsize,
179
+ ax = [s.xaxis, s.yaxis],
180
+ radius = s.points.radius,
181
+ err = [s.points.xerr, s.points.yerr],
182
+ tmp;
183
+
184
+ //sanity check, in case some inverted axis hack is applied to flot
185
+ var invertX = false;
186
+ if (ax[0].p2c(ax[0].max) < ax[0].p2c(ax[0].min)) {
187
+ invertX = true;
188
+ tmp = err[0].lowerCap;
189
+ err[0].lowerCap = err[0].upperCap;
190
+ err[0].upperCap = tmp;
191
+ }
192
+
193
+ var invertY = false;
194
+ if (ax[1].p2c(ax[1].min) < ax[1].p2c(ax[1].max)) {
195
+ invertY = true;
196
+ tmp = err[1].lowerCap;
197
+ err[1].lowerCap = err[1].upperCap;
198
+ err[1].upperCap = tmp;
199
+ }
200
+
201
+ for (var i = 0; i < s.datapoints.points.length; i += ps) {
202
+ //parse
203
+ var errRanges = parseErrors(s, i);
204
+
205
+ //cycle xerr & yerr
206
+ for (var e = 0; e < err.length; e++) {
207
+ var minmax = [ax[e].min, ax[e].max];
208
+
209
+ //draw this error?
210
+ if (errRanges[e * err.length]) {
211
+ //data coordinates
212
+ var x = points[i],
213
+ y = points[i + 1];
214
+
215
+ //errorbar ranges
216
+ var upper = [x, y][e] + errRanges[e * err.length + 1],
217
+ lower = [x, y][e] - errRanges[e * err.length];
218
+
219
+ //points outside of the canvas
220
+ if (err[e].err === 'x') {
221
+ if (y > ax[1].max || y < ax[1].min || upper < ax[0].min || lower > ax[0].max) {
222
+ continue;
223
+ }
224
+ }
225
+
226
+ if (err[e].err === 'y') {
227
+ if (x > ax[0].max || x < ax[0].min || upper < ax[1].min || lower > ax[1].max) {
228
+ continue;
229
+ }
230
+ }
231
+
232
+ // prevent errorbars getting out of the canvas
233
+ var drawUpper = true,
234
+ drawLower = true;
235
+
236
+ if (upper > minmax[1]) {
237
+ drawUpper = false;
238
+ upper = minmax[1];
239
+ }
240
+ if (lower < minmax[0]) {
241
+ drawLower = false;
242
+ lower = minmax[0];
243
+ }
244
+
245
+ //sanity check, in case some inverted axis hack is applied to flot
246
+ if ((err[e].err === 'x' && invertX) || (err[e].err === 'y' && invertY)) {
247
+ //swap coordinates
248
+ tmp = lower;
249
+ lower = upper;
250
+ upper = tmp;
251
+ tmp = drawLower;
252
+ drawLower = drawUpper;
253
+ drawUpper = tmp;
254
+ tmp = minmax[0];
255
+ minmax[0] = minmax[1];
256
+ minmax[1] = tmp;
257
+ }
258
+
259
+ // convert to pixels
260
+ x = ax[0].p2c(x);
261
+ y = ax[1].p2c(y);
262
+ upper = ax[e].p2c(upper);
263
+ lower = ax[e].p2c(lower);
264
+ minmax[0] = ax[e].p2c(minmax[0]);
265
+ minmax[1] = ax[e].p2c(minmax[1]);
266
+
267
+ //same style as points by default
268
+ var lw = err[e].lineWidth ? err[e].lineWidth : s.points.lineWidth,
269
+ sw = s.points.shadowSize != null ? s.points.shadowSize : s.shadowSize;
270
+
271
+ //shadow as for points
272
+ if (lw > 0 && sw > 0) {
273
+ var w = sw / 2;
274
+ ctx.lineWidth = w;
275
+ ctx.strokeStyle = "rgba(0,0,0,0.1)";
276
+ drawError(ctx, err[e], x, y, upper, lower, drawUpper, drawLower, radius, w + w / 2, minmax);
277
+
278
+ ctx.strokeStyle = "rgba(0,0,0,0.2)";
279
+ drawError(ctx, err[e], x, y, upper, lower, drawUpper, drawLower, radius, w / 2, minmax);
280
+ }
281
+
282
+ ctx.strokeStyle = err[e].color
283
+ ? err[e].color
284
+ : s.color;
285
+ ctx.lineWidth = lw;
286
+ //draw it
287
+ drawError(ctx, err[e], x, y, upper, lower, drawUpper, drawLower, radius, 0, minmax);
288
+ }
289
+ }
290
+ }
291
+ }
292
+
293
+ function drawError(ctx, err, x, y, upper, lower, drawUpper, drawLower, radius, offset, minmax) {
294
+ //shadow offset
295
+ y += offset;
296
+ upper += offset;
297
+ lower += offset;
298
+
299
+ // error bar - avoid plotting over circles
300
+ if (err.err === 'x') {
301
+ if (upper > x + radius) drawPath(ctx, [[upper, y], [Math.max(x + radius, minmax[0]), y]]);
302
+ else drawUpper = false;
303
+
304
+ if (lower < x - radius) drawPath(ctx, [[Math.min(x - radius, minmax[1]), y], [lower, y]]);
305
+ else drawLower = false;
306
+ } else {
307
+ if (upper < y - radius) drawPath(ctx, [[x, upper], [x, Math.min(y - radius, minmax[0])]]);
308
+ else drawUpper = false;
309
+
310
+ if (lower > y + radius) drawPath(ctx, [[x, Math.max(y + radius, minmax[1])], [x, lower]]);
311
+ else drawLower = false;
312
+ }
313
+
314
+ //internal radius value in errorbar, allows to plot radius 0 points and still keep proper sized caps
315
+ //this is a way to get errorbars on lines without visible connecting dots
316
+ radius = err.radius != null
317
+ ? err.radius
318
+ : radius;
319
+
320
+ // upper cap
321
+ if (drawUpper) {
322
+ if (err.upperCap === '-') {
323
+ if (err.err === 'x') drawPath(ctx, [[upper, y - radius], [upper, y + radius]]);
324
+ else drawPath(ctx, [[x - radius, upper], [x + radius, upper]]);
325
+ } else if (typeof err.upperCap === 'function') {
326
+ if (err.err === 'x') err.upperCap(ctx, upper, y, radius);
327
+ else err.upperCap(ctx, x, upper, radius);
328
+ }
329
+ }
330
+ // lower cap
331
+ if (drawLower) {
332
+ if (err.lowerCap === '-') {
333
+ if (err.err === 'x') drawPath(ctx, [[lower, y - radius], [lower, y + radius]]);
334
+ else drawPath(ctx, [[x - radius, lower], [x + radius, lower]]);
335
+ } else if (typeof err.lowerCap === 'function') {
336
+ if (err.err === 'x') err.lowerCap(ctx, lower, y, radius);
337
+ else err.lowerCap(ctx, x, lower, radius);
338
+ }
339
+ }
340
+ }
341
+
342
+ function drawPath(ctx, pts) {
343
+ ctx.beginPath();
344
+ ctx.moveTo(pts[0][0], pts[0][1]);
345
+ for (var p = 1; p < pts.length; p++) {
346
+ ctx.lineTo(pts[p][0], pts[p][1]);
347
+ }
348
+
349
+ ctx.stroke();
350
+ }
351
+
352
+ function draw(plot, ctx) {
353
+ var plotOffset = plot.getPlotOffset();
354
+
355
+ ctx.save();
356
+ ctx.translate(plotOffset.left, plotOffset.top);
357
+ plot.getData().forEach(function (s) {
358
+ if (s.points.errorbars && (s.points.xerr.show || s.points.yerr.show)) {
359
+ drawSeriesErrors(plot, ctx, s);
360
+ }
361
+ });
362
+ ctx.restore();
363
+ }
364
+
365
+ function init(plot) {
366
+ plot.hooks.processRawData.push(processRawData);
367
+ plot.hooks.draw.push(draw);
368
+ }
369
+
370
+ plugins.push({
371
+ init: init,
372
+ options: options,
373
+ name: 'errorbars',
374
+ version: '1.0'
375
+ });
@@ -0,0 +1,254 @@
1
+ /* Flot plugin for computing bottoms for filled line and bar charts.
2
+
3
+ Copyright (c) 2007-2014 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ The case: you've got two series that you want to fill the area between. In Flot
7
+ terms, you need to use one as the fill bottom of the other. You can specify the
8
+ bottom of each data point as the third coordinate manually, or you can use this
9
+ plugin to compute it for you.
10
+
11
+ In order to name the other series, you need to give it an id, like this:
12
+
13
+ var dataset = [
14
+ { data: [ ... ], id: "foo" } , // use default bottom
15
+ { data: [ ... ], fillBetween: "foo" }, // use first dataset as bottom
16
+ ];
17
+
18
+ $.plot($("#placeholder"), dataset, { lines: { show: true, fill: true }});
19
+
20
+ As a convenience, if the id given is a number that doesn't appear as an id in
21
+ the series, it is interpreted as the index in the array instead (so fillBetween:
22
+ 0 can also mean the first series).
23
+
24
+ Internally, the plugin modifies the datapoints in each series. For line series,
25
+ extra data points might be inserted through interpolation. Note that at points
26
+ where the bottom line is not defined (due to a null point or start/end of line),
27
+ the current line will show a gap too. The algorithm comes from the
28
+ jquery.flot.stack.js plugin, possibly some code could be shared.
29
+
30
+ */
31
+
32
+ import { plugins } from './jquery.flot.js';
33
+
34
+ var options = {
35
+ series: {
36
+ fillBetween: null // or number
37
+ }
38
+ };
39
+
40
+ function init(plot) {
41
+ function findBottomSeries(s, allseries) {
42
+ var i;
43
+
44
+ for (i = 0; i < allseries.length; ++i) {
45
+ if (allseries[ i ].id === s.fillBetween) {
46
+ return allseries[ i ];
47
+ }
48
+ }
49
+
50
+ if (typeof s.fillBetween === "number") {
51
+ if (s.fillBetween < 0 || s.fillBetween >= allseries.length) {
52
+ return null;
53
+ }
54
+ return allseries[ s.fillBetween ];
55
+ }
56
+
57
+ return null;
58
+ }
59
+
60
+ function computeFormat(plot, s, data, datapoints) {
61
+ if (s.fillBetween == null) {
62
+ return;
63
+ }
64
+
65
+ var format = datapoints.format;
66
+ var plotHasId = function(id) {
67
+ var plotData = plot.getData();
68
+ for (var i = 0; i < plotData.length; i++) {
69
+ if (plotData[i].id === id) {
70
+ return true;
71
+ }
72
+ }
73
+
74
+ return false;
75
+ }
76
+
77
+ if (!format) {
78
+ format = [];
79
+
80
+ format.push({
81
+ x: true,
82
+ number: true,
83
+ computeRange: s.xaxis.options.autoScale !== 'none',
84
+ required: true
85
+ });
86
+ format.push({
87
+ y: true,
88
+ number: true,
89
+ computeRange: s.yaxis.options.autoScale !== 'none',
90
+ required: true
91
+ });
92
+
93
+ if (s.fillBetween !== undefined && s.fillBetween !== '' && plotHasId(s.fillBetween) && s.fillBetween !== s.id) {
94
+ format.push({
95
+ x: false,
96
+ y: true,
97
+ number: true,
98
+ required: false,
99
+ computeRange: s.yaxis.options.autoScale !== 'none',
100
+ defaultValue: 0
101
+ });
102
+ }
103
+
104
+ datapoints.format = format;
105
+ }
106
+ }
107
+
108
+ function computeFillBottoms(plot, s, datapoints) {
109
+ if (s.fillBetween == null) {
110
+ return;
111
+ }
112
+
113
+ var other = findBottomSeries(s, plot.getData());
114
+
115
+ if (!other) {
116
+ return;
117
+ }
118
+
119
+ var ps = datapoints.pointsize,
120
+ points = datapoints.points,
121
+ otherps = other.datapoints.pointsize,
122
+ otherpoints = other.datapoints.points,
123
+ newpoints = [],
124
+ px, py, intery, qx, qy, bottom,
125
+ withlines = s.lines.show,
126
+ withbottom = ps > 2 && datapoints.format[2].y,
127
+ withsteps = withlines && s.lines.steps,
128
+ fromgap = true,
129
+ i = 0,
130
+ j = 0,
131
+ l, m;
132
+
133
+ while (true) {
134
+ if (i >= points.length) {
135
+ break;
136
+ }
137
+
138
+ l = newpoints.length;
139
+
140
+ if (points[ i ] == null) {
141
+ // copy gaps
142
+ for (m = 0; m < ps; ++m) {
143
+ newpoints.push(points[ i + m ]);
144
+ }
145
+
146
+ i += ps;
147
+ } else if (j >= otherpoints.length) {
148
+ // for lines, we can't use the rest of the points
149
+ if (!withlines) {
150
+ for (m = 0; m < ps; ++m) {
151
+ newpoints.push(points[ i + m ]);
152
+ }
153
+ }
154
+
155
+ i += ps;
156
+ } else if (otherpoints[ j ] == null) {
157
+ // oops, got a gap
158
+ for (m = 0; m < ps; ++m) {
159
+ newpoints.push(null);
160
+ }
161
+
162
+ fromgap = true;
163
+ j += otherps;
164
+ } else {
165
+ // cases where we actually got two points
166
+ px = points[ i ];
167
+ py = points[ i + 1 ];
168
+ qx = otherpoints[ j ];
169
+ qy = otherpoints[ j + 1 ];
170
+ bottom = 0;
171
+
172
+ if (px === qx) {
173
+ for (m = 0; m < ps; ++m) {
174
+ newpoints.push(points[ i + m ]);
175
+ }
176
+
177
+ //newpoints[ l + 1 ] += qy;
178
+ bottom = qy;
179
+
180
+ i += ps;
181
+ j += otherps;
182
+ } else if (px > qx) {
183
+ // we got past point below, might need to
184
+ // insert interpolated extra point
185
+
186
+ if (withlines && i > 0 && points[ i - ps ] != null) {
187
+ intery = py + (points[ i - ps + 1 ] - py) * (qx - px) / (points[ i - ps ] - px);
188
+ newpoints.push(qx);
189
+ newpoints.push(intery);
190
+ for (m = 2; m < ps; ++m) {
191
+ newpoints.push(points[ i + m ]);
192
+ }
193
+ bottom = qy;
194
+ }
195
+
196
+ j += otherps;
197
+ } else {
198
+ // px < qx
199
+ // if we come from a gap, we just skip this point
200
+
201
+ if (fromgap && withlines) {
202
+ i += ps;
203
+ continue;
204
+ }
205
+
206
+ for (m = 0; m < ps; ++m) {
207
+ newpoints.push(points[ i + m ]);
208
+ }
209
+
210
+ // we might be able to interpolate a point below,
211
+ // this can give us a better y
212
+
213
+ if (withlines && j > 0 && otherpoints[ j - otherps ] != null) {
214
+ bottom = qy + (otherpoints[ j - otherps + 1 ] - qy) * (px - qx) / (otherpoints[ j - otherps ] - qx);
215
+ }
216
+
217
+ //newpoints[l + 1] += bottom;
218
+
219
+ i += ps;
220
+ }
221
+
222
+ fromgap = false;
223
+
224
+ if (l !== newpoints.length && withbottom) {
225
+ newpoints[ l + 2 ] = bottom;
226
+ }
227
+ }
228
+
229
+ // maintain the line steps invariant
230
+
231
+ if (withsteps && l !== newpoints.length && l > 0 &&
232
+ newpoints[ l ] !== null &&
233
+ newpoints[ l ] !== newpoints[ l - ps ] &&
234
+ newpoints[ l + 1 ] !== newpoints[ l - ps + 1 ]) {
235
+ for (m = 0; m < ps; ++m) {
236
+ newpoints[ l + ps + m ] = newpoints[ l + m ];
237
+ }
238
+ newpoints[ l + 1 ] = newpoints[ l - ps + 1 ];
239
+ }
240
+ }
241
+
242
+ datapoints.points = newpoints;
243
+ }
244
+
245
+ plot.hooks.processRawData.push(computeFormat);
246
+ plot.hooks.processDatapoints.push(computeFillBottoms);
247
+ }
248
+
249
+ plugins.push({
250
+ init: init,
251
+ options: options,
252
+ name: "fillbetween",
253
+ version: "1.0"
254
+ });
@@ -0,0 +1,47 @@
1
+ /* Support for flat 1D data series.
2
+
3
+ A 1D flat data series is a data series in the form of a regular 1D array. The
4
+ main reason for using a flat data series is that it performs better, consumes
5
+ less memory and generates less garbage collection than the regular flot format.
6
+
7
+ Example:
8
+
9
+ plot.setData([[[0,0], [1,1], [2,2], [3,3]]]); // regular flot format
10
+ plot.setData([{flatdata: true, data: [0, 1, 2, 3]}]); // flatdata format
11
+
12
+ Set series.flatdata to true to enable this plugin.
13
+
14
+ You can use series.start to specify the starting index of the series (default is 0)
15
+ You can use series.step to specify the interval between consecutive indexes of the series (default is 1)
16
+ */
17
+
18
+ /* global jQuery*/
19
+
20
+ import { plugins } from './jquery.flot.js';
21
+
22
+ 'use strict';
23
+
24
+ function process1DRawData(plot, series, data, datapoints) {
25
+ if (series.flatdata === true) {
26
+ var start = series.start || 0;
27
+ var step = typeof series.step === 'number' ? series.step : 1;
28
+ datapoints.pointsize = 2;
29
+ for (var i = 0, j = 0; i < data.length; i++, j += 2) {
30
+ datapoints.points[j] = start + (i * step);
31
+ datapoints.points[j + 1] = data[i];
32
+ }
33
+ if (datapoints.points !== undefined) {
34
+ datapoints.points.length = data.length * 2;
35
+ } else {
36
+ datapoints.points = [];
37
+ }
38
+ }
39
+ }
40
+
41
+ plugins.push({
42
+ init: function(plot) {
43
+ plot.hooks.processRawData.push(process1DRawData);
44
+ },
45
+ name: 'flatdata',
46
+ version: '0.0.2'
47
+ });