Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@fishawack/lab-d3

Package Overview
Dependencies
38
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.1 to 3.1.2

2

package.json
{
"name": "@fishawack/lab-d3",
"version": "3.1.1",
"version": "3.1.2",
"description": "Abstract layer built on top of d3",

@@ -5,0 +5,0 @@ "scripts": {

@@ -172,72 +172,75 @@ "use strict";

// Get data in flat structure, all level 0's at levelData[0] cominbed etc
var levelData = Shared.flattenValuesLengths(data, [], data.length);
// If local.levels not set then .data not yet called so can't calculate axis height
if (local.levels != null) {
// Get data in flat structure, all level 0's at levelData[0] cominbed etc
var levelData = Shared.flattenValuesLengths(data);
// Loop over each level of data backwards (top to bottom) as each level need previous levels width to calculate its own
for (var levelIndex = levelData.length; levelIndex--;) {
// LevelWidth either level above or total width - outer padding
var levelWidth = 0;
// Loop over each level of data backwards (top to bottom) as each level need previous levels width to calculate its own
for (var levelIndex = levelData.length; levelIndex--;) {
// LevelWidth either level above or total width - outer padding
var levelWidth = 0;
// If top level, then apply outer padding as percentage of width/height
if (levelIndex === local.levels) {
var outerPad = local[local.pD] * local.padding.outer;
levelWidth = local[local.pD] - outerPad * 2;
// Else get previous width from level above
} else {
levelWidth = local.levelWidth[levelIndex + 1];
}
// If top level, then apply outer padding as percentage of width/height
if (levelIndex === local.levels) {
var outerPad = local[local.pD] * local.padding.outer;
levelWidth = local[local.pD] - outerPad * 2;
// Else get previous width from level above
} else {
levelWidth = local.levelWidth[levelIndex + 1];
}
// Calculate inner padding as percentage of levelWidth
var innerPad = local.padding[levelIndex] == null ? local.padding.inner * (att.padding.ratio ? levelWidth : local.width) : local.padding[levelIndex] * (att.padding.ratio ? levelWidth : 1);
// Calculate inner padding as percentage of levelWidth
var innerPad = local.padding[levelIndex] == null ? local.padding.inner * (att.padding.ratio ? levelWidth : local.width) : local.padding[levelIndex] * (att.padding.ratio ? levelWidth : 1);
// Used to find biggest dataset at current levelIndex
var biggestDataset = 0;
// Used to find biggest dataset at current levelIndex
var biggestDataset = 0;
// Find biggest dataset at current levelIndex, need to loop through parents to check all dataset lengths for parent.values
if (levelIndex !== local.levels /* && levelIndex !== 0*/) {
var prevLevel = levelData[levelIndex + 1];
for (var i = prevLevel.length; i--;) {
var prevLength = prevLevel[i].values.length;
if (prevLength > biggestDataset) {
biggestDataset = prevLength;
// If top level then no parent and can 100% say current dataset is the biggest
if (levelIndex === local.levels) {
biggestDataset = data.length;
// Find biggest dataset at current levelIndex, need to loop through parents to check all dataset lengths for parent.values
} else {
var prevLevel = levelData[levelIndex + 1];
for (var i = prevLevel.length; i--;) {
var prevLength = prevLevel[i].values.length;
if (prevLength > biggestDataset) {
biggestDataset = prevLength;
}
}
}
// If top level then no parent and can 100% say current dataset is the biggest
} else {
biggestDataset = data.length;
}
// Level width is biggestDataset / currentLevel - inner padding
local.levelWidth[levelIndex] = levelWidth - innerPad * (biggestDataset - 1);
local.levelWidth[levelIndex] /= biggestDataset;
var biggest = 0;
var tempBiggest = 0;
var label = '';
for (var j = levelData[levelIndex].length; j--;) {
var tempLabel = Shared.valueFormat(Shared.label(levelData[levelIndex][j], att), levelData[levelIndex][j], att, 'label');
if (tempLabel) {
tempBiggest = Shared.textWidth(tempLabel);
if (tempBiggest > biggest) {
biggest = tempBiggest;
label = tempLabel;
// Level width is biggestDataset / currentLevel - inner padding
local.levelWidth[levelIndex] = levelWidth - innerPad * (biggestDataset - 1);
local.levelWidth[levelIndex] /= biggestDataset;
var biggest = 0;
var tempBiggest = 0;
var label = '';
for (var j = levelData[levelIndex].length; j--;) {
var tempLabel = Shared.valueFormat(Shared.label(levelData[levelIndex][j], att), levelData[levelIndex][j], att, 'label');
if (tempLabel) {
tempBiggest = Shared.textWidth(tempLabel);
if (tempBiggest > biggest) {
biggest = tempBiggest;
label = tempLabel;
}
}
}
var hidden = att.hide["level".concat(levelIndex)] || att.hide["level--".concat(levelIndex)] || att.hide["level--".concat(levelIndex, "--label")] || false;
// Dont add spacing if height 0
if (!tempBiggest || hidden) {
local.levelHeight[levelIndex] = 0;
} else if (att.axis[local.pA[0]].rotate) {
local.levelHeight[levelIndex] = Shared.textWidth(label) + local.padding.space;
} else {
local.levelHeight[levelIndex] = Shared.textHeight(chart, label, local.levelWidth[levelIndex]) + local.padding.space;
}
height += local.levelHeight[levelIndex];
}
var hidden = att.hide["level".concat(levelIndex)] || att.hide["level--".concat(levelIndex)] || att.hide["level--".concat(levelIndex, "--label")] || false;
// Dont add spacing if height 0
if (!tempBiggest || hidden) {
local.levelHeight[levelIndex] = 0;
} else if (att.axis[local.pA[0]].rotate) {
local.levelHeight[levelIndex] = Shared.textWidth(label) + local.padding.space;
} else {
local.levelHeight[levelIndex] = Shared.textHeight(chart, label, local.levelWidth[levelIndex]) + local.padding.space;
// Calculate axis label height
if (att.label[scale]) {
height += Shared.textHeight(chart, att.label[scale], local[local.pD]) + local.padding.space;
}
height += local.levelHeight[levelIndex];
}
// Calculate axis label height
if (att.label[scale]) {
height += Shared.textHeight(chart, att.label[scale], local[local.pD]) + local.padding.space;
}
return height;

@@ -244,0 +247,0 @@ }

@@ -97,3 +97,4 @@ "use strict";

if (status === 'update') {
element.classed('area__stroke ' + Shared.getKey(att, d, _.index, 'colors'), true);
var prevColor = element.attr('class').split(':').slice(1);
element.classed(prevColor, false).classed('area__stroke : ' + Shared.getKey(att, d, _.index, 'colors'), true);
}

@@ -100,0 +101,0 @@ if (status === 'anim') {

@@ -505,72 +505,75 @@ "use strict";

// Get data in flat structure, all level 0's at levelData[0] cominbed etc
var levelData = Shared.flattenValuesLengths(data, [], data.length);
// If local.levels not set then .data not yet called so can't calculate axis height
if (local.levels != null) {
// Get data in flat structure, all level 0's at levelData[0] cominbed etc
var levelData = Shared.flattenValuesLengths(data);
// Loop over each level of data backwards (top to bottom) as each level need previous levels width to calculate its own
for (var levelIndex = levelData.length; levelIndex--;) {
// If top level, then apply outer padding as percentage of width/height
if (levelIndex === local.levels) {
var outerPad = local[local.pD] * local.padding.outer;
local.levelWidth[levelIndex] = local[local.pD] - outerPad * 2;
// Else get previous width from level above
} else {
local.levelWidth[levelIndex] = local.levelWidth[levelIndex + 1];
}
// Loop over each level of data backwards (top to bottom) as each level need previous levels width to calculate its own
for (var levelIndex = levelData.length; levelIndex--;) {
// If top level, then apply outer padding as percentage of width/height
if (levelIndex === local.levels) {
var outerPad = local[local.pD] * local.padding.outer;
local.levelWidth[levelIndex] = local[local.pD] - outerPad * 2;
// Else get previous width from level above
} else {
local.levelWidth[levelIndex] = local.levelWidth[levelIndex + 1];
}
// Used to find biggest dataset at current levelIndex
var biggestDataset = 0;
// Used to find biggest dataset at current levelIndex
var biggestDataset = 0;
// Find biggest dataset at current levelIndex, need to loop through parents to check all dataset lengths for parent.values
if (levelIndex !== local.levels) {
var prevLevel = levelData[levelIndex + 1];
for (var i = prevLevel.length; i--;) {
var prevLength = prevLevel[i].values.length;
if (prevLength > biggestDataset) {
biggestDataset = prevLength;
// If top level then no parent and can 100% say current dataset is the biggest
if (levelIndex === local.levels) {
biggestDataset = data.length;
// Find biggest dataset at current levelIndex, need to loop through parents to check all dataset lengths for parent.values
} else {
var prevLevel = levelData[levelIndex + 1];
for (var i = prevLevel.length; i--;) {
var prevLength = prevLevel[i].values.length;
if (prevLength > biggestDataset) {
biggestDataset = prevLength;
}
}
}
// If top level then no parent and can 100% say current dataset is the biggest
} else {
biggestDataset = data.length;
}
// Level 0 in stacked are all on same x so width doesn't need dividing
if (levelIndex) {
// Calculate inner padding as percentage of levelWidth
var innerPad = local.padding[levelIndex] == null ? local.padding.inner * (att.padding.ratio ? levelWidth : local.width) : local.padding[levelIndex] * (att.padding.ratio ? levelWidth : 1);
// Level 0 in stacked are all on same x so width doesn't need dividing
if (levelIndex) {
// Calculate inner padding as percentage of levelWidth
var innerPad = local.padding[levelIndex] == null ? local.padding.inner * (att.padding.ratio ? levelWidth : local.width) : local.padding[levelIndex] * (att.padding.ratio ? levelWidth : 1);
// Level width is biggestDataset / currentLevel - inner padding
local.levelWidth[levelIndex] -= innerPad * (biggestDataset - 1);
local.levelWidth[levelIndex] /= biggestDataset;
}
var biggest = 0;
var tempBiggest = 0;
var label = '';
for (var j = levelData[levelIndex].length; j--;) {
var tempLabel = Shared.valueFormat(Shared.label(levelData[levelIndex][j], att), levelData[levelIndex][j], att, 'label');
if (tempLabel) {
tempBiggest = Shared.textWidth(tempLabel);
if (tempBiggest > biggest) {
biggest = tempBiggest;
label = tempLabel;
// Level width is biggestDataset / currentLevel - inner padding
local.levelWidth[levelIndex] -= innerPad * (biggestDataset - 1);
local.levelWidth[levelIndex] /= biggestDataset;
}
var biggest = 0;
var tempBiggest = 0;
var label = '';
for (var j = levelData[levelIndex].length; j--;) {
var tempLabel = Shared.valueFormat(Shared.label(levelData[levelIndex][j], att), levelData[levelIndex][j], att, 'label');
if (tempLabel) {
tempBiggest = Shared.textWidth(tempLabel);
if (tempBiggest > biggest) {
biggest = tempBiggest;
label = tempLabel;
}
}
}
var hidden = att.hide["level".concat(levelIndex)] || att.hide["level--".concat(levelIndex)] || att.hide["level--".concat(levelIndex, "--label")] || false;
// Dont add spacing if height 0 / if the level is hidden / if the levelIndex is 0 because this on barstacked is moved onto the bar itself not underneath
if (!tempBiggest || hidden || !levelIndex) {
local.levelHeight[levelIndex] = 0;
} else if (att.axis[local.pA[0]].rotate) {
local.levelHeight[levelIndex] = Shared.textWidth(label) + local.padding.space;
} else {
local.levelHeight[levelIndex] = Shared.textHeight(chart, label, local.levelWidth[levelIndex]) + local.padding.space;
}
height += local.levelHeight[levelIndex];
}
var hidden = att.hide["level".concat(levelIndex)] || att.hide["level--".concat(levelIndex)] || att.hide["level--".concat(levelIndex, "--label")] || false;
// Dont add spacing if height 0 / if the level is hidden / if the levelIndex is 0 because this on barstacked is moved onto the bar itself not underneath
if (!tempBiggest || hidden || !levelIndex) {
local.levelHeight[levelIndex] = 0;
} else if (att.axis[local.pA[0]].rotate) {
local.levelHeight[levelIndex] = Shared.textWidth(label) + local.padding.space;
} else {
local.levelHeight[levelIndex] = Shared.textHeight(chart, label, local.levelWidth[levelIndex]) + local.padding.space;
// Calculate axis label height
if (att.label[scale]) {
height += Shared.textHeight(chart, att.label[scale], local[local.pD]) + local.padding.space;
}
height += local.levelHeight[levelIndex];
}
// Calculate axis label height
if (att.label[scale]) {
height += Shared.textHeight(chart, att.label[scale], local[local.pD]) + local.padding.space;
}
return height;

@@ -577,0 +580,0 @@ }

@@ -48,3 +48,3 @@ "use strict";

}
var levelData = Shared.flattenValuesLengths(data, [], data.length);
var levelData = Shared.flattenValuesLengths(data);
function getMax(d) {

@@ -51,0 +51,0 @@ return Shared.value(d, att);

"use strict";
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -63,3 +69,3 @@ import Shared from '../shared';

chart = local.chart;
var height = this.y(data, data.length);
var height = this.y(data);
height += att.margin.top + att.margin.bottom;

@@ -322,3 +328,3 @@ height -= att.padding.outer; // Removed the padding after the last gantt item

d.attr('transform', function (d, i) {
return "translate(0, " + ((hide ? 0 : att.itemSize * 0.5) + that.y(localData, i)) + ")";
return "translate(0, " + ((hide ? 0 : att.itemSize * 0.5) + that.y(localData.slice(0, i))) + ")";
});

@@ -390,22 +396,22 @@ });

};
Gantt.prototype.y = function (localData, index) {
// Currently all levels create a single item (or two if minmax is enabled) so flatten entire data structure and loop over to get the sum of all itemSize calculations
// The height calculation passes the full data object to dynamically calculate the height of the full chart
// The shared level only passes localData up to the local index so calculate the height of all elements before it relative to it's parent level
Gantt.prototype.y = function (localData) {
var _arr$0$filter;
var local = this.store,
att = local.att;
var sum = 0;
var arr = Shared.flattenValuesLengths(localData, [], index);
for (var level = 0, ilen = arr.length; level < ilen; level++) {
for (var i = 0, jlen = arr[level].length; i < jlen; i++) {
if (level + 1 >= ilen && i >= index) {
break;
}
var hidden = att.hide["level".concat(level)] || att.hide["level--".concat(level)] || false;
if (!hidden) {
sum += att.itemSize + att.padding.outer;
}
if (arr[level][i].minmax && !att.hide.minmax) {
sum += att.itemSize + att.padding.outer;
}
}
}
return sum;
var arr = Shared.flattenValuesLengths(localData);
return (_arr$0$filter = arr[0]
// First grab all level-0 elements that use minmax values to add to the sum
.filter(function (d, level) {
return d.minmax && !att.hide.minmax;
})).concat.apply(_arr$0$filter, _toConsumableArray(arr.filter(function (d, level) {
return !att.hide["level".concat(level)] && !att.hide["level--".concat(level)];
})))
// Then do the sum calculation for all minmax & elements remaining as they all currently have a consistent height across the board
.reduce(function (sum, b) {
return sum + att.itemSize + att.padding.outer;
}, 0);
};

@@ -412,0 +418,0 @@ Gantt.prototype.data = function (value) {

@@ -223,3 +223,4 @@ "use strict";

if (status === 'update') {
element.classed('line__stroke ' + Shared.getKey(att, d, _.index, 'colors') + '-stroked', true);
var prevColor = element.attr('class').split(':').slice(1);
element.classed(prevColor, false).classed('line__stroke : ' + Shared.getKey(att, d, _.index, 'colors') + '-stroked', true);
}

@@ -226,0 +227,0 @@ if (status === 'anim') {

@@ -283,28 +283,23 @@ "use strict";

},
flattenValuesLengths: function flattenValuesLengths(data, levels, index) {
if (!data.length) {
return [];
flattenValuesLengths: function flattenValuesLengths() {
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var arr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
// If this is the first time a level is being processed then create an empty array for it
if (!arr[index]) {
arr[index] = [];
}
if (!levels) {
levels = [];
}
var flatData = [];
for (var i = 0, ilen = data.length; i < ilen; i++) {
if (i >= index) {
continue;
for (var i = 0; i < data.length; i++) {
var d = data[i];
if (d.values) {
this.flattenValuesLengths(d.values, arr, index + 1);
}
if (data[i].values) {
flatData = flatData.concat(data[i].values);
}
arr[index].push(d);
}
if (flatData.length) {
levels.unshift(flatData);
// After unravelling from recursion reverse the list so that level-0 appears first for backwards compatibility
if (!index) {
arr.reverse();
}
if (this.findKey(flatData, 'values')) {
this.flattenValuesLengths(flatData, levels);
}
if (index != null) {
levels.push(data);
}
return levels;
return arr;
},

@@ -311,0 +306,0 @@ // colors/symbols can be array or object, if object this function will use the key by default when picking the color/symbol. key can be overridden to use a differet property. If property is empty it will fall back to using the index again

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc