Socket
Socket
Sign inDemoInstall

d3-funnel

Package Overview
Dependencies
18
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.2.2-alpha.0

.idea/codeStyles/codeStyleConfig.xml

26

gulpfile.js

@@ -36,16 +36,16 @@ const gulp = require('gulp');

gulp.task('test-mocha', ['compile-test'], () => (
gulp.task('test-mocha', gulp.series('compile-test', () => (
gulp.src(['test/test.html'])
.pipe(mocha({ reporter: 'spec' }))
));
)));
gulp.task('test', ['test-format', 'test-mocha']);
gulp.task('test', gulp.series('test-format', 'test-mocha'));
gulp.task('build', ['test'], () => (
gulp.task('build', gulp.series('test', () => (
gulp.src(['./src/index.js'])
.pipe(webpackStream(webpackConfig, webpack))
.pipe(gulp.dest('./dist/'))
));
)));
gulp.task('build-min', ['build'], () => (
gulp.task('build-min', gulp.series('build', () => (
gulp.src(['./src/index.js'])

@@ -59,3 +59,3 @@ .pipe(webpackStream({

.pipe(gulp.dest('./dist/'))
));
)));

@@ -89,10 +89,10 @@ gulp.task('build-examples-style', () => (

gulp.task('examples', ['build-examples-style', 'build-examples-script', 'build-examples-html'], () => {
gulp.task('examples', gulp.series(gulp.parallel('build-examples-style', 'build-examples-script', 'build-examples-html'), () => {
browserSync.init({ server: './examples/dist' });
gulp.watch(['./src/**/*.js', './examples/src/**/*.js'], ['build-examples-script']);
gulp.watch(['./examples/src/scss/**/*.scss'], ['build-examples-style']);
gulp.watch(['./examples/src/**/*.html'], ['build-examples-html']).on('change', browserSync.reload);
});
gulp.watch(['./src/**/*.js', './examples/src/**/*.js']).on('change', gulp.series('build-examples-script'));
gulp.watch(['./examples/src/scss/**/*.scss']).on('change', gulp.series('build-examples-style'));
gulp.watch(['./examples/src/**/*.html']).on('change', gulp.series('build-examples-html', browserSync.reload));
}));
gulp.task('default', ['build-min']);
gulp.task('default', gulp.series('build-min'));
{
"name": "d3-funnel",
"version": "1.2.1",
"version": "1.2.2-alpha.0",
"description": "A library for rendering SVG funnel charts using D3.js",

@@ -32,10 +32,11 @@ "author": "Jake Zatecky",

"babel-loader": "^8.0.0",
"browser-sync": "^2.18.6",
"browser-sync": "^2.26.3",
"chai": "^4.0.1",
"chai-spies": "^1.0.0",
"d3": "^5.5.0",
"eslint": "^5.0.0",
"eslint-config-takiyon": "^0.3.1",
"eslint-import-resolver-webpack": "^0.10.1",
"eslint-import-resolver-webpack": "^0.11.0",
"eslint-plugin-import": "^2.7.0",
"gulp": "^3.9.0",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^6.0.0",

@@ -47,3 +48,3 @@ "gulp-eslint": "^5.0.0",

"gulp-sass": "^4.0.1",
"gulp-scss-lint": "^0.7.0",
"gulp-scss-lint": "^1.0.0",
"lodash": "^4.17.10",

@@ -55,3 +56,6 @@ "mocha": "^5.0.0",

"dependencies": {
"d3": "^5.5.0",
"d3-array": "^2.0.3",
"d3-ease": "^1.0.5",
"d3-scale": "^2.1.2",
"d3-scale-chromatic": "^1.3.3",
"d3-selection": "^1.0.1",

@@ -58,0 +62,0 @@ "d3-selection-multi": "^1.0.0",

@@ -7,2 +7,3 @@ # d3-funnel

[![devDependency Status](https://david-dm.org/jakezatecky/d3-funnel/dev-status.svg?style=flat-square)](https://david-dm.org/jakezatecky/d3-funnel?type=dev)
[![Greenkeeper badge](https://badges.greenkeeper.io/jakezatecky/d3-funnel.svg?style=flat-square)](https://greenkeeper.io/)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/jakezatecky/d3-funnel/master/LICENSE.txt)

@@ -9,0 +10,0 @@

import shortid from 'shortid';
import {
easeLinear,
range,
scaleOrdinal,
schemeCategory10,
} from 'd3';
import { linear as easeLinear } from 'd3-ease/src/linear';
import range from 'd3-array/src/range';
import scaleOrdinal from 'd3-scale/src/ordinal';
import schemeCategory10 from 'd3-scale-chromatic/src/categorical/category10';
import { select } from 'd3-selection';

@@ -9,0 +7,0 @@ import 'd3-selection-multi';

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

import _ from 'lodash';
import * as d3 from 'd3';
import { cloneDeep } from 'lodash';
import {
range,
select,
selectAll,
scaleOrdinal,
schemeCategory10,
} from 'd3';
import chai from 'chai';

@@ -16,3 +22,3 @@ import spies from 'chai-spies';

function getSvg() {
return d3.select('#funnel').selectAll('svg');
return select('#funnel').selectAll('svg');
}

@@ -67,3 +73,3 @@

const defaults = _.clone(D3Funnel.defaults, true);
const defaults = cloneDeep(D3Funnel.defaults);

@@ -73,6 +79,6 @@ describe('D3Funnel', () => {

// Reset any styles
d3.select('#funnel').attr('style', null);
select('#funnel').attr('style', null);
// Reset defaults
D3Funnel.defaults = _.clone(defaults, true);
D3Funnel.defaults = cloneDeep(defaults);

@@ -161,5 +167,5 @@ // Clear out sandbox

assert.equal('Node A: One', d3.select(texts[0]).text());
assert.equal('Node B: 2', d3.select(texts[1]).text());
assert.equal('Node C: Three', d3.select(texts[2]).text());
assert.equal('Node A: One', select(texts[0]).text());
assert.equal('Node B: 2', select(texts[1]).text());
assert.equal('Node C: Three', select(texts[2]).text());
});

@@ -176,3 +182,3 @@

assert.equal('Node B: 2', d3.select(texts[0]).text());
assert.equal('Node B: 2', select(texts[0]).text());
assert.equal(undefined, texts[1]);

@@ -190,8 +196,8 @@ });

const paths = getSvg().selectAll('path').nodes();
const colorScale = d3.scaleOrdinal(d3.schemeCategory10).domain(d3.range(0, 10));
const colorScale = scaleOrdinal(schemeCategory10).domain(range(0, 10));
assert.equal('#111', d3.select(paths[0]).attr('fill'));
assert.equal('#222', d3.select(paths[1]).attr('fill'));
assert.equal(colorScale(2), d3.select(paths[2]).attr('fill'));
assert.equal('#444', d3.select(paths[3]).attr('fill'));
assert.equal('#111', select(paths[0]).attr('fill'));
assert.equal('#222', select(paths[1]).attr('fill'));
assert.equal(colorScale(2), select(paths[2]).attr('fill'));
assert.equal('#444', select(paths[3]).attr('fill'));
});

@@ -209,10 +215,10 @@

assert.equal('#111', d3.select(texts[0]).attr('fill'));
assert.equal('#222', d3.select(texts[1]).attr('fill'));
assert.equal('#fff', d3.select(texts[2]).attr('fill'));
assert.equal('#444', d3.select(texts[3]).attr('fill'));
assert.equal('#111', select(texts[0]).attr('fill'));
assert.equal('#222', select(texts[1]).attr('fill'));
assert.equal('#fff', select(texts[2]).attr('fill'));
assert.equal('#444', select(texts[3]).attr('fill'));
});
it('should remove other elements from container', () => {
const container = d3.select('#funnel');
const container = select('#funnel');
const funnel = getFunnel();

@@ -234,3 +240,3 @@

it('should remove inner text from container', () => {
const container = d3.select('#funnel');
const container = select('#funnel');
const funnel = getFunnel();

@@ -275,3 +281,3 @@

assert.isTrue(d3.select('#funnel text').attr('fill').indexOf('#777') > -1);
assert.isTrue(select('#funnel text').attr('fill').indexOf('#777') > -1);
});

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

['width', 'height'].forEach((direction) => {
d3.select('#funnel').style(direction, '250px');
select('#funnel').style(direction, '250px');

@@ -317,3 +323,3 @@ getFunnel().draw(getBasicData());

['width', 'height'].forEach((direction) => {
d3.select('#funnel').style(direction, '200px');
select('#funnel').style(direction, '200px');

@@ -333,3 +339,3 @@ getFunnel().draw(getBasicData(), {

it('should default to the container\'s height', () => {
d3.select('#funnel').style('height', '250px');
select('#funnel').style('height', '250px');

@@ -352,3 +358,3 @@ getFunnel().draw(getBasicData());

it('should set the funnel\'s percentage height to the specified amount', () => {
d3.select('#funnel').style('height', '300px');
select('#funnel').style('height', '300px');

@@ -374,3 +380,3 @@ getFunnel().draw(getBasicData(), {

assert.equal(100, getPathBottomWidth(d3.select('path')));
assert.equal(100, getPathBottomWidth(select('path')));
});

@@ -393,3 +399,3 @@ });

const paths = d3.selectAll('path').nodes();
const paths = selectAll('path').nodes();

@@ -418,3 +424,3 @@ assert.equal(150, paths[1].getBBox().width);

const paths = d3.selectAll('path').nodes();
const paths = selectAll('path').nodes();

@@ -445,3 +451,3 @@ assert.equal(150, paths[2].getBBox().width);

const paths = d3.selectAll('path').nodes();
const paths = selectAll('path').nodes();

@@ -464,6 +470,6 @@ assert.equal(120, paths[4].getBBox().width);

const paths = d3.selectAll('path').nodes();
const paths = selectAll('path').nodes();
assert.equal(200, getPathTopWidth(d3.select(paths[0])));
assert.equal(100, getPathBottomWidth(d3.select(paths[1])));
assert.equal(200, getPathTopWidth(select(paths[0])));
assert.equal(100, getPathBottomWidth(select(paths[1])));
});

@@ -483,6 +489,6 @@

const paths = d3.selectAll('path').nodes();
const paths = selectAll('path').nodes();
assert.equal(100, getPathTopWidth(d3.select(paths[0])));
assert.equal(200, getPathBottomWidth(d3.select(paths[1])));
assert.equal(100, getPathTopWidth(select(paths[0])));
assert.equal(200, getPathBottomWidth(select(paths[1])));
});

@@ -501,3 +507,3 @@ });

assert.equal(2, d3.selectAll('#funnel path').nodes().length);
assert.equal(2, selectAll('#funnel path').nodes().length);
});

@@ -514,4 +520,4 @@

const paths = d3.selectAll('#funnel path').nodes();
const quadraticPaths = paths.filter(path => d3.select(path).attr('d').indexOf('Q') > -1);
const paths = selectAll('#funnel path').nodes();
const quadraticPaths = paths.filter(path => select(path).attr('d').indexOf('Q') > -1);

@@ -533,6 +539,6 @@ assert.equal(paths.length, quadraticPaths.length);

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.equal(150, getPathHeight(d3.select(paths[0])));
assert.equal(150, getPathHeight(d3.select(paths[1])));
assert.equal(150, getPathHeight(select(paths[0])));
assert.equal(150, getPathHeight(select(paths[1])));
});

@@ -553,6 +559,6 @@

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.equal(100, parseInt(getPathHeight(d3.select(paths[0])), 10));
assert.equal(200, parseInt(getPathHeight(d3.select(paths[1])), 10));
assert.equal(100, parseInt(getPathHeight(select(paths[0])), 10));
assert.equal(200, parseInt(getPathHeight(select(paths[1])), 10));
});

@@ -577,5 +583,5 @@

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.equal(-1, d3.select(paths[3]).attr('d').indexOf('NaN'));
assert.equal(-1, select(paths[3]).attr('d').indexOf('NaN'));
});

@@ -608,4 +614,4 @@

d3.selectAll('path').nodes().forEach((node) => {
const definition = String(d3.select(node).attr('d'));
selectAll('path').nodes().forEach((node) => {
const definition = String(select(node).attr('d'));

@@ -629,6 +635,6 @@ assert.equal(false, definition.indexOf('NaN') > -1 || definition.indexOf('Infinity') > -1);

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.equal(150, getPathHeight(d3.select(paths[0])));
assert.equal(150, getPathHeight(d3.select(paths[1])));
assert.equal(150, getPathHeight(select(paths[0])));
assert.equal(150, getPathHeight(select(paths[1])));
});

@@ -653,8 +659,8 @@ });

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.equal(parseFloat(getPathTopWidth(d3.select(paths[0]))), 100);
assert.equal(parseFloat(getPathTopWidth(d3.select(paths[1]))), 55);
assert.equal(parseFloat(getPathTopWidth(d3.select(paths[2]))), 42);
assert.equal(parseFloat(getPathTopWidth(d3.select(paths[3]))), 74);
assert.equal(parseFloat(getPathTopWidth(select(paths[0]))), 100);
assert.equal(parseFloat(getPathTopWidth(select(paths[1]))), 55);
assert.equal(parseFloat(getPathTopWidth(select(paths[2]))), 42);
assert.equal(parseFloat(getPathTopWidth(select(paths[3]))), 74);
});

