New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

barchart

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barchart - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

25

gulpfile.js
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var gutil = require('gulp-util');

@@ -13,3 +14,3 @@ var less = require('gulp-less');

gulp.task('dev', ['clean', 'static-files', 'build', 'less', 'watch'], function(done) {
gulp.task('dev', ['clean', 'lint', 'static-files', 'build', 'less', 'watch'], function(done) {
var app = connect();

@@ -36,2 +37,24 @@ app.use(connect.static('build'));

gulp.task('lint', ['clean'], function() {
return gulp.src('index.js')
.pipe(jshint({
node: true,
browser: true,
undef: true,
unused: 'vars',
curly: true,
freeze: true,
latedef: true,
noarg: true,
trailing: true,
nonew: true,
newcap: false,
nonbsp: true,
maxdepth: 5,
maxcomplexity: 10,
predef: ["alert", "confirm", "prompt", "Q", "_", "d3", "define"]
}))
.pipe(jshint.reporter('default'));
});
gulp.task('static-files', ['clean'], function() {

@@ -38,0 +61,0 @@ return gulp.src('static/**/*')

112

index.js

@@ -12,3 +12,3 @@ //TODO unit tests

(function() {
(function(global) {
function defineBarChart(d3, _, Q) {

@@ -27,6 +27,2 @@ function getId(d, i) {

function getLabelInside(d, i) {
return d.__chartLabelInside;
}
function px(fn) {

@@ -61,9 +57,9 @@ return function() {

function BarChart(options) {
function Chart(options) {
if (options) {
_.extend(this, options);
}
};
}
BarChart.prototype.data = function(data) {
Chart.prototype.data = function(data) {
if (!_.isArray(data)) {

@@ -83,2 +79,4 @@ console.warn('Data should be an array.');

this.barColors = this.palette(this.numDatasets);
}
if (!this.labelInsideColors || this.labelInsideColors.length !== this.numDatasets) {
this.labelInsideColors = this.contrastingGrayPalette(this.barColors);

@@ -93,3 +91,3 @@ }

var isNumber = _.isNumber(point);
var obj = isNumber ? {} : point;
var obj = isNumber ? {} : _.clone(point);

@@ -114,3 +112,3 @@ //create ID prefixed with dataset number

BarChart.prototype.palette = function(size, seed) {
Chart.prototype.palette = function(size, seed) {
seed = seed || d3.hsl(_.random(360), 0.4, 0.7);

@@ -128,3 +126,3 @@ var start = d3.hsl(seed);

BarChart.prototype.contrastingGrayPalette = function(colors) {
Chart.prototype.contrastingGrayPalette = function(colors) {
return _.map(colors, function(color) {

@@ -136,32 +134,32 @@ color = d3.hsl(color);

BarChart.prototype.animationDelay = function(d, i) {
Chart.prototype.animationDelay = function(d, i) {
return i * 100;
};
BarChart.prototype.container = null;
BarChart.prototype.hasRendered = false;
BarChart.prototype.isAnimated = true;
BarChart.prototype.animationDuration = 600;
BarChart.prototype.autoScale = false;
BarChart.prototype.heightScaleType = 'linear';
BarChart.prototype.barColors = null;
BarChart.prototype.barSpacing = 2;
BarChart.prototype.groupSpacing = 8;
BarChart.prototype.chartPadding = 0;
BarChart.prototype.numDatasets = 0;
BarChart.prototype.minimum = null;
BarChart.prototype.maximum = null;
BarChart.prototype.dataIdKey = null;
BarChart.prototype.dataValueKey = 'value';
BarChart.prototype.height = 300;
BarChart.prototype.width = 700;
BarChart.prototype.labelTopColors = '#003D4C';
BarChart.prototype.labelInsideColors = '#FFF';
BarChart.prototype.labelInsideKey = 'value';
BarChart.prototype.labelPadding = 3;
BarChart.prototype.labelSize = 16;
BarChart.prototype.labelTopKey = 'name';
Chart.prototype.container = null;
Chart.prototype.hasRendered = false;
Chart.prototype.isAnimated = true;
Chart.prototype.animationDuration = 600;
Chart.prototype.autoScale = false;
Chart.prototype.heightScaleType = 'linear';
Chart.prototype.barColors = null;
Chart.prototype.barSpacing = 2;
Chart.prototype.groupSpacing = 8;
Chart.prototype.chartPadding = 0;
Chart.prototype.numDatasets = 0;
Chart.prototype.minimum = null;
Chart.prototype.maximum = null;
Chart.prototype.dataIdKey = null;
Chart.prototype.dataValueKey = 'value';
Chart.prototype.height = 300;
Chart.prototype.width = 700;
Chart.prototype.labelTopColors = '#003D4C';
Chart.prototype.labelInsideColors = null;
Chart.prototype.labelInsideKey = 'value';
Chart.prototype.labelPadding = 3;
Chart.prototype.labelSize = 16;
Chart.prototype.labelTopKey = 'name';
//TODO break this down into separate functions so you can override individual calculations
BarChart.prototype.computeBoundaries = function() {
Chart.prototype.computeBoundaries = function() {
var chart = this;

@@ -221,3 +219,3 @@

BarChart.prototype.render = function() {
Chart.prototype.render = function() {
if (!this.$container) {

@@ -240,3 +238,3 @@ if (this.container === undefined) {

if (this._data === undefined || this._data.length == 0) {
if (this._data === undefined || this._data.length === 0) {
this.$container.classed('no-data', true);

@@ -265,4 +263,4 @@ this.svg.remove();

if (d3.scale[this.heightScaleType] === undefined) {
console.warn('Invalid heightScaleType "' + this.heightScaleType + '", using "' + BarChart.prototype.heightScaleType + '" instead.');
this.heightScaleType = BarChart.prototype.heightScaleType;
console.warn('Invalid heightScaleType "' + this.heightScaleType + '", using "' + Chart.prototype.heightScaleType + '" instead.');
this.heightScaleType = Chart.prototype.heightScaleType;
}

@@ -297,3 +295,3 @@

BarChart.prototype.addNewBars = function(bars) {
Chart.prototype.addNewBars = function(bars) {
var enter = bars.enter();

@@ -314,3 +312,3 @@

BarChart.prototype.addNewLabelsTop = function(labelsTop) {
Chart.prototype.addNewLabelsTop = function(labelsTop) {
var enter = labelsTop.enter();

@@ -335,3 +333,3 @@

BarChart.prototype.addNewLabelsInside = function(labelsInside) {
Chart.prototype.addNewLabelsInside = function(labelsInside) {
var enter = labelsInside.enter();

@@ -362,3 +360,3 @@

BarChart.prototype.removeOldBars = function(bars) {
Chart.prototype.removeOldBars = function(bars) {
var exit = bars.exit();

@@ -379,3 +377,3 @@

BarChart.prototype.removeOldLabelsTop = function(labelsTop) {
Chart.prototype.removeOldLabelsTop = function(labelsTop) {
var exit = labelsTop.exit();

@@ -396,3 +394,3 @@

BarChart.prototype.removeOldLabelsInside = function(labelsInside) {
Chart.prototype.removeOldLabelsInside = function(labelsInside) {
var exit = labelsInside.exit();

@@ -413,3 +411,3 @@

BarChart.prototype.transitionBars = function(bars) {
Chart.prototype.transitionBars = function(bars) {
if (bars.empty()) {

@@ -430,3 +428,3 @@ return Q(bars);

BarChart.prototype.transitionLabelsTop = function(labelsTop) {
Chart.prototype.transitionLabelsTop = function(labelsTop) {
if (labelsTop.empty()) {

@@ -446,3 +444,3 @@ return Q(labelsTop);

BarChart.prototype.transitionLabelsInside = function(labelsInside) {
Chart.prototype.transitionLabelsInside = function(labelsInside) {
var chart = this;

@@ -489,5 +487,5 @@

BarChart.prototype.LN10x2 = Math.LN10 * 2;
Chart.prototype.LN10x2 = Math.LN10 * 2;
//TODO ability to parameterize based on domain of dataset?
BarChart.prototype.prettifyNumber = function(num) {
Chart.prototype.prettifyNumber = function(num) {
var suffixes = ' kMBT';

@@ -501,3 +499,3 @@ var abs = Math.abs(num);

//average with magnitude of num + 1 to correct for floating-point error
mag = Math.floor((Math.log(abs) + Math.log(abs + 1)) / (BarChart.prototype.LN10x2));
mag = Math.floor((Math.log(abs) + Math.log(abs + 1)) / (Chart.prototype.LN10x2));
}

@@ -524,3 +522,3 @@

BarChart.prototype.transitionPromise = function(transition) {
Chart.prototype.transitionPromise = function(transition) {
var defer = Q.defer();

@@ -540,4 +538,4 @@ var count = 0;

return BarChart;
};
return Chart;
}

@@ -551,4 +549,4 @@ if (typeof define === 'function' && define.amd) {

else {
BarChart = defineBarChart(d3, _, Q);
global.BarChart = defineBarChart(d3, _, Q);
}
}());
}(window || global));
{
"name": "barchart",
"version": "0.6.0",
"version": "0.6.1",
"description": "make some barcharts",

@@ -30,3 +30,4 @@ "main": "index.js",

"gulp-concat": "~2.3.3",
"gulp-less": "~1.3.1"
"gulp-less": "~1.3.1",
"gulp-jshint": "~1.9.0"
},

@@ -33,0 +34,0 @@ "dependencies": {

@@ -87,3 +87,3 @@ ## barchart

Color(s) to fill the bars with (also accepts an array for multi-dataset support) (default: `#00AB8E`).
Color(s) to fill the bars with (also accepts an array for multi-dataset support) (default: generated).

@@ -116,3 +116,3 @@ #### barSpacing

Text color of the labels inside the bars (also accepts an array for multi-dataset support) (default: `#FFF`).
Text color of the labels inside the bars (also accepts an array for multi-dataset support) (default: generated to constrast with `barColors`).

@@ -119,0 +119,0 @@ #### labelInsideKey

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