Socket
Socket
Sign inDemoInstall

@fishawack/lab-d3

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fishawack/lab-d3 - npm Package Compare versions

Comparing version 2.0.6 to 2.0.7

3

_Build/js/base.js

@@ -71,3 +71,4 @@ (function (root, factory) {

y: 'value',
value: 'value'
value: 'value',
label: 'label'
},

@@ -74,0 +75,0 @@ tooltip: {

@@ -140,2 +140,3 @@ (function (root, factory) {

var y = local.padding.space;
var label = Shared.label(d, att);

@@ -147,3 +148,3 @@ if(status === 'enter'){

if(status === 'enter' || status === 'update'){
element.text(d.label);
element.text(label);
}

@@ -158,6 +159,6 @@

x -= (local.textHeight * 0.5);
y += (Shared.textWidth(d.label) * 0.5);
y += (Shared.textWidth(label) * 0.5);
} else {
if(att.axis.x.flip){
y += Shared.textHeight(chart, d.label, local.levelWidth[levelIndex]);
y += Shared.textHeight(chart, label, local.levelWidth[levelIndex]);
}

@@ -182,5 +183,5 @@

x -= (local.textHeight * 0.5);
y += (Shared.textWidth(d.label) * 0.5);
y += (Shared.textWidth(label) * 0.5);
} else {
y += Shared.textHeight(chart, d.label, local.levelWidth[levelIndex]);
y += Shared.textHeight(chart, label, local.levelWidth[levelIndex]);

@@ -260,3 +261,4 @@ if(status === 'enter' || status === 'update'){

for(var j = levelData[levelIndex].length; j--;){
var tempLabel = levelData[levelIndex][j].label;
var tempLabel = Shared.label(levelData[levelIndex][j], att);
if(tempLabel){

@@ -263,0 +265,0 @@ tempBiggest = Shared.textWidth(tempLabel);

@@ -58,2 +58,3 @@ (function (root, factory) {

y: null,
value: null
},

@@ -505,3 +506,3 @@ label: {

local.scale[scale] = d3.scalePoint()
.domain(local.flatData.map(function(d){return Shared[scale](d, att.plot[scale]);}))
.domain(local.flatData.map(function(d){return Shared[scale](d, att);}))
.padding(local.padding.outer);

@@ -515,3 +516,3 @@

local.scale[scale] = d3.scaleBand()
.domain(local.flatData.map(function(d){return Shared[scale](d, att.plot[scale]);}))
.domain(local.flatData.map(function(d){return Shared[scale](d, att);}))
.paddingInner(local.padding.inner)

@@ -526,3 +527,3 @@ .paddingOuter(local.padding.outer);

getLimit = function(minmax){
return (att[minmax][scale]) ? att.parseDate(att[minmax][scale]) : Shared.minmax(minmax, data, scale, att.plot[scale], att.parseDate);
return (att[minmax][scale]) ? att.parseDate(att[minmax][scale]) : Shared.minmax(minmax, data, scale, att);
};

@@ -539,3 +540,3 @@

getLimit = function(minmax){
return (att[minmax][scale] != null) ? att[minmax][scale] : Shared.minmax(minmax, data, scale, att.plot[scale]);
return (att[minmax][scale] != null) ? att[minmax][scale] : Shared.minmax(minmax, data, scale, att);
};

@@ -542,0 +543,0 @@

@@ -86,3 +86,3 @@ (function (root, factory) {

.defined(function(d) {
return Shared[sA](d, att.plot[sA]) !== null;
return Shared[sA](d, att) !== null;
})

@@ -97,3 +97,3 @@ [sA + '0'](function(d){

return local.scale[sA](d.accumulated + Shared[sA](d, att.plot[sA])) + bandwidth;
return local.scale[sA](d.accumulated + Shared[sA](d, att)) + bandwidth;
})

@@ -103,3 +103,3 @@ [pA](function(d) {

return local.scale[pA](Shared[pA](d, att.plot[pA])) + bandwidth;
return local.scale[pA](Shared[pA](d, att)) + bandwidth;
});

@@ -106,0 +106,0 @@

@@ -111,3 +111,3 @@ (function (root, factory) {

_.value = Shared.x(d, att.plot.value);
_.value = Shared.value(d, att);
_.val = local.scale[_.sA](d.percent);

@@ -114,0 +114,0 @@

@@ -87,3 +87,3 @@ (function (root, factory) {

function getMax(d){
return Shared.x(d, att.plot.value);
return Shared.value(d, att);
}

@@ -129,3 +129,3 @@

_.value = Shared.x(d, att.plot.value);
_.value = Shared.value(d, att);

@@ -204,3 +204,3 @@ _.x = width * 0.5;

.data(function(d, i){
var value = Shared.x(d, att.plot.value);
var value = Shared.value(d, att);

@@ -207,0 +207,0 @@ var arr = Array(Math.round(value));

@@ -57,3 +57,3 @@ (function (root, factory) {

_.value = Shared.x(d, att.plot.value);
_.value = Shared.value(d, att);

@@ -60,0 +60,0 @@ _.x = local.scale.x(d[att.plot.x]);

@@ -118,2 +118,7 @@ "use strict";

if(local.autoSize.width || !att.width){
local.autoSize.width = true;
att.width = this.store.chart.node().parentNode.clientWidth;
}
chart.node().parentNode.style.paddingBottom = att.height + 'px';

@@ -169,4 +174,6 @@

_.x = local.scale.x(att.parseDate(Shared.x(d, att.plot.x)[0]));
_.label = Shared.label(d, att);
_.x = local.scale.x(Shared.x(d, att)[0]);
if(_.x < 0){

@@ -176,3 +183,3 @@ _.x = 0;

_.width = local.scale.x(att.parseDate(Shared.x(d, att.plot.x)[1])) - _.x;
_.width = local.scale.x(Shared.x(d, att)[1]) - _.x;

@@ -250,8 +257,8 @@ if(_.x <= 0){

})
.text(d.label)
.text(_.label)
.each(function(){
if(_.x <= 0 && _.width <= 100){
Shared.ellipse(this, d.label, att.width * 0.25);
Shared.ellipse(this, _.label, att.width * 0.25);
} else {
Shared.ellipse(this, d.label, _.width - att.padding.inner * 3);
Shared.ellipse(this, _.label, _.width - att.padding.inner * 3);
}

@@ -290,3 +297,3 @@ });

if(status === 'update'){
element.text(att.formatDate(att.parseDate(Shared.x(d, att.plot.x)[0])));
element.text(att.formatDate(Shared.x(d, att)[0]));
}

@@ -472,3 +479,3 @@

_.x = local.scale.x(Shared.min(d.values, 'x', 'value', att.parseDate));
_.x = local.scale.x(Shared.min(d.values, 'x', att));

@@ -479,3 +486,3 @@ if(_.x < 0){

_.width = local.scale.x(Shared.max(d.values, 'x', 'value', att.parseDate)) - _.x;
_.width = local.scale.x(Shared.max(d.values, 'x', att)) - _.x;

@@ -556,3 +563,5 @@ if(_.x <= 0){

_.x = local.scale.x(Shared.min(d.values, 'x', 'value', att.parseDate));
_.label = Shared.label(d, att);
_.x = local.scale.x(Shared.min(d.values, 'x', att));

@@ -563,3 +572,3 @@ if(_.x < 0){

_.width = Shared.textWidth(d.label);
_.width = Shared.textWidth(_.label);
};

@@ -597,3 +606,3 @@

if(status === 'update'){
element.text(d.label);
element.text(_.label);
}

@@ -600,0 +609,0 @@

@@ -51,6 +51,8 @@ (function (root, factory) {

Key.prototype.buildList = function(element, data, index){
Key.prototype.buildList = function(element, data, level){
var local = this.store, att = local.att, that = this;
var selection = element.selectAll(".level--" + index)
var levelIndex = local.levels - level;
var selection = element.selectAll(".level--" + levelIndex)
.data(data, function(d, i){return (d.key != null) ? d.key : i;});

@@ -61,4 +63,3 @@

var enter = selection.enter()
.append("li")
.attr('class', 'level--' + index);
.append("li");

@@ -68,5 +69,7 @@ var update = enter.merge(selection);

update.html(function(d){
return "<span>" + d.label + "</span>";
return "<span>" + Shared.label(d, att) + "</span>";
})
.each(function(d){
.each(function(d, i){
this.index = i;
element = d3.select(this);

@@ -77,6 +80,13 @@

that.buildList(nest, d.values, index + 1);
that.buildList(nest, d.values, level + 1);
}
});
update.attr('class', function(d, i){
// Pass children[0] just to keep function call consistent with chart.js buildLevel calls
var index = Shared.getPrimaryIndex(this.children[0], att.primaryIndex, local.levels, levelIndex);
return 'level--' + levelIndex + ' ' + att.colors[index % att.colors.length];
});
selection.exit().remove();

@@ -83,0 +93,0 @@ };

@@ -93,6 +93,6 @@ (function (root, factory) {

_.value = Shared[_.sA](d, att.plot[_.sA]);
_.value = Shared[_.sA](d, att);
_.x = local.scale.x(Shared.x(d, att.plot.x)) + (local.scale.x.bandwidth && local.scale.x.bandwidth() * 0.5 || 0);
_.y = local.scale.y(Shared.y(d, att.plot.y)) + (local.scale.y.bandwidth && local.scale.y.bandwidth() * 0.5 || 0);
_.x = local.scale.x(Shared.x(d, att)) + (local.scale.x.bandwidth && local.scale.x.bandwidth() * 0.5 || 0);
_.y = local.scale.y(Shared.y(d, att)) + (local.scale.y.bandwidth && local.scale.y.bandwidth() * 0.5 || 0);

@@ -267,3 +267,3 @@ _.width = local.plotWidth[_.pA];

.defined(function(d) {
return Shared[sA](d, att.plot[sA]) !== null;
return Shared[sA](d, att) !== null;
})

@@ -273,3 +273,3 @@ [sA](function(d) {

return local.scale[sA](Shared[sA](d, att.plot[sA])) + bandwidth;
return local.scale[sA](Shared[sA](d, att)) + bandwidth;
})

@@ -279,3 +279,3 @@ [pA](function(d) {

return local.scale[pA](Shared[pA](d, att.plot[pA])) + bandwidth;
return local.scale[pA](Shared[pA](d, att)) + bandwidth;
});

@@ -282,0 +282,0 @@

@@ -92,6 +92,6 @@ (function (root, factory) {

_.value = Shared.x(d, att.plot.value);
_.value = Shared.value(d, att);
_.x = local.scale.x(Shared.x(d, att.plot.x)) + (local.scale.x.bandwidth && local.scale.x.bandwidth() * 0.5 || 0);
_.y = local.scale.y(Shared.y(d, att.plot.y)) + (local.scale.y.bandwidth && local.scale.y.bandwidth() * 0.5 || 0);
_.x = local.scale.x(Shared.x(d, att)) + (local.scale.x.bandwidth && local.scale.x.bandwidth() * 0.5 || 0);
_.y = local.scale.y(Shared.y(d, att)) + (local.scale.y.bandwidth && local.scale.y.bandwidth() * 0.5 || 0);
_.width = local.plotWidth[_.pA];

@@ -98,0 +98,0 @@

@@ -101,3 +101,3 @@ (function (root, factory) {

if(last != null && last !== Shared.x(d, att.plot.value)){
if(last != null && last !== Shared.value(d, att)){
temp += 'labD3__updated ';

@@ -117,5 +117,5 @@

local.dataLast.set(this, Shared.x(d, att.plot.value));
local.dataLast.set(this, Shared.value(d, att));
element[att.value.html ? 'html' : 'text'](Shared.valueFormat(Shared.x(d, att.plot.value), d, att));
element[att.value.html ? 'html' : 'text'](Shared.valueFormat(Shared.value(d, att), d, att));

@@ -122,0 +122,0 @@ // Needs more testing

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

table: document.getElementById('chart--table'),
p: document.getElementById('chart--p')
p: document.getElementById('chart--p'),
ul: document.getElementById('chart--ul')
};

@@ -46,9 +47,3 @@

myChart.att({
stagger: 0,
coords: [
{
long: -95,
lat: 35
}
]
stagger: 0
})

@@ -55,0 +50,0 @@ .att(chart.att)

@@ -211,19 +211,37 @@ (function (root, factory) {

},
y: function(d, plot){
return d[plot];
getValue: function(d, att, axis){
if(att.scale && att.scale[axis] === 'date'){
if(typeof d[att.plot[axis]] === 'object'){
return d[att.plot[axis]].map(function(d){
return att.parseDate(d);
});
} else {
return att.parseDate(d[att.plot[axis]]);
}
} else {
return d[att.plot[axis]];
}
},
x: function(d, plot){
return d[plot];
y: function(d, att){
return Shared.getValue(d, att, "y");
},
min: function(d, scale, plot, parse){
return Shared.minmax('min', d, scale, plot, parse);
x: function(d, att){
return Shared.getValue(d, att, "x");
},
max: function(d, scale, plot, parse){
return Shared.minmax('max', d, scale, plot, parse);
value: function(d, att){
return Shared.getValue(d, att, "value");
},
minmax: function(minmax, d, scale, plot, parse){
label: function(d, att){
return Shared.getValue(d, att, "label");
},
min: function(d, scale, att){
return Shared.minmax('min', d, scale, att);
},
max: function(d, scale, att){
return Shared.minmax('max', d, scale, att);
},
minmax: function(minmax, d, scale, att){
return d3[minmax](d, function(dd){
var preparsed = false;
if(dd.hasOwnProperty('values')){
return Shared.minmax(minmax, dd.values, scale, plot, parse);
return Shared.minmax(minmax, dd.values, scale, att);
} else {

@@ -233,7 +251,6 @@ var value;

if(typeof dd === 'object' && !Array.isArray(dd)){
value = Shared[scale](dd, plot);
value = Shared[scale](dd, att);
if(dd.hasOwnProperty('minmax')){
value = Shared[minmax]([value, dd.minmax], scale, plot, parse);
preparsed = true;
value = Shared[minmax]([value, dd.minmax], scale, att);
} else if(dd.hasOwnProperty('accumulated')){

@@ -249,6 +266,2 @@ value += dd.accumulated;

}
if(!preparsed && parse){
return parse(value);
}

@@ -255,0 +268,0 @@ return value;

@@ -32,7 +32,6 @@ var Key = require('key');

it('single level data should create container <ul> with 2 child <li> tags', function () {
it('single level data should create 2 child <li> tags', function () {
myChart.data(data[1]).init().render();
expect(select('ul').length).to.equal(1);
expect(select('li').length).to.equal(2);
expect(select('#chart-3 > li').length).to.equal(2);
});

@@ -47,4 +46,5 @@

expect(select('#chart-3 > li > ul').length).to.equal(2);
expect(select('#chart-3 > li > ul > li').length).to.equal(4);
expect(select('#chart-3 > li:nth-child(1) > ul > li').length).to.equal(2);
expect(select('#chart-3 > li:nth-child(1) > ul > li').length).to.equal(2);
});
});
var Shared = require('shared');
var d3 = require('d3');
var Chart = require('chart');
describe('shared.js', function () {
var data,
parseDate = d3.timeParse("%Y-%m-%d"),
formatDate = d3.timeFormat("%Y-%m-%d");
myChart,
att;

@@ -18,5 +18,8 @@ before(function(){

);
});
beforeEach(function(){
fixture.load('chart.html');
myChart = new Chart('#chart-1');
att = myChart.att();
});

@@ -67,10 +70,16 @@

it('x should return value if no plot specified', function () {
expect(Shared.x(data[1][0], 'value')).to.be.equal(10);
expect(Shared.x(data[4][0].values[1], 'x')).to.be.equal(30);
att.plot.x = 'value';
expect(Shared.x(data[1][0], att)).to.be.equal(10);
att.plot.x = 'x';
expect(Shared.x(data[4][0].values[1], att)).to.be.equal(30);
});
// Y
it('x should return value if no plot specified', function () {
expect(Shared.y(data[1][0], 'value')).to.be.equal(10);
expect(Shared.y(data[4][0].values[0], 'y')).to.be.equal(20);
it('y should return value if no plot specified', function () {
att.plot.y = 'value';
expect(Shared.y(data[1][0], att)).to.be.equal(10);
att.plot.y = 'y';
expect(Shared.y(data[4][0].values[0], att)).to.be.equal(20);
});

@@ -80,7 +89,11 @@

it('min should return lowest value with plot value given', function () {
expect(Shared.min(data[1], 'x', 'value')).to.be.equal(10);
expect(formatDate(Shared.min(data[2], 'x', 'value', parseDate))).to.be.equal("2016-06-05");
expect(formatDate(Shared.min(data[3], 'x', 'value', parseDate))).to.be.equal("2017-06-05");
expect(Shared.min(data[4], 'x', 'x')).to.be.equal(10);
expect(Shared.min(data[4], 'y', 'y')).to.be.equal(20);
att.plot.x = 'value';
expect(Shared.min(data[1], 'x', att)).to.be.equal(10);
expect(Shared.min(data[2], 'x', att)).to.be.equal("2016-06-05");
expect(Shared.min(data[3], 'x', att)).to.be.equal("2017-06-05");
att.plot.x = 'x';
att.plot.y = 'y';
expect(Shared.min(data[4], 'x', att)).to.be.equal(10);
expect(Shared.min(data[4], 'y', att)).to.be.equal(20);
});

@@ -90,7 +103,11 @@

it('max should return highest value with plot value given', function () {
expect(Shared.max(data[1], 'x', 'value')).to.be.equal(20);
expect(formatDate(Shared.max(data[2], 'x', 'value', parseDate))).to.be.equal("2018-09-05");
expect(formatDate(Shared.max(data[3], 'x', 'value', parseDate))).to.be.equal("2018-09-25");
expect(Shared.max(data[4], 'x', 'x')).to.be.equal(60);
expect(Shared.max(data[4], 'y', 'y')).to.be.equal(70);
att.plot.x = 'value';
expect(Shared.max(data[1], 'x', att)).to.be.equal(20);
expect(Shared.max(data[2], 'x', att)).to.be.equal("2018-09-05");
expect(Shared.max(data[3], 'x', att)).to.be.equal("2018-09-25");
att.plot.x = 'x';
att.plot.y = 'y';
expect(Shared.max(data[4], 'x', att)).to.be.equal(60);
expect(Shared.max(data[4], 'y', att)).to.be.equal(70);
});

@@ -97,0 +114,0 @@

{
"name": "@fishawack/lab-d3",
"version": "2.0.6",
"version": "2.0.7",
"description": "Abstract layer built on top of d3",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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