@@ -677,6 +683,6 @@

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.equal(parseFloat(getPathTopWidth(d3.select(paths[3]))), 74);
assert.equal(parseFloat(getPathBottomWidth(d3.select(paths[3]))), 74);
assert.equal(parseFloat(getPathTopWidth(select(paths[3]))), 74);
assert.equal(parseFloat(getPathBottomWidth(select(paths[3]))), 74);
});

@@ -695,6 +701,6 @@

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.equal(parseFloat(getPathTopWidth(d3.select(paths[0]))), 100);
assert.equal(parseFloat(getPathBottomWidth(d3.select(paths[1]))), 40);
assert.equal(parseFloat(getPathTopWidth(select(paths[0]))), 100);
assert.equal(parseFloat(getPathBottomWidth(select(paths[1]))), 40);
});

@@ -715,3 +721,3 @@ });

// draw 2 path for each data point
assert.equal(4, d3.selectAll('#funnel path').nodes().length);
assert.equal(4, selectAll('#funnel path').nodes().length);
});

@@ -732,8 +738,8 @@

const paths = d3.selectAll('path').nodes();
const paths = selectAll('path').nodes();
const APathFullWidth = getPathTopWidth(d3.select(paths[0]));
const APathOverlayWidth = getPathTopWidth(d3.select(paths[1]));
const BPathFullWidth = getPathTopWidth(d3.select(paths[2]));
const BPathOverlayWidth = getPathTopWidth(d3.select(paths[3]));
const APathFullWidth = getPathTopWidth(select(paths[0]));
const APathOverlayWidth = getPathTopWidth(select(paths[1]));
const BPathFullWidth = getPathTopWidth(select(paths[2]));
const BPathOverlayWidth = getPathTopWidth(select(paths[3]));

