@fishawack/lab-d3
Advanced tools
Comparing version 2.0.7 to 2.1.0
@@ -60,3 +60,3 @@ (function (root, factory) { | ||
}, | ||
minmax: 0.1, | ||
minmax: 0.01, | ||
label: { | ||
@@ -63,0 +63,0 @@ x: null, |
@@ -201,3 +201,4 @@ (function (root, factory) { | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject.shared || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, null, null, !i); | ||
@@ -270,3 +271,6 @@ }); | ||
if(att.axis[local.pA[0]].rotate){ | ||
// Dont add spacing if height 0 | ||
if(!tempBiggest){ | ||
local.levelHeight[levelIndex] = 0; | ||
} else if(att.axis[local.pA[0]].rotate){ | ||
local.levelHeight[levelIndex] = Shared.textWidth(label) + local.padding.space; | ||
@@ -273,0 +277,0 @@ } else { |
@@ -137,3 +137,4 @@ (function (root, factory) { | ||
} | ||
} | ||
}, | ||
inject: {} | ||
}); | ||
@@ -233,2 +234,6 @@ } | ||
if(local.att.inject.init){ | ||
local.att.inject.init.call(this); | ||
} | ||
local.inited = true; | ||
@@ -304,2 +309,6 @@ | ||
if(att.inject.render){ | ||
att.inject.render.call(this); | ||
} | ||
this._buildLevels(local.draw, local.data, 0, 0, {}); | ||
@@ -578,8 +587,8 @@ | ||
if(att.label[scale]){ | ||
select = chart.select("." + scale + ".label"); | ||
select = chart.select("." + scale + ".label"); | ||
select = select.select('text') | ||
.text(att.label[scale]); | ||
select = select.select('text') | ||
.text(att.label[scale]); | ||
if(att.label[scale]){ | ||
var tempHeight = Shared.textHeight(chart, att.label[scale], local[(scale === 'x') ? 'width' : 'height']); | ||
@@ -695,10 +704,13 @@ | ||
// This cannot work with wrap below, wrap not called on each successive transition call, need to look into Shared.wrap and then also look at a way of fixing the transform hack below as that also applies inccorectly with transition | ||
/*if(att.transitionSpeed || att.delaySpeed){ | ||
select = select.transition() | ||
.ease(d3['ease' + att.transitionType]) | ||
.delay(att.delaySpeed) | ||
.duration(att.transitionSpeed); | ||
} else { | ||
select = select.interrupt(); | ||
}*/ | ||
// Added back in under a flag, use with caution | ||
if(att.axis[scale].animate){ | ||
if(att.transitionSpeed || att.delaySpeed){ | ||
select = select.transition() | ||
.ease(d3['ease' + att.transitionType]) | ||
.delay(att.delaySpeed) | ||
.duration(att.transitionSpeed); | ||
} else { | ||
select = select.interrupt(); | ||
} | ||
} | ||
@@ -776,3 +788,4 @@ var temp = select.call(local.axis[scale]) | ||
local.plotHeight = biggest + local.padding.space; | ||
// Don't add spacing if height is 0 | ||
local.plotHeight = (biggest) ? biggest + local.padding.space : 0; | ||
@@ -779,0 +792,0 @@ calcHeight += local.axisHeight; |
@@ -144,3 +144,3 @@ (function (root, factory) { | ||
if(status === 'update'){ | ||
element.classed('area__stroke ' + att.colors[_.index % att.colors.length], true); | ||
element.classed('area__stroke ' + Shared.getKey(att, d, _.index, 'colors'), true); | ||
} | ||
@@ -160,3 +160,4 @@ | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -163,0 +164,0 @@ }); |
@@ -112,9 +112,8 @@ (function (root, factory) { | ||
_.value = Shared.value(d, att); | ||
_.val = local.scale[_.sA](d.percent); | ||
_.x = x; | ||
_.y = local.scale[_.sA](d.percent); | ||
_.y = local.scale[_.sA](_.value); | ||
_.max = (d.max) ? local.scale[_.sA](d.max) : _.val; | ||
_.min = (d.min) ? local.scale[_.sA](d.min) : _.val; | ||
_.max = (d.max) ? local.scale[_.sA](d.max) : _.y; | ||
_.min = (d.min) ? local.scale[_.sA](d.min) : _.y; | ||
@@ -385,3 +384,4 @@ _.index = Shared.getPrimaryIndex(element, att.primaryIndex, local.levels, levelIndex); | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -393,3 +393,3 @@ }); | ||
var tempWidth = x * att.minmax; | ||
var tempWidth = local.width * att.minmax; | ||
@@ -396,0 +396,0 @@ if(status === 'enter'){ |
@@ -194,3 +194,4 @@ (function (root, factory) { | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -211,2 +212,3 @@ }); | ||
arr[j] = { | ||
key: d.key, | ||
length: value, | ||
@@ -213,0 +215,0 @@ i: _.index |
@@ -150,3 +150,3 @@ (function (root, factory) { | ||
var y = local.scale.y(d.min); | ||
var width = _.width * att.minmax; | ||
var width = local.width * att.minmax; | ||
@@ -183,3 +183,3 @@ if(status === 'enter'){ | ||
var y = local.scale.y(d.max); | ||
var width = _.width * att.minmax; | ||
var width = local.width * att.minmax; | ||
@@ -269,3 +269,4 @@ if(status === 'enter'){ | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -272,0 +273,0 @@ }); |
@@ -245,3 +245,4 @@ (function (root, factory) { | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, null, null, !i); | ||
@@ -248,0 +249,0 @@ }); |
@@ -411,3 +411,4 @@ "use strict"; | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -519,3 +520,4 @@ }); | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -665,3 +667,4 @@ }); | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject.shared || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -668,0 +671,0 @@ }); |
@@ -125,3 +125,4 @@ (function (root, factory) { | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, null, null, !i); | ||
@@ -128,0 +129,0 @@ }); |
@@ -35,2 +35,3 @@ (function (root, factory) { | ||
this.att({ | ||
key: null | ||
}); | ||
@@ -47,3 +48,3 @@ | ||
this.buildList(chart, data, 0); | ||
this.buildList(chart, att.key || data, 0); | ||
@@ -87,3 +88,3 @@ return this; | ||
return 'level--' + levelIndex + ' ' + att.colors[index % att.colors.length]; | ||
return 'level--' + levelIndex + ' ' + Shared.getKey(att, d, index, 'colors'); | ||
}); | ||
@@ -90,0 +91,0 @@ |
@@ -164,3 +164,3 @@ (function (root, factory) { | ||
if(status === 'update'){ | ||
element.attr('class', name + ' ' + att.colors[_.index % att.colors.length]) | ||
element.attr('class', name + ' ' + Shared.getKey(att, d, _.index, 'colors')) | ||
.attr('d', d3.symbol() | ||
@@ -224,3 +224,4 @@ .type(d3['symbol' + symbol]) | ||
], | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -233,3 +234,3 @@ }); | ||
var value = local.scale[_.sA](d[minmax]); | ||
var width = _.width * att.minmax; | ||
var width = local.width * att.minmax; | ||
@@ -347,3 +348,3 @@ if(status === 'enter'){ | ||
if(status === 'update'){ | ||
element.classed('line__stroke ' + att.colors[_.index % att.colors.length] + '-stroked', true); | ||
element.classed('line__stroke ' + Shared.getKey(att, d, _.index, 'colors') + '-stroked', true); | ||
} | ||
@@ -363,3 +364,4 @@ | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -366,0 +368,0 @@ }); |
@@ -94,3 +94,4 @@ (function (root, factory) { | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, null, null, !i); | ||
@@ -97,0 +98,0 @@ }); |
@@ -183,3 +183,4 @@ (function (root, factory) { | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -186,0 +187,0 @@ }); |
@@ -48,2 +48,7 @@ (function (root, factory) { | ||
} | ||
}, | ||
random: { | ||
seed: 0, | ||
call: null, | ||
scale: null | ||
} | ||
@@ -97,4 +102,13 @@ }); | ||
_.y = local.scale.y(Shared.y(d, att)) + (local.scale.y.bandwidth && local.scale.y.bandwidth() * 0.5 || 0); | ||
_.width = local.plotWidth[_.pA]; | ||
if(att.random.scale){ | ||
if(!att.random.call){ | ||
att.random.call = Shared.seedRandom(att.random.seed); | ||
} | ||
_[_.pA] += ((att.random.call() - 0.5) * (_.width * att.random.scale)); | ||
} | ||
_.index = Shared.getPrimaryIndex(element, att.primaryIndex, local.levels, levelIndex); | ||
@@ -161,3 +175,3 @@ }; | ||
if(status === 'update'){ | ||
element.attr('class', name + ' ' + att.colors[_.index % att.colors.length]) | ||
element.attr('class', name + ' ' + Shared.getKey(att, d, _.index, 'colors')) | ||
.attr('d', d3.symbol() | ||
@@ -220,3 +234,4 @@ .type(d3['symbol' + Shared.getKey(att, d, localIndex, 'symbols')]) | ||
] | ||
].forEach(function(element, i){ | ||
].concat(att.inject[levelIndex] || []) | ||
.forEach(function(element, i){ | ||
that._buildElements(element, levelIndex, enter, update, hide, defineLocalVariables, localVariables, !i); | ||
@@ -229,3 +244,3 @@ }); | ||
var value = local.scale[_.sA](d[minmax]); | ||
var width = _.width * att.minmax; | ||
var width = local.width * att.minmax; | ||
@@ -232,0 +247,0 @@ if(status === 'enter'){ |
@@ -12,8 +12,9 @@ (function (root, factory) { | ||
require("d3-format") | ||
) | ||
), | ||
require("seedrandom") | ||
); | ||
} else { | ||
root.Shared = factory(root.d3); | ||
root.Shared = factory(root.d3, root.seedrandom); | ||
} | ||
})(this || window, function (d3) { | ||
})(this || window, function (d3, seedrandom) { | ||
"use strict"; | ||
@@ -346,7 +347,4 @@ | ||
if(tempIndex == null){ | ||
tempIndex = i; | ||
} | ||
return values[tempIndex]; | ||
// Allow unknown key in colors/symbols for any undefined keys | ||
return values[tempIndex] || values.unknown; | ||
} | ||
@@ -378,3 +376,6 @@ | ||
return tempElement.index; | ||
} | ||
}, | ||
seedRandom: function(seed){ | ||
return seedrandom(seed); | ||
} | ||
}; | ||
@@ -381,0 +382,0 @@ |
{ | ||
"name": "@fishawack/lab-d3", | ||
"version": "2.0.7", | ||
"version": "2.1.0", | ||
"description": "Abstract layer built on top of d3", | ||
@@ -38,4 +38,5 @@ "vars": { | ||
"moment": "2.18.1", | ||
"seedrandom": "2.4.4", | ||
"topojson": "3.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
2480487
78624
4
+ Addedseedrandom@2.4.4
+ Addedseedrandom@2.4.4(transitive)