@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 CHANGED
@@ -5,6 +5,51 @@ All notable changes to this project will be documented in this file.
5
5
  Starting with 5.0.0, this changelog tracks the @kevinburke/flot fork.
6
6
  For earlier upstream history, see the [flot/flot repository](https://github.com/flot/flot).
7
7
 
8
+ ## Unreleased
9
+
10
+ ## [5.1.4] - 2026-05-22
11
+
12
+ ### Changed
13
+
14
+ - `jquery.flot.js` / `Makefile`: clear the remaining TypeScript
15
+ `checkJs` source warnings and run `make types-source` as a direct
16
+ `tsc --project tsconfig.json` check. The old `.tsc-baseline`
17
+ ratchet is no longer needed now that the source warning count is
18
+ zero.
19
+ - `biome.json`: update the schema URL to match Biome 2.4.15.
20
+
21
+ ### Fixed
22
+
23
+ - `jquery.flot.js`: make `findNearbyItems()` skip series whose
24
+ `datapoints` have been removed instead of letting `findItems()`
25
+ return `undefined`. This preserves a list return value for hover
26
+ lookup and adds a regression test for the malformed-series case.
27
+ - `jquery.flot.js`: include the first and last ticks in
28
+ `measureTickLabels` for `showTickLabels: 'major'` (the default), so
29
+ that an endpoint label wider than the middle ticks no longer
30
+ overflows the axis box and gets clipped. Upstream `flot/flot#1729`
31
+ and `flot/flot#1788`.
32
+
33
+ ## [5.1.3] - 2026-04-22
34
+
35
+ ### Fixed
36
+
37
+ - `rollup.config.js` / `jquery-adapter.js` / `jquery.flot.image.js`:
38
+ fix the standalone plugin bundles so they resolve their external
39
+ imports against `window.Flot` and `window.Flot.helpers` at runtime
40
+ instead of referencing missing Rollup-generated identifiers. This
41
+ restores loading for the broken standalone IIFE plugins, including
42
+ `jquery.flot.image.js`, `jquery.flot.crosshair.js`,
43
+ `jquery.flot.pie.js`, `jquery.flot.resize.js`, and
44
+ `jquery.flot.threshold.js`.
45
+
46
+ ### Documentation
47
+
48
+ - `API.md` / `CHANGELOG.md` (2.0.1 section): document the
49
+ `bars.barWidth` semantics correctly. Since 2.0, a plain numeric
50
+ `barWidth` is a multiplier of the minimum point spacing and absolute
51
+ widths require `[width, true]`.
52
+
8
53
  ## [5.1.2] - 2026-04-22
9
54
 
10
55
  ### Fixed
@@ -425,6 +470,24 @@ After:
425
470
 
426
471
  Note: A new capability allows for data (and min/max settings of axes) to be specified with a `timeBase` of either seconds or milliseconds. So, a range from 1-10 can either represent 9 milliseconds of data, or 9 seconds of data, depending on the setting of `timeBase` (whose default is "seconds").
427
472
 
473
+ ### `bars.barWidth`:
474
+ Before:
475
+
476
+ bars: { show: true, barWidth: 24 * 60 * 60 * 1000 } // one day, time mode
477
+
478
+ After:
479
+
480
+ bars: { show: true, barWidth: [24 * 60 * 60 * 1000, true] } // one day, absolute
481
+
482
+ Note: A plain-number `barWidth` is now interpreted as a *multiplier* of
483
+ the minimum distance between consecutive x-values in the series (so
484
+ `barWidth: 0.8` means "80% of the point spacing"). To keep the pre-2.0
485
+ behavior where `barWidth` is an absolute width in axis units, pass
486
+ `[width, true]`. Code ported from 0.x / 1.x that used absolute widths
487
+ (typical in time-mode bar charts) will silently produce bars many
488
+ orders of magnitude too wide, which can also inflate `axis.datamin` /
489
+ `axis.datamax` enough to break the time-axis tick generator.
490
+
428
491
  ### Script Locations:
429
492
 
430
493
  All scripts have been moved under the 'source' folder, so you will need to update all reference scripts to point to new location. Or you can use the file dist/es5/jquery.flot.js which is all source combined and minified.
package/dist/flot.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @kevinburke/flot v5.1.2 | MIT License | https://github.com/kevinburke/flot */
1
+ /*! @kevinburke/flot v5.1.4 | MIT License | https://github.com/kevinburke/flot */
2
2
  var Flot = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1735,6 +1735,120 @@ var Flot = (function (exports) {
1735
1735
  */
1736
1736
 
1737
1737
 
1738
+ /**
1739
+ * @typedef {{ [key: string]: any }} PluginOptions
1740
+ */
1741
+
1742
+ /**
1743
+ * @typedef {PluginOptions & {
1744
+ * points: PluginOptions,
1745
+ * lines: PluginOptions,
1746
+ * bars: PluginOptions,
1747
+ * shadowSize: number,
1748
+ * highlightColor: string | null
1749
+ * }} InternalSeriesOptions
1750
+ */
1751
+
1752
+ /**
1753
+ * @typedef {PluginOptions & {
1754
+ * position?: string,
1755
+ * color?: string | number | null,
1756
+ * tickColor?: string | number | null,
1757
+ * font?: PluginOptions | null,
1758
+ * autoScale?: string,
1759
+ * offset?: PluginOptions,
1760
+ * boxPosition?: AxisBoxPosition
1761
+ * }} InternalAxisOptions
1762
+ */
1763
+
1764
+ /**
1765
+ * @typedef {{ top: number, right: number, bottom: number, left: number }} BorderWidth
1766
+ */
1767
+
1768
+ /**
1769
+ * @typedef {{ top: string, right: string, bottom: string, left: string }} BorderColor
1770
+ */
1771
+
1772
+ /**
1773
+ * @typedef {{ left: number, top: number, width: number, height: number, padding: number }} AxisBox
1774
+ */
1775
+
1776
+ /**
1777
+ * @typedef {{ centerX: number, centerY: number }} AxisBoxPosition
1778
+ */
1779
+
1780
+ /**
1781
+ * @typedef {PluginOptions & {
1782
+ * n: number,
1783
+ * direction: "x" | "y",
1784
+ * options: InternalAxisOptions,
1785
+ * used: boolean,
1786
+ * show: boolean,
1787
+ * reserveSpace: boolean,
1788
+ * labelWidth: number,
1789
+ * labelHeight: number,
1790
+ * box: AxisBox,
1791
+ * boxPosition: AxisBoxPosition,
1792
+ * min: number,
1793
+ * max: number,
1794
+ * datamin: number | null,
1795
+ * datamax: number | null,
1796
+ * scale: number,
1797
+ * tickSize: number,
1798
+ * tickDecimals: number,
1799
+ * ticks: Array<PluginOptions>,
1800
+ * p2c: function(string | number): number,
1801
+ * c2p: function(string | number): number
1802
+ * }} InternalAxis
1803
+ */
1804
+
1805
+ /**
1806
+ * @typedef {PluginOptions & {
1807
+ * show: boolean,
1808
+ * aboveData: boolean,
1809
+ * color: string,
1810
+ * backgroundColor: string | PluginOptions | null,
1811
+ * borderColor: string | BorderColor | null,
1812
+ * tickColor: string | null,
1813
+ * margin: number | PluginOptions,
1814
+ * borderWidth: number | BorderWidth,
1815
+ * minBorderMargin: number | null,
1816
+ * markings: any,
1817
+ * markingsColor: string,
1818
+ * markingsLineWidth: number,
1819
+ * clickable: boolean,
1820
+ * hoverable: boolean,
1821
+ * autoHighlight: boolean,
1822
+ * mouseActiveRadius: number
1823
+ * }} InternalGridOptions
1824
+ */
1825
+
1826
+ /**
1827
+ * @typedef {PluginOptions & {
1828
+ * colors: string[],
1829
+ * xaxis: InternalAxisOptions,
1830
+ * yaxis: InternalAxisOptions,
1831
+ * xaxes: InternalAxisOptions[],
1832
+ * yaxes: InternalAxisOptions[],
1833
+ * series: InternalSeriesOptions,
1834
+ * grid: InternalGridOptions,
1835
+ * interaction: PluginOptions,
1836
+ * hooks: PluginOptions
1837
+ * }} InternalOptions
1838
+ */
1839
+
1840
+ /**
1841
+ * @typedef {{ [key: string]: Array<function(...any): any> }} HookRegistry
1842
+ */
1843
+
1844
+ /**
1845
+ * @typedef {PluginOptions} InternalPlot
1846
+ */
1847
+
1848
+ /**
1849
+ * @typedef {{ from?: number, to?: number, axis: InternalAxis }} ExtractedRange
1850
+ */
1851
+
1738
1852
  function defaultTickGenerator(axis) {
1739
1853
  var ticks = [],
1740
1854
  start = saturated.saturate(saturated.floorInBase(axis.min, axis.tickSize)),
@@ -1823,6 +1937,7 @@ var Flot = (function (exports) {
1823
1937
  // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
1824
1938
 
1825
1939
  var series = [],
1940
+ /** @type {InternalOptions} */
1826
1941
  options = {
1827
1942
  // the color theme used for graphs
1828
1943
  colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"],
@@ -1935,7 +2050,9 @@ var Flot = (function (exports) {
1935
2050
  eventHolder = null, // DOM element that events should be bound to
1936
2051
  ctx = null,
1937
2052
  octx = null,
2053
+ /** @type {InternalAxis[]} */
1938
2054
  xaxes = [],
2055
+ /** @type {InternalAxis[]} */
1939
2056
  yaxes = [],
1940
2057
  plotOffset = {
1941
2058
  left: 0,
@@ -1945,6 +2062,7 @@ var Flot = (function (exports) {
1945
2062
  },
1946
2063
  plotWidth = 0,
1947
2064
  plotHeight = 0,
2065
+ /** @type {HookRegistry} */
1948
2066
  hooks = {
1949
2067
  processOptions: [],
1950
2068
  processRawData: [],
@@ -1964,6 +2082,7 @@ var Flot = (function (exports) {
1964
2082
  resize: [],
1965
2083
  shutdown: []
1966
2084
  },
2085
+ /** @type {InternalPlot} */
1967
2086
  plot = this;
1968
2087
 
1969
2088
  var eventManager = {};
@@ -2030,8 +2149,8 @@ var Flot = (function (exports) {
2030
2149
  plot.triggerRedrawOverlay = triggerRedrawOverlay;
2031
2150
  plot.pointOffset = function(point) {
2032
2151
  return {
2033
- left: parseInt(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left, 10),
2034
- top: parseInt(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top, 10)
2152
+ left: parseInt(String(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left), 10),
2153
+ top: parseInt(String(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top), 10)
2035
2154
  };
2036
2155
  };
2037
2156
  plot.shutdown = shutdown;
@@ -2041,6 +2160,7 @@ var Flot = (function (exports) {
2041
2160
  placeholder.innerHTML = '';
2042
2161
 
2043
2162
  series = [];
2163
+ // @ts-expect-error destroy clears closure references after shutdown.
2044
2164
  options = null;
2045
2165
  surface = null;
2046
2166
  overlay = null;
@@ -2049,7 +2169,9 @@ var Flot = (function (exports) {
2049
2169
  octx = null;
2050
2170
  xaxes = [];
2051
2171
  yaxes = [];
2172
+ // @ts-expect-error destroy clears closure references after shutdown.
2052
2173
  hooks = null;
2174
+ // @ts-expect-error destroy clears closure references after shutdown.
2053
2175
  plot = null;
2054
2176
  };
2055
2177
 
@@ -2278,6 +2400,9 @@ var Flot = (function (exports) {
2278
2400
  return a;
2279
2401
  }
2280
2402
 
2403
+ /**
2404
+ * @returns {InternalAxis[]}
2405
+ */
2281
2406
  function allAxes() {
2282
2407
  // return flat array without annoying null entries
2283
2408
  return xaxes.concat(yaxes).filter(function(a) {
@@ -2356,16 +2481,23 @@ var Flot = (function (exports) {
2356
2481
 
2357
2482
  function getOrCreateAxis(axes, number) {
2358
2483
  if (!axes[number - 1]) {
2359
- axes[number - 1] = {
2484
+ axes[number - 1] = /** @type {InternalAxis} */ (/** @type {unknown} */ ({
2360
2485
  n: number, // save the number for future reference
2361
2486
  direction: axes === xaxes ? "x" : "y",
2362
2487
  options: extend(true, {}, axes === xaxes ? options.xaxis : options.yaxis)
2363
- };
2488
+ }));
2364
2489
  }
2365
2490
 
2366
2491
  return axes[number - 1];
2367
2492
  }
2368
2493
 
2494
+ function firstAxis(axes) {
2495
+ if (!axes[0]) {
2496
+ throw new Error("missing first axis");
2497
+ }
2498
+ return axes[0];
2499
+ }
2500
+
2369
2501
  function fillInSeriesOptions() {
2370
2502
  var neededColors = series.length,
2371
2503
  maxIndex = -1,
@@ -2788,8 +2920,13 @@ var Flot = (function (exports) {
2788
2920
  function measureTickLabels(axis) {
2789
2921
  var opts = axis.options,
2790
2922
  ticks = opts.showTickLabels !== 'none' && axis.ticks ? axis.ticks : [],
2791
- showMajorTickLabels = opts.showTickLabels === 'major' || opts.showTickLabels === 'all',
2792
- showEndpointsTickLabels = opts.showTickLabels === 'endpoints' || opts.showTickLabels === 'all',
2923
+ // Mirror drawAxisLabels: 'major' and 'all' draw every tick;
2924
+ // only 'endpoints' skips middle ticks. Measurement must cover
2925
+ // every label that will be drawn, otherwise labelWidth can be
2926
+ // too small for the widest one — e.g. a top tick of 100 next
2927
+ // to 70/80/90 gets clipped to "00" because the axis box was
2928
+ // sized for 2-char labels. See flot/flot#1729, flot/flot#1788.
2929
+ endpointsOnly = opts.showTickLabels === 'endpoints',
2793
2930
  labelWidth = opts.labelWidth || 0,
2794
2931
  labelHeight = opts.labelHeight || 0,
2795
2932
  legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
@@ -2800,9 +2937,7 @@ var Flot = (function (exports) {
2800
2937
  var t = ticks[i];
2801
2938
  var label = t.label;
2802
2939
 
2803
- if (!t.label ||
2804
- (showMajorTickLabels === false && i > 0 && i < ticks.length - 1) ||
2805
- (showEndpointsTickLabels === false && (i === 0 || i === ticks.length - 1))) {
2940
+ if (!t.label || (endpointsOnly && i > 0 && i < ticks.length - 1)) {
2806
2941
  continue;
2807
2942
  }
2808
2943
 
@@ -3126,9 +3261,11 @@ var Flot = (function (exports) {
3126
3261
  if (delta === 0.0) {
3127
3262
  // degenerate case
3128
3263
  var widen = max === 0 ? 1 : 0.01;
3129
- var wmin = null;
3264
+ var wmin = 0;
3265
+ var wminSet = false;
3130
3266
  if (min == null) {
3131
- wmin -= widen;
3267
+ wmin = -widen;
3268
+ wminSet = true;
3132
3269
  }
3133
3270
 
3134
3271
  // always widen max if we couldn't widen min to ensure we
@@ -3137,7 +3274,7 @@ var Flot = (function (exports) {
3137
3274
  max += widen;
3138
3275
  }
3139
3276
 
3140
- if (wmin != null) {
3277
+ if (wminSet) {
3141
3278
  min = wmin;
3142
3279
  }
3143
3280
  }
@@ -3533,8 +3670,13 @@ var Flot = (function (exports) {
3533
3670
  triggerRedrawOverlay();
3534
3671
  }
3535
3672
 
3673
+ /**
3674
+ * @returns {ExtractedRange}
3675
+ */
3536
3676
  function extractRange(ranges, coord) {
3537
- var axis, from, to, key, axes = allAxes();
3677
+ var axis, from, to, axes = allAxes();
3678
+ var key = "";
3679
+ var keyFound = false;
3538
3680
 
3539
3681
  for (var i = 0; i < axes.length; ++i) {
3540
3682
  axis = axes[i];
@@ -3546,6 +3688,7 @@ var Flot = (function (exports) {
3546
3688
  }
3547
3689
 
3548
3690
  if (ranges[key]) {
3691
+ keyFound = true;
3549
3692
  from = ranges[key].from;
3550
3693
  to = ranges[key].to;
3551
3694
  break;
@@ -3554,8 +3697,8 @@ var Flot = (function (exports) {
3554
3697
  }
3555
3698
 
3556
3699
  // backwards-compat stuff - to be removed in future
3557
- if (!ranges[key]) {
3558
- axis = coord === "x" ? xaxes[0] : yaxes[0];
3700
+ if (!keyFound) {
3701
+ axis = firstAxis(coord === "x" ? xaxes : yaxes);
3559
3702
  from = ranges[coord + "1"];
3560
3703
  to = ranges[coord + "2"];
3561
3704
  }
@@ -3570,7 +3713,7 @@ var Flot = (function (exports) {
3570
3713
  return {
3571
3714
  from: from,
3572
3715
  to: to,
3573
- axis: axis
3716
+ axis: /** @type {InternalAxis} */ (axis)
3574
3717
  };
3575
3718
  }
3576
3719
 
@@ -3820,7 +3963,8 @@ var Flot = (function (exports) {
3820
3963
  // check if the line will be overlapped with a border
3821
3964
  var overlappedWithBorder = function (value) {
3822
3965
  var bw = options.grid.borderWidth;
3823
- return (((typeof bw === "object" && bw[axis.position] > 0) || bw > 0) && (value === axis.min || value === axis.max));
3966
+ var overlapsBorder = typeof bw === "object" ? bw[axis.position] > 0 : bw > 0;
3967
+ return overlapsBorder && (value === axis.min || value === axis.max);
3824
3968
  };
3825
3969
 
3826
3970
  ctx.strokeStyle = options.grid.tickColor;
@@ -3866,6 +4010,10 @@ var Flot = (function (exports) {
3866
4010
  var bw = options.grid.borderWidth,
3867
4011
  bc = options.grid.borderColor;
3868
4012
 
4013
+ if (bc == null) {
4014
+ bc = options.grid.color;
4015
+ }
4016
+
3869
4017
  if (typeof bw === "object" || typeof bc === "object") {
3870
4018
  if (typeof bw !== "object") {
3871
4019
  bw = {
@@ -4243,10 +4391,14 @@ var Flot = (function (exports) {
4243
4391
  smallestDistance = radius * radius + 1;
4244
4392
 
4245
4393
  for (i = series.length - 1; i >= 0; --i) {
4246
- if (!seriesFilter(i)) continue;
4394
+ if (!seriesFilter(i)) {
4395
+ continue;
4396
+ }
4247
4397
 
4248
4398
  var s = series[i];
4249
- if (!s.datapoints) return;
4399
+ if (!s.datapoints) {
4400
+ continue;
4401
+ }
4250
4402
 
4251
4403
  var foundPoint = false;
4252
4404
  if (s.lines.show || s.points.show) {
@@ -4533,7 +4685,7 @@ var Flot = (function (exports) {
4533
4685
  // Plugin registry. Plugins push to this array to register themselves.
4534
4686
  var plugins = [];
4535
4687
 
4536
- var version = "5.1.2";
4688
+ var version = "5.1.4";
4537
4689
 
4538
4690
  // The main plot function.
4539
4691
  function plot(placeholder, data, options) {