@@ -766,4 +772,4 @@ assert.equal(10, Math.round((APathOverlayWidth / APathFullWidth) * 100));

assert.equal('#111', d3.select(paths[0]).attr('fill'));
assert.equal('#222', d3.select(paths[1]).attr('fill'));
assert.equal('#111', select(paths[0]).attr('fill'));
assert.equal('#222', select(paths[1]).attr('fill'));
});

@@ -785,4 +791,4 @@

assert.equal('#111', d3.select(paths[0]).attr('fill'));
assert.equal('#222', d3.select(paths[1]).attr('fill'));
assert.equal('#111', select(paths[0]).attr('fill'));
assert.equal('#222', select(paths[1]).attr('fill'));
});

@@ -807,5 +813,5 @@ });

// https://bugs.webkit.org/show_bug.cgi?id=83438
assert.equal(1, d3.selectAll(`#funnel defs #${id}-gradient-0`).nodes().length);
assert.equal(1, selectAll(`#funnel defs #${id}-gradient-0`).nodes().length);
assert.equal(`url(#${id}-gradient-0)`, d3.select('#funnel path').attr('fill'));
assert.equal(`url(#${id}-gradient-0)`, select('#funnel path').attr('fill'));
});

@@ -818,3 +824,3 @@

assert.isTrue(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(
d3.select('#funnel path').attr('fill'),
select('#funnel path').attr('fill'),
));

