@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,207 @@
|
|
|
1
|
+
/*! @kevinburke/flot v5.0.0 | MIT License | https://github.com/kevinburke/flot */
|
|
2
|
+
(function (jquery_flot_js, helpers_js) {
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
/* Flot plugin for showing crosshairs when the mouse hovers over the plot.
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
8
|
+
Licensed under the MIT license.
|
|
9
|
+
|
|
10
|
+
The plugin supports these options:
|
|
11
|
+
|
|
12
|
+
crosshair: {
|
|
13
|
+
mode: null or "x" or "y" or "xy"
|
|
14
|
+
color: color
|
|
15
|
+
lineWidth: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Set the mode to one of "x", "y" or "xy". The "x" mode enables a vertical
|
|
19
|
+
crosshair that lets you trace the values on the x axis, "y" enables a
|
|
20
|
+
horizontal crosshair and "xy" enables them both. "color" is the color of the
|
|
21
|
+
crosshair (default is "rgba(170, 0, 0, 0.80)"), "lineWidth" is the width of
|
|
22
|
+
the drawn lines (default is 1).
|
|
23
|
+
|
|
24
|
+
The plugin also adds four public methods:
|
|
25
|
+
|
|
26
|
+
- setCrosshair( pos )
|
|
27
|
+
|
|
28
|
+
Set the position of the crosshair. Note that this is cleared if the user
|
|
29
|
+
moves the mouse. "pos" is in coordinates of the plot and should be on the
|
|
30
|
+
form { x: xpos, y: ypos } (you can use x2/x3/... if you're using multiple
|
|
31
|
+
axes), which is coincidentally the same format as what you get from a
|
|
32
|
+
"plothover" event. If "pos" is null, the crosshair is cleared.
|
|
33
|
+
|
|
34
|
+
- clearCrosshair()
|
|
35
|
+
|
|
36
|
+
Clear the crosshair.
|
|
37
|
+
|
|
38
|
+
- lockCrosshair(pos)
|
|
39
|
+
|
|
40
|
+
Cause the crosshair to lock to the current location, no longer updating if
|
|
41
|
+
the user moves the mouse. Optionally supply a position (passed on to
|
|
42
|
+
setCrosshair()) to move it to.
|
|
43
|
+
|
|
44
|
+
Example usage:
|
|
45
|
+
|
|
46
|
+
var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
|
|
47
|
+
$("#graph").bind( "plothover", function ( evt, position, item ) {
|
|
48
|
+
if ( item ) {
|
|
49
|
+
// Lock the crosshair to the data point being hovered
|
|
50
|
+
myFlot.lockCrosshair({
|
|
51
|
+
x: item.datapoint[ 0 ],
|
|
52
|
+
y: item.datapoint[ 1 ]
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
// Return normal crosshair operation
|
|
56
|
+
myFlot.unlockCrosshair();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
- unlockCrosshair()
|
|
61
|
+
|
|
62
|
+
Free the crosshair to move again after locking it.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
var options = {
|
|
67
|
+
crosshair: {
|
|
68
|
+
mode: null, // one of null, "x", "y" or "xy",
|
|
69
|
+
color: "rgba(170, 0, 0, 0.80)",
|
|
70
|
+
lineWidth: 1
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function init(plot) {
|
|
75
|
+
// position of crosshair in pixels
|
|
76
|
+
var crosshair = {x: -1, y: -1, locked: false, highlighted: false};
|
|
77
|
+
|
|
78
|
+
plot.setCrosshair = function setCrosshair(pos) {
|
|
79
|
+
if (!pos) {
|
|
80
|
+
crosshair.x = -1;
|
|
81
|
+
} else {
|
|
82
|
+
var o = plot.p2c(pos);
|
|
83
|
+
crosshair.x = Math.max(0, Math.min(o.left, plot.width()));
|
|
84
|
+
crosshair.y = Math.max(0, Math.min(o.top, plot.height()));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
plot.triggerRedrawOverlay();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
plot.clearCrosshair = plot.setCrosshair; // passes null for pos
|
|
91
|
+
|
|
92
|
+
plot.lockCrosshair = function lockCrosshair(pos) {
|
|
93
|
+
if (pos) {
|
|
94
|
+
plot.setCrosshair(pos);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
crosshair.locked = true;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
plot.unlockCrosshair = function unlockCrosshair() {
|
|
101
|
+
crosshair.locked = false;
|
|
102
|
+
crosshair.rect = null;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
function onMouseOut(e) {
|
|
106
|
+
if (crosshair.locked) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (crosshair.x !== -1) {
|
|
111
|
+
crosshair.x = -1;
|
|
112
|
+
plot.triggerRedrawOverlay();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function onMouseMove(e) {
|
|
117
|
+
var offset = plot.offset();
|
|
118
|
+
if (crosshair.locked) {
|
|
119
|
+
var mouseX = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
|
|
120
|
+
var mouseY = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
|
|
121
|
+
|
|
122
|
+
if ((mouseX > crosshair.x - 4) && (mouseX < crosshair.x + 4) && (mouseY > crosshair.y - 4) && (mouseY < crosshair.y + 4)) {
|
|
123
|
+
if (!crosshair.highlighted) {
|
|
124
|
+
crosshair.highlighted = true;
|
|
125
|
+
plot.triggerRedrawOverlay();
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
if (crosshair.highlighted) {
|
|
129
|
+
crosshair.highlighted = false;
|
|
130
|
+
plot.triggerRedrawOverlay();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (plot.getSelection && plot.getSelection()) {
|
|
137
|
+
crosshair.x = -1; // hide the crosshair while selecting
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
|
|
142
|
+
crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
|
|
143
|
+
plot.triggerRedrawOverlay();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
plot.hooks.bindEvents.push(function (plot, eventHolder) {
|
|
147
|
+
if (!plot.getOptions().crosshair.mode) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
helpers_js.bind(eventHolder, "mouseout", onMouseOut);
|
|
152
|
+
helpers_js.bind(eventHolder, "mousemove", onMouseMove);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
|
156
|
+
var c = plot.getOptions().crosshair;
|
|
157
|
+
if (!c.mode) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var plotOffset = plot.getPlotOffset();
|
|
162
|
+
|
|
163
|
+
ctx.save();
|
|
164
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
|
165
|
+
|
|
166
|
+
if (crosshair.x !== -1) {
|
|
167
|
+
var adj = plot.getOptions().crosshair.lineWidth % 2 ? 0.5 : 0;
|
|
168
|
+
|
|
169
|
+
ctx.strokeStyle = c.color;
|
|
170
|
+
ctx.lineWidth = c.lineWidth;
|
|
171
|
+
ctx.lineJoin = "round";
|
|
172
|
+
|
|
173
|
+
ctx.beginPath();
|
|
174
|
+
if (c.mode.indexOf("x") !== -1) {
|
|
175
|
+
var drawX = Math.floor(crosshair.x) + adj;
|
|
176
|
+
ctx.moveTo(drawX, 0);
|
|
177
|
+
ctx.lineTo(drawX, plot.height());
|
|
178
|
+
}
|
|
179
|
+
if (c.mode.indexOf("y") !== -1) {
|
|
180
|
+
var drawY = Math.floor(crosshair.y) + adj;
|
|
181
|
+
ctx.moveTo(0, drawY);
|
|
182
|
+
ctx.lineTo(plot.width(), drawY);
|
|
183
|
+
}
|
|
184
|
+
if (crosshair.locked) {
|
|
185
|
+
if (crosshair.highlighted) ctx.fillStyle = 'orange';
|
|
186
|
+
else ctx.fillStyle = c.color;
|
|
187
|
+
ctx.fillRect(Math.floor(crosshair.x) + adj - 4, Math.floor(crosshair.y) + adj - 4, 8, 8);
|
|
188
|
+
}
|
|
189
|
+
ctx.stroke();
|
|
190
|
+
}
|
|
191
|
+
ctx.restore();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
|
195
|
+
helpers_js.unbind(eventHolder, "mouseout", onMouseOut);
|
|
196
|
+
helpers_js.unbind(eventHolder, "mousemove", onMouseMove);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
jquery_flot_js.plugins.push({
|
|
201
|
+
init: init,
|
|
202
|
+
options: options,
|
|
203
|
+
name: 'crosshair',
|
|
204
|
+
version: '1.0'
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
})(jquery_flot_js, helpers_js);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"use strict";e.plugins.push({init:function(e){var i={x:-1,y:-1,locked:!1,highlighted:!1};function o(t){i.locked||-1!==i.x&&(i.x=-1,e.triggerRedrawOverlay())}function r(t){var o=e.offset();if(i.locked){var r=Math.max(0,Math.min(t.pageX-o.left,e.width())),h=Math.max(0,Math.min(t.pageY-o.top,e.height()));r>i.x-4&&r<i.x+4&&h>i.y-4&&h<i.y+4?i.highlighted||(i.highlighted=!0,e.triggerRedrawOverlay()):i.highlighted&&(i.highlighted=!1,e.triggerRedrawOverlay())}else e.getSelection&&e.getSelection()?i.x=-1:(i.x=Math.max(0,Math.min(t.pageX-o.left,e.width())),i.y=Math.max(0,Math.min(t.pageY-o.top,e.height())),e.triggerRedrawOverlay())}e.setCrosshair=function(t){if(t){var o=e.p2c(t);i.x=Math.max(0,Math.min(o.left,e.width())),i.y=Math.max(0,Math.min(o.top,e.height()))}else i.x=-1;e.triggerRedrawOverlay()},e.clearCrosshair=e.setCrosshair,e.lockCrosshair=function(t){t&&e.setCrosshair(t),i.locked=!0},e.unlockCrosshair=function(){i.locked=!1,i.rect=null},e.hooks.bindEvents.push(function(e,i){e.getOptions().crosshair.mode&&(t.bind(i,"mouseout",o),t.bind(i,"mousemove",r))}),e.hooks.drawOverlay.push(function(e,t){var o=e.getOptions().crosshair;if(o.mode){var r=e.getPlotOffset();if(t.save(),t.translate(r.left,r.top),-1!==i.x){var h=e.getOptions().crosshair.lineWidth%2?.5:0;if(t.strokeStyle=o.color,t.lineWidth=o.lineWidth,t.lineJoin="round",t.beginPath(),-1!==o.mode.indexOf("x")){var a=Math.floor(i.x)+h;t.moveTo(a,0),t.lineTo(a,e.height())}if(-1!==o.mode.indexOf("y")){var n=Math.floor(i.y)+h;t.moveTo(0,n),t.lineTo(e.width(),n)}i.locked&&(i.highlighted?t.fillStyle="orange":t.fillStyle=o.color,t.fillRect(Math.floor(i.x)+h-4,Math.floor(i.y)+h-4,8,8)),t.stroke()}t.restore()}}),e.hooks.shutdown.push(function(e,i){t.unbind(i,"mouseout",o),t.unbind(i,"mousemove",r)})},options:{crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}},name:"crosshair",version:"1.0"})}(jquery_flot_js,helpers_js);
|
|
2
|
+
//# sourceMappingURL=jquery.flot.crosshair.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jquery.flot.crosshair.min.js","sources":["../../source/jquery.flot.crosshair.js"],"sourcesContent":["/* Flot plugin for showing crosshairs when the mouse hovers over the plot.\n\nCopyright (c) 2007-2014 IOLA and Ole Laursen.\nLicensed under the MIT license.\n\nThe plugin supports these options:\n\n crosshair: {\n mode: null or \"x\" or \"y\" or \"xy\"\n color: color\n lineWidth: number\n }\n\nSet the mode to one of \"x\", \"y\" or \"xy\". The \"x\" mode enables a vertical\ncrosshair that lets you trace the values on the x axis, \"y\" enables a\nhorizontal crosshair and \"xy\" enables them both. \"color\" is the color of the\ncrosshair (default is \"rgba(170, 0, 0, 0.80)\"), \"lineWidth\" is the width of\nthe drawn lines (default is 1).\n\nThe plugin also adds four public methods:\n\n - setCrosshair( pos )\n\n Set the position of the crosshair. Note that this is cleared if the user\n moves the mouse. \"pos\" is in coordinates of the plot and should be on the\n form { x: xpos, y: ypos } (you can use x2/x3/... if you're using multiple\n axes), which is coincidentally the same format as what you get from a\n \"plothover\" event. If \"pos\" is null, the crosshair is cleared.\n\n - clearCrosshair()\n\n Clear the crosshair.\n\n - lockCrosshair(pos)\n\n Cause the crosshair to lock to the current location, no longer updating if\n the user moves the mouse. Optionally supply a position (passed on to\n setCrosshair()) to move it to.\n\n Example usage:\n\n var myFlot = $.plot( $(\"#graph\"), ..., { crosshair: { mode: \"x\" } } };\n $(\"#graph\").bind( \"plothover\", function ( evt, position, item ) {\n if ( item ) {\n // Lock the crosshair to the data point being hovered\n myFlot.lockCrosshair({\n x: item.datapoint[ 0 ],\n y: item.datapoint[ 1 ]\n });\n } else {\n // Return normal crosshair operation\n myFlot.unlockCrosshair();\n }\n });\n\n - unlockCrosshair()\n\n Free the crosshair to move again after locking it.\n*/\n\nimport { plugins } from './jquery.flot.js';\nimport { bind, unbind } from './helpers.js';\n\n var options = {\n crosshair: {\n mode: null, // one of null, \"x\", \"y\" or \"xy\",\n color: \"rgba(170, 0, 0, 0.80)\",\n lineWidth: 1\n }\n };\n\n function init(plot) {\n // position of crosshair in pixels\n var crosshair = {x: -1, y: -1, locked: false, highlighted: false};\n\n plot.setCrosshair = function setCrosshair(pos) {\n if (!pos) {\n crosshair.x = -1;\n } else {\n var o = plot.p2c(pos);\n crosshair.x = Math.max(0, Math.min(o.left, plot.width()));\n crosshair.y = Math.max(0, Math.min(o.top, plot.height()));\n }\n\n plot.triggerRedrawOverlay();\n };\n\n plot.clearCrosshair = plot.setCrosshair; // passes null for pos\n\n plot.lockCrosshair = function lockCrosshair(pos) {\n if (pos) {\n plot.setCrosshair(pos);\n }\n\n crosshair.locked = true;\n };\n\n plot.unlockCrosshair = function unlockCrosshair() {\n crosshair.locked = false;\n crosshair.rect = null;\n };\n\n function onMouseOut(e) {\n if (crosshair.locked) {\n return;\n }\n\n if (crosshair.x !== -1) {\n crosshair.x = -1;\n plot.triggerRedrawOverlay();\n }\n }\n\n function onMouseMove(e) {\n var offset = plot.offset();\n if (crosshair.locked) {\n var mouseX = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));\n var mouseY = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));\n\n if ((mouseX > crosshair.x - 4) && (mouseX < crosshair.x + 4) && (mouseY > crosshair.y - 4) && (mouseY < crosshair.y + 4)) {\n if (!crosshair.highlighted) {\n crosshair.highlighted = true;\n plot.triggerRedrawOverlay();\n }\n } else {\n if (crosshair.highlighted) {\n crosshair.highlighted = false;\n plot.triggerRedrawOverlay();\n }\n }\n return;\n }\n\n if (plot.getSelection && plot.getSelection()) {\n crosshair.x = -1; // hide the crosshair while selecting\n return;\n }\n\n crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));\n crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));\n plot.triggerRedrawOverlay();\n }\n\n plot.hooks.bindEvents.push(function (plot, eventHolder) {\n if (!plot.getOptions().crosshair.mode) {\n return;\n }\n\n bind(eventHolder, \"mouseout\", onMouseOut);\n bind(eventHolder, \"mousemove\", onMouseMove);\n });\n\n plot.hooks.drawOverlay.push(function (plot, ctx) {\n var c = plot.getOptions().crosshair;\n if (!c.mode) {\n return;\n }\n\n var plotOffset = plot.getPlotOffset();\n\n ctx.save();\n ctx.translate(plotOffset.left, plotOffset.top);\n\n if (crosshair.x !== -1) {\n var adj = plot.getOptions().crosshair.lineWidth % 2 ? 0.5 : 0;\n\n ctx.strokeStyle = c.color;\n ctx.lineWidth = c.lineWidth;\n ctx.lineJoin = \"round\";\n\n ctx.beginPath();\n if (c.mode.indexOf(\"x\") !== -1) {\n var drawX = Math.floor(crosshair.x) + adj;\n ctx.moveTo(drawX, 0);\n ctx.lineTo(drawX, plot.height());\n }\n if (c.mode.indexOf(\"y\") !== -1) {\n var drawY = Math.floor(crosshair.y) + adj;\n ctx.moveTo(0, drawY);\n ctx.lineTo(plot.width(), drawY);\n }\n if (crosshair.locked) {\n if (crosshair.highlighted) ctx.fillStyle = 'orange';\n else ctx.fillStyle = c.color;\n ctx.fillRect(Math.floor(crosshair.x) + adj - 4, Math.floor(crosshair.y) + adj - 4, 8, 8);\n }\n ctx.stroke();\n }\n ctx.restore();\n });\n\n plot.hooks.shutdown.push(function (plot, eventHolder) {\n unbind(eventHolder, \"mouseout\", onMouseOut);\n unbind(eventHolder, \"mousemove\", onMouseMove);\n });\n }\n\n plugins.push({\n init: init,\n options: options,\n name: 'crosshair',\n version: '1.0'\n });\n"],"names":["plugins","push","init","plot","crosshair","x","y","locked","highlighted","onMouseOut","e","triggerRedrawOverlay","onMouseMove","offset","mouseX","Math","max","min","pageX","left","width","mouseY","pageY","top","height","getSelection","setCrosshair","pos","o","p2c","clearCrosshair","lockCrosshair","unlockCrosshair","rect","hooks","bindEvents","eventHolder","getOptions","mode","bind","drawOverlay","ctx","c","plotOffset","getPlotOffset","save","translate","adj","lineWidth","strokeStyle","color","lineJoin","beginPath","indexOf","drawX","floor","moveTo","lineTo","drawY","fillStyle","fillRect","stroke","restore","shutdown","unbind","options","name","version"],"mappings":"4BAqMIA,EAAAA,QAAQC,KAAK,CACTC,KA/HJ,SAAcC,GAEV,IAAIC,EAAY,CAACC,KAAOC,GAAG,EAAIC,QAAQ,EAAOC,aAAa,GA6B3D,SAASC,EAAWC,GACZN,EAAUG,aAIVH,EAAUC,IACVD,EAAUC,GAAI,EACdF,EAAKQ,uBAEb,CAEA,SAASC,EAAYF,GACjB,IAAIG,EAASV,EAAKU,SAClB,GAAIT,EAAUG,OAAd,CACI,IAAIO,EAASC,KAAKC,IAAI,EAAGD,KAAKE,IAAIP,EAAEQ,MAAQL,EAAOM,KAAMhB,EAAKiB,UAC1DC,EAASN,KAAKC,IAAI,EAAGD,KAAKE,IAAIP,EAAEY,MAAQT,EAAOU,IAAKpB,EAAKqB,WAExDV,EAASV,EAAUC,EAAI,GAAOS,EAASV,EAAUC,EAAI,GAAOgB,EAASjB,EAAUE,EAAI,GAAOe,EAASjB,EAAUE,EAAI,EAC7GF,EAAUI,cACXJ,EAAUI,aAAc,EACxBL,EAAKQ,wBAGLP,EAAUI,cACVJ,EAAUI,aAAc,EACxBL,EAAKQ,uBAIjB,MAEIR,EAAKsB,cAAgBtB,EAAKsB,eAC1BrB,EAAUC,MAIdD,EAAUC,EAAIU,KAAKC,IAAI,EAAGD,KAAKE,IAAIP,EAAEQ,MAAQL,EAAOM,KAAMhB,EAAKiB,UAC/DhB,EAAUE,EAAIS,KAAKC,IAAI,EAAGD,KAAKE,IAAIP,EAAEY,MAAQT,EAAOU,IAAKpB,EAAKqB,WAC9DrB,EAAKQ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KqB,SAC3B,CACA,IAA4B,IAAxBkB,EAAEJ,KAAKe,QAAQ,KAAa,CAC5B,IAAIK,EAAQ3C,KAAKwC,MAAMnD,EAAUE,GAAKyC,EACtCN,EAAIe,OAAO,EAAGE,GACdjB,EAAIgB,OAAOtD,EAAKiB,QAASsC,EAC7B,CACItD,EAAUG,SACNH,EAAUI,YAAaiC,EAAIkB,UAAY,SACtClB,EAAIkB,UAAYjB,EAAEQ,MACvBT,EAAImB,SAAS7C,KAAKwC,MAAMnD,EAAUC,GAAK0C,EAAM,EAAGhC,KAAKwC,MAAMnD,EAAUE,GAAKyC,EAAM,EAAG,EAAG,IAE1FN,EAAIoB,QACR,CACApB,EAAIqB,SAhCJ,CAiCJ,GAEA3D,EAAK+B,MAAM6B,SAAS9D,KAAK,SAAUE,EAAMiC,GACrC4B,SAAO5B,EAAa,WAAY3B,GAChCuD,SAAO5B,EAAa,YAAaxB,EACrC,EACJ,EAIIqD,QAxIU,CACV7D,UAAW,CACPkC,KAAM,KACNY,MAAO,wBACPF,UAAW,IAqIfkB,KAAM,YACNC,QAAS"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/*! @kevinburke/flot v5.0.0 | MIT License | https://github.com/kevinburke/flot */
|
|
2
|
+
(function (exports, jquery_flot_js) {
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
/* Flot plugin for plotting images.
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
8
|
+
Licensed under the MIT license.
|
|
9
|
+
|
|
10
|
+
The data syntax is [ [ image, x1, y1, x2, y2 ], ... ] where (x1, y1) and
|
|
11
|
+
(x2, y2) are where you intend the two opposite corners of the image to end up
|
|
12
|
+
in the plot. Image must be a fully loaded Javascript image (you can make one
|
|
13
|
+
with new Image()). If the image is not complete, it's skipped when plotting.
|
|
14
|
+
|
|
15
|
+
There are two helpers included for retrieving images. The easiest work the way
|
|
16
|
+
that you put in URLs instead of images in the data, like this:
|
|
17
|
+
|
|
18
|
+
[ "myimage.png", 0, 0, 10, 10 ]
|
|
19
|
+
|
|
20
|
+
Then call $.plot.image.loadData( data, options, callback ) where data and
|
|
21
|
+
options are the same as you pass in to $.plot. This loads the images, replaces
|
|
22
|
+
the URLs in the data with the corresponding images and calls "callback" when
|
|
23
|
+
all images are loaded (or failed loading). In the callback, you can then call
|
|
24
|
+
$.plot with the data set. See the included example.
|
|
25
|
+
|
|
26
|
+
A more low-level helper, $.plot.image.load(urls, callback) is also included.
|
|
27
|
+
Given a list of URLs, it calls callback with an object mapping from URL to
|
|
28
|
+
Image object when all images are loaded or have failed loading.
|
|
29
|
+
|
|
30
|
+
The plugin supports these options:
|
|
31
|
+
|
|
32
|
+
series: {
|
|
33
|
+
images: {
|
|
34
|
+
show: boolean
|
|
35
|
+
anchor: "corner" or "center"
|
|
36
|
+
alpha: [ 0, 1 ]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
They can be specified for a specific series:
|
|
41
|
+
|
|
42
|
+
$.plot( $("#placeholder"), [{
|
|
43
|
+
data: [ ... ],
|
|
44
|
+
images: { ... }
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
Note that because the data format is different from usual data points, you
|
|
48
|
+
can't use images with anything else in a specific data series.
|
|
49
|
+
|
|
50
|
+
Setting "anchor" to "center" causes the pixels in the image to be anchored at
|
|
51
|
+
the corner pixel centers inside of at the pixel corners, effectively letting
|
|
52
|
+
half a pixel stick out to each side in the plot.
|
|
53
|
+
|
|
54
|
+
A possible future direction could be support for tiling for large images (like
|
|
55
|
+
Google Maps).
|
|
56
|
+
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var options = {
|
|
61
|
+
series: {
|
|
62
|
+
images: {
|
|
63
|
+
show: false,
|
|
64
|
+
alpha: 1,
|
|
65
|
+
anchor: "corner" // or "center"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var image = {};
|
|
71
|
+
|
|
72
|
+
image.loadDataImages = function (series, options, callback) {
|
|
73
|
+
var urls = [], points = [];
|
|
74
|
+
|
|
75
|
+
var defaultShow = options.series.images.show;
|
|
76
|
+
|
|
77
|
+
series.forEach(function (s) {
|
|
78
|
+
if (!(defaultShow || s.images.show)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (s.data) {
|
|
83
|
+
s = s.data;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
s.forEach(function (p) {
|
|
87
|
+
if (typeof p[0] === "string") {
|
|
88
|
+
urls.push(p[0]);
|
|
89
|
+
points.push(p);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
image.load(urls, function (loadedImages) {
|
|
95
|
+
points.forEach(function (p) {
|
|
96
|
+
var url = p[0];
|
|
97
|
+
if (loadedImages[url]) {
|
|
98
|
+
p[0] = loadedImages[url];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
callback();
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
image.load = function (urls, callback) {
|
|
107
|
+
var missing = urls.length, loaded = {};
|
|
108
|
+
if (missing === 0) {
|
|
109
|
+
callback({});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
urls.forEach(function (url) {
|
|
113
|
+
var handler = function () {
|
|
114
|
+
--missing;
|
|
115
|
+
loaded[url] = this;
|
|
116
|
+
|
|
117
|
+
if (missing === 0) {
|
|
118
|
+
callback(loaded);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
var img = document.createElement('img');
|
|
123
|
+
img.onload = handler;
|
|
124
|
+
img.onerror = handler;
|
|
125
|
+
img.src = url;
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
function drawSeries(plot, ctx, series) {
|
|
130
|
+
var plotOffset = plot.getPlotOffset();
|
|
131
|
+
|
|
132
|
+
if (!series.images || !series.images.show) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var points = series.datapoints.points,
|
|
137
|
+
ps = series.datapoints.pointsize;
|
|
138
|
+
|
|
139
|
+
for (var i = 0; i < points.length; i += ps) {
|
|
140
|
+
var img = points[i],
|
|
141
|
+
x1 = points[i + 1], y1 = points[i + 2],
|
|
142
|
+
x2 = points[i + 3], y2 = points[i + 4],
|
|
143
|
+
xaxis = series.xaxis, yaxis = series.yaxis,
|
|
144
|
+
tmp;
|
|
145
|
+
|
|
146
|
+
// actually we should check img.complete, but it
|
|
147
|
+
// appears to be a somewhat unreliable indicator in
|
|
148
|
+
// IE6 (false even after load event)
|
|
149
|
+
if (!img || img.width <= 0 || img.height <= 0) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (x1 > x2) {
|
|
154
|
+
tmp = x2;
|
|
155
|
+
x2 = x1;
|
|
156
|
+
x1 = tmp;
|
|
157
|
+
}
|
|
158
|
+
if (y1 > y2) {
|
|
159
|
+
tmp = y2;
|
|
160
|
+
y2 = y1;
|
|
161
|
+
y1 = tmp;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// if the anchor is at the center of the pixel, expand the
|
|
165
|
+
// image by 1/2 pixel in each direction
|
|
166
|
+
if (series.images.anchor === "center") {
|
|
167
|
+
tmp = 0.5 * (x2 - x1) / (img.width - 1);
|
|
168
|
+
x1 -= tmp;
|
|
169
|
+
x2 += tmp;
|
|
170
|
+
tmp = 0.5 * (y2 - y1) / (img.height - 1);
|
|
171
|
+
y1 -= tmp;
|
|
172
|
+
y2 += tmp;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// clip
|
|
176
|
+
if (x1 === x2 || y1 === y2 ||
|
|
177
|
+
x1 >= xaxis.max || x2 <= xaxis.min ||
|
|
178
|
+
y1 >= yaxis.max || y2 <= yaxis.min) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
var sx1 = 0, sy1 = 0, sx2 = img.width, sy2 = img.height;
|
|
183
|
+
if (x1 < xaxis.min) {
|
|
184
|
+
sx1 += (sx2 - sx1) * (xaxis.min - x1) / (x2 - x1);
|
|
185
|
+
x1 = xaxis.min;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (x2 > xaxis.max) {
|
|
189
|
+
sx2 += (sx2 - sx1) * (xaxis.max - x2) / (x2 - x1);
|
|
190
|
+
x2 = xaxis.max;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (y1 < yaxis.min) {
|
|
194
|
+
sy2 += (sy1 - sy2) * (yaxis.min - y1) / (y2 - y1);
|
|
195
|
+
y1 = yaxis.min;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (y2 > yaxis.max) {
|
|
199
|
+
sy1 += (sy1 - sy2) * (yaxis.max - y2) / (y2 - y1);
|
|
200
|
+
y2 = yaxis.max;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
x1 = xaxis.p2c(x1);
|
|
204
|
+
x2 = xaxis.p2c(x2);
|
|
205
|
+
y1 = yaxis.p2c(y1);
|
|
206
|
+
y2 = yaxis.p2c(y2);
|
|
207
|
+
|
|
208
|
+
// the transformation may have swapped us
|
|
209
|
+
if (x1 > x2) {
|
|
210
|
+
tmp = x2;
|
|
211
|
+
x2 = x1;
|
|
212
|
+
x1 = tmp;
|
|
213
|
+
}
|
|
214
|
+
if (y1 > y2) {
|
|
215
|
+
tmp = y2;
|
|
216
|
+
y2 = y1;
|
|
217
|
+
y1 = tmp;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
tmp = ctx.globalAlpha;
|
|
221
|
+
ctx.globalAlpha *= series.images.alpha;
|
|
222
|
+
ctx.drawImage(img,
|
|
223
|
+
sx1, sy1, sx2 - sx1, sy2 - sy1,
|
|
224
|
+
x1 + plotOffset.left, y1 + plotOffset.top,
|
|
225
|
+
x2 - x1, y2 - y1);
|
|
226
|
+
ctx.globalAlpha = tmp;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function processRawData(plot, series, data, datapoints) {
|
|
231
|
+
if (!series.images.show) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// format is Image, x1, y1, x2, y2 (opposite corners)
|
|
236
|
+
datapoints.format = [
|
|
237
|
+
{ required: true },
|
|
238
|
+
{ x: true, number: true, required: true },
|
|
239
|
+
{ y: true, number: true, required: true },
|
|
240
|
+
{ x: true, number: true, required: true },
|
|
241
|
+
{ y: true, number: true, required: true }
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function init(plot) {
|
|
246
|
+
plot.hooks.processRawData.push(processRawData);
|
|
247
|
+
plot.hooks.drawSeries.push(drawSeries);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
jquery_flot_js.plugins.push({
|
|
251
|
+
init: init,
|
|
252
|
+
options: options,
|
|
253
|
+
name: 'image',
|
|
254
|
+
version: '1.1'
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
exports.image = image;
|
|
258
|
+
|
|
259
|
+
return exports;
|
|
260
|
+
|
|
261
|
+
})({}, jquery_flot_js);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(a,i){"use strict";var n={};function e(a,i,n){var e=a.getPlotOffset();if(n.images&&n.images.show)for(var o=n.datapoints.points,r=n.datapoints.pointsize,t=0;t<o.length;t+=r){var s,m=o[t],h=o[t+1],u=o[t+2],c=o[t+3],f=o[t+4],g=n.xaxis,p=n.yaxis;if(!(!m||m.width<=0||m.height<=0||(h>c&&(s=c,c=h,h=s),u>f&&(s=f,f=u,u=s),"center"===n.images.anchor&&(h-=s=.5*(c-h)/(m.width-1),c+=s,u-=s=.5*(f-u)/(m.height-1),f+=s),h===c||u===f||h>=g.max||c<=g.min||u>=p.max||f<=p.min))){var l=0,d=0,x=m.width,w=m.height;h<g.min&&(l+=(x-l)*(g.min-h)/(c-h),h=g.min),c>g.max&&(x+=(x-l)*(g.max-c)/(c-h),c=g.max),u<p.min&&(w+=(d-w)*(p.min-u)/(f-u),u=p.min),f>p.max&&(d+=(d-w)*(p.max-f)/(f-u),f=p.max),(h=g.p2c(h))>(c=g.p2c(c))&&(s=c,c=h,h=s),(u=p.p2c(u))>(f=p.p2c(f))&&(s=f,f=u,u=s),s=i.globalAlpha,i.globalAlpha*=n.images.alpha,i.drawImage(m,l,d,x-l,w-d,h+e.left,u+e.top,c-h,f-u),i.globalAlpha=s}}}function o(a,i,n,e){i.images.show&&(e.format=[{required:!0},{x:!0,number:!0,required:!0},{y:!0,number:!0,required:!0},{x:!0,number:!0,required:!0},{y:!0,number:!0,required:!0}])}n.loadDataImages=function(a,i,e){var o=[],r=[],t=i.series.images.show;a.forEach(function(a){(t||a.images.show)&&(a.data&&(a=a.data),a.forEach(function(a){"string"==typeof a[0]&&(o.push(a[0]),r.push(a))}))}),n.load(o,function(a){r.forEach(function(i){var n=i[0];a[n]&&(i[0]=a[n])}),e()})},n.load=function(a,i){var n=a.length,e={};0===n&&i({}),a.forEach(function(a){var o=function(){--n,e[a]=this,0===n&&i(e)},r=document.createElement("img");r.onload=o,r.onerror=o,r.src=a})},i.plugins.push({init:function(a){a.hooks.processRawData.push(o),a.hooks.drawSeries.push(e)},options:{series:{images:{show:!1,alpha:1,anchor:"corner"}}},name:"image",version:"1.1"})}(0,jquery_flot_js);
|
|
2
|
+
//# sourceMappingURL=jquery.flot.image.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jquery.flot.image.min.js","sources":["../../source/jquery.flot.image.js"],"sourcesContent":["/* Flot plugin for plotting images.\n\nCopyright (c) 2007-2014 IOLA and Ole Laursen.\nLicensed under the MIT license.\n\nThe data syntax is [ [ image, x1, y1, x2, y2 ], ... ] where (x1, y1) and\n(x2, y2) are where you intend the two opposite corners of the image to end up\nin the plot. Image must be a fully loaded Javascript image (you can make one\nwith new Image()). If the image is not complete, it's skipped when plotting.\n\nThere are two helpers included for retrieving images. The easiest work the way\nthat you put in URLs instead of images in the data, like this:\n\n [ \"myimage.png\", 0, 0, 10, 10 ]\n\nThen call $.plot.image.loadData( data, options, callback ) where data and\noptions are the same as you pass in to $.plot. This loads the images, replaces\nthe URLs in the data with the corresponding images and calls \"callback\" when\nall images are loaded (or failed loading). In the callback, you can then call\n$.plot with the data set. See the included example.\n\nA more low-level helper, $.plot.image.load(urls, callback) is also included.\nGiven a list of URLs, it calls callback with an object mapping from URL to\nImage object when all images are loaded or have failed loading.\n\nThe plugin supports these options:\n\n series: {\n images: {\n show: boolean\n anchor: \"corner\" or \"center\"\n alpha: [ 0, 1 ]\n }\n }\n\nThey can be specified for a specific series:\n\n $.plot( $(\"#placeholder\"), [{\n data: [ ... ],\n images: { ... }\n ])\n\nNote that because the data format is different from usual data points, you\ncan't use images with anything else in a specific data series.\n\nSetting \"anchor\" to \"center\" causes the pixels in the image to be anchored at\nthe corner pixel centers inside of at the pixel corners, effectively letting\nhalf a pixel stick out to each side in the plot.\n\nA possible future direction could be support for tiling for large images (like\nGoogle Maps).\n\n*/\n\nimport { plugins } from './jquery.flot.js';\n\n var options = {\n series: {\n images: {\n show: false,\n alpha: 1,\n anchor: \"corner\" // or \"center\"\n }\n }\n };\n\n export var image = {};\n\n image.loadDataImages = function (series, options, callback) {\n var urls = [], points = [];\n\n var defaultShow = options.series.images.show;\n\n series.forEach(function (s) {\n if (!(defaultShow || s.images.show)) {\n return;\n }\n\n if (s.data) {\n s = s.data;\n }\n\n s.forEach(function (p) {\n if (typeof p[0] === \"string\") {\n urls.push(p[0]);\n points.push(p);\n }\n });\n });\n\n image.load(urls, function (loadedImages) {\n points.forEach(function (p) {\n var url = p[0];\n if (loadedImages[url]) {\n p[0] = loadedImages[url];\n }\n });\n\n callback();\n });\n }\n\n image.load = function (urls, callback) {\n var missing = urls.length, loaded = {};\n if (missing === 0) {\n callback({});\n }\n\n urls.forEach(function (url) {\n var handler = function () {\n --missing;\n loaded[url] = this;\n\n if (missing === 0) {\n callback(loaded);\n }\n };\n\n var img = document.createElement('img');\n img.onload = handler;\n img.onerror = handler;\n img.src = url;\n });\n };\n\n function drawSeries(plot, ctx, series) {\n var plotOffset = plot.getPlotOffset();\n\n if (!series.images || !series.images.show) {\n return;\n }\n\n var points = series.datapoints.points,\n ps = series.datapoints.pointsize;\n\n for (var i = 0; i < points.length; i += ps) {\n var img = points[i],\n x1 = points[i + 1], y1 = points[i + 2],\n x2 = points[i + 3], y2 = points[i + 4],\n xaxis = series.xaxis, yaxis = series.yaxis,\n tmp;\n\n // actually we should check img.complete, but it\n // appears to be a somewhat unreliable indicator in\n // IE6 (false even after load event)\n if (!img || img.width <= 0 || img.height <= 0) {\n continue;\n }\n\n if (x1 > x2) {\n tmp = x2;\n x2 = x1;\n x1 = tmp;\n }\n if (y1 > y2) {\n tmp = y2;\n y2 = y1;\n y1 = tmp;\n }\n\n // if the anchor is at the center of the pixel, expand the\n // image by 1/2 pixel in each direction\n if (series.images.anchor === \"center\") {\n tmp = 0.5 * (x2 - x1) / (img.width - 1);\n x1 -= tmp;\n x2 += tmp;\n tmp = 0.5 * (y2 - y1) / (img.height - 1);\n y1 -= tmp;\n y2 += tmp;\n }\n\n // clip\n if (x1 === x2 || y1 === y2 ||\n x1 >= xaxis.max || x2 <= xaxis.min ||\n y1 >= yaxis.max || y2 <= yaxis.min) {\n continue;\n }\n\n var sx1 = 0, sy1 = 0, sx2 = img.width, sy2 = img.height;\n if (x1 < xaxis.min) {\n sx1 += (sx2 - sx1) * (xaxis.min - x1) / (x2 - x1);\n x1 = xaxis.min;\n }\n\n if (x2 > xaxis.max) {\n sx2 += (sx2 - sx1) * (xaxis.max - x2) / (x2 - x1);\n x2 = xaxis.max;\n }\n\n if (y1 < yaxis.min) {\n sy2 += (sy1 - sy2) * (yaxis.min - y1) / (y2 - y1);\n y1 = yaxis.min;\n }\n\n if (y2 > yaxis.max) {\n sy1 += (sy1 - sy2) * (yaxis.max - y2) / (y2 - y1);\n y2 = yaxis.max;\n }\n\n x1 = xaxis.p2c(x1);\n x2 = xaxis.p2c(x2);\n y1 = yaxis.p2c(y1);\n y2 = yaxis.p2c(y2);\n\n // the transformation may have swapped us\n if (x1 > x2) {\n tmp = x2;\n x2 = x1;\n x1 = tmp;\n }\n if (y1 > y2) {\n tmp = y2;\n y2 = y1;\n y1 = tmp;\n }\n\n tmp = ctx.globalAlpha;\n ctx.globalAlpha *= series.images.alpha;\n ctx.drawImage(img,\n sx1, sy1, sx2 - sx1, sy2 - sy1,\n x1 + plotOffset.left, y1 + plotOffset.top,\n x2 - x1, y2 - y1);\n ctx.globalAlpha = tmp;\n }\n }\n\n function processRawData(plot, series, data, datapoints) {\n if (!series.images.show) {\n return;\n }\n\n // format is Image, x1, y1, x2, y2 (opposite corners)\n datapoints.format = [\n { required: true },\n { x: true, number: true, required: true },\n { y: true, number: true, required: true },\n { x: true, number: true, required: true },\n { y: true, number: true, required: true }\n ];\n }\n\n function init(plot) {\n plot.hooks.processRawData.push(processRawData);\n plot.hooks.drawSeries.push(drawSeries);\n }\n\n plugins.push({\n init: init,\n options: options,\n name: 'image',\n version: '1.1'\n });\n"],"names":["image","drawSeries","plot","ctx","series","plotOffset","getPlotOffset","images","show","points","datapoints","ps","pointsize","i","length","tmp","img","x1","y1","x2","y2","xaxis","yaxis","width","height","anchor","max","min","sx1","sy1","sx2","sy2","p2c","globalAlpha","alpha","drawImage","left","top","processRawData","data","format","required","x","number","y","loadDataImages","options","callback","urls","defaultShow","forEach","s","p","push","load","loadedImages","url","missing","loaded","handler","this","document","createElement","onload","onerror","src","plugins","init","hooks","name","version"],"mappings":"4BAwDI,IAUWA,EAAQ,CAAA,EA2DnB,SAASC,EAAWC,EAAMC,EAAKC,GAC3B,IAAIC,EAAaH,EAAKI,gBAEtB,GAAKF,EAAOG,QAAWH,EAAOG,OAAOC,KAOrC,IAHA,IAAIC,EAASL,EAAOM,WAAWD,OA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