@kevinburke/flot 5.1.2 → 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 +63 -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 +205 -27
- package/dist/jquery.flot.min.js +1 -1
- package/dist/jquery.flot.min.js.map +1 -1
- package/dist/plugins/jquery.flot.crosshair.js +2 -2
- package/dist/plugins/jquery.flot.crosshair.min.js +1 -1
- package/dist/plugins/jquery.flot.image.js +6 -6
- package/dist/plugins/jquery.flot.image.min.js +1 -1
- package/dist/plugins/jquery.flot.image.min.js.map +1 -1
- package/dist/plugins/jquery.flot.pie.js +2 -2
- package/dist/plugins/jquery.flot.pie.min.js +1 -1
- package/dist/plugins/jquery.flot.resize.js +2 -2
- package/dist/plugins/jquery.flot.resize.min.js +1 -1
- package/dist/plugins/jquery.flot.resize.min.js.map +1 -1
- package/dist/plugins/jquery.flot.threshold.js +2 -2
- package/dist/plugins/jquery.flot.threshold.min.js +1 -1
- package/package.json +1 -1
- package/source/globals.d.ts +5 -0
- package/source/jquery-adapter.js +15 -5
- package/source/jquery.flot.image.js +6 -1
- package/source/jquery.flot.js +172 -20
- package/types/index.d.ts +1 -0
- package/types/jquery.d.ts +2 -1
package/dist/flot.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @kevinburke/flot v5.1.
|
|
1
|
+
/*! @kevinburke/flot v5.1.4 | MIT License | https://github.com/kevinburke/flot */
|
|
2
2
|
var browser = {
|
|
3
3
|
getPageXY: function (e) {
|
|
4
4
|
var doc = document.documentElement,
|
|
@@ -1732,6 +1732,120 @@ Licensed under the MIT license.
|
|
|
1732
1732
|
*/
|
|
1733
1733
|
|
|
1734
1734
|
|
|
1735
|
+
/**
|
|
1736
|
+
* @typedef {{ [key: string]: any }} PluginOptions
|
|
1737
|
+
*/
|
|
1738
|
+
|
|
1739
|
+
/**
|
|
1740
|
+
* @typedef {PluginOptions & {
|
|
1741
|
+
* points: PluginOptions,
|
|
1742
|
+
* lines: PluginOptions,
|
|
1743
|
+
* bars: PluginOptions,
|
|
1744
|
+
* shadowSize: number,
|
|
1745
|
+
* highlightColor: string | null
|
|
1746
|
+
* }} InternalSeriesOptions
|
|
1747
|
+
*/
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* @typedef {PluginOptions & {
|
|
1751
|
+
* position?: string,
|
|
1752
|
+
* color?: string | number | null,
|
|
1753
|
+
* tickColor?: string | number | null,
|
|
1754
|
+
* font?: PluginOptions | null,
|
|
1755
|
+
* autoScale?: string,
|
|
1756
|
+
* offset?: PluginOptions,
|
|
1757
|
+
* boxPosition?: AxisBoxPosition
|
|
1758
|
+
* }} InternalAxisOptions
|
|
1759
|
+
*/
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* @typedef {{ top: number, right: number, bottom: number, left: number }} BorderWidth
|
|
1763
|
+
*/
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* @typedef {{ top: string, right: string, bottom: string, left: string }} BorderColor
|
|
1767
|
+
*/
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* @typedef {{ left: number, top: number, width: number, height: number, padding: number }} AxisBox
|
|
1771
|
+
*/
|
|
1772
|
+
|
|
1773
|
+
/**
|
|
1774
|
+
* @typedef {{ centerX: number, centerY: number }} AxisBoxPosition
|
|
1775
|
+
*/
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* @typedef {PluginOptions & {
|
|
1779
|
+
* n: number,
|
|
1780
|
+
* direction: "x" | "y",
|
|
1781
|
+
* options: InternalAxisOptions,
|
|
1782
|
+
* used: boolean,
|
|
1783
|
+
* show: boolean,
|
|
1784
|
+
* reserveSpace: boolean,
|
|
1785
|
+
* labelWidth: number,
|
|
1786
|
+
* labelHeight: number,
|
|
1787
|
+
* box: AxisBox,
|
|
1788
|
+
* boxPosition: AxisBoxPosition,
|
|
1789
|
+
* min: number,
|
|
1790
|
+
* max: number,
|
|
1791
|
+
* datamin: number | null,
|
|
1792
|
+
* datamax: number | null,
|
|
1793
|
+
* scale: number,
|
|
1794
|
+
* tickSize: number,
|
|
1795
|
+
* tickDecimals: number,
|
|
1796
|
+
* ticks: Array<PluginOptions>,
|
|
1797
|
+
* p2c: function(string | number): number,
|
|
1798
|
+
* c2p: function(string | number): number
|
|
1799
|
+
* }} InternalAxis
|
|
1800
|
+
*/
|
|
1801
|
+
|
|
1802
|
+
/**
|
|
1803
|
+
* @typedef {PluginOptions & {
|
|
1804
|
+
* show: boolean,
|
|
1805
|
+
* aboveData: boolean,
|
|
1806
|
+
* color: string,
|
|
1807
|
+
* backgroundColor: string | PluginOptions | null,
|
|
1808
|
+
* borderColor: string | BorderColor | null,
|
|
1809
|
+
* tickColor: string | null,
|
|
1810
|
+
* margin: number | PluginOptions,
|
|
1811
|
+
* borderWidth: number | BorderWidth,
|
|
1812
|
+
* minBorderMargin: number | null,
|
|
1813
|
+
* markings: any,
|
|
1814
|
+
* markingsColor: string,
|
|
1815
|
+
* markingsLineWidth: number,
|
|
1816
|
+
* clickable: boolean,
|
|
1817
|
+
* hoverable: boolean,
|
|
1818
|
+
* autoHighlight: boolean,
|
|
1819
|
+
* mouseActiveRadius: number
|
|
1820
|
+
* }} InternalGridOptions
|
|
1821
|
+
*/
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* @typedef {PluginOptions & {
|
|
1825
|
+
* colors: string[],
|
|
1826
|
+
* xaxis: InternalAxisOptions,
|
|
1827
|
+
* yaxis: InternalAxisOptions,
|
|
1828
|
+
* xaxes: InternalAxisOptions[],
|
|
1829
|
+
* yaxes: InternalAxisOptions[],
|
|
1830
|
+
* series: InternalSeriesOptions,
|
|
1831
|
+
* grid: InternalGridOptions,
|
|
1832
|
+
* interaction: PluginOptions,
|
|
1833
|
+
* hooks: PluginOptions
|
|
1834
|
+
* }} InternalOptions
|
|
1835
|
+
*/
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* @typedef {{ [key: string]: Array<function(...any): any> }} HookRegistry
|
|
1839
|
+
*/
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* @typedef {PluginOptions} InternalPlot
|
|
1843
|
+
*/
|
|
1844
|
+
|
|
1845
|
+
/**
|
|
1846
|
+
* @typedef {{ from?: number, to?: number, axis: InternalAxis }} ExtractedRange
|
|
1847
|
+
*/
|
|
1848
|
+
|
|
1735
1849
|
function defaultTickGenerator(axis) {
|
|
1736
1850
|
var ticks = [],
|
|
1737
1851
|
start = saturated.saturate(saturated.floorInBase(axis.min, axis.tickSize)),
|
|
@@ -1820,6 +1934,7 @@ Licensed under the MIT license.
|
|
|
1820
1934
|
// or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
|
|
1821
1935
|
|
|
1822
1936
|
var series = [],
|
|
1937
|
+
/** @type {InternalOptions} */
|
|
1823
1938
|
options = {
|
|
1824
1939
|
// the color theme used for graphs
|
|
1825
1940
|
colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"],
|
|
@@ -1932,7 +2047,9 @@ Licensed under the MIT license.
|
|
|
1932
2047
|
eventHolder = null, // DOM element that events should be bound to
|
|
1933
2048
|
ctx = null,
|
|
1934
2049
|
octx = null,
|
|
2050
|
+
/** @type {InternalAxis[]} */
|
|
1935
2051
|
xaxes = [],
|
|
2052
|
+
/** @type {InternalAxis[]} */
|
|
1936
2053
|
yaxes = [],
|
|
1937
2054
|
plotOffset = {
|
|
1938
2055
|
left: 0,
|
|
@@ -1942,6 +2059,7 @@ Licensed under the MIT license.
|
|
|
1942
2059
|
},
|
|
1943
2060
|
plotWidth = 0,
|
|
1944
2061
|
plotHeight = 0,
|
|
2062
|
+
/** @type {HookRegistry} */
|
|
1945
2063
|
hooks = {
|
|
1946
2064
|
processOptions: [],
|
|
1947
2065
|
processRawData: [],
|
|
@@ -1961,6 +2079,7 @@ Licensed under the MIT license.
|
|
|
1961
2079
|
resize: [],
|
|
1962
2080
|
shutdown: []
|
|
1963
2081
|
},
|
|
2082
|
+
/** @type {InternalPlot} */
|
|
1964
2083
|
plot = this;
|
|
1965
2084
|
|
|
1966
2085
|
var eventManager = {};
|
|
@@ -2027,8 +2146,8 @@ Licensed under the MIT license.
|
|
|
2027
2146
|
plot.triggerRedrawOverlay = triggerRedrawOverlay;
|
|
2028
2147
|
plot.pointOffset = function(point) {
|
|
2029
2148
|
return {
|
|
2030
|
-
left: parseInt(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left, 10),
|
|
2031
|
-
top: parseInt(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top, 10)
|
|
2149
|
+
left: parseInt(String(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left), 10),
|
|
2150
|
+
top: parseInt(String(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top), 10)
|
|
2032
2151
|
};
|
|
2033
2152
|
};
|
|
2034
2153
|
plot.shutdown = shutdown;
|
|
@@ -2038,6 +2157,7 @@ Licensed under the MIT license.
|
|
|
2038
2157
|
placeholder.innerHTML = '';
|
|
2039
2158
|
|
|
2040
2159
|
series = [];
|
|
2160
|
+
// @ts-expect-error destroy clears closure references after shutdown.
|
|
2041
2161
|
options = null;
|
|
2042
2162
|
surface = null;
|
|
2043
2163
|
overlay = null;
|
|
@@ -2046,7 +2166,9 @@ Licensed under the MIT license.
|
|
|
2046
2166
|
octx = null;
|
|
2047
2167
|
xaxes = [];
|
|
2048
2168
|
yaxes = [];
|
|
2169
|
+
// @ts-expect-error destroy clears closure references after shutdown.
|
|
2049
2170
|
hooks = null;
|
|
2171
|
+
// @ts-expect-error destroy clears closure references after shutdown.
|
|
2050
2172
|
plot = null;
|
|
2051
2173
|
};
|
|
2052
2174
|
|
|
@@ -2275,6 +2397,9 @@ Licensed under the MIT license.
|
|
|
2275
2397
|
return a;
|
|
2276
2398
|
}
|
|
2277
2399
|
|
|
2400
|
+
/**
|
|
2401
|
+
* @returns {InternalAxis[]}
|
|
2402
|
+
*/
|
|
2278
2403
|
function allAxes() {
|
|
2279
2404
|
// return flat array without annoying null entries
|
|
2280
2405
|
return xaxes.concat(yaxes).filter(function(a) {
|
|
@@ -2353,16 +2478,23 @@ Licensed under the MIT license.
|
|
|
2353
2478
|
|
|
2354
2479
|
function getOrCreateAxis(axes, number) {
|
|
2355
2480
|
if (!axes[number - 1]) {
|
|
2356
|
-
axes[number - 1] = {
|
|
2481
|
+
axes[number - 1] = /** @type {InternalAxis} */ (/** @type {unknown} */ ({
|
|
2357
2482
|
n: number, // save the number for future reference
|
|
2358
2483
|
direction: axes === xaxes ? "x" : "y",
|
|
2359
2484
|
options: extend(true, {}, axes === xaxes ? options.xaxis : options.yaxis)
|
|
2360
|
-
};
|
|
2485
|
+
}));
|
|
2361
2486
|
}
|
|
2362
2487
|
|
|
2363
2488
|
return axes[number - 1];
|
|
2364
2489
|
}
|
|
2365
2490
|
|
|
2491
|
+
function firstAxis(axes) {
|
|
2492
|
+
if (!axes[0]) {
|
|
2493
|
+
throw new Error("missing first axis");
|
|
2494
|
+
}
|
|
2495
|
+
return axes[0];
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2366
2498
|
function fillInSeriesOptions() {
|
|
2367
2499
|
var neededColors = series.length,
|
|
2368
2500
|
maxIndex = -1,
|
|
@@ -2785,8 +2917,13 @@ Licensed under the MIT license.
|
|
|
2785
2917
|
function measureTickLabels(axis) {
|
|
2786
2918
|
var opts = axis.options,
|
|
2787
2919
|
ticks = opts.showTickLabels !== 'none' && axis.ticks ? axis.ticks : [],
|
|
2788
|
-
|
|
2789
|
-
|
|
2920
|
+
// Mirror drawAxisLabels: 'major' and 'all' draw every tick;
|
|
2921
|
+
// only 'endpoints' skips middle ticks. Measurement must cover
|
|
2922
|
+
// every label that will be drawn, otherwise labelWidth can be
|
|
2923
|
+
// too small for the widest one — e.g. a top tick of 100 next
|
|
2924
|
+
// to 70/80/90 gets clipped to "00" because the axis box was
|
|
2925
|
+
// sized for 2-char labels. See flot/flot#1729, flot/flot#1788.
|
|
2926
|
+
endpointsOnly = opts.showTickLabels === 'endpoints',
|
|
2790
2927
|
labelWidth = opts.labelWidth || 0,
|
|
2791
2928
|
labelHeight = opts.labelHeight || 0,
|
|
2792
2929
|
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
|
|
@@ -2797,9 +2934,7 @@ Licensed under the MIT license.
|
|
|
2797
2934
|
var t = ticks[i];
|
|
2798
2935
|
var label = t.label;
|
|
2799
2936
|
|
|
2800
|
-
if (!t.label ||
|
|
2801
|
-
(showMajorTickLabels === false && i > 0 && i < ticks.length - 1) ||
|
|
2802
|
-
(showEndpointsTickLabels === false && (i === 0 || i === ticks.length - 1))) {
|
|
2937
|
+
if (!t.label || (endpointsOnly && i > 0 && i < ticks.length - 1)) {
|
|
2803
2938
|
continue;
|
|
2804
2939
|
}
|
|
2805
2940
|
|
|
@@ -3123,9 +3258,11 @@ Licensed under the MIT license.
|
|
|
3123
3258
|
if (delta === 0.0) {
|
|
3124
3259
|
// degenerate case
|
|
3125
3260
|
var widen = max === 0 ? 1 : 0.01;
|
|
3126
|
-
var wmin =
|
|
3261
|
+
var wmin = 0;
|
|
3262
|
+
var wminSet = false;
|
|
3127
3263
|
if (min == null) {
|
|
3128
|
-
wmin
|
|
3264
|
+
wmin = -widen;
|
|
3265
|
+
wminSet = true;
|
|
3129
3266
|
}
|
|
3130
3267
|
|
|
3131
3268
|
// always widen max if we couldn't widen min to ensure we
|
|
@@ -3134,7 +3271,7 @@ Licensed under the MIT license.
|
|
|
3134
3271
|
max += widen;
|
|
3135
3272
|
}
|
|
3136
3273
|
|
|
3137
|
-
if (
|
|
3274
|
+
if (wminSet) {
|
|
3138
3275
|
min = wmin;
|
|
3139
3276
|
}
|
|
3140
3277
|
}
|
|
@@ -3530,8 +3667,13 @@ Licensed under the MIT license.
|
|
|
3530
3667
|
triggerRedrawOverlay();
|
|
3531
3668
|
}
|
|
3532
3669
|
|
|
3670
|
+
/**
|
|
3671
|
+
* @returns {ExtractedRange}
|
|
3672
|
+
*/
|
|
3533
3673
|
function extractRange(ranges, coord) {
|
|
3534
|
-
var axis, from, to,
|
|
3674
|
+
var axis, from, to, axes = allAxes();
|
|
3675
|
+
var key = "";
|
|
3676
|
+
var keyFound = false;
|
|
3535
3677
|
|
|
3536
3678
|
for (var i = 0; i < axes.length; ++i) {
|
|
3537
3679
|
axis = axes[i];
|
|
@@ -3543,6 +3685,7 @@ Licensed under the MIT license.
|
|
|
3543
3685
|
}
|
|
3544
3686
|
|
|
3545
3687
|
if (ranges[key]) {
|
|
3688
|
+
keyFound = true;
|
|
3546
3689
|
from = ranges[key].from;
|
|
3547
3690
|
to = ranges[key].to;
|
|
3548
3691
|
break;
|
|
@@ -3551,8 +3694,8 @@ Licensed under the MIT license.
|
|
|
3551
3694
|
}
|
|
3552
3695
|
|
|
3553
3696
|
// backwards-compat stuff - to be removed in future
|
|
3554
|
-
if (!
|
|
3555
|
-
axis = coord === "x" ? xaxes
|
|
3697
|
+
if (!keyFound) {
|
|
3698
|
+
axis = firstAxis(coord === "x" ? xaxes : yaxes);
|
|
3556
3699
|
from = ranges[coord + "1"];
|
|
3557
3700
|
to = ranges[coord + "2"];
|
|
3558
3701
|
}
|
|
@@ -3567,7 +3710,7 @@ Licensed under the MIT license.
|
|
|
3567
3710
|
return {
|
|
3568
3711
|
from: from,
|
|
3569
3712
|
to: to,
|
|
3570
|
-
axis: axis
|
|
3713
|
+
axis: /** @type {InternalAxis} */ (axis)
|
|
3571
3714
|
};
|
|
3572
3715
|
}
|
|
3573
3716
|
|
|
@@ -3817,7 +3960,8 @@ Licensed under the MIT license.
|
|
|
3817
3960
|
// check if the line will be overlapped with a border
|
|
3818
3961
|
var overlappedWithBorder = function (value) {
|
|
3819
3962
|
var bw = options.grid.borderWidth;
|
|
3820
|
-
|
|
3963
|
+
var overlapsBorder = typeof bw === "object" ? bw[axis.position] > 0 : bw > 0;
|
|
3964
|
+
return overlapsBorder && (value === axis.min || value === axis.max);
|
|
3821
3965
|
};
|
|
3822
3966
|
|
|
3823
3967
|
ctx.strokeStyle = options.grid.tickColor;
|
|
@@ -3863,6 +4007,10 @@ Licensed under the MIT license.
|
|
|
3863
4007
|
var bw = options.grid.borderWidth,
|
|
3864
4008
|
bc = options.grid.borderColor;
|
|
3865
4009
|
|
|
4010
|
+
if (bc == null) {
|
|
4011
|
+
bc = options.grid.color;
|
|
4012
|
+
}
|
|
4013
|
+
|
|
3866
4014
|
if (typeof bw === "object" || typeof bc === "object") {
|
|
3867
4015
|
if (typeof bw !== "object") {
|
|
3868
4016
|
bw = {
|
|
@@ -4240,10 +4388,14 @@ Licensed under the MIT license.
|
|
|
4240
4388
|
smallestDistance = radius * radius + 1;
|
|
4241
4389
|
|
|
4242
4390
|
for (i = series.length - 1; i >= 0; --i) {
|
|
4243
|
-
if (!seriesFilter(i))
|
|
4391
|
+
if (!seriesFilter(i)) {
|
|
4392
|
+
continue;
|
|
4393
|
+
}
|
|
4244
4394
|
|
|
4245
4395
|
var s = series[i];
|
|
4246
|
-
if (!s.datapoints)
|
|
4396
|
+
if (!s.datapoints) {
|
|
4397
|
+
continue;
|
|
4398
|
+
}
|
|
4247
4399
|
|
|
4248
4400
|
var foundPoint = false;
|
|
4249
4401
|
if (s.lines.show || s.points.show) {
|
|
@@ -4530,7 +4682,7 @@ Licensed under the MIT license.
|
|
|
4530
4682
|
// Plugin registry. Plugins push to this array to register themselves.
|
|
4531
4683
|
var plugins = [];
|
|
4532
4684
|
|
|
4533
|
-
var version = "5.1.
|
|
4685
|
+
var version = "5.1.4";
|
|
4534
4686
|
|
|
4535
4687
|
// The main plot function.
|
|
4536
4688
|
function plot(placeholder, data, options) {
|