@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.
- package/CHANGELOG.md +1814 -0
- package/LICENSE.txt +22 -0
- package/README.md +119 -0
- package/dist/flot.js +9830 -0
- package/dist/flot.min.js +2 -0
- package/dist/flot.min.js.map +1 -0
- package/dist/flot.mjs +9805 -0
- package/dist/jquery.flot.js +9869 -0
- package/dist/jquery.flot.min.js +2 -0
- package/dist/jquery.flot.min.js.map +1 -0
- package/dist/plugins/jquery.flot.crosshair.js +207 -0
- package/dist/plugins/jquery.flot.crosshair.min.js +2 -0
- package/dist/plugins/jquery.flot.crosshair.min.js.map +1 -0
- package/dist/plugins/jquery.flot.image.js +261 -0
- package/dist/plugins/jquery.flot.image.min.js +2 -0
- package/dist/plugins/jquery.flot.image.min.js.map +1 -0
- package/dist/plugins/jquery.flot.pie.js +815 -0
- package/dist/plugins/jquery.flot.pie.min.js +2 -0
- package/dist/plugins/jquery.flot.pie.min.js.map +1 -0
- package/dist/plugins/jquery.flot.resize.js +62 -0
- package/dist/plugins/jquery.flot.resize.min.js +2 -0
- package/dist/plugins/jquery.flot.resize.min.js.map +1 -0
- package/dist/plugins/jquery.flot.threshold.js +148 -0
- package/dist/plugins/jquery.flot.threshold.min.js +2 -0
- package/dist/plugins/jquery.flot.threshold.min.js.map +1 -0
- package/docs/API.md +1767 -0
- package/docs/PLUGINS.md +143 -0
- package/docs/absRelTime.md +42 -0
- package/docs/browser.md +24 -0
- package/docs/canvaswrapper.md +116 -0
- package/docs/composeImages.md +32 -0
- package/docs/drawSeries.md +35 -0
- package/docs/hover.md +21 -0
- package/docs/interactions.md +57 -0
- package/docs/logaxis.md +27 -0
- package/docs/navigate.md +110 -0
- package/package.json +53 -0
- package/source/helpers.js +168 -0
- package/source/index.js +70 -0
- package/source/jquery-adapter.js +83 -0
- package/source/jquery.canvaswrapper.js +546 -0
- package/source/jquery.colorhelpers.js +198 -0
- package/source/jquery.flot.axislabels.js +214 -0
- package/source/jquery.flot.browser.js +53 -0
- package/source/jquery.flot.categories.js +202 -0
- package/source/jquery.flot.composeImages.js +327 -0
- package/source/jquery.flot.crosshair.js +203 -0
- package/source/jquery.flot.drawSeries.js +699 -0
- package/source/jquery.flot.errorbars.js +375 -0
- package/source/jquery.flot.fillbetween.js +254 -0
- package/source/jquery.flot.flatdata.js +47 -0
- package/source/jquery.flot.hover.js +354 -0
- package/source/jquery.flot.image.js +252 -0
- package/source/jquery.flot.js +2814 -0
- package/source/jquery.flot.legend.js +444 -0
- package/source/jquery.flot.logaxis.js +299 -0
- package/source/jquery.flot.navigate.js +842 -0
- package/source/jquery.flot.pie.js +811 -0
- package/source/jquery.flot.resize.js +57 -0
- package/source/jquery.flot.saturated.js +40 -0
- package/source/jquery.flot.selection.js +552 -0
- package/source/jquery.flot.stack.js +220 -0
- package/source/jquery.flot.symbol.js +98 -0
- package/source/jquery.flot.threshold.js +144 -0
- package/source/jquery.flot.time.js +584 -0
- package/source/jquery.flot.touch.js +320 -0
- package/source/jquery.flot.touchNavigate.js +357 -0
- package/source/jquery.flot.uiConstants.js +9 -0
- package/source/jquery.js +9473 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Vanilla replacements for jQuery utility functions used throughout flot.
|
|
2
|
+
|
|
3
|
+
function isPlainObject(value) {
|
|
4
|
+
if (!value || Object.prototype.toString.call(value) !== '[object Object]') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var prototype = Object.getPrototypeOf(value);
|
|
9
|
+
return prototype === Object.prototype || prototype === null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function cloneDeepValue(value) {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
return value.map(cloneDeepValue);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (isPlainObject(value)) {
|
|
18
|
+
var copy = {};
|
|
19
|
+
var keys = Object.keys(value);
|
|
20
|
+
for (var i = 0; i < keys.length; i++) {
|
|
21
|
+
var key = keys[i];
|
|
22
|
+
var nestedValue = value[key];
|
|
23
|
+
if (nestedValue !== undefined) {
|
|
24
|
+
copy[key] = cloneDeepValue(nestedValue);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return copy;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Deep-extend target with one or more source objects. When `deep` is true,
|
|
34
|
+
// nested objects are recursively merged rather than replaced. Arrays are
|
|
35
|
+
// replaced, not concatenated (matching $.extend behavior that flot relies on).
|
|
36
|
+
export function extend(deep, target) {
|
|
37
|
+
var sources = Array.prototype.slice.call(arguments, 2);
|
|
38
|
+
if (typeof deep !== 'boolean') {
|
|
39
|
+
sources.unshift(target);
|
|
40
|
+
target = deep;
|
|
41
|
+
deep = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (var i = 0; i < sources.length; i++) {
|
|
45
|
+
var src = sources[i];
|
|
46
|
+
if (src == null) continue;
|
|
47
|
+
var keys = Object.keys(src);
|
|
48
|
+
for (var k = 0; k < keys.length; k++) {
|
|
49
|
+
var key = keys[k];
|
|
50
|
+
var val = src[key];
|
|
51
|
+
if (val === undefined) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (deep && Array.isArray(val)) {
|
|
55
|
+
target[key] = cloneDeepValue(val);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (deep && isPlainObject(val)) {
|
|
59
|
+
if (typeof target[key] !== 'object' || target[key] == null) {
|
|
60
|
+
target[key] = {};
|
|
61
|
+
}
|
|
62
|
+
extend(true, target[key], val);
|
|
63
|
+
} else {
|
|
64
|
+
target[key] = val;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return target;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Get inner width of an element (content area, no padding/border/scrollbar).
|
|
73
|
+
export function width(el) {
|
|
74
|
+
return el.clientWidth;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Get inner height of an element.
|
|
78
|
+
export function height(el) {
|
|
79
|
+
return el.clientHeight;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Get or set a CSS property on an element.
|
|
83
|
+
export function css(el, prop, val) {
|
|
84
|
+
if (val !== undefined) {
|
|
85
|
+
el.style[prop] = typeof val === 'number' ? val + 'px' : val;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
return getComputedStyle(el)[prop];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Store or retrieve arbitrary data on an element.
|
|
92
|
+
var dataStore = new WeakMap();
|
|
93
|
+
|
|
94
|
+
export function data(el, key, val) {
|
|
95
|
+
var store = dataStore.get(el);
|
|
96
|
+
if (!store) {
|
|
97
|
+
store = {};
|
|
98
|
+
dataStore.set(el, store);
|
|
99
|
+
}
|
|
100
|
+
if (val !== undefined) {
|
|
101
|
+
store[key] = val;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
return store[key];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function removeData(el, key) {
|
|
108
|
+
var store = dataStore.get(el);
|
|
109
|
+
if (store) {
|
|
110
|
+
if (key) {
|
|
111
|
+
delete store[key];
|
|
112
|
+
} else {
|
|
113
|
+
dataStore.delete(el);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Trigger a custom event on an element. Extra args are passed as the
|
|
119
|
+
// event's `detail` property (an array). For jQuery adapter compatibility,
|
|
120
|
+
// the adapter re-dispatches these as jQuery events so $(el).on() works.
|
|
121
|
+
export function trigger(el, type, args) {
|
|
122
|
+
var event = new CustomEvent(type, {
|
|
123
|
+
detail: args || [],
|
|
124
|
+
bubbles: true,
|
|
125
|
+
cancelable: true
|
|
126
|
+
});
|
|
127
|
+
el.dispatchEvent(event);
|
|
128
|
+
return event;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Bind an event listener, tracking it so unbindAll can remove it later.
|
|
132
|
+
var listenerStore = new WeakMap();
|
|
133
|
+
|
|
134
|
+
export function bind(el, type, handler) {
|
|
135
|
+
el.addEventListener(type, handler);
|
|
136
|
+
var listeners = listenerStore.get(el);
|
|
137
|
+
if (!listeners) {
|
|
138
|
+
listeners = [];
|
|
139
|
+
listenerStore.set(el, listeners);
|
|
140
|
+
}
|
|
141
|
+
listeners.push({ type: type, handler: handler });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function unbind(el, type, handler) {
|
|
145
|
+
if (type && handler) {
|
|
146
|
+
el.removeEventListener(type, handler);
|
|
147
|
+
var listeners = listenerStore.get(el);
|
|
148
|
+
if (listeners) {
|
|
149
|
+
listenerStore.set(el, listeners.filter(function(l) {
|
|
150
|
+
return l.type !== type || l.handler !== handler;
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// Remove all listeners (optionally filtered by type)
|
|
156
|
+
var listeners = listenerStore.get(el);
|
|
157
|
+
if (listeners) {
|
|
158
|
+
var remaining = [];
|
|
159
|
+
for (var i = 0; i < listeners.length; i++) {
|
|
160
|
+
if (type && listeners[i].type !== type) {
|
|
161
|
+
remaining.push(listeners[i]);
|
|
162
|
+
} else {
|
|
163
|
+
el.removeEventListener(listeners[i].type, listeners[i].handler);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
listenerStore.set(el, remaining);
|
|
167
|
+
}
|
|
168
|
+
}
|
package/source/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Main entry point for @kevinburke/flot.
|
|
2
|
+
//
|
|
3
|
+
// This module has NO jQuery dependency. It exports the core plot
|
|
4
|
+
// function and all bundled plugins. Use it directly:
|
|
5
|
+
//
|
|
6
|
+
// import { plot } from '@kevinburke/flot';
|
|
7
|
+
// plot(document.getElementById('ph'), data, options);
|
|
8
|
+
//
|
|
9
|
+
// For jQuery backwards compatibility ($.plot), import the adapter:
|
|
10
|
+
//
|
|
11
|
+
// import '@kevinburke/flot/jquery';
|
|
12
|
+
|
|
13
|
+
// Core modules
|
|
14
|
+
import { Canvas } from './jquery.canvaswrapper.js';
|
|
15
|
+
import { color } from './jquery.colorhelpers.js';
|
|
16
|
+
import { saturated } from './jquery.flot.saturated.js';
|
|
17
|
+
import { browser } from './jquery.flot.browser.js';
|
|
18
|
+
import { uiConstants } from './jquery.flot.uiConstants.js';
|
|
19
|
+
import { drawSeries as drawSeriesModule } from './jquery.flot.drawSeries.js';
|
|
20
|
+
|
|
21
|
+
// Core plot function and plugin registry
|
|
22
|
+
import {
|
|
23
|
+
plot,
|
|
24
|
+
plugins,
|
|
25
|
+
version,
|
|
26
|
+
linearTickGenerator,
|
|
27
|
+
defaultTickFormatter,
|
|
28
|
+
expRepTickFormatter,
|
|
29
|
+
} from './jquery.flot.js';
|
|
30
|
+
|
|
31
|
+
// Bundled plugins (side-effect imports — each pushes to `plugins`)
|
|
32
|
+
import './jquery.flot.errorbars.js';
|
|
33
|
+
import { logTicksGenerator, logTickFormatter } from './jquery.flot.logaxis.js';
|
|
34
|
+
import './jquery.flot.symbol.js';
|
|
35
|
+
import './jquery.flot.flatdata.js';
|
|
36
|
+
import './jquery.flot.navigate.js';
|
|
37
|
+
import './jquery.flot.fillbetween.js';
|
|
38
|
+
import './jquery.flot.categories.js';
|
|
39
|
+
import './jquery.flot.stack.js';
|
|
40
|
+
import './jquery.flot.touchNavigate.js';
|
|
41
|
+
import './jquery.flot.hover.js';
|
|
42
|
+
import './jquery.flot.touch.js';
|
|
43
|
+
import { formatDate, makeUtcWrapper, dateGenerator, dateTickGenerator } from './jquery.flot.time.js';
|
|
44
|
+
import './jquery.flot.axislabels.js';
|
|
45
|
+
import './jquery.flot.selection.js';
|
|
46
|
+
import { composeImages } from './jquery.flot.composeImages.js';
|
|
47
|
+
import './jquery.flot.legend.js';
|
|
48
|
+
|
|
49
|
+
// Named exports.
|
|
50
|
+
export {
|
|
51
|
+
Canvas,
|
|
52
|
+
color,
|
|
53
|
+
saturated,
|
|
54
|
+
browser,
|
|
55
|
+
uiConstants,
|
|
56
|
+
drawSeriesModule as drawSeries,
|
|
57
|
+
plot,
|
|
58
|
+
plugins,
|
|
59
|
+
version,
|
|
60
|
+
linearTickGenerator,
|
|
61
|
+
defaultTickFormatter,
|
|
62
|
+
expRepTickFormatter,
|
|
63
|
+
logTicksGenerator,
|
|
64
|
+
logTickFormatter,
|
|
65
|
+
formatDate,
|
|
66
|
+
makeUtcWrapper,
|
|
67
|
+
dateGenerator,
|
|
68
|
+
dateTickGenerator,
|
|
69
|
+
composeImages,
|
|
70
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// jQuery adapter for @kevinburke/flot.
|
|
2
|
+
//
|
|
3
|
+
// Loads the core (jQuery-free) and wires everything onto the jQuery
|
|
4
|
+
// namespace so existing $.plot() code works unchanged.
|
|
5
|
+
//
|
|
6
|
+
// Usage:
|
|
7
|
+
// <script src="jquery.js"></script>
|
|
8
|
+
// <script src="dist/jquery.flot.js"></script>
|
|
9
|
+
// <script>$.plot("#placeholder", data, options);</script>
|
|
10
|
+
//
|
|
11
|
+
// Or as ESM:
|
|
12
|
+
// import '@kevinburke/flot/jquery';
|
|
13
|
+
// $.plot("#placeholder", data, options);
|
|
14
|
+
|
|
15
|
+
import $ from 'jquery';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
Canvas,
|
|
19
|
+
color,
|
|
20
|
+
saturated,
|
|
21
|
+
browser,
|
|
22
|
+
uiConstants,
|
|
23
|
+
drawSeries,
|
|
24
|
+
plot,
|
|
25
|
+
plugins,
|
|
26
|
+
version,
|
|
27
|
+
linearTickGenerator,
|
|
28
|
+
defaultTickFormatter,
|
|
29
|
+
expRepTickFormatter,
|
|
30
|
+
logTicksGenerator,
|
|
31
|
+
logTickFormatter,
|
|
32
|
+
formatDate,
|
|
33
|
+
makeUtcWrapper,
|
|
34
|
+
dateGenerator,
|
|
35
|
+
dateTickGenerator,
|
|
36
|
+
composeImages,
|
|
37
|
+
} from './index.js';
|
|
38
|
+
|
|
39
|
+
// Register $.plot and $.color on the jQuery object.
|
|
40
|
+
$.plot = function(placeholder, data, options) {
|
|
41
|
+
var el = typeof placeholder === 'string'
|
|
42
|
+
? document.querySelector(placeholder)
|
|
43
|
+
: (placeholder instanceof $ ? placeholder[0] : placeholder);
|
|
44
|
+
return plot(el, data, options);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
$.plot.plugins = plugins;
|
|
48
|
+
$.plot.version = version;
|
|
49
|
+
$.plot.saturated = saturated;
|
|
50
|
+
$.plot.browser = browser;
|
|
51
|
+
$.plot.uiConstants = uiConstants;
|
|
52
|
+
$.plot.drawSeries = drawSeries;
|
|
53
|
+
$.plot.linearTickGenerator = linearTickGenerator;
|
|
54
|
+
$.plot.defaultTickFormatter = defaultTickFormatter;
|
|
55
|
+
$.plot.expRepTickFormatter = expRepTickFormatter;
|
|
56
|
+
$.plot.logTicksGenerator = logTicksGenerator;
|
|
57
|
+
$.plot.logTickFormatter = logTickFormatter;
|
|
58
|
+
$.plot.formatDate = formatDate;
|
|
59
|
+
$.plot.makeUtcWrapper = makeUtcWrapper;
|
|
60
|
+
$.plot.dateGenerator = dateGenerator;
|
|
61
|
+
$.plot.dateTickGenerator = dateTickGenerator;
|
|
62
|
+
$.plot.composeImages = composeImages;
|
|
63
|
+
// Wrap color.extract to accept jQuery-wrapped elements.
|
|
64
|
+
var origExtract = color.extract;
|
|
65
|
+
$.color = Object.create(color);
|
|
66
|
+
$.color.extract = function(elem, cssProp) {
|
|
67
|
+
if (elem instanceof $ && elem.length) elem = elem[0];
|
|
68
|
+
return origExtract(elem, cssProp);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Chainable jQuery plugin: $(el).plot(data, options)
|
|
72
|
+
$.fn.plot = function(data, options) {
|
|
73
|
+
return this.each(function() {
|
|
74
|
+
plot(this, data, options);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
if (typeof window !== 'undefined') {
|
|
79
|
+
if (!window.Flot) {
|
|
80
|
+
window.Flot = {};
|
|
81
|
+
}
|
|
82
|
+
window.Flot.Canvas = Canvas;
|
|
83
|
+
}
|