Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flot

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flot - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

11

package.json
{
"name": "flot",
"version": "3.1.1",
"version": "3.2.0",
"main": "dist/es5/jquery.flot.js",
"scripts": {
"test": "node node_modules/karma/bin/karma start --single-run --no-auto-watch --concurrency=1 --stopOnEsLintError",
"karma": "node node_modules/karma/bin/karma start --no-auto-watch",
"coverage": "node node_modules/karma/bin/karma start --single-run --coverage --no-auto-watch --concurrency=1",

@@ -22,4 +23,2 @@ "build": "node ./node_modules/gulp/bin/gulp.js build",

"devDependencies": {
"babelify": "~10.0.0",
"browserify": "~16.2.3",
"@babel/cli": "^7.2.3",

@@ -38,3 +37,2 @@ "@babel/core": "^7.4.0",

"karma": "^1.3.0",
"karma-browserify": "^6.0.0",
"karma-chrome-launcher": "^2.0.0",

@@ -53,8 +51,5 @@ "karma-coverage": "^1.1.2",

"tmp": "0.0.33",
"vinyl-source-stream": "~2.0.0",
"webcharts-development-settings": "^1.0.9"
},
"dependencies": {
"regenerator-runtime": "~0.13.2"
}
"dependencies": {}
}

@@ -42,6 +42,6 @@ /** ## jquery.flot.canvaswrapper

// Size the canvas to match the internal dimensions of its container
var width = $(container).width();
var height = $(container).height();
this.resize(width, height);
var box = container.getBoundingClientRect();
this.resize(box.width, box.height);
// Collection of HTML div layers for text overlaid onto the canvas

@@ -48,0 +48,0 @@

@@ -1,3 +0,1 @@

import regeneratorRuntime from "regenerator-runtime";
import {getCrossDomainCSSRules} from "./getCORSCss";
/** ## jquery.flot.composeImages.js

@@ -114,2 +112,16 @@

function getCSSRules(document) {
var styleSheets = document.styleSheets,
rulesList = [];
for (var i = 0; i < styleSheets.length; i++) {
// in Chrome, the external CSS files are empty when the page is directly loaded from disk
var rules = styleSheets[i].cssRules || [];
for (var j = 0; j < rules.length; j++) {
var rule = rules[j];
rulesList.push(rule.cssText);
}
}
return rulesList;
}
function embedCSSRulesInSVG(rules, svg) {

@@ -129,4 +141,4 @@ var text = [

async function copySVGToImgMostBrowsers(svg, img) {
var rules = await getCrossDomainCSSRules(document),
function copySVGToImgMostBrowsers(svg, img) {
var rules = getCSSRules(document),
source = embedCSSRulesInSVG(rules, svg);

@@ -142,3 +154,3 @@

async function copySVGToImgSafari(svg, img) {
function copySVGToImgSafari(svg, img) {
// Use this method to convert a string buffer array to a binary string.

@@ -159,3 +171,3 @@ // Do so by breaking up large strings into smaller substrings; this is necessary to avoid the

var rules = await getCrossDomainCSSRules(document),
var rules = getCSSRules(document),
source = embedCSSRulesInSVG(rules, svg),

@@ -162,0 +174,0 @@ data,

@@ -187,2 +187,3 @@ /**

ps = -ps;
ypos = 1;
i = segmentStart = segmentEnd + ps;

@@ -189,0 +190,0 @@ continue;

@@ -64,6 +64,6 @@ /* Flot plugin for computing bottoms for filled line and bar charts.

var format = datapoints.format;
format = datapoints.format;
var plotHasId = function(id) {
var plotData = plot.getData();
for (var i = 0; i < plotData.length; i++) {
for (i = 0; i < plotData.length; i++) {
if (plotData[i].id === id) {

@@ -70,0 +70,0 @@ return true;

@@ -38,243 +38,228 @@ /* global jQuery */

var browser = $.plot.browser;
var highlights = [];
function init(plot) {
plot.hooks.processOptions.push(initHover);
var eventType = {
click: 'click',
hover: 'hover'
}
function initHover(plot, options) {
var highlights = [];
var lastMouseMoveEvent;
var eventType = {
click: 'click',
hover: 'hover'
}
var plot;
var lastMouseMoveEvent = plot.getPlaceholder()[0].lastMouseMoveEvent;
function bindEvents(plot, eventHolder) {
var o = plot.getOptions();
plot.highlight = highlight;
plot.unhighlight = unhighlight;
if (o.grid.hoverable || o.grid.clickable) {
eventHolder[0].addEventListener('touchevent', triggerCleanupEvent, false);
eventHolder[0].addEventListener('tap', tap.generatePlothoverEvent, false);
}
var tap = {
generatePlothoverEvent: function (e) {
var o = plot.getOptions(),
newEvent = new CustomEvent('mouseevent');
if (o.grid.clickable) {
eventHolder.bind("click", onClick);
}
//transform from touch event to mouse event format
newEvent.pageX = e.detail.changedTouches[0].pageX;
newEvent.pageY = e.detail.changedTouches[0].pageY;
newEvent.clientX = e.detail.changedTouches[0].clientX;
newEvent.clientY = e.detail.changedTouches[0].clientY;
if (o.grid.hoverable) {
eventHolder.bind("mousemove", onMouseMove);
if (o.grid.hoverable) {
doTriggerClickHoverEvent(newEvent, eventType.hover, 30);
}
return false;
}
};
// Use bind, rather than .mouseleave, because we officially
// still support jQuery 1.2.6, which doesn't define a shortcut
// for mouseenter or mouseleave. This was a bug/oversight that
// was fixed somewhere around 1.3.x. We can return to using
// .mouseleave when we drop support for 1.2.6.
function bindEvents(plot, eventHolder) {
var o = plot.getOptions();
eventHolder.bind("mouseleave", onMouseLeave);
}
}
if (o.grid.hoverable || o.grid.clickable) {
eventHolder[0].addEventListener('touchevent', triggerCleanupEvent, false);
eventHolder[0].addEventListener('tap', tap.generatePlothoverEvent, false);
}
function shutdown(plot, eventHolder) {
eventHolder[0].removeEventListener('tap', tap.generatePlothoverEvent);
eventHolder[0].removeEventListener('touchevent', triggerCleanupEvent);
eventHolder.unbind("mousemove", onMouseMove);
eventHolder.unbind("mouseleave", onMouseLeave);
eventHolder.unbind("click", onClick);
highlights = [];
}
if (options.grid.clickable) {
eventHolder.click(onClick);
}
var tap = {
generatePlothoverEvent: function (e) {
var o = plot.getOptions(),
newEvent = new CustomEvent('mouseevent');
if (options.grid.hoverable) {
eventHolder.mousemove(onMouseMove);
//transform from touch event to mouse event format
newEvent.pageX = e.detail.changedTouches[0].pageX;
newEvent.pageY = e.detail.changedTouches[0].pageY;
newEvent.clientX = e.detail.changedTouches[0].clientX;
newEvent.clientY = e.detail.changedTouches[0].clientY;
// Use bind, rather than .mouseleave, because we officially
// still support jQuery 1.2.6, which doesn't define a shortcut
// for mouseenter or mouseleave. This was a bug/oversight that
// was fixed somewhere around 1.3.x. We can return to using
// .mouseleave when we drop support for 1.2.6.
eventHolder.bind("mouseleave", onMouseLeave);
if (o.grid.hoverable) {
doTriggerClickHoverEvent(newEvent, eventType.hover, 30);
}
return false;
}
};
function shutdown(plot, eventHolder) {
eventHolder[0].removeEventListener('tap', tap.generatePlothoverEvent);
eventHolder[0].removeEventListener('touchevent', triggerCleanupEvent);
eventHolder.unbind("mousemove", onMouseMove);
eventHolder.unbind("mouseleave", onMouseLeave);
eventHolder.unbind("click", onClick);
highlights = [];
function doTriggerClickHoverEvent(event, eventType, searchDistance) {
var series = plot.getData();
if (event !== undefined
&& series.length > 0
&& series[0].xaxis.c2p !== undefined
&& series[0].yaxis.c2p !== undefined) {
var eventToTrigger = "plot" + eventType;
var seriesFlag = eventType + "able";
triggerClickHoverEvent(eventToTrigger, event,
function(i) {
return series[i][seriesFlag] !== false;
}, searchDistance);
}
}
function doTriggerClickHoverEvent(event, eventType, searchDistance) {
var series = plot.getData();
if (event !== undefined
&& series.length > 0
&& series[0].xaxis.c2p !== undefined
&& series[0].yaxis.c2p !== undefined) {
var eventToTrigger = "plot" + eventType;
var seriesFlag = eventType + "able";
triggerClickHoverEvent(eventToTrigger, event,
function(i) {
return series[i][seriesFlag] !== false;
}, searchDistance);
}
}
function onMouseMove(e) {
lastMouseMoveEvent = e;
plot.getPlaceholder()[0].lastMouseMoveEvent = e;
doTriggerClickHoverEvent(e, eventType.hover);
}
if (options.grid.hoverable || options.grid.clickable) {
plot.hooks.bindEvents.push(bindEvents);
plot.hooks.shutdown.push(shutdown);
plot.hooks.drawOverlay.push(drawOverlay);
plot.hooks.processRawData.push(processRawData);
}
function onMouseLeave(e) {
lastMouseMoveEvent = undefined;
plot.getPlaceholder()[0].lastMouseMoveEvent = undefined;
triggerClickHoverEvent("plothover", e,
function(i) {
return false;
});
}
function onMouseMove(e) {
lastMouseMoveEvent = e;
plot.getPlaceholder()[0].lastMouseMoveEvent = e;
doTriggerClickHoverEvent(e, eventType.hover);
}
function onClick(e) {
doTriggerClickHoverEvent(e, eventType.click);
}
function onMouseLeave(e) {
lastMouseMoveEvent = undefined;
plot.getPlaceholder()[0].lastMouseMoveEvent = undefined;
triggerClickHoverEvent("plothover", e,
function(i) {
return false;
});
}
function triggerCleanupEvent() {
plot.unhighlight();
plot.getPlaceholder().trigger('plothovercleanup');
}
function onClick(e) {
doTriggerClickHoverEvent(e, eventType.click);
}
// trigger click or hover event (they send the same parameters
// so we share their code)
function triggerClickHoverEvent(eventname, event, seriesFilter, searchDistance) {
var options = plot.getOptions(),
offset = plot.offset(),
page = browser.getPageXY(event),
canvasX = page.X - offset.left,
canvasY = page.Y - offset.top,
pos = plot.c2p({
left: canvasX,
top: canvasY
}),
distance = searchDistance !== undefined ? searchDistance : options.grid.mouseActiveRadius;
function triggerCleanupEvent() {
plot.unhighlight();
plot.getPlaceholder().trigger('plothovercleanup');
}
pos.pageX = page.X;
pos.pageY = page.Y;
// trigger click or hover event (they send the same parameters
// so we share their code)
function triggerClickHoverEvent(eventname, event, seriesFilter, searchDistance) {
var options = plot.getOptions(),
offset = plot.offset(),
page = browser.getPageXY(event),
canvasX = page.X - offset.left,
canvasY = page.Y - offset.top,
pos = plot.c2p({
left: canvasX,
top: canvasY
}),
distance = searchDistance !== undefined ? searchDistance : options.grid.mouseActiveRadius;
var item = plot.findNearbyItem(canvasX, canvasY, seriesFilter, distance);
pos.pageX = page.X;
pos.pageY = page.Y;
if (item) {
// fill in mouse pos for any listeners out there
item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left, 10);
item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top, 10);
}
var item = plot.findNearbyItem(canvasX, canvasY, seriesFilter, distance);
if (options.grid.autoHighlight) {
// clear auto-highlights
for (var i = 0; i < highlights.length; ++i) {
var h = highlights[i];
if ((h.auto === eventname &&
!(item && h.series === item.series &&
h.point[0] === item.datapoint[0] &&
h.point[1] === item.datapoint[1])) || !item) {
unhighlight(h.series, h.point);
}
}
if (item) {
// fill in mouse pos for any listeners out there
item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left, 10);
item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top, 10);
highlight(item.series, item.datapoint, eventname);
}
}
if (options.grid.autoHighlight) {
// clear auto-highlights
for (var i = 0; i < highlights.length; ++i) {
var h = highlights[i];
if ((h.auto === eventname &&
!(item && h.series === item.series &&
h.point[0] === item.datapoint[0] &&
h.point[1] === item.datapoint[1])) || !item) {
unhighlight(h.series, h.point);
}
}
plot.getPlaceholder().trigger(eventname, [pos, item]);
}
if (item) {
highlight(item.series, item.datapoint, eventname);
}
}
function highlight(s, point, auto) {
if (typeof s === "number") {
s = plot.getData()[s];
}
plot.getPlaceholder().trigger(eventname, [pos, item]);
if (typeof point === "number") {
var ps = s.datapoints.pointsize;
point = s.datapoints.points.slice(ps * point, ps * (point + 1));
}
function highlight(s, point, auto) {
if (typeof s === "number") {
s = plot.getData()[s];
}
var i = indexOfHighlight(s, point);
if (i === -1) {
highlights.push({
series: s,
point: point,
auto: auto
});
if (typeof point === "number") {
var ps = s.datapoints.pointsize;
point = s.datapoints.points.slice(ps * point, ps * (point + 1));
}
plot.triggerRedrawOverlay();
} else if (!auto) {
highlights[i].auto = false;
}
}
var i = indexOfHighlight(s, point);
if (i === -1) {
highlights.push({
series: s,
point: point,
auto: auto
});
function unhighlight(s, point) {
if (s == null && point == null) {
highlights = [];
plot.triggerRedrawOverlay();
return;
}
plot.triggerRedrawOverlay();
} else if (!auto) {
highlights[i].auto = false;
}
if (typeof s === "number") {
s = plot.getData()[s];
}
function unhighlight(s, point) {
if (s == null && point == null) {
highlights = [];
plot.triggerRedrawOverlay();
return;
}
if (typeof point === "number") {
var ps = s.datapoints.pointsize;
point = s.datapoints.points.slice(ps * point, ps * (point + 1));
}
if (typeof s === "number") {
s = plot.getData()[s];
}
var i = indexOfHighlight(s, point);
if (i !== -1) {
highlights.splice(i, 1);
if (typeof point === "number") {
var ps = s.datapoints.pointsize;
point = s.datapoints.points.slice(ps * point, ps * (point + 1));
}
plot.triggerRedrawOverlay();
}
}
var i = indexOfHighlight(s, point);
if (i !== -1) {
highlights.splice(i, 1);
plot.triggerRedrawOverlay();
function indexOfHighlight(s, p) {
for (var i = 0; i < highlights.length; ++i) {
var h = highlights[i];
if (h.series === s &&
h.point[0] === p[0] &&
h.point[1] === p[1]) {
return i;
}
}
function indexOfHighlight(s, p) {
for (var i = 0; i < highlights.length; ++i) {
var h = highlights[i];
if (h.series === s &&
h.point[0] === p[0] &&
h.point[1] === p[1]) {
return i;
}
}
return -1;
}
return -1;
}
function processRawData() {
triggerCleanupEvent();
doTriggerClickHoverEvent(lastMouseMoveEvent, eventType.hover);
}
function processRawData() {
triggerCleanupEvent();
doTriggerClickHoverEvent(lastMouseMoveEvent, eventType.hover);
}
function drawOverlay(plot, octx, overlay) {
var plotOffset = plot.getPlotOffset(),
i, hi;
function drawOverlay(plot, octx, overlay) {
var plotOffset = plot.getPlotOffset(),
i, hi;
octx.save();
octx.translate(plotOffset.left, plotOffset.top);
for (i = 0; i < highlights.length; ++i) {
hi = highlights[i];
octx.save();
octx.translate(plotOffset.left, plotOffset.top);
for (i = 0; i < highlights.length; ++i) {
hi = highlights[i];
if (hi.series.bars.show) drawBarHighlight(hi.series, hi.point, octx);
else drawPointHighlight(hi.series, hi.point, octx, plot);
}
octx.restore();
if (hi.series.bars.show) drawBarHighlight(hi.series, hi.point, octx);
else drawPointHighlight(hi.series, hi.point, octx, plot);
}
octx.restore();
}

@@ -341,2 +326,20 @@

function initHover(plot, options) {
plot.highlight = highlight;
plot.unhighlight = unhighlight;
if (options.grid.hoverable || options.grid.clickable) {
plot.hooks.drawOverlay.push(drawOverlay);
plot.hooks.processRawData.push(processRawData);
}
lastMouseMoveEvent = plot.getPlaceholder()[0].lastMouseMoveEvent;
}
function init(plt) {
plot = plt;
plot.hooks.bindEvents.push(bindEvents);
plot.hooks.shutdown.push(shutdown);
plot.hooks.processOptions.push(initHover);
}
$.plot.plugins.push({

@@ -343,0 +346,0 @@ init: init,

@@ -38,3 +38,2 @@ /* Pretty handling of time axes.

microEpoch = Math.round(microEpoch*1000)/1000;
this.microEpoch = microEpoch;

@@ -46,4 +45,6 @@ // Microseconds are stored as integers

var oldGetTime = newDate.getTime.bind(newDate);
newDate.getTime = function () {
return this.microEpoch;
var microEpoch = oldGetTime() + this.microseconds / 1000;
return microEpoch;
};

@@ -61,3 +62,3 @@

// Replace the microsecond part (6 last digits) in microEpoch
var epochWithoutMicroseconds = 1000*Math.floor(this.microEpoch/1000);
var epochWithoutMicroseconds = oldGetTime();
var newEpoch = epochWithoutMicroseconds + microseconds/1000;

@@ -64,0 +65,0 @@ this.update(newEpoch);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc