@d3plus/core 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6219 -0
- package/es/index.js +4 -0
- package/es/src/charts/AreaPlot.js +86 -0
- package/es/src/charts/BarChart.js +93 -0
- package/es/src/charts/BoxWhisker.js +97 -0
- package/es/src/charts/BumpChart.js +148 -0
- package/es/src/charts/Donut.js +84 -0
- package/es/src/charts/Geomap.js +833 -0
- package/es/src/charts/LinePlot.js +84 -0
- package/es/src/charts/Matrix.js +358 -0
- package/es/src/charts/Network.js +787 -0
- package/es/src/charts/Pack.js +318 -0
- package/es/src/charts/Pie.js +242 -0
- package/es/src/charts/Plot.js +2212 -0
- package/es/src/charts/Priestley.js +312 -0
- package/es/src/charts/Radar.js +365 -0
- package/es/src/charts/RadialMatrix.js +393 -0
- package/es/src/charts/Rings.js +777 -0
- package/es/src/charts/Sankey.js +413 -0
- package/es/src/charts/StackedArea.js +80 -0
- package/es/src/charts/Tree.js +312 -0
- package/es/src/charts/Treemap.js +406 -0
- package/es/src/charts/Viz.js +2017 -0
- package/es/src/charts/drawSteps/drawAttribution.js +14 -0
- package/es/src/charts/drawSteps/drawBack.js +23 -0
- package/es/src/charts/drawSteps/drawColorScale.js +69 -0
- package/es/src/charts/drawSteps/drawLegend.js +120 -0
- package/es/src/charts/drawSteps/drawSubtitle.js +31 -0
- package/es/src/charts/drawSteps/drawTimeline.js +80 -0
- package/es/src/charts/drawSteps/drawTitle.js +31 -0
- package/es/src/charts/drawSteps/drawTotal.js +32 -0
- package/es/src/charts/drawSteps/zoomControls.js +254 -0
- package/es/src/charts/events/click.legend.js +76 -0
- package/es/src/charts/events/click.shape.js +26 -0
- package/es/src/charts/events/mouseenter.js +31 -0
- package/es/src/charts/events/mouseleave.js +21 -0
- package/es/src/charts/events/mousemove.legend.js +64 -0
- package/es/src/charts/events/mousemove.shape.js +42 -0
- package/es/src/charts/events/touchstart.body.js +7 -0
- package/es/src/charts/helpers/matrixData.js +104 -0
- package/es/src/charts/helpers/tileAttributions.js +34 -0
- package/es/src/charts/index.js +21 -0
- package/es/src/charts/plotBuffers/Bar.js +65 -0
- package/es/src/charts/plotBuffers/Box.js +60 -0
- package/es/src/charts/plotBuffers/Circle.js +39 -0
- package/es/src/charts/plotBuffers/Line.js +30 -0
- package/es/src/charts/plotBuffers/Rect.js +40 -0
- package/es/src/charts/plotBuffers/discreteBuffer.js +24 -0
- package/es/src/charts/plotBuffers/numericBuffer.js +111 -0
- package/es/src/components/Axis.js +1567 -0
- package/es/src/components/AxisBottom.js +77 -0
- package/es/src/components/AxisLeft.js +77 -0
- package/es/src/components/AxisRight.js +77 -0
- package/es/src/components/AxisTop.js +77 -0
- package/es/src/components/ColorScale.js +958 -0
- package/es/src/components/Legend.js +673 -0
- package/es/src/components/Message.js +95 -0
- package/es/src/components/TextBox.js +752 -0
- package/es/src/components/Timeline.js +760 -0
- package/es/src/components/Tooltip.js +726 -0
- package/es/src/components/index.js +11 -0
- package/es/src/shapes/Area.js +361 -0
- package/es/src/shapes/Bar.js +342 -0
- package/es/src/shapes/Box.js +482 -0
- package/es/src/shapes/Circle.js +201 -0
- package/es/src/shapes/Image.js +255 -0
- package/es/src/shapes/Line.js +289 -0
- package/es/src/shapes/Path.js +186 -0
- package/es/src/shapes/Rect.js +215 -0
- package/es/src/shapes/Shape.js +1156 -0
- package/es/src/shapes/Whisker.js +330 -0
- package/es/src/shapes/index.js +10 -0
- package/es/src/utils/BaseClass.js +204 -0
- package/es/src/utils/RESET.js +4 -0
- package/es/src/utils/accessor.js +19 -0
- package/es/src/utils/configPrep.js +76 -0
- package/es/src/utils/constant.js +15 -0
- package/es/src/utils/getProp.js +9 -0
- package/es/src/utils/index.js +7 -0
- package/es/src/utils/uuid.js +13 -0
- package/package.json +68 -0
- package/umd/d3plus-core.full.js +56459 -0
- package/umd/d3plus-core.full.js.map +1 -0
- package/umd/d3plus-core.full.min.js +7241 -0
- package/umd/d3plus-core.js +14422 -0
- package/umd/d3plus-core.js.map +1 -0
- package/umd/d3plus-core.min.js +4564 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
function _instanceof(left, right) {
|
|
2
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
3
|
+
return !!right[Symbol.hasInstance](left);
|
|
4
|
+
} else {
|
|
5
|
+
return left instanceof right;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
import { merge } from "d3-array";
|
|
9
|
+
/**
|
|
10
|
+
@module clickLegend
|
|
11
|
+
@desc On click event for all legend shapes in a Viz.
|
|
12
|
+
@param {Object} *d* The data object being interacted with.
|
|
13
|
+
@param {Number} *i* The index of the data object being interacted with.
|
|
14
|
+
@private
|
|
15
|
+
*/ export default function(d, i, x, event) {
|
|
16
|
+
var _this = this;
|
|
17
|
+
this._select.style("cursor", "auto");
|
|
18
|
+
if (this._tooltip(d, i)) this._tooltipClass.data([]).render();
|
|
19
|
+
var id = this._id(d, i);
|
|
20
|
+
if (!_instanceof(id, Array)) id = [
|
|
21
|
+
id
|
|
22
|
+
];
|
|
23
|
+
var hiddenIndex = this._hidden.indexOf(id[0]);
|
|
24
|
+
var soloIndex = this._solo.indexOf(id[0]);
|
|
25
|
+
var dataLength = merge(this._legendClass.data().map(function(d, i) {
|
|
26
|
+
var id = _this._id(d, i);
|
|
27
|
+
if (!_instanceof(id, Array)) id = [
|
|
28
|
+
id
|
|
29
|
+
];
|
|
30
|
+
return id;
|
|
31
|
+
})).length;
|
|
32
|
+
var inverted = this._legendFilterInvert.bind(this)();
|
|
33
|
+
if (inverted) {
|
|
34
|
+
if (event.shiftKey) {
|
|
35
|
+
if (hiddenIndex < 0 && !this._solo.length) {
|
|
36
|
+
this._hidden = this._hidden.concat(id);
|
|
37
|
+
if (soloIndex >= 0) this._solo = [];
|
|
38
|
+
if (this._hidden.length === dataLength) this._hidden = [];
|
|
39
|
+
this.render();
|
|
40
|
+
} else if (soloIndex >= 0) {
|
|
41
|
+
this._solo = [];
|
|
42
|
+
this._hidden = [];
|
|
43
|
+
this.render();
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
if (soloIndex < 0 && this._hidden.length < dataLength - 1) {
|
|
47
|
+
this._solo = id;
|
|
48
|
+
this._hidden = [];
|
|
49
|
+
} else {
|
|
50
|
+
this._solo = [];
|
|
51
|
+
this._hidden = [];
|
|
52
|
+
}
|
|
53
|
+
this.render();
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
if (event.shiftKey && soloIndex < 0) {
|
|
57
|
+
this._solo = id;
|
|
58
|
+
this._hidden = [];
|
|
59
|
+
this.render();
|
|
60
|
+
} else if (!event.shiftKey) {
|
|
61
|
+
if (hiddenIndex >= 0) {
|
|
62
|
+
this._hidden.splice(hiddenIndex, id.length);
|
|
63
|
+
} else if (soloIndex >= 0) {
|
|
64
|
+
this._solo = [];
|
|
65
|
+
this._hidden = [];
|
|
66
|
+
} else if (this._solo.length && soloIndex < 0) {
|
|
67
|
+
this._solo = this._solo.concat(id);
|
|
68
|
+
if (this._solo.length === dataLength) this._solo = [];
|
|
69
|
+
} else {
|
|
70
|
+
this._hidden = this._hidden.concat(id);
|
|
71
|
+
if (this._hidden.length === dataLength) this._hidden = [];
|
|
72
|
+
}
|
|
73
|
+
this.render();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@module clickShape
|
|
3
|
+
@desc On click event for all shapes in a Viz.
|
|
4
|
+
@param {Object} *d* The data object being interacted with.
|
|
5
|
+
@param {Number} *i* The index of the data object being interacted with.
|
|
6
|
+
@private
|
|
7
|
+
*/ export default function(d, i, x, event) {
|
|
8
|
+
event.stopPropagation();
|
|
9
|
+
if (this._drawDepth < this._groupBy.length - 1) {
|
|
10
|
+
this._select.style("cursor", "auto");
|
|
11
|
+
var filterGroup = this._groupBy[this._drawDepth], filterId = filterGroup(d, i);
|
|
12
|
+
this.hover(false);
|
|
13
|
+
if (this._tooltip(d, i)) this._tooltipClass.data([]).render();
|
|
14
|
+
var oldFilter = this._filter;
|
|
15
|
+
this._history.push({
|
|
16
|
+
depth: this._depth,
|
|
17
|
+
filter: oldFilter
|
|
18
|
+
});
|
|
19
|
+
this.config({
|
|
20
|
+
depth: this._drawDepth + 1,
|
|
21
|
+
filter: function(f, x) {
|
|
22
|
+
return (!oldFilter || oldFilter(f, x)) && filterGroup(f, x) === filterId;
|
|
23
|
+
}
|
|
24
|
+
}).render();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@module mouseEnter
|
|
3
|
+
@desc On mouseenter event for all shapes in a Viz.
|
|
4
|
+
@param {Object} *d* The data object being interacted with.
|
|
5
|
+
@param {Number} *i* The index of the data object being interacted with.
|
|
6
|
+
@private
|
|
7
|
+
*/ function _instanceof(left, right) {
|
|
8
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
9
|
+
return !!right[Symbol.hasInstance](left);
|
|
10
|
+
} else {
|
|
11
|
+
return left instanceof right;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default function(d, i) {
|
|
15
|
+
var _this = this;
|
|
16
|
+
if (this._shapeConfig.hoverOpacity !== 1) {
|
|
17
|
+
var filterIds = this._id(d, i);
|
|
18
|
+
if (!_instanceof(filterIds, Array)) filterIds = [
|
|
19
|
+
filterIds
|
|
20
|
+
];
|
|
21
|
+
this.hover(function(h, x) {
|
|
22
|
+
var id = _this._id(h, x);
|
|
23
|
+
if (!_instanceof(id, Array)) id = [
|
|
24
|
+
id
|
|
25
|
+
];
|
|
26
|
+
return filterIds.some(function(f) {
|
|
27
|
+
return id.includes(f);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@module mouseLeave
|
|
3
|
+
@desc On mouseleave event for all shapes in a Viz.
|
|
4
|
+
@param {Object} *d* The data object being interacted with.
|
|
5
|
+
@param {Number} *i* The index of the data object being interacted with.
|
|
6
|
+
@private
|
|
7
|
+
*/ export default function(d, i) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
setTimeout(function() {
|
|
10
|
+
if (_this._shapeConfig.hoverOpacity !== 1 && _this._hover ? _this._hover(d, i) : true) {
|
|
11
|
+
_this.hover(false);
|
|
12
|
+
}
|
|
13
|
+
var tooltipData = _this._tooltipClass.data();
|
|
14
|
+
if (tooltipData.length && _this._tooltip(d, i)) {
|
|
15
|
+
var tooltipDatum = tooltipData[0];
|
|
16
|
+
while(tooltipDatum.__d3plus__ && tooltipDatum.data)tooltipDatum = tooltipDatum.data;
|
|
17
|
+
if (_this._id(tooltipDatum) === _this._id(d)) _this._tooltipClass.data([]).render();
|
|
18
|
+
}
|
|
19
|
+
}, 50);
|
|
20
|
+
this._select.style("cursor", "auto");
|
|
21
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _instanceof(left, right) {
|
|
2
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
3
|
+
return !!right[Symbol.hasInstance](left);
|
|
4
|
+
} else {
|
|
5
|
+
return left instanceof right;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
import { merge } from "d3-array";
|
|
9
|
+
import clickLegend from "./click.legend.js";
|
|
10
|
+
import { legendLabel } from "../drawSteps/drawLegend.js";
|
|
11
|
+
import { configPrep } from "../../utils/index.js";
|
|
12
|
+
/**
|
|
13
|
+
@module mouseMoveLegend
|
|
14
|
+
@desc Tooltip logic for a specified data point.
|
|
15
|
+
@param {Object} *d* The data object being interacted with.
|
|
16
|
+
@param {Number} *i* The index of the data object being interacted with.
|
|
17
|
+
@param {Object} [*config*] Optional configuration methods for the Tooltip class.
|
|
18
|
+
@private
|
|
19
|
+
*/ export default function(d, i, x, event) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
var position = event.touches ? [
|
|
22
|
+
event.touches[0].clientX,
|
|
23
|
+
event.touches[0].clientY
|
|
24
|
+
] : [
|
|
25
|
+
event.clientX,
|
|
26
|
+
event.clientY
|
|
27
|
+
];
|
|
28
|
+
var dataLength = merge(this._legendClass.data().map(function(d, i) {
|
|
29
|
+
var id = _this._id(d, i);
|
|
30
|
+
if (!_instanceof(id, Array)) id = [
|
|
31
|
+
id
|
|
32
|
+
];
|
|
33
|
+
return id;
|
|
34
|
+
})).length;
|
|
35
|
+
if (d && this._tooltip(d, i)) {
|
|
36
|
+
var id = this._id(d, i);
|
|
37
|
+
if (_instanceof(id, Array)) id = id[0];
|
|
38
|
+
var t = this._translate;
|
|
39
|
+
var defaultClick = clickLegend.bind(this).toString();
|
|
40
|
+
// does the legend have any user-defined click events?
|
|
41
|
+
var hasUserClick = Object.keys(this._on).some(function(e) {
|
|
42
|
+
return(// all valid click event keys,
|
|
43
|
+
[
|
|
44
|
+
"click",
|
|
45
|
+
"click.legend"
|
|
46
|
+
].includes(e) && // truthy values (no nulls),
|
|
47
|
+
_this._on[e] && // and it is not our default click.legend function
|
|
48
|
+
_this._on[e].toString() !== defaultClick);
|
|
49
|
+
});
|
|
50
|
+
// does the legend still have our default "click.legend" event?
|
|
51
|
+
// (if the user only sets "click", both functions will fire)
|
|
52
|
+
var hasDefaultClick = this._on["click.legend"] && this._on["click.legend"].toString() === defaultClick;
|
|
53
|
+
// can the viz show deeper data?
|
|
54
|
+
var hasDeeperLevel = this._drawDepth < this._groupBy.length - 1;
|
|
55
|
+
// only show the hand cursor when the shape has a click event
|
|
56
|
+
this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
|
|
57
|
+
var invertedBehavior = this._legendFilterInvert.bind(this)();
|
|
58
|
+
var solo = this._solo.includes(id);
|
|
59
|
+
var hidden = this._hidden.includes(id);
|
|
60
|
+
this._tooltipClass.data([
|
|
61
|
+
x || d
|
|
62
|
+
]).footer(hasDefaultClick ? invertedBehavior ? this._solo.length && !solo || hidden ? t("Click to Highlight") : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : "".concat(t("Click to Highlight"), "<br />").concat(t("Shift+Click to Hide")) : this._solo.length && !solo || hidden ? "".concat(t("Click to Show"), "<br />").concat(t("Shift+Click to Highlight")) : this._solo.length === 1 && solo || this._hidden.length === dataLength - 1 ? t("Click to Show All") : "".concat(t("Click to Hide"), "<br />").concat(t("Shift+Click to Highlight")) : false).title(this._legendConfig.label ? this._legendClass.label() : legendLabel.bind(this)).position(position).config(configPrep.bind(this)(this._tooltipConfig)).config(configPrep.bind(this)(this._legendTooltip)).render();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { configPrep } from "../../utils/index.js";
|
|
2
|
+
import clickShape from "./click.shape.js";
|
|
3
|
+
/**
|
|
4
|
+
@module mouseMoveShape
|
|
5
|
+
@desc Tooltip logic for a specified data point.
|
|
6
|
+
@param {Object} *d* The data object being interacted with.
|
|
7
|
+
@param {Number} *i* The index of the data object being interacted with.
|
|
8
|
+
@param {Object} [*config*] Optional configuration methods for the Tooltip class.
|
|
9
|
+
@private
|
|
10
|
+
*/ export default function(d, i, x, event) {
|
|
11
|
+
var _this = this;
|
|
12
|
+
if (d && this._tooltip(d, i)) {
|
|
13
|
+
var defaultClick = clickShape.bind(this).toString();
|
|
14
|
+
// does the shape have any user-defined click events?
|
|
15
|
+
var hasUserClick = Object.keys(this._on).some(function(e) {
|
|
16
|
+
return(// all valid click event keys,
|
|
17
|
+
[
|
|
18
|
+
"click",
|
|
19
|
+
"click.shape"
|
|
20
|
+
].includes(e) && // truthy values (no nulls),
|
|
21
|
+
_this._on[e] && // and it is not our default click.shape function
|
|
22
|
+
_this._on[e].toString() !== defaultClick);
|
|
23
|
+
});
|
|
24
|
+
// does the shape still have our default "click.shape" event?
|
|
25
|
+
// (if the user only sets "click", both functions will fire)
|
|
26
|
+
var hasDefaultClick = this._on["click.shape"] && this._on["click.shape"].toString() === defaultClick;
|
|
27
|
+
// can the viz show deeper data?
|
|
28
|
+
var hasDeeperLevel = this._drawDepth < this._groupBy.length - 1;
|
|
29
|
+
// only show the hand cursor when the shape has a click event
|
|
30
|
+
this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
|
|
31
|
+
var position = event.touches ? [
|
|
32
|
+
event.touches[0].clientX,
|
|
33
|
+
event.touches[0].clientY
|
|
34
|
+
] : [
|
|
35
|
+
event.clientX,
|
|
36
|
+
event.clientY
|
|
37
|
+
];
|
|
38
|
+
this._tooltipClass.data([
|
|
39
|
+
x || d
|
|
40
|
+
]).footer(hasDefaultClick && hasDeeperLevel ? this._translate("Click to Expand") : false).title(this._drawLabel).position(position).config(configPrep.bind(this)(this._tooltipConfig)).render();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
+
}
|
|
12
|
+
function _iterable_to_array(iter) {
|
|
13
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
14
|
+
}
|
|
15
|
+
function _iterable_to_array_limit(arr, i) {
|
|
16
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
17
|
+
if (_i == null) return;
|
|
18
|
+
var _arr = [];
|
|
19
|
+
var _n = true;
|
|
20
|
+
var _d = false;
|
|
21
|
+
var _s, _e;
|
|
22
|
+
try {
|
|
23
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
24
|
+
_arr.push(_s.value);
|
|
25
|
+
if (i && _arr.length === i) break;
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
_d = true;
|
|
29
|
+
_e = err;
|
|
30
|
+
} finally{
|
|
31
|
+
try {
|
|
32
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
33
|
+
} finally{
|
|
34
|
+
if (_d) throw _e;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return _arr;
|
|
38
|
+
}
|
|
39
|
+
function _non_iterable_rest() {
|
|
40
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
41
|
+
}
|
|
42
|
+
function _non_iterable_spread() {
|
|
43
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
44
|
+
}
|
|
45
|
+
function _sliced_to_array(arr, i) {
|
|
46
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
47
|
+
}
|
|
48
|
+
function _to_consumable_array(arr) {
|
|
49
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
50
|
+
}
|
|
51
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
52
|
+
if (!o) return;
|
|
53
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
54
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
57
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
58
|
+
}
|
|
59
|
+
var _instance;
|
|
60
|
+
import { unique } from "@d3plus/data";
|
|
61
|
+
var cartesian = function(a, b) {
|
|
62
|
+
return (_instance = []).concat.apply(_instance, _to_consumable_array(a.map(function(d) {
|
|
63
|
+
return b.map(function(e) {
|
|
64
|
+
return [].concat(d, e);
|
|
65
|
+
});
|
|
66
|
+
})));
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
@module matrixData
|
|
70
|
+
@private
|
|
71
|
+
*/ export default function() {
|
|
72
|
+
var _this = this;
|
|
73
|
+
var data = this._filteredData;
|
|
74
|
+
var rowValues = (this._rowList || unique(data.map(this._row))).sort(this._rowSort);
|
|
75
|
+
var columnValues = (this._columnList || unique(data.map(this._column))).sort(this._columnSort);
|
|
76
|
+
if (!rowValues.length || !columnValues.length) return this;
|
|
77
|
+
var shapeData = cartesian(rowValues, columnValues).map(function(param) {
|
|
78
|
+
var _param = _sliced_to_array(param, 2), rowValue = _param[0], columnValue = _param[1];
|
|
79
|
+
var dataObj = {
|
|
80
|
+
__d3plusTooltip__: true,
|
|
81
|
+
__d3plus__: true,
|
|
82
|
+
column: columnValue,
|
|
83
|
+
row: rowValue
|
|
84
|
+
};
|
|
85
|
+
var dataIndex = data.findIndex(function(d, i) {
|
|
86
|
+
return _this._row(d, i) === rowValue && _this._column(d, i) === columnValue;
|
|
87
|
+
});
|
|
88
|
+
if (dataIndex >= 0) {
|
|
89
|
+
dataObj.i = dataIndex;
|
|
90
|
+
dataObj.data = data[dataIndex];
|
|
91
|
+
} else {
|
|
92
|
+
dataObj.data = {
|
|
93
|
+
row: rowValue,
|
|
94
|
+
column: columnValue
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return dataObj;
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
rowValues: rowValues,
|
|
101
|
+
columnValues: columnValues,
|
|
102
|
+
shapeData: shapeData
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
matches: [
|
|
4
|
+
"cartodb",
|
|
5
|
+
"cartocdn"
|
|
6
|
+
],
|
|
7
|
+
text: "© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
matches: [
|
|
11
|
+
"opentopomap.org"
|
|
12
|
+
],
|
|
13
|
+
text: "© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
matches: [
|
|
17
|
+
"arcgisonline.com"
|
|
18
|
+
],
|
|
19
|
+
text: "Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
matches: [
|
|
23
|
+
"/watercolor/"
|
|
24
|
+
],
|
|
25
|
+
text: "Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
matches: [
|
|
29
|
+
"stamen-tiles",
|
|
30
|
+
"stamen.com"
|
|
31
|
+
],
|
|
32
|
+
text: "Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."
|
|
33
|
+
}
|
|
34
|
+
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { default as AreaPlot } from "./AreaPlot";
|
|
2
|
+
export { default as BarChart } from "./BarChart";
|
|
3
|
+
export { default as BoxWhisker } from "./BoxWhisker";
|
|
4
|
+
export { default as BumpChart } from "./BumpChart";
|
|
5
|
+
export { default as Donut } from "./Donut";
|
|
6
|
+
export { default as Geomap } from "./Geomap";
|
|
7
|
+
export { default as LinePlot } from "./LinePlot";
|
|
8
|
+
export { default as Matrix } from "./Matrix";
|
|
9
|
+
export { default as Network } from "./Network";
|
|
10
|
+
export { default as Pack } from "./Pack";
|
|
11
|
+
export { default as Pie } from "./Pie";
|
|
12
|
+
export { default as Plot } from "./Plot";
|
|
13
|
+
export { default as Priestley } from "./Priestley";
|
|
14
|
+
export { default as Radar } from "./Radar";
|
|
15
|
+
export { default as RadialMatrix } from "./RadialMatrix";
|
|
16
|
+
export { default as Rings } from "./Rings";
|
|
17
|
+
export { default as Sankey } from "./Sankey";
|
|
18
|
+
export { default as StackedArea } from "./StackedArea";
|
|
19
|
+
export { default as Tree } from "./Tree";
|
|
20
|
+
export { default as Treemap } from "./Treemap";
|
|
21
|
+
export { default as Viz } from "./Viz";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { max, min, sum } from "d3-array";
|
|
2
|
+
import { nest } from "d3-collection";
|
|
3
|
+
/**
|
|
4
|
+
@module barBuffer
|
|
5
|
+
@desc Adds a buffer to either side of the non-discrete axis.
|
|
6
|
+
@param {Array} data
|
|
7
|
+
@param {D3Scale} x
|
|
8
|
+
@param {D3Scale} y
|
|
9
|
+
@param {Object} [config]
|
|
10
|
+
@param {Number} [buffer = 10]
|
|
11
|
+
@private
|
|
12
|
+
*/ export default function(param) {
|
|
13
|
+
var _this = this;
|
|
14
|
+
var data = param.data, x = param.x, y = param.y, x2 = param.x2, y2 = param.y2, _param_buffer = param.buffer, buffer = _param_buffer === void 0 ? 10 : _param_buffer;
|
|
15
|
+
var xKey = x2 ? "x2" : "x";
|
|
16
|
+
var yKey = y2 ? "y2" : "y";
|
|
17
|
+
var oppScale = this._discrete === "x" ? y : x;
|
|
18
|
+
var oppDomain = oppScale.domain().slice();
|
|
19
|
+
var isDiscreteX = this._discrete === "x";
|
|
20
|
+
if (isDiscreteX) oppDomain.reverse();
|
|
21
|
+
var negVals, posVals;
|
|
22
|
+
if (this._stacked) {
|
|
23
|
+
var groupedData = nest().key(function(d) {
|
|
24
|
+
return "".concat(d[_this._discrete], "_").concat(d.group);
|
|
25
|
+
}).entries(data).map(function(d) {
|
|
26
|
+
return d.values.map(function(x) {
|
|
27
|
+
return x[isDiscreteX ? yKey : xKey];
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
posVals = groupedData.map(function(arr) {
|
|
31
|
+
return sum(arr.filter(function(d) {
|
|
32
|
+
return d > 0;
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
negVals = groupedData.map(function(arr) {
|
|
36
|
+
return sum(arr.filter(function(d) {
|
|
37
|
+
return d < 0;
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
var allValues = data.map(function(d) {
|
|
42
|
+
return d[isDiscreteX ? yKey : xKey];
|
|
43
|
+
});
|
|
44
|
+
posVals = allValues.filter(function(d) {
|
|
45
|
+
return d > 0;
|
|
46
|
+
});
|
|
47
|
+
negVals = allValues.filter(function(d) {
|
|
48
|
+
return d < 0;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
var bMax = oppScale(max(posVals));
|
|
52
|
+
if (isDiscreteX ? bMax < oppScale(0) : bMax > oppScale(0)) bMax += isDiscreteX ? -buffer : buffer;
|
|
53
|
+
bMax = oppScale.invert(bMax);
|
|
54
|
+
var bMin = oppScale(min(negVals));
|
|
55
|
+
if (isDiscreteX ? bMin > oppScale(0) : bMin < oppScale(0)) bMin += isDiscreteX ? buffer : -buffer;
|
|
56
|
+
bMin = oppScale.invert(bMin);
|
|
57
|
+
if (bMax > oppDomain[1]) oppDomain[1] = bMax;
|
|
58
|
+
if (bMin < oppDomain[0]) oppDomain[0] = bMin;
|
|
59
|
+
if (isDiscreteX) oppDomain.reverse();
|
|
60
|
+
oppScale.domain(oppDomain);
|
|
61
|
+
return [
|
|
62
|
+
x,
|
|
63
|
+
y
|
|
64
|
+
];
|
|
65
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { max, min, sum } from "d3-array";
|
|
2
|
+
import { nest } from "d3-collection";
|
|
3
|
+
/**
|
|
4
|
+
@module boxBuffer
|
|
5
|
+
@desc Adds a buffer to either side of the non-discrete axis.
|
|
6
|
+
@param {Array} data
|
|
7
|
+
@param {D3Scale} x
|
|
8
|
+
@param {D3Scale} y
|
|
9
|
+
@param {Object} [config]
|
|
10
|
+
@param {Number} [buffer = 10]
|
|
11
|
+
@private
|
|
12
|
+
*/ export default function(param) {
|
|
13
|
+
var _this = this;
|
|
14
|
+
var data = param.data, x = param.x, y = param.y, x2 = param.x2, y2 = param.y2, _param_buffer = param.buffer, buffer = _param_buffer === void 0 ? 10 : _param_buffer;
|
|
15
|
+
var xKey = x2 ? "x2" : "x";
|
|
16
|
+
var yKey = y2 ? "y2" : "y";
|
|
17
|
+
var oppScale = this._discrete === "x" ? y : x;
|
|
18
|
+
var oppDomain = oppScale.domain().slice();
|
|
19
|
+
var isDiscreteX = this._discrete === "x";
|
|
20
|
+
if (isDiscreteX) oppDomain.reverse();
|
|
21
|
+
var negVals, posVals;
|
|
22
|
+
if (this._stacked) {
|
|
23
|
+
var groupedData = nest().key(function(d) {
|
|
24
|
+
return d[_this._discrete];
|
|
25
|
+
}).entries(data).map(function(d) {
|
|
26
|
+
return d.values.map(function(x) {
|
|
27
|
+
return x[isDiscreteX ? yKey : xKey];
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
posVals = groupedData.map(function(arr) {
|
|
31
|
+
return sum(arr.filter(function(d) {
|
|
32
|
+
return d > 0;
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
negVals = groupedData.map(function(arr) {
|
|
36
|
+
return sum(arr.filter(function(d) {
|
|
37
|
+
return d < 0;
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
posVals = data.map(function(d) {
|
|
42
|
+
return d[isDiscreteX ? yKey : xKey];
|
|
43
|
+
});
|
|
44
|
+
negVals = posVals;
|
|
45
|
+
}
|
|
46
|
+
var bMax = oppScale(max(posVals));
|
|
47
|
+
bMax += isDiscreteX ? -buffer : buffer;
|
|
48
|
+
bMax = oppScale.invert(bMax);
|
|
49
|
+
var bMin = oppScale(min(negVals));
|
|
50
|
+
bMin += isDiscreteX ? buffer : -buffer;
|
|
51
|
+
bMin = oppScale.invert(bMin);
|
|
52
|
+
if (bMax > oppDomain[1]) oppDomain[1] = bMax;
|
|
53
|
+
if (bMin < oppDomain[0]) oppDomain[0] = bMin;
|
|
54
|
+
if (isDiscreteX) oppDomain.reverse();
|
|
55
|
+
oppScale.domain(oppDomain);
|
|
56
|
+
return [
|
|
57
|
+
x,
|
|
58
|
+
y
|
|
59
|
+
];
|
|
60
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import discreteBuffer from "./discreteBuffer.js";
|
|
2
|
+
import numericBuffer from "./numericBuffer.js";
|
|
3
|
+
/**
|
|
4
|
+
@module circleBuffer
|
|
5
|
+
@desc Adds a buffer to either side of the non-discrete axis.
|
|
6
|
+
@param {Array} data
|
|
7
|
+
@param {D3Scale} x
|
|
8
|
+
@param {D3Scale} y
|
|
9
|
+
@param {Object} [config]
|
|
10
|
+
@param {Number} [buffer] Defaults to the radius of the largest Circle.
|
|
11
|
+
@private
|
|
12
|
+
*/ export default function(param) {
|
|
13
|
+
var data = param.data, x = param.x, y = param.y, x2 = param.x2, y2 = param.y2, yScale = param.yScale, xScale = param.xScale, config = param.config, buffer = param.buffer;
|
|
14
|
+
x = x.copy();
|
|
15
|
+
y = y.copy();
|
|
16
|
+
var xKey = x2 ? "x2" : "x";
|
|
17
|
+
var yKey = y2 ? "y2" : "y";
|
|
18
|
+
var xD = x.domain().slice(), yD = y.domain().slice();
|
|
19
|
+
var xR = x.range(), yR = y.range();
|
|
20
|
+
if (!x.invert && x.padding) discreteBuffer(x, data, this._discrete);
|
|
21
|
+
if (!y.invert && y.padding) discreteBuffer(y, data, this._discrete);
|
|
22
|
+
if (x.invert || y.invert) {
|
|
23
|
+
data.forEach(function(d) {
|
|
24
|
+
var s = buffer ? buffer : config.r(d.data, d.i) * 2;
|
|
25
|
+
if (x.invert) {
|
|
26
|
+
xD = numericBuffer(x, xScale, d[xKey], s, xR, xD, 0, false);
|
|
27
|
+
xD = numericBuffer(x, xScale, d[xKey], s, xR, xD, 1, false);
|
|
28
|
+
}
|
|
29
|
+
if (y.invert) {
|
|
30
|
+
yD = numericBuffer(y, yScale, d[yKey], s, yR, yD, 0, true);
|
|
31
|
+
yD = numericBuffer(y, yScale, d[yKey], s, yR, yD, 1, true);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return [
|
|
36
|
+
x,
|
|
37
|
+
y
|
|
38
|
+
];
|
|
39
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { max } from "d3-array";
|
|
2
|
+
/**
|
|
3
|
+
@module lineBuffer
|
|
4
|
+
@desc Adds a buffer to either side of the non-discrete axis.
|
|
5
|
+
@param {Array} data
|
|
6
|
+
@param {D3Scale} x
|
|
7
|
+
@param {D3Scale} y
|
|
8
|
+
@param {Object} [config]
|
|
9
|
+
@param {Number} [buffer] Defaults to the radius of the largest Circle.
|
|
10
|
+
@private
|
|
11
|
+
*/ export default function(param) {
|
|
12
|
+
var _this = this;
|
|
13
|
+
var data = param.data, x = param.x, y = param.y, x2 = param.x2, y2 = param.y2;
|
|
14
|
+
var xKey = x2 ? "x2" : "x";
|
|
15
|
+
var yKey = y2 ? "y2" : "y";
|
|
16
|
+
var s = this._discrete === "x" ? y : x;
|
|
17
|
+
var d = s.domain().slice();
|
|
18
|
+
if (this._discrete === "x") d.reverse();
|
|
19
|
+
var vals = data.map(function(d) {
|
|
20
|
+
return d[_this._discrete === "x" ? yKey : xKey];
|
|
21
|
+
});
|
|
22
|
+
var b = s.invert(s(max(vals)) + (this._discrete === "x" ? -10 : 10));
|
|
23
|
+
if (b > d[1]) d[1] = b;
|
|
24
|
+
if (this._discrete === "x") d.reverse();
|
|
25
|
+
s.domain(d);
|
|
26
|
+
return [
|
|
27
|
+
x,
|
|
28
|
+
y
|
|
29
|
+
];
|
|
30
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import discreteBuffer from "./discreteBuffer.js";
|
|
2
|
+
import numericBuffer from "./numericBuffer.js";
|
|
3
|
+
/**
|
|
4
|
+
@module rectBuffer
|
|
5
|
+
@desc Adds a buffer to either side of the non-discrete axis.
|
|
6
|
+
@param {Array} data
|
|
7
|
+
@param {D3Scale} x
|
|
8
|
+
@param {D3Scale} y
|
|
9
|
+
@param {Object} [config]
|
|
10
|
+
@param {Number} [buffer] Defaults to the width/height of the largest Rect.
|
|
11
|
+
@private
|
|
12
|
+
*/ export default function(param) {
|
|
13
|
+
var data = param.data, x = param.x, y = param.y, x2 = param.x2, y2 = param.y2, yScale = param.yScale, xScale = param.xScale, config = param.config;
|
|
14
|
+
x = x.copy();
|
|
15
|
+
y = y.copy();
|
|
16
|
+
var xKey = x2 ? "x2" : "x";
|
|
17
|
+
var yKey = y2 ? "y2" : "y";
|
|
18
|
+
var xD = x.domain().slice(), yD = y.domain().slice();
|
|
19
|
+
var xR = x.range(), yR = y.range();
|
|
20
|
+
if (!x.invert && x.padding) discreteBuffer(x, data, this._discrete);
|
|
21
|
+
if (!y.invert && y.padding) discreteBuffer(y, data, this._discrete);
|
|
22
|
+
if (x.invert || y.invert) {
|
|
23
|
+
data.forEach(function(d) {
|
|
24
|
+
if (x.invert) {
|
|
25
|
+
var w = config.width(d.data, d.i);
|
|
26
|
+
xD = numericBuffer(x, xScale, d[xKey], w, xR, xD, 0, false);
|
|
27
|
+
xD = numericBuffer(x, xScale, d[xKey], w, xR, xD, 1, false);
|
|
28
|
+
}
|
|
29
|
+
if (y.invert) {
|
|
30
|
+
var h = config.height(d.data, d.i);
|
|
31
|
+
yD = numericBuffer(y, yScale, d[yKey], h, yR, yD, 0, true);
|
|
32
|
+
yD = numericBuffer(y, yScale, d[yKey], h, yR, yD, 1, true);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return [
|
|
37
|
+
x,
|
|
38
|
+
y
|
|
39
|
+
];
|
|
40
|
+
}
|