@@ -839,6 +845,6 @@ });

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.isAbove(parseFloat(getPathHeight(d3.select(paths[0]))), 10);
assert.isAbove(parseFloat(getPathHeight(d3.select(paths[1]))), 10);
assert.isAbove(parseFloat(getPathHeight(select(paths[0]))), 10);
assert.isAbove(parseFloat(getPathHeight(select(paths[1]))), 10);
});

@@ -860,5 +866,5 @@

const paths = d3.selectAll('#funnel path').nodes();
const paths = selectAll('#funnel path').nodes();
assert.isBelow(parseFloat(getPathHeight(d3.select(paths[0]))), 290);
assert.isBelow(parseFloat(getPathHeight(select(paths[0]))), 290);
});

@@ -880,6 +886,6 @@ });

d3.select('#funnel path').node().dispatchEvent(event);
select('#funnel path').node().dispatchEvent(event);
// #fff * -1/5 => #cccccc
assert.equal('#cccccc', d3.select('#funnel path').attr('fill'));
assert.equal('#cccccc', select('#funnel path').attr('fill'));
});

@@ -894,3 +900,3 @@ });

assert.equal(1, d3.selectAll('#funnel text').size());
assert.equal(1, selectAll('#funnel text').size());
});

@@ -903,3 +909,3 @@

