@kevinburke/flot 5.0.0 → 5.1.1
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 +129 -0
- package/README.md +2 -2
- package/dist/flot.js +100 -21
- package/dist/flot.min.js +1 -1
- package/dist/flot.min.js.map +1 -1
- package/dist/flot.mjs +100 -21
- package/dist/jquery.flot.js +100 -21
- 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 +9 -1
- package/dist/plugins/jquery.flot.pie.min.js +1 -1
- package/dist/plugins/jquery.flot.pie.min.js.map +1 -1
- package/dist/plugins/jquery.flot.resize.js +1 -1
- package/dist/plugins/jquery.flot.threshold.js +2 -2
- package/dist/plugins/jquery.flot.threshold.min.js +1 -1
- package/dist/plugins/jquery.flot.threshold.min.js.map +1 -1
- package/package.json +19 -6
- package/source/globals.d.ts +22 -0
- package/source/jquery.canvaswrapper.js +15 -9
- package/source/jquery.flot.browser.js +4 -2
- package/source/jquery.flot.composeImages.js +1 -1
- package/source/jquery.flot.js +27 -7
- package/source/jquery.flot.legend.js +36 -3
- package/source/jquery.flot.navigate.js +18 -0
- package/source/jquery.flot.pie.js +9 -1
- package/source/jquery.flot.threshold.js +1 -1
- package/types/index.d.ts +580 -0
- package/types/jquery.d.ts +37 -0
- package/types/test.ts +72 -0
- package/types/tsconfig.json +15 -0
package/source/jquery.flot.js
CHANGED
|
@@ -362,7 +362,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
362
362
|
// initialize
|
|
363
363
|
var MINOR_TICKS_COUNT_CONSTANT = uiConstants.MINOR_TICKS_COUNT_CONSTANT;
|
|
364
364
|
var TICK_LENGTH_CONSTANT = uiConstants.TICK_LENGTH_CONSTANT;
|
|
365
|
-
initPlugins(
|
|
365
|
+
initPlugins();
|
|
366
366
|
setupCanvases();
|
|
367
367
|
parseOptions(options_);
|
|
368
368
|
setData(data_);
|
|
@@ -1660,8 +1660,11 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1660
1660
|
};
|
|
1661
1661
|
|
|
1662
1662
|
// we might need an extra decimal since forced
|
|
1663
|
-
// ticks don't necessarily fit naturally
|
|
1664
|
-
|
|
1663
|
+
// ticks don't necessarily fit naturally.
|
|
1664
|
+
// Guard against axis.delta <= 0 (min == max): Math.log(0)
|
|
1665
|
+
// is -Infinity, so extraDec would be +Infinity and
|
|
1666
|
+
// toFixed(Infinity) throws. Upstream #1869 / PR #1870.
|
|
1667
|
+
if (!axis.mode && opts.tickDecimals == null && axis.delta > 0) {
|
|
1665
1668
|
var extraDec = Math.max(0, -Math.floor(Math.log(axis.delta) / Math.LN10) + 1),
|
|
1666
1669
|
ts = axis.tickGenerator(axis, plot);
|
|
1667
1670
|
|
|
@@ -1879,6 +1882,8 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
1879
1882
|
markings = markings(axes);
|
|
1880
1883
|
}
|
|
1881
1884
|
|
|
1885
|
+
if (!markings) return;
|
|
1886
|
+
|
|
1882
1887
|
var i;
|
|
1883
1888
|
for (i = 0; i < markings.length; ++i) {
|
|
1884
1889
|
var m = markings[i],
|
|
@@ -2231,7 +2236,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2231
2236
|
}
|
|
2232
2237
|
|
|
2233
2238
|
if (axis.gridLines === true) {
|
|
2234
|
-
drawGridLines(axis
|
|
2239
|
+
drawGridLines(axis);
|
|
2235
2240
|
}
|
|
2236
2241
|
}
|
|
2237
2242
|
|
|
@@ -2574,7 +2579,13 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2574
2579
|
maxy = maxDistance / series.yaxis.scale,
|
|
2575
2580
|
points = series.datapoints.points,
|
|
2576
2581
|
ps = series.datapoints.pointsize,
|
|
2577
|
-
|
|
2582
|
+
// Seed with maxDistance (or its square, matching the
|
|
2583
|
+
// default squared-distance metric) so points outside
|
|
2584
|
+
// the hover radius are never selected. Without this,
|
|
2585
|
+
// the maxx/maxy coordinate-space pre-filter is the
|
|
2586
|
+
// only radius check, and it's disabled for axes with
|
|
2587
|
+
// inverseTransform — see upstream flot/flot#1871.
|
|
2588
|
+
smallestDistance = computeDistance ? maxDistance : maxDistance * maxDistance;
|
|
2578
2589
|
|
|
2579
2590
|
// with inverse transforms, we can't use the maxx/maxy
|
|
2580
2591
|
// optimization, sadly
|
|
@@ -2774,7 +2785,16 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2774
2785
|
} else {
|
|
2775
2786
|
// assume this is a gradient spec; IE currently only
|
|
2776
2787
|
// supports a simple vertical gradient properly, so that's
|
|
2777
|
-
// what we support too
|
|
2788
|
+
// what we support too.
|
|
2789
|
+
// createLinearGradient throws if any coordinate is NaN or
|
|
2790
|
+
// ±Infinity (e.g. when the plot container has zero size
|
|
2791
|
+
// or the user supplies bogus bounds) — fall back to the
|
|
2792
|
+
// default solid color instead. Global isFinite coerces
|
|
2793
|
+
// null → 0 (finite), matching the drawSeriesPoints path
|
|
2794
|
+
// that passes (null, null). Upstream flot/flot#1867.
|
|
2795
|
+
if (!isFinite(top) || !isFinite(bottom)) {
|
|
2796
|
+
return defaultColor;
|
|
2797
|
+
}
|
|
2778
2798
|
var gradient = ctx.createLinearGradient(0, top, 0, bottom);
|
|
2779
2799
|
|
|
2780
2800
|
for (var i = 0, l = spec.colors.length; i < l; ++i) {
|
|
@@ -2802,7 +2822,7 @@ import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
|
2802
2822
|
// Plugin registry. Plugins push to this array to register themselves.
|
|
2803
2823
|
export var plugins = [];
|
|
2804
2824
|
|
|
2805
|
-
export var version = "5.
|
|
2825
|
+
export var version = "5.1.1";
|
|
2806
2826
|
|
|
2807
2827
|
// The main plot function.
|
|
2808
2828
|
export function plot(placeholder, data, options) {
|
|
@@ -119,6 +119,17 @@ import { plugins } from './jquery.flot.js';
|
|
|
119
119
|
shape.strokeWidth = entry.options.points.lineWidth;
|
|
120
120
|
iconHtml += getEntryIconHtml(shape);
|
|
121
121
|
}
|
|
122
|
+
// fallback for plugin-drawn series (pie, errorbars, etc.)
|
|
123
|
+
// that don't turn on any of lines/bars/points — without
|
|
124
|
+
// this the legend entry has a label but no icon. Upstream
|
|
125
|
+
// flot/flot#1641, minus the switch to `else if` so series
|
|
126
|
+
// that deliberately overlay (e.g. lines + points) keep
|
|
127
|
+
// rendering both icons.
|
|
128
|
+
if (iconHtml === '') {
|
|
129
|
+
shape.name = 'box';
|
|
130
|
+
shape.fillColor = entry.color;
|
|
131
|
+
iconHtml += getEntryIconHtml(shape);
|
|
132
|
+
}
|
|
122
133
|
|
|
123
134
|
labelHtml = '<text x="' + shape.xPos + '" y="' + shape.yPos + '" text-anchor="start"><tspan dx="2em" dy="1.2em">' + shape.label + '</tspan></text>'
|
|
124
135
|
html[j++] = '<g>' + iconHtml + labelHtml + '</g>';
|
|
@@ -158,9 +169,17 @@ import { plugins } from './jquery.flot.js';
|
|
|
158
169
|
legendEl.style.pointerEvents = 'none';
|
|
159
170
|
placeholder.appendChild(legendEl);
|
|
160
171
|
} else {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
// Accept either a DOM Element or a jQuery-wrapped container.
|
|
173
|
+
// Upstream flot/flot#1750 switched to `$(container).get(0)` to
|
|
174
|
+
// always land on the underlying element; since this fork is
|
|
175
|
+
// jQuery-optional, do the unwrap inline.
|
|
176
|
+
var container = options.legend.container;
|
|
177
|
+
if (container && typeof container.get === 'function' && container[0]) {
|
|
178
|
+
container = container[0];
|
|
179
|
+
}
|
|
180
|
+
container.innerHTML = html.join('');
|
|
181
|
+
container.style.width = width + 'px';
|
|
182
|
+
container.style.height = height + 'em';
|
|
164
183
|
}
|
|
165
184
|
}
|
|
166
185
|
|
|
@@ -254,6 +273,14 @@ import { plugins } from './jquery.flot.js';
|
|
|
254
273
|
'width="1.5em" height="1.5em"' +
|
|
255
274
|
'/>';
|
|
256
275
|
break;
|
|
276
|
+
case 'box':
|
|
277
|
+
html = '<use xlink:href="#box" class="legendIcon" ' +
|
|
278
|
+
'x="' + x + '" ' +
|
|
279
|
+
'y="' + y + '" ' +
|
|
280
|
+
'fill="' + fill + '" ' +
|
|
281
|
+
'width="1.5em" height="1.5em"' +
|
|
282
|
+
'/>';
|
|
283
|
+
break;
|
|
257
284
|
default:
|
|
258
285
|
// default is circle
|
|
259
286
|
html = '<use xlink:href="#circle" class="legendIcon" ' +
|
|
@@ -276,6 +303,12 @@ import { plugins } from './jquery.flot.js';
|
|
|
276
303
|
'<polyline points="0,15 5,5 10,10 15,0"/>' +
|
|
277
304
|
'</symbol>' +
|
|
278
305
|
|
|
306
|
+
// Fallback icon for plugin-drawn series that don't turn on
|
|
307
|
+
// any of lines / bars / points. Upstream flot/flot#1641.
|
|
308
|
+
'<symbol id="box" stroke-width="1" viewBox="-5 -5 25 25">' +
|
|
309
|
+
'<rect x="0" y="0" width="15" height="15"/>' +
|
|
310
|
+
'</symbol>' +
|
|
311
|
+
|
|
279
312
|
'<symbol id="area" stroke-width="1" viewBox="-5 -5 25 25">' +
|
|
280
313
|
'<polyline points="0,15 5,5 10,10 15,0, 15,15, 0,15"/>' +
|
|
281
314
|
'</symbol>' +
|
|
@@ -555,6 +555,17 @@ import { bind, unbind, trigger, css } from './helpers.js';
|
|
|
555
555
|
var minD = axis.p2c(opts.panRange[0]) - axis.p2c(axis.min);
|
|
556
556
|
// calc max delta (revealing right edge of plot)
|
|
557
557
|
var maxD = axis.p2c(opts.panRange[1]) - axis.p2c(axis.max);
|
|
558
|
+
// For the y-axis, screen coordinates are inverted
|
|
559
|
+
// (p2c(smaller v) > p2c(larger v)), so minD/maxD end up
|
|
560
|
+
// with the opposite signs from the x-axis case. Swap
|
|
561
|
+
// them so the clamp comparisons below keep their
|
|
562
|
+
// x-axis semantics. Upstream flot/flot#1789, ports the
|
|
563
|
+
// minimal form of PR #1793.
|
|
564
|
+
if (axis.direction === 'y') {
|
|
565
|
+
var swap = minD;
|
|
566
|
+
minD = maxD;
|
|
567
|
+
maxD = swap;
|
|
568
|
+
}
|
|
558
569
|
// limit delta to min or max if enabled
|
|
559
570
|
if (opts.panRange[0] !== undefined && d >= maxD) d = maxD;
|
|
560
571
|
if (opts.panRange[1] !== undefined && d <= minD) d = minD;
|
|
@@ -719,6 +730,13 @@ import { bind, unbind, trigger, css } from './helpers.js';
|
|
|
719
730
|
var minD = p + axis.p2c(opts.panRange[0]) - axis.p2c(axisMin);
|
|
720
731
|
// calc max delta (revealing right edge of plot)
|
|
721
732
|
var maxD = p + axis.p2c(opts.panRange[1]) - axis.p2c(axisMax);
|
|
733
|
+
// Same y-axis swap as plot.pan — see comment there.
|
|
734
|
+
// Upstream flot/flot#1789 / PR #1793.
|
|
735
|
+
if (axis.direction === 'y') {
|
|
736
|
+
var swap = minD;
|
|
737
|
+
minD = maxD;
|
|
738
|
+
maxD = swap;
|
|
739
|
+
}
|
|
722
740
|
// limit delta to min or max if enabled
|
|
723
741
|
if (opts.panRange[0] !== undefined && d >= maxD) d = maxD;
|
|
724
742
|
if (opts.panRange[1] !== undefined && d <= minD) d = minD;
|
|
@@ -141,7 +141,7 @@ import { extend, bind, unbind, trigger, width, height } from './helpers.js';
|
|
|
141
141
|
plot.hooks.processDatapoints.push(function(plot, series, data, datapoints) {
|
|
142
142
|
var options = plot.getOptions();
|
|
143
143
|
if (options.series.pie.show) {
|
|
144
|
-
processDatapoints(plot, series,
|
|
144
|
+
processDatapoints(plot, series, datapoints);
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
|
|
@@ -539,6 +539,11 @@ import { extend, bind, unbind, trigger, width, height } from './helpers.js';
|
|
|
539
539
|
// Placed here because it needs to be accessed from multiple locations
|
|
540
540
|
|
|
541
541
|
function drawDonutHole(layer) {
|
|
542
|
+
// The closure-scoped `options` is set by the processDatapoints
|
|
543
|
+
// hook on first draw, but drawDonutHole can be reached from
|
|
544
|
+
// paths that fire before that hook, leaving `options` null.
|
|
545
|
+
// Read it eagerly. Upstream flot/flot#1559.
|
|
546
|
+
var options = plot.getOptions();
|
|
542
547
|
if (options.series.pie.innerRadius > 0) {
|
|
543
548
|
// subtract the center
|
|
544
549
|
layer.save();
|
|
@@ -651,6 +656,9 @@ import { extend, bind, unbind, trigger, width, height } from './helpers.js';
|
|
|
651
656
|
// trigger click or hover event (they send the same parameters so we share their code)
|
|
652
657
|
|
|
653
658
|
function triggerClickHoverEvent(eventname, e) {
|
|
659
|
+
// See drawDonutHole above: read `options` fresh in case the
|
|
660
|
+
// event fires before processDatapoints has run.
|
|
661
|
+
var options = plot.getOptions();
|
|
654
662
|
var offset = plot.offset();
|
|
655
663
|
var canvasX = parseInt(e.pageX - offset.left);
|
|
656
664
|
var canvasY = parseInt(e.pageY - offset.top);
|
|
@@ -76,7 +76,7 @@ import { extend } from './helpers.js';
|
|
|
76
76
|
if (y < below) p = threspoints;
|
|
77
77
|
else p = newpoints;
|
|
78
78
|
|
|
79
|
-
if (addCrossingPoints && prevp !== p &&
|
|
79
|
+
if (addCrossingPoints && prevp !== undefined && prevp !== p &&
|
|
80
80
|
x !== null && i > 0 &&
|
|
81
81
|
origpoints[i - ps] != null) {
|
|
82
82
|
var interx = x + (below - y) * (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]);
|