@kevinburke/flot 5.1.3 → 5.1.4
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.
- package/CHANGELOG.md +25 -0
- package/dist/flot.js +173 -21
- package/dist/flot.min.js +1 -1
- package/dist/flot.min.js.map +1 -1
- package/dist/flot.mjs +173 -21
- package/dist/jquery.flot.js +181 -25
- package/dist/jquery.flot.min.js +1 -1
- package/dist/jquery.flot.min.js.map +1 -1
- package/dist/plugins/jquery.flot.crosshair.js +1 -1
- package/dist/plugins/jquery.flot.image.js +1 -1
- package/dist/plugins/jquery.flot.pie.js +1 -1
- package/dist/plugins/jquery.flot.resize.js +1 -1
- package/dist/plugins/jquery.flot.threshold.js +1 -1
- package/package.json +1 -1
- package/source/jquery-adapter.js +8 -4
- package/source/jquery.flot.js +172 -20
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
package/source/jquery-adapter.js
CHANGED
|
@@ -56,13 +56,15 @@ setTrigger(function(el, type, args) {
|
|
|
56
56
|
$(el).trigger(event);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
$.plot = /** @type {typeof $.plot} */ (function(placeholder, data, options) {
|
|
59
|
+
function jqueryPlot(placeholder, data, options) {
|
|
61
60
|
var el = typeof placeholder === 'string'
|
|
62
61
|
? document.querySelector(placeholder)
|
|
63
62
|
: (placeholder instanceof $ ? placeholder[0] : placeholder);
|
|
64
63
|
return plot(el, data, options);
|
|
65
|
-
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Register $.plot and $.color on the jQuery object.
|
|
67
|
+
$.plot = /** @type {typeof $.plot} */ (/** @type {unknown} */ (jqueryPlot));
|
|
66
68
|
|
|
67
69
|
$.plot.plugins = plugins;
|
|
68
70
|
$.plot.version = version;
|
|
@@ -84,7 +86,9 @@ $.plot.composeImages = composeImages;
|
|
|
84
86
|
var origExtract = color.extract;
|
|
85
87
|
$.color = Object.create(color);
|
|
86
88
|
$.color.extract = function(elem, cssProp) {
|
|
87
|
-
if (elem instanceof $
|
|
89
|
+
if (elem instanceof $) {
|
|
90
|
+
elem = elem[0];
|
|
91
|
+
}
|
|
88
92
|
return origExtract(elem, cssProp);
|
|
89
93
|
};
|
|
90
94
|
|
package/source/jquery.flot.js
CHANGED
|
@@ -13,6 +13,120 @@ import { browser } from './jquery.flot.browser.js';
|
|
|
13
13
|
import { uiConstants } from './jquery.flot.uiConstants.js';
|
|
14
14
|
import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {{ [key: string]: any }} PluginOptions
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {PluginOptions & {
|
|
22
|
+
* points: PluginOptions,
|
|
23
|
+
* lines: PluginOptions,
|
|
24
|
+
* bars: PluginOptions,
|
|
25
|
+
* shadowSize: number,
|
|
26
|
+
* highlightColor: string | null
|
|
27
|
+
* }} InternalSeriesOptions
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {PluginOptions & {
|
|
32
|
+
* position?: string,
|
|
33
|
+
* color?: string | number | null,
|
|
34
|
+
* tickColor?: string | number | null,
|
|
35
|
+
* font?: PluginOptions | null,
|
|
36
|
+
* autoScale?: string,
|
|
37
|
+
* offset?: PluginOptions,
|
|
38
|
+
* boxPosition?: AxisBoxPosition
|
|
39
|
+
* }} InternalAxisOptions
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {{ top: number, right: number, bottom: number, left: number }} BorderWidth
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {{ top: string, right: string, bottom: string, left: string }} BorderColor
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {{ left: number, top: number, width: number, height: number, padding: number }} AxisBox
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {{ centerX: number, centerY: number }} AxisBoxPosition
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @typedef {PluginOptions & {
|
|
60
|
+
* n: number,
|
|
61
|
+
* direction: "x" | "y",
|
|
62
|
+
* options: InternalAxisOptions,
|
|
63
|
+
* used: boolean,
|
|
64
|
+
* show: boolean,
|
|
65
|
+
* reserveSpace: boolean,
|
|
66
|
+
* labelWidth: number,
|
|
67
|
+
* labelHeight: number,
|
|
68
|
+
* box: AxisBox,
|
|
69
|
+
* boxPosition: AxisBoxPosition,
|
|
70
|
+
* min: number,
|
|
71
|
+
* max: number,
|
|
72
|
+
* datamin: number | null,
|
|
73
|
+
* datamax: number | null,
|
|
74
|
+
* scale: number,
|
|
75
|
+
* tickSize: number,
|
|
76
|
+
* tickDecimals: number,
|
|
77
|
+
* ticks: Array<PluginOptions>,
|
|
78
|
+
* p2c: function(string | number): number,
|
|
79
|
+
* c2p: function(string | number): number
|
|
80
|
+
* }} InternalAxis
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {PluginOptions & {
|
|
85
|
+
* show: boolean,
|
|
86
|
+
* aboveData: boolean,
|
|
87
|
+
* color: string,
|
|
88
|
+
* backgroundColor: string | PluginOptions | null,
|
|
89
|
+
* borderColor: string | BorderColor | null,
|
|
90
|
+
* tickColor: string | null,
|
|
91
|
+
* margin: number | PluginOptions,
|
|
92
|
+
* borderWidth: number | BorderWidth,
|
|
93
|
+
* minBorderMargin: number | null,
|
|
94
|
+
* markings: any,
|
|
95
|
+
* markingsColor: string,
|
|
96
|
+
* markingsLineWidth: number,
|
|
97
|
+
* clickable: boolean,
|
|
98
|
+
* hoverable: boolean,
|
|
99
|
+
* autoHighlight: boolean,
|
|
100
|
+
* mouseActiveRadius: number
|
|
101
|
+
* }} InternalGridOptions
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @typedef {PluginOptions & {
|
|
106
|
+
* colors: string[],
|
|
107
|
+
* xaxis: InternalAxisOptions,
|
|
108
|
+
* yaxis: InternalAxisOptions,
|
|
109
|
+
* xaxes: InternalAxisOptions[],
|
|
110
|
+
* yaxes: InternalAxisOptions[],
|
|
111
|
+
* series: InternalSeriesOptions,
|
|
112
|
+
* grid: InternalGridOptions,
|
|
113
|
+
* interaction: PluginOptions,
|
|
114
|
+
* hooks: PluginOptions
|
|
115
|
+
* }} InternalOptions
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @typedef {{ [key: string]: Array<function(...any): any> }} HookRegistry
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @typedef {PluginOptions} InternalPlot
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @typedef {{ from?: number, to?: number, axis: InternalAxis }} ExtractedRange
|
|
128
|
+
*/
|
|
129
|
+
|
|
16
130
|
function defaultTickGenerator(axis) {
|
|
17
131
|
var ticks = [],
|
|
18
132
|
start = saturated.saturate(saturated.floorInBase(axis.min, axis.tickSize)),
|
|
@@ -102,6 +216,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
102
216
|
// or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
|
|
103
217
|
|
|
104
218
|
var series = [],
|
|
219
|
+
/** @type {InternalOptions} */
|
|
105
220
|
options = {
|
|
106
221
|
// the color theme used for graphs
|
|
107
222
|
colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"],
|
|
@@ -214,7 +329,9 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
214
329
|
eventHolder = null, // DOM element that events should be bound to
|
|
215
330
|
ctx = null,
|
|
216
331
|
octx = null,
|
|
332
|
+
/** @type {InternalAxis[]} */
|
|
217
333
|
xaxes = [],
|
|
334
|
+
/** @type {InternalAxis[]} */
|
|
218
335
|
yaxes = [],
|
|
219
336
|
plotOffset = {
|
|
220
337
|
left: 0,
|
|
@@ -224,6 +341,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
224
341
|
},
|
|
225
342
|
plotWidth = 0,
|
|
226
343
|
plotHeight = 0,
|
|
344
|
+
/** @type {HookRegistry} */
|
|
227
345
|
hooks = {
|
|
228
346
|
processOptions: [],
|
|
229
347
|
processRawData: [],
|
|
@@ -243,6 +361,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
243
361
|
resize: [],
|
|
244
362
|
shutdown: []
|
|
245
363
|
},
|
|
364
|
+
/** @type {InternalPlot} */
|
|
246
365
|
plot = this;
|
|
247
366
|
|
|
248
367
|
var eventManager = {};
|
|
@@ -309,8 +428,8 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
309
428
|
plot.triggerRedrawOverlay = triggerRedrawOverlay;
|
|
310
429
|
plot.pointOffset = function(point) {
|
|
311
430
|
return {
|
|
312
|
-
left: parseInt(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left, 10),
|
|
313
|
-
top: parseInt(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top, 10)
|
|
431
|
+
left: parseInt(String(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left), 10),
|
|
432
|
+
top: parseInt(String(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top), 10)
|
|
314
433
|
};
|
|
315
434
|
};
|
|
316
435
|
plot.shutdown = shutdown;
|
|
@@ -320,6 +439,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
320
439
|
placeholder.innerHTML = '';
|
|
321
440
|
|
|
322
441
|
series = [];
|
|
442
|
+
// @ts-expect-error destroy clears closure references after shutdown.
|
|
323
443
|
options = null;
|
|
324
444
|
surface = null;
|
|
325
445
|
overlay = null;
|
|
@@ -328,7 +448,9 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
328
448
|
octx = null;
|
|
329
449
|
xaxes = [];
|
|
330
450
|
yaxes = [];
|
|
451
|
+
// @ts-expect-error destroy clears closure references after shutdown.
|
|
331
452
|
hooks = null;
|
|
453
|
+
// @ts-expect-error destroy clears closure references after shutdown.
|
|
332
454
|
plot = null;
|
|
333
455
|
};
|
|
334
456
|
|
|
@@ -557,6 +679,9 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
557
679
|
return a;
|
|
558
680
|
}
|
|
559
681
|
|
|
682
|
+
/**
|
|
683
|
+
* @returns {InternalAxis[]}
|
|
684
|
+
*/
|
|
560
685
|
function allAxes() {
|
|
561
686
|
// return flat array without annoying null entries
|
|
562
687
|
return xaxes.concat(yaxes).filter(function(a) {
|
|
@@ -635,16 +760,23 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
635
760
|
|
|
636
761
|
function getOrCreateAxis(axes, number) {
|
|
637
762
|
if (!axes[number - 1]) {
|
|
638
|
-
axes[number - 1] = {
|
|
763
|
+
axes[number - 1] = /** @type {InternalAxis} */ (/** @type {unknown} */ ({
|
|
639
764
|
n: number, // save the number for future reference
|
|
640
765
|
direction: axes === xaxes ? "x" : "y",
|
|
641
766
|
options: extend(true, {}, axes === xaxes ? options.xaxis : options.yaxis)
|
|
642
|
-
};
|
|
767
|
+
}));
|
|
643
768
|
}
|
|
644
769
|
|
|
645
770
|
return axes[number - 1];
|
|
646
771
|
}
|
|
647
772
|
|
|
773
|
+
function firstAxis(axes) {
|
|
774
|
+
if (!axes[0]) {
|
|
775
|
+
throw new Error("missing first axis");
|
|
776
|
+
}
|
|
777
|
+
return axes[0];
|
|
778
|
+
}
|
|
779
|
+
|
|
648
780
|
function fillInSeriesOptions() {
|
|
649
781
|
var neededColors = series.length,
|
|
650
782
|
maxIndex = -1,
|
|
@@ -1067,8 +1199,13 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1067
1199
|
function measureTickLabels(axis) {
|
|
1068
1200
|
var opts = axis.options,
|
|
1069
1201
|
ticks = opts.showTickLabels !== 'none' && axis.ticks ? axis.ticks : [],
|
|
1070
|
-
|
|
1071
|
-
|
|
1202
|
+
// Mirror drawAxisLabels: 'major' and 'all' draw every tick;
|
|
1203
|
+
// only 'endpoints' skips middle ticks. Measurement must cover
|
|
1204
|
+
// every label that will be drawn, otherwise labelWidth can be
|
|
1205
|
+
// too small for the widest one — e.g. a top tick of 100 next
|
|
1206
|
+
// to 70/80/90 gets clipped to "00" because the axis box was
|
|
1207
|
+
// sized for 2-char labels. See flot/flot#1729, flot/flot#1788.
|
|
1208
|
+
endpointsOnly = opts.showTickLabels === 'endpoints',
|
|
1072
1209
|
labelWidth = opts.labelWidth || 0,
|
|
1073
1210
|
labelHeight = opts.labelHeight || 0,
|
|
1074
1211
|
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
|
|
@@ -1079,9 +1216,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1079
1216
|
var t = ticks[i];
|
|
1080
1217
|
var label = t.label;
|
|
1081
1218
|
|
|
1082
|
-
if (!t.label ||
|
|
1083
|
-
(showMajorTickLabels === false && i > 0 && i < ticks.length - 1) ||
|
|
1084
|
-
(showEndpointsTickLabels === false && (i === 0 || i === ticks.length - 1))) {
|
|
1219
|
+
if (!t.label || (endpointsOnly && i > 0 && i < ticks.length - 1)) {
|
|
1085
1220
|
continue;
|
|
1086
1221
|
}
|
|
1087
1222
|
|
|
@@ -1405,9 +1540,11 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1405
1540
|
if (delta === 0.0) {
|
|
1406
1541
|
// degenerate case
|
|
1407
1542
|
var widen = max === 0 ? 1 : 0.01;
|
|
1408
|
-
var wmin =
|
|
1543
|
+
var wmin = 0;
|
|
1544
|
+
var wminSet = false;
|
|
1409
1545
|
if (min == null) {
|
|
1410
|
-
wmin
|
|
1546
|
+
wmin = -widen;
|
|
1547
|
+
wminSet = true;
|
|
1411
1548
|
}
|
|
1412
1549
|
|
|
1413
1550
|
// always widen max if we couldn't widen min to ensure we
|
|
@@ -1416,7 +1553,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1416
1553
|
max += widen;
|
|
1417
1554
|
}
|
|
1418
1555
|
|
|
1419
|
-
if (
|
|
1556
|
+
if (wminSet) {
|
|
1420
1557
|
min = wmin;
|
|
1421
1558
|
}
|
|
1422
1559
|
}
|
|
@@ -1814,8 +1951,13 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1814
1951
|
triggerRedrawOverlay();
|
|
1815
1952
|
}
|
|
1816
1953
|
|
|
1954
|
+
/**
|
|
1955
|
+
* @returns {ExtractedRange}
|
|
1956
|
+
*/
|
|
1817
1957
|
function extractRange(ranges, coord) {
|
|
1818
|
-
var axis, from, to,
|
|
1958
|
+
var axis, from, to, axes = allAxes();
|
|
1959
|
+
var key = "";
|
|
1960
|
+
var keyFound = false;
|
|
1819
1961
|
|
|
1820
1962
|
for (var i = 0; i < axes.length; ++i) {
|
|
1821
1963
|
axis = axes[i];
|
|
@@ -1827,6 +1969,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1827
1969
|
}
|
|
1828
1970
|
|
|
1829
1971
|
if (ranges[key]) {
|
|
1972
|
+
keyFound = true;
|
|
1830
1973
|
from = ranges[key].from;
|
|
1831
1974
|
to = ranges[key].to;
|
|
1832
1975
|
break;
|
|
@@ -1835,8 +1978,8 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1835
1978
|
}
|
|
1836
1979
|
|
|
1837
1980
|
// backwards-compat stuff - to be removed in future
|
|
1838
|
-
if (!
|
|
1839
|
-
axis = coord === "x" ? xaxes
|
|
1981
|
+
if (!keyFound) {
|
|
1982
|
+
axis = firstAxis(coord === "x" ? xaxes : yaxes);
|
|
1840
1983
|
from = ranges[coord + "1"];
|
|
1841
1984
|
to = ranges[coord + "2"];
|
|
1842
1985
|
}
|
|
@@ -1851,7 +1994,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1851
1994
|
return {
|
|
1852
1995
|
from: from,
|
|
1853
1996
|
to: to,
|
|
1854
|
-
axis: axis
|
|
1997
|
+
axis: /** @type {InternalAxis} */ (axis)
|
|
1855
1998
|
};
|
|
1856
1999
|
}
|
|
1857
2000
|
|
|
@@ -2105,7 +2248,8 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2105
2248
|
// check if the line will be overlapped with a border
|
|
2106
2249
|
var overlappedWithBorder = function (value) {
|
|
2107
2250
|
var bw = options.grid.borderWidth;
|
|
2108
|
-
|
|
2251
|
+
var overlapsBorder = typeof bw === "object" ? bw[axis.position] > 0 : bw > 0;
|
|
2252
|
+
return overlapsBorder && (value === axis.min || value === axis.max);
|
|
2109
2253
|
};
|
|
2110
2254
|
|
|
2111
2255
|
ctx.strokeStyle = options.grid.tickColor;
|
|
@@ -2152,6 +2296,10 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2152
2296
|
var bw = options.grid.borderWidth,
|
|
2153
2297
|
bc = options.grid.borderColor;
|
|
2154
2298
|
|
|
2299
|
+
if (bc == null) {
|
|
2300
|
+
bc = options.grid.color;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2155
2303
|
if (typeof bw === "object" || typeof bc === "object") {
|
|
2156
2304
|
if (typeof bw !== "object") {
|
|
2157
2305
|
bw = {
|
|
@@ -2532,10 +2680,14 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2532
2680
|
smallestDistance = radius * radius + 1;
|
|
2533
2681
|
|
|
2534
2682
|
for (i = series.length - 1; i >= 0; --i) {
|
|
2535
|
-
if (!seriesFilter(i))
|
|
2683
|
+
if (!seriesFilter(i)) {
|
|
2684
|
+
continue;
|
|
2685
|
+
}
|
|
2536
2686
|
|
|
2537
2687
|
var s = series[i];
|
|
2538
|
-
if (!s.datapoints)
|
|
2688
|
+
if (!s.datapoints) {
|
|
2689
|
+
continue;
|
|
2690
|
+
}
|
|
2539
2691
|
|
|
2540
2692
|
var foundPoint = false;
|
|
2541
2693
|
if (s.lines.show || s.points.show) {
|
|
@@ -2822,7 +2974,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2822
2974
|
// Plugin registry. Plugins push to this array to register themselves.
|
|
2823
2975
|
export var plugins = [];
|
|
2824
2976
|
|
|
2825
|
-
export var version = "5.1.
|
|
2977
|
+
export var version = "5.1.4";
|
|
2826
2978
|
|
|
2827
2979
|
// The main plot function.
|
|
2828
2980
|
export function plot(placeholder, data, options) {
|
package/types/index.d.ts
CHANGED