assert.equal(0, d3.selectAll('#funnel text').size());
assert.equal(0, selectAll('#funnel text').size());
});

@@ -916,3 +922,3 @@ });

assert.equal('Open Sans', d3.select('#funnel text').attr('font-family'));
assert.equal('Open Sans', select('#funnel text').attr('font-family'));
});

@@ -929,3 +935,3 @@ });

assert.equal('16px', d3.select('#funnel text').attr('font-size'));
assert.equal('16px', select('#funnel text').attr('font-size'));
});

@@ -942,3 +948,3 @@ });

assert.isTrue(d3.select('#funnel text').attr('fill').indexOf('#777') > -1);
assert.isTrue(select('#funnel text').attr('fill').indexOf('#777') > -1);
});

@@ -958,3 +964,3 @@ });

// https://github.com/joyent/node/issues/4689
assert.equal('Node 1000 1000', d3.select('#funnel text').text());
assert.equal('Node 1000 1000', select('#funnel text').text());
});

@@ -969,6 +975,6 @@

const tspans = d3.selectAll('#funnel text tspan').nodes();
const tspans = selectAll('#funnel text tspan').nodes();
assert.equal('Node', d3.select(tspans[0]).text());
assert.equal('1000', d3.select(tspans[1]).text());
assert.equal('Node', select(tspans[0]).text());
assert.equal('1000', select(tspans[1]).text());
});

@@ -986,7 +992,7 @@

const tspans = d3.selectAll('#funnel text tspan').nodes();
const tspans = selectAll('#funnel text tspan').nodes();
assert.equal(-20, d3.select(tspans[0]).attr('dy'));
assert.equal(20, d3.select(tspans[1]).attr('dy'));
assert.equal(20, d3.select(tspans[2]).attr('dy'));
assert.equal(-20, select(tspans[0]).attr('dy'));
assert.equal(20, select(tspans[1]).attr('dy'));
assert.equal(20, select(tspans[2]).attr('dy'));
});

@@ -1001,3 +1007,3 @@

assert.equal('Node/1000/null', d3.select('#funnel text').text());
assert.equal('Node/1000/null', select('#funnel text').text());
});

@@ -1017,5 +1023,5 @@ });

d3.select('#funnel path').node().dispatchEvent(event);
select('#funnel path').node().dispatchEvent(event);
assert.notEqual(null, d3.select('#funnel .d3-funnel-tooltip').node());
assert.notEqual(null, select('#funnel .d3-funnel-tooltip').node());
});

@@ -1035,6 +1041,6 @@

d3.select('#funnel path').node().dispatchEvent(mouseMove);
d3.select('#funnel path').node().dispatchEvent(mouseOut);
select('#funnel path').node().dispatchEvent(mouseMove);
select('#funnel path').node().dispatchEvent(mouseOut);
assert.equal(null, d3.select('#funnel .d3-funnel-tooltip').node());
assert.equal(null, select('#funnel .d3-funnel-tooltip').node());
});

@@ -1055,5 +1061,5 @@ });

d3.select('#funnel path').node().dispatchEvent(event);
select('#funnel path').node().dispatchEvent(event);
assert.equal('Node - 1000', d3.select('#funnel .d3-funnel-tooltip').text());
assert.equal('Node - 1000', select('#funnel .d3-funnel-tooltip').text());
});

@@ -1084,7 +1090,7 @@ });

d3.select('#funnel path').node().dispatchEvent(event);
select('#funnel path').node().dispatchEvent(event);
chai.expect(spy).to.have.been.called.once.with({
index: 0,
node: d3.select('#funnel path').node(),
node: select('#funnel path').node(),
label: 'Node',

@@ -1107,3 +1113,3 @@ value: 1000,

d3.select('#funnel path').node().dispatchEvent(event);
select('#funnel path').node().dispatchEvent(event);
});

@@ -1121,3 +1127,3 @@

assert.equal('pointer', d3.select('#funnel path').style('cursor'));
assert.equal('pointer', select('#funnel path').style('cursor'));
});

@@ -1124,0 +1130,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc