d3plus-priestley
Advanced tools
Comparing version 0.1.20 to 0.2.0
/* | ||
d3plus-priestley v0.1.20 | ||
d3plus-priestley v0.2.0 | ||
A reusable Priestley timeline built on D3. | ||
@@ -67,189 +67,189 @@ Copyright (c) 2018 D3plus - https://d3plus.org | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-collection'), require('d3-scale'), require('d3plus-axis'), require('d3plus-common'), require('d3plus-shape'), require('d3plus-viz')) : | ||
typeof define === 'function' && define.amd ? define('d3plus-priestley', ['exports', 'd3-array', 'd3-collection', 'd3-scale', 'd3plus-axis', 'd3plus-common', 'd3plus-shape', 'd3plus-viz'], factory) : | ||
(factory((global.d3plus = {}),global.d3Array,global.d3Collection,global.d3Scale,global.d3plusAxis,global.d3plusCommon,global.d3plusShape,global.d3plusViz)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-collection'), require('d3-scale'), require('d3plus-axis'), require('d3plus-common'), require('d3plus-shape'), require('d3plus-viz')) : | ||
typeof define === 'function' && define.amd ? define('d3plus-priestley', ['exports', 'd3-array', 'd3-collection', 'd3-scale', 'd3plus-axis', 'd3plus-common', 'd3plus-shape', 'd3plus-viz'], factory) : | ||
(factory((global.d3plus = {}),global.d3Array,global.d3Collection,global.d3Scale,global.d3plusAxis,global.d3plusCommon,global.d3plusShape,global.d3plusViz)); | ||
}(this, (function (exports,d3Array,d3Collection,d3Scale,d3plusAxis,d3plusCommon,d3plusShape,d3plusViz) { 'use strict'; | ||
/** | ||
@external Viz | ||
@see https://github.com/d3plus/d3plus-viz#Viz | ||
*/ | ||
/** | ||
@external Viz | ||
@see https://github.com/d3plus/d3plus-viz#Viz | ||
*/ | ||
/** | ||
@class Priestley | ||
@extends external:Viz | ||
@desc Creates a priestley timeline based on an array of data. | ||
*/ | ||
var Priestley = (function (Viz) { | ||
function Priestley() { | ||
/** | ||
@class Priestley | ||
@extends external:Viz | ||
@desc Creates a priestley timeline based on an array of data. | ||
*/ | ||
var Priestley = (function (Viz) { | ||
function Priestley() { | ||
Viz.call(this); | ||
this._axis = new d3plusAxis.Axis().align("end").orient("bottom"); | ||
this._axisConfig = {scale: "time"}; | ||
this._axisTest = new d3plusAxis.Axis().align("end").gridSize(0).orient("bottom"); | ||
this.end("end"); | ||
this.start("start"); | ||
Viz.call(this); | ||
this._axis = new d3plusAxis.Axis().align("end").orient("bottom"); | ||
this._axisConfig = {scale: "time"}; | ||
this._axisTest = new d3plusAxis.Axis().align("end").gridSize(0).orient("bottom"); | ||
this.end("end"); | ||
this.start("start"); | ||
} | ||
} | ||
if ( Viz ) Priestley.__proto__ = Viz; | ||
Priestley.prototype = Object.create( Viz && Viz.prototype ); | ||
Priestley.prototype.constructor = Priestley; | ||
if ( Viz ) Priestley.__proto__ = Viz; | ||
Priestley.prototype = Object.create( Viz && Viz.prototype ); | ||
Priestley.prototype.constructor = Priestley; | ||
/** | ||
@memberof Priestley | ||
@desc Extends the render behavior of the abstract Viz class. | ||
@private | ||
*/ | ||
Priestley.prototype.render = function render (callback) { | ||
var this$1 = this; | ||
/** | ||
@memberof Priestley | ||
@desc Extends the render behavior of the abstract Viz class. | ||
@private | ||
*/ | ||
Priestley.prototype.render = function render (callback) { | ||
var this$1 = this; | ||
Viz.prototype.render.call(this, callback); | ||
Viz.prototype.render.call(this, callback); | ||
if (!this._filteredData) { return this; } | ||
if (!this._filteredData) { return this; } | ||
var data = this._filteredData.map(function (data, i) { return ({ | ||
__d3plus__: true, | ||
data: data, | ||
end: this$1._axisConfig.scale === "time" ? d3plusAxis.date(this$1._end(data, i)) : this$1._end(data, i), | ||
i: i, | ||
id: this$1._id(data, i), | ||
start: this$1._axisConfig.scale === "time" ? d3plusAxis.date(this$1._start(data, i)) : this$1._start(data, i) | ||
}); }).filter(function (d) { return d.end - d.start > 0; }).sort(function (a, b) { return a.start - b.start; }); | ||
var data = this._filteredData.map(function (data, i) { return ({ | ||
__d3plus__: true, | ||
data: data, | ||
end: this$1._axisConfig.scale === "time" ? d3plusAxis.date(this$1._end(data, i)) : this$1._end(data, i), | ||
i: i, | ||
id: this$1._id(data, i), | ||
start: this$1._axisConfig.scale === "time" ? d3plusAxis.date(this$1._start(data, i)) : this$1._start(data, i) | ||
}); }).filter(function (d) { return d.end - d.start > 0; }).sort(function (a, b) { return a.start - b.start; }); | ||
var nestedData; | ||
if (this._groupBy.length > 1 && this._drawDepth > 0) { | ||
var dataNest = d3Collection.nest(); | ||
var loop = function ( i ) { | ||
dataNest.key(function (d) { return this$1._groupBy[i](d.data, d.i); }); | ||
}; | ||
var nestedData; | ||
if (this._groupBy.length > 1 && this._drawDepth > 0) { | ||
var dataNest = d3Collection.nest(); | ||
var loop = function ( i ) { | ||
dataNest.key(function (d) { return this$1._groupBy[i](d.data, d.i); }); | ||
}; | ||
for (var i = 0; i < this._drawDepth; i++) loop( i ); | ||
nestedData = dataNest.entries(data); | ||
} | ||
else { nestedData = [{values: data}]; } | ||
for (var i = 0; i < this._drawDepth; i++) loop( i ); | ||
nestedData = dataNest.entries(data); | ||
} | ||
else { nestedData = [{values: data}]; } | ||
var maxLane = 0; | ||
nestedData.forEach(function (g) { | ||
var track = []; | ||
g.values.forEach(function (d) { | ||
track = track.map(function (t) { return t <= d.start ? false : t; }); | ||
var i = track.indexOf(false); | ||
if (i < 0) { | ||
d.lane = maxLane + track.length; | ||
track.push(d.end); | ||
} | ||
else { | ||
track[i] = d.end; | ||
d.lane = maxLane + i; | ||
} | ||
var maxLane = 0; | ||
nestedData.forEach(function (g) { | ||
var track = []; | ||
g.values.forEach(function (d) { | ||
track = track.map(function (t) { return t <= d.start ? false : t; }); | ||
var i = track.indexOf(false); | ||
if (i < 0) { | ||
d.lane = maxLane + track.length; | ||
track.push(d.end); | ||
} | ||
else { | ||
track[i] = d.end; | ||
d.lane = maxLane + i; | ||
} | ||
}); | ||
maxLane += track.length; | ||
}); | ||
maxLane += track.length; | ||
}); | ||
var axisConfig = { | ||
domain: [d3Array.min(data, function (d) { return d.start; }) || 0, d3Array.max(data, function (d) { return d.end; }) || 0], | ||
height: this._height - this._margin.top - this._margin.bottom, | ||
width: this._width - this._margin.left - this._margin.right | ||
}; | ||
var axisConfig = { | ||
domain: [d3Array.min(data, function (d) { return d.start; }) || 0, d3Array.max(data, function (d) { return d.end; }) || 0], | ||
height: this._height - this._margin.top - this._margin.bottom, | ||
width: this._width - this._margin.left - this._margin.right | ||
}; | ||
var transform = "translate(" + (this._margin.left) + ", " + (this._margin.top) + ")"; | ||
var transform = "translate(" + (this._margin.left) + ", " + (this._margin.top) + ")"; | ||
this._axisTest | ||
.config(axisConfig) | ||
.config(this._axisConfig) | ||
.select(d3plusCommon.elem("g.d3plus-priestley-axis-test", {parent: this._select, enter: {opacity: 0}}).node()) | ||
.render(); | ||
this._axisTest | ||
.config(axisConfig) | ||
.config(this._axisConfig) | ||
.select(d3plusCommon.elem("g.d3plus-priestley-axis-test", {parent: this._select, enter: {opacity: 0}}).node()) | ||
.render(); | ||
this._axis | ||
.config(axisConfig) | ||
.config(this._axisConfig) | ||
.select(d3plusCommon.elem("g.d3plus-priestley-axis", {parent: this._select, enter: {transform: transform}, update: {transform: transform}}).node()) | ||
.render(); | ||
this._axis | ||
.config(axisConfig) | ||
.config(this._axisConfig) | ||
.select(d3plusCommon.elem("g.d3plus-priestley-axis", {parent: this._select, enter: {transform: transform}, update: {transform: transform}}).node()) | ||
.render(); | ||
var axisPad = this._axisTest._padding; | ||
var axisPad = this._axisTest._padding; | ||
var xScale = this._axis._d3Scale; | ||
var xScale = this._axis._d3Scale; | ||
var yScale = d3Scale.scalePoint() | ||
.domain(d3Array.range(0, maxLane, 1)) | ||
.padding(0.5) | ||
.rangeRound([this._height - this._margin.bottom - this._axisTest.outerBounds().height - axisPad, this._margin.top + axisPad]); | ||
var yScale = d3Scale.scalePoint() | ||
.domain(d3Array.range(0, maxLane, 1)) | ||
.padding(0.5) | ||
.rangeRound([this._height - this._margin.bottom - this._axisTest.outerBounds().height - axisPad, this._margin.top + axisPad]); | ||
var step = yScale.step(); | ||
var step = yScale.step(); | ||
this._shapes.push(new d3plusShape.Rect() | ||
.data(data) | ||
.duration(this._duration) | ||
.height(step >= this._padding * 2 ? step - this._padding : step > 2 ? step - 2 : step) | ||
.label(function (d, i) { return this$1._drawLabel(d.data, i); }) | ||
.select(d3plusCommon.elem("g.d3plus-priestley-shapes", {parent: this._select}).node()) | ||
.width(function (d) { | ||
var w = Math.abs(xScale(d.end) - xScale(d.start)); | ||
return w > 2 ? w - 2 : w; | ||
}) | ||
.x(function (d) { return xScale(d.start) + (xScale(d.end) - xScale(d.start)) / 2; }) | ||
.y(function (d) { return yScale(d.lane); }) | ||
.config(d3plusCommon.configPrep.bind(this)(this._shapeConfig, "shape", "Rect")) | ||
.render()); | ||
this._shapes.push(new d3plusShape.Rect() | ||
.data(data) | ||
.duration(this._duration) | ||
.height(step >= this._padding * 2 ? step - this._padding : step > 2 ? step - 2 : step) | ||
.label(function (d, i) { return this$1._drawLabel(d.data, i); }) | ||
.select(d3plusCommon.elem("g.d3plus-priestley-shapes", {parent: this._select}).node()) | ||
.width(function (d) { | ||
var w = Math.abs(xScale(d.end) - xScale(d.start)); | ||
return w > 2 ? w - 2 : w; | ||
}) | ||
.x(function (d) { return xScale(d.start) + (xScale(d.end) - xScale(d.start)) / 2; }) | ||
.y(function (d) { return yScale(d.lane); }) | ||
.config(d3plusCommon.configPrep.bind(this)(this._shapeConfig, "shape", "Rect")) | ||
.render()); | ||
return this; | ||
return this; | ||
}; | ||
}; | ||
/** | ||
@memberof Priestley | ||
@desc If *value* is specified, sets the config method for the axis and returns the current class instance. If *value* is not specified, returns the current axis configuration. | ||
@param {Object} [*value*] | ||
@chainable | ||
*/ | ||
Priestley.prototype.axisConfig = function axisConfig (_) { | ||
return arguments.length ? (this._axisConfig = d3plusCommon.assign(this._axisConfig, _), this) : this._axisConfig; | ||
}; | ||
/** | ||
@memberof Priestley | ||
@desc If *value* is specified, sets the config method for the axis and returns the current class instance. If *value* is not specified, returns the current axis configuration. | ||
@param {Object} [*value*] | ||
@chainable | ||
*/ | ||
Priestley.prototype.axisConfig = function axisConfig (_) { | ||
return arguments.length ? (this._axisConfig = d3plusCommon.assign(this._axisConfig, _), this) : this._axisConfig; | ||
}; | ||
/** | ||
@memberof Priestley | ||
@desc If *value* is specified, sets the end accessor to the specified function or key and returns the current class instance. If *value* is not specified, returns the current end accessor. | ||
@param {Function|String} [*value*] | ||
@chainable | ||
*/ | ||
Priestley.prototype.end = function end (_) { | ||
if (arguments.length) { | ||
if (typeof _ === "function") { this._end = _; } | ||
else { | ||
this._end = d3plusCommon.accessor(_); | ||
if (!this._aggs[_]) { this._aggs[_] = function (a) { return d3Array.max(a); }; } | ||
/** | ||
@memberof Priestley | ||
@desc If *value* is specified, sets the end accessor to the specified function or key and returns the current class instance. If *value* is not specified, returns the current end accessor. | ||
@param {Function|String} [*value*] | ||
@chainable | ||
*/ | ||
Priestley.prototype.end = function end (_) { | ||
if (arguments.length) { | ||
if (typeof _ === "function") { this._end = _; } | ||
else { | ||
this._end = d3plusCommon.accessor(_); | ||
if (!this._aggs[_]) { this._aggs[_] = function (a) { return d3Array.max(a); }; } | ||
} | ||
return this; | ||
} | ||
return this; | ||
} | ||
else { return this._end; } | ||
}; | ||
else { return this._end; } | ||
}; | ||
/** | ||
@memberof Priestley | ||
@desc If *value* is specified, sets the start accessor to the specified function or key and returns the current class instance. If *value* is not specified, returns the current start accessor. | ||
@param {Function|String} [*value*] | ||
@chainable | ||
*/ | ||
Priestley.prototype.start = function start (_) { | ||
if (arguments.length) { | ||
if (typeof _ === "function") { this._start = _; } | ||
else { | ||
this._start = d3plusCommon.accessor(_); | ||
if (!this._aggs[_]) { this._aggs[_] = function (a) { return d3Array.min(a); }; } | ||
/** | ||
@memberof Priestley | ||
@desc If *value* is specified, sets the start accessor to the specified function or key and returns the current class instance. If *value* is not specified, returns the current start accessor. | ||
@param {Function|String} [*value*] | ||
@chainable | ||
*/ | ||
Priestley.prototype.start = function start (_) { | ||
if (arguments.length) { | ||
if (typeof _ === "function") { this._start = _; } | ||
else { | ||
this._start = d3plusCommon.accessor(_); | ||
if (!this._aggs[_]) { this._aggs[_] = function (a) { return d3Array.min(a); }; } | ||
} | ||
return this; | ||
} | ||
return this; | ||
} | ||
else { return this._start; } | ||
}; | ||
else { return this._start; } | ||
}; | ||
return Priestley; | ||
}(d3plusViz.Viz)); | ||
return Priestley; | ||
}(d3plusViz.Viz)); | ||
exports.Priestley = Priestley; | ||
exports.Priestley = Priestley; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=d3plus-priestley.js.map |
/* | ||
d3plus-priestley v0.1.20 | ||
d3plus-priestley v0.2.0 | ||
A reusable Priestley timeline built on D3. | ||
@@ -4,0 +4,0 @@ Copyright (c) 2018 D3plus - https://d3plus.org |
{ | ||
"name": "d3plus-priestley", | ||
"version": "0.1.20", | ||
"version": "0.2.0", | ||
"description": "A reusable Priestley timeline built on D3.", | ||
@@ -31,5 +31,5 @@ "main": "build/d3plus-priestley.js", | ||
"d3plus-axis": "^0.3.43", | ||
"d3plus-common": "^0.6.33", | ||
"d3plus-common": "^0.6.34", | ||
"d3plus-shape": "^0.14.2", | ||
"d3plus-viz": "^0.10.18" | ||
"d3plus-viz": "^0.11.0" | ||
}, | ||
@@ -46,3 +46,3 @@ "scripts": { | ||
"devDependencies": { | ||
"d3plus-dev": "^0.6.5" | ||
"d3plus-dev": "^0.6.6" | ||
}, | ||
@@ -49,0 +49,0 @@ "module": "es/index", |
@@ -12,3 +12,3 @@ # d3plus-priestley | ||
```html | ||
<script src="https://d3plus.org/js/d3plus-priestley.v0.1.full.min.js"></script> | ||
<script src="https://d3plus.org/js/d3plus-priestley.v0.2.full.min.js"></script> | ||
``` | ||
@@ -103,2 +103,2 @@ | ||
###### <sub>Documentation generated on Thu, 29 Mar 2018 15:03:01 GMT</sub> | ||
###### <sub>Documentation generated on Fri, 30 Mar 2018 18:57:16 GMT</sub> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50180
+ Addedd3plus-tooltip@0.3.14(transitive)
+ Addedd3plus-viz@0.11.17(transitive)
+ Addedpopper.js@1.16.1(transitive)
- Removedd3plus-tooltip@0.2.7(transitive)
- Removedd3plus-viz@0.10.18(transitive)
Updatedd3plus-common@^0.6.34
Updatedd3plus-viz@^0.11.0