@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.
Files changed (87) hide show
  1. package/README.md +6219 -0
  2. package/es/index.js +4 -0
  3. package/es/src/charts/AreaPlot.js +86 -0
  4. package/es/src/charts/BarChart.js +93 -0
  5. package/es/src/charts/BoxWhisker.js +97 -0
  6. package/es/src/charts/BumpChart.js +148 -0
  7. package/es/src/charts/Donut.js +84 -0
  8. package/es/src/charts/Geomap.js +833 -0
  9. package/es/src/charts/LinePlot.js +84 -0
  10. package/es/src/charts/Matrix.js +358 -0
  11. package/es/src/charts/Network.js +787 -0
  12. package/es/src/charts/Pack.js +318 -0
  13. package/es/src/charts/Pie.js +242 -0
  14. package/es/src/charts/Plot.js +2212 -0
  15. package/es/src/charts/Priestley.js +312 -0
  16. package/es/src/charts/Radar.js +365 -0
  17. package/es/src/charts/RadialMatrix.js +393 -0
  18. package/es/src/charts/Rings.js +777 -0
  19. package/es/src/charts/Sankey.js +413 -0
  20. package/es/src/charts/StackedArea.js +80 -0
  21. package/es/src/charts/Tree.js +312 -0
  22. package/es/src/charts/Treemap.js +406 -0
  23. package/es/src/charts/Viz.js +2017 -0
  24. package/es/src/charts/drawSteps/drawAttribution.js +14 -0
  25. package/es/src/charts/drawSteps/drawBack.js +23 -0
  26. package/es/src/charts/drawSteps/drawColorScale.js +69 -0
  27. package/es/src/charts/drawSteps/drawLegend.js +120 -0
  28. package/es/src/charts/drawSteps/drawSubtitle.js +31 -0
  29. package/es/src/charts/drawSteps/drawTimeline.js +80 -0
  30. package/es/src/charts/drawSteps/drawTitle.js +31 -0
  31. package/es/src/charts/drawSteps/drawTotal.js +32 -0
  32. package/es/src/charts/drawSteps/zoomControls.js +254 -0
  33. package/es/src/charts/events/click.legend.js +76 -0
  34. package/es/src/charts/events/click.shape.js +26 -0
  35. package/es/src/charts/events/mouseenter.js +31 -0
  36. package/es/src/charts/events/mouseleave.js +21 -0
  37. package/es/src/charts/events/mousemove.legend.js +64 -0
  38. package/es/src/charts/events/mousemove.shape.js +42 -0
  39. package/es/src/charts/events/touchstart.body.js +7 -0
  40. package/es/src/charts/helpers/matrixData.js +104 -0
  41. package/es/src/charts/helpers/tileAttributions.js +34 -0
  42. package/es/src/charts/index.js +21 -0
  43. package/es/src/charts/plotBuffers/Bar.js +65 -0
  44. package/es/src/charts/plotBuffers/Box.js +60 -0
  45. package/es/src/charts/plotBuffers/Circle.js +39 -0
  46. package/es/src/charts/plotBuffers/Line.js +30 -0
  47. package/es/src/charts/plotBuffers/Rect.js +40 -0
  48. package/es/src/charts/plotBuffers/discreteBuffer.js +24 -0
  49. package/es/src/charts/plotBuffers/numericBuffer.js +111 -0
  50. package/es/src/components/Axis.js +1567 -0
  51. package/es/src/components/AxisBottom.js +77 -0
  52. package/es/src/components/AxisLeft.js +77 -0
  53. package/es/src/components/AxisRight.js +77 -0
  54. package/es/src/components/AxisTop.js +77 -0
  55. package/es/src/components/ColorScale.js +958 -0
  56. package/es/src/components/Legend.js +673 -0
  57. package/es/src/components/Message.js +95 -0
  58. package/es/src/components/TextBox.js +752 -0
  59. package/es/src/components/Timeline.js +760 -0
  60. package/es/src/components/Tooltip.js +726 -0
  61. package/es/src/components/index.js +11 -0
  62. package/es/src/shapes/Area.js +361 -0
  63. package/es/src/shapes/Bar.js +342 -0
  64. package/es/src/shapes/Box.js +482 -0
  65. package/es/src/shapes/Circle.js +201 -0
  66. package/es/src/shapes/Image.js +255 -0
  67. package/es/src/shapes/Line.js +289 -0
  68. package/es/src/shapes/Path.js +186 -0
  69. package/es/src/shapes/Rect.js +215 -0
  70. package/es/src/shapes/Shape.js +1156 -0
  71. package/es/src/shapes/Whisker.js +330 -0
  72. package/es/src/shapes/index.js +10 -0
  73. package/es/src/utils/BaseClass.js +204 -0
  74. package/es/src/utils/RESET.js +4 -0
  75. package/es/src/utils/accessor.js +19 -0
  76. package/es/src/utils/configPrep.js +76 -0
  77. package/es/src/utils/constant.js +15 -0
  78. package/es/src/utils/getProp.js +9 -0
  79. package/es/src/utils/index.js +7 -0
  80. package/es/src/utils/uuid.js +13 -0
  81. package/package.json +68 -0
  82. package/umd/d3plus-core.full.js +56459 -0
  83. package/umd/d3plus-core.full.js.map +1 -0
  84. package/umd/d3plus-core.full.min.js +7241 -0
  85. package/umd/d3plus-core.js +14422 -0
  86. package/umd/d3plus-core.js.map +1 -0
  87. package/umd/d3plus-core.min.js +4564 -0
@@ -0,0 +1,186 @@
1
+ function _assert_this_initialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _call_super(_this, derived, args) {
8
+ derived = _get_prototype_of(derived);
9
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
10
+ }
11
+ function _class_call_check(instance, Constructor) {
12
+ if (!(instance instanceof Constructor)) {
13
+ throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ }
16
+ function _defineProperties(target, props) {
17
+ for(var i = 0; i < props.length; i++){
18
+ var descriptor = props[i];
19
+ descriptor.enumerable = descriptor.enumerable || false;
20
+ descriptor.configurable = true;
21
+ if ("value" in descriptor) descriptor.writable = true;
22
+ Object.defineProperty(target, descriptor.key, descriptor);
23
+ }
24
+ }
25
+ function _create_class(Constructor, protoProps, staticProps) {
26
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
+ if (staticProps) _defineProperties(Constructor, staticProps);
28
+ return Constructor;
29
+ }
30
+ function _get(target, property, receiver) {
31
+ if (typeof Reflect !== "undefined" && Reflect.get) {
32
+ _get = Reflect.get;
33
+ } else {
34
+ _get = function get(target, property, receiver) {
35
+ var base = _super_prop_base(target, property);
36
+ if (!base) return;
37
+ var desc = Object.getOwnPropertyDescriptor(base, property);
38
+ if (desc.get) {
39
+ return desc.get.call(receiver || target);
40
+ }
41
+ return desc.value;
42
+ };
43
+ }
44
+ return _get(target, property, receiver || target);
45
+ }
46
+ function _get_prototype_of(o) {
47
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
48
+ return o.__proto__ || Object.getPrototypeOf(o);
49
+ };
50
+ return _get_prototype_of(o);
51
+ }
52
+ function _inherits(subClass, superClass) {
53
+ if (typeof superClass !== "function" && superClass !== null) {
54
+ throw new TypeError("Super expression must either be null or a function");
55
+ }
56
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
57
+ constructor: {
58
+ value: subClass,
59
+ writable: true,
60
+ configurable: true
61
+ }
62
+ });
63
+ if (superClass) _set_prototype_of(subClass, superClass);
64
+ }
65
+ function _possible_constructor_return(self, call) {
66
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
67
+ return call;
68
+ }
69
+ return _assert_this_initialized(self);
70
+ }
71
+ function _set_prototype_of(o, p) {
72
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
73
+ o.__proto__ = p;
74
+ return o;
75
+ };
76
+ return _set_prototype_of(o, p);
77
+ }
78
+ function _super_prop_base(object, property) {
79
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
80
+ object = _get_prototype_of(object);
81
+ if (object === null) break;
82
+ }
83
+ return object;
84
+ }
85
+ function _type_of(obj) {
86
+ "@swc/helpers - typeof";
87
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
88
+ }
89
+ function _is_native_reflect_construct() {
90
+ try {
91
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
92
+ } catch (_) {}
93
+ return (_is_native_reflect_construct = function() {
94
+ return !!result;
95
+ })();
96
+ }
97
+ import { largestRect, path2polygon } from "@d3plus/math";
98
+ import { accessor, constant } from "../utils/index.js";
99
+ import Shape from "./Shape.js";
100
+ var Path = /*#__PURE__*/ function(Shape) {
101
+ "use strict";
102
+ _inherits(Path, Shape);
103
+ function Path() {
104
+ _class_call_check(this, Path);
105
+ var _this;
106
+ _this = _call_super(this, Path, [
107
+ "path"
108
+ ]);
109
+ _this._d = accessor("path");
110
+ _this._labelBounds = function(d, i, aes) {
111
+ var r = largestRect(aes.points, {
112
+ angle: _this._labelConfig.rotate ? _this._labelConfig.rotate(d, i) : 0
113
+ });
114
+ return r ? {
115
+ angle: r.angle,
116
+ width: r.width,
117
+ height: r.height,
118
+ x: r.cx - r.width / 2,
119
+ y: r.cy - r.height / 2
120
+ } : false;
121
+ };
122
+ _this._name = "Path";
123
+ _this._labelConfig = Object.assign(_this._labelConfig, {
124
+ textAnchor: "middle",
125
+ verticalAlign: "middle"
126
+ });
127
+ return _this;
128
+ }
129
+ _create_class(Path, [
130
+ {
131
+ /**
132
+ @memberof Path
133
+ @desc Given a specific data point and index, returns the aesthetic properties of the shape.
134
+ @param {Object} *data point*
135
+ @param {Number} *index*
136
+ @private
137
+ */ key: "_aes",
138
+ value: function _aes(d, i) {
139
+ return {
140
+ points: path2polygon(this._d(d, i))
141
+ };
142
+ }
143
+ },
144
+ {
145
+ /**
146
+ @memberof Path
147
+ @desc Draws the paths.
148
+ @param {Function} [*callback*]
149
+ @chainable
150
+ */ key: "render",
151
+ value: function render(callback) {
152
+ _get(_get_prototype_of(Path.prototype), "render", this).call(this, callback);
153
+ var enter = this._enter.attr("d", this._d).call(this._applyStyle.bind(this));
154
+ var update = this._update;
155
+ if (this._duration) {
156
+ enter.attr("opacity", 0).transition(this._transition).attr("opacity", 1);
157
+ update = update.transition(this._transition);
158
+ this._exit.transition(this._transition).attr("opacity", 0);
159
+ }
160
+ update.call(this._applyStyle.bind(this)).attr("d", this._d);
161
+ return this;
162
+ }
163
+ },
164
+ {
165
+ /**
166
+ @memberof Path
167
+ @desc If *value* is specified, sets the "d" attribute accessor to the specified function or number and returns the current class instance.
168
+ @param {Function|String} [*value*]
169
+ @chainable
170
+ @example
171
+ function(d) {
172
+ return d.path;
173
+ }
174
+ */ key: "d",
175
+ value: function d(_) {
176
+ return arguments.length ? (this._d = typeof _ === "function" ? _ : constant(_), this) : this._d;
177
+ }
178
+ }
179
+ ]);
180
+ return Path;
181
+ }(Shape);
182
+ /**
183
+ @class Path
184
+ @extends Shape
185
+ @desc Creates SVG Paths based on an array of data.
186
+ */ export { Path as default };
@@ -0,0 +1,215 @@
1
+ function _assert_this_initialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _call_super(_this, derived, args) {
8
+ derived = _get_prototype_of(derived);
9
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
10
+ }
11
+ function _class_call_check(instance, Constructor) {
12
+ if (!(instance instanceof Constructor)) {
13
+ throw new TypeError("Cannot call a class as a function");
14
+ }
15
+ }
16
+ function _defineProperties(target, props) {
17
+ for(var i = 0; i < props.length; i++){
18
+ var descriptor = props[i];
19
+ descriptor.enumerable = descriptor.enumerable || false;
20
+ descriptor.configurable = true;
21
+ if ("value" in descriptor) descriptor.writable = true;
22
+ Object.defineProperty(target, descriptor.key, descriptor);
23
+ }
24
+ }
25
+ function _create_class(Constructor, protoProps, staticProps) {
26
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
+ if (staticProps) _defineProperties(Constructor, staticProps);
28
+ return Constructor;
29
+ }
30
+ function _get(target, property, receiver) {
31
+ if (typeof Reflect !== "undefined" && Reflect.get) {
32
+ _get = Reflect.get;
33
+ } else {
34
+ _get = function get(target, property, receiver) {
35
+ var base = _super_prop_base(target, property);
36
+ if (!base) return;
37
+ var desc = Object.getOwnPropertyDescriptor(base, property);
38
+ if (desc.get) {
39
+ return desc.get.call(receiver || target);
40
+ }
41
+ return desc.value;
42
+ };
43
+ }
44
+ return _get(target, property, receiver || target);
45
+ }
46
+ function _get_prototype_of(o) {
47
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
48
+ return o.__proto__ || Object.getPrototypeOf(o);
49
+ };
50
+ return _get_prototype_of(o);
51
+ }
52
+ function _inherits(subClass, superClass) {
53
+ if (typeof superClass !== "function" && superClass !== null) {
54
+ throw new TypeError("Super expression must either be null or a function");
55
+ }
56
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
57
+ constructor: {
58
+ value: subClass,
59
+ writable: true,
60
+ configurable: true
61
+ }
62
+ });
63
+ if (superClass) _set_prototype_of(subClass, superClass);
64
+ }
65
+ function _possible_constructor_return(self, call) {
66
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
67
+ return call;
68
+ }
69
+ return _assert_this_initialized(self);
70
+ }
71
+ function _set_prototype_of(o, p) {
72
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
73
+ o.__proto__ = p;
74
+ return o;
75
+ };
76
+ return _set_prototype_of(o, p);
77
+ }
78
+ function _super_prop_base(object, property) {
79
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
80
+ object = _get_prototype_of(object);
81
+ if (object === null) break;
82
+ }
83
+ return object;
84
+ }
85
+ function _type_of(obj) {
86
+ "@swc/helpers - typeof";
87
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
88
+ }
89
+ function _is_native_reflect_construct() {
90
+ try {
91
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
92
+ } catch (_) {}
93
+ return (_is_native_reflect_construct = function() {
94
+ return !!result;
95
+ })();
96
+ }
97
+ import { accessor, constant } from "../utils/index.js";
98
+ import Shape from "./Shape.js";
99
+ var Rect = /*#__PURE__*/ function(Shape) {
100
+ "use strict";
101
+ _inherits(Rect, Shape);
102
+ function Rect() {
103
+ _class_call_check(this, Rect);
104
+ var _this;
105
+ _this = _call_super(this, Rect, [
106
+ "rect"
107
+ ]);
108
+ _this._height = accessor("height");
109
+ _this._labelBounds = function(d, i, s) {
110
+ return {
111
+ width: s.width,
112
+ height: s.height,
113
+ x: -s.width / 2,
114
+ y: -s.height / 2
115
+ };
116
+ };
117
+ _this._name = "Rect";
118
+ _this._width = accessor("width");
119
+ return _this;
120
+ }
121
+ _create_class(Rect, [
122
+ {
123
+ /**
124
+ @memberof Rect
125
+ @desc Draws the rectangles.
126
+ @param {Function} [*callback*]
127
+ @chainable
128
+ */ key: "render",
129
+ value: function render(callback) {
130
+ _get(_get_prototype_of(Rect.prototype), "render", this).call(this, callback);
131
+ var enter = this._enter.attr("width", 0).attr("height", 0).attr("x", 0).attr("y", 0).call(this._applyStyle.bind(this));
132
+ var update = this._update;
133
+ if (this._duration) {
134
+ enter = enter.transition(this._transition);
135
+ update = update.transition(this._transition);
136
+ this._exit.transition(this._transition).attr("width", 0).attr("height", 0).attr("x", 0).attr("y", 0);
137
+ }
138
+ enter.call(this._applyPosition.bind(this));
139
+ update.call(this._applyStyle.bind(this)).call(this._applyPosition.bind(this));
140
+ return this;
141
+ }
142
+ },
143
+ {
144
+ /**
145
+ @memberof Rect
146
+ @desc Given a specific data point and index, returns the aesthetic properties of the shape.
147
+ @param {Object} *data point*
148
+ @param {Number} *index*
149
+ @private
150
+ */ key: "_aes",
151
+ value: function _aes(d, i) {
152
+ return {
153
+ width: this._width(d, i),
154
+ height: this._height(d, i)
155
+ };
156
+ }
157
+ },
158
+ {
159
+ /**
160
+ @memberof Rect
161
+ @desc Provides the default positioning to the <rect> elements.
162
+ @param {D3Selection} *elem*
163
+ @private
164
+ */ key: "_applyPosition",
165
+ value: function _applyPosition(elem) {
166
+ var _this = this;
167
+ elem.attr("width", function(d, i) {
168
+ return _this._width(d, i);
169
+ }).attr("height", function(d, i) {
170
+ return _this._height(d, i);
171
+ }).attr("x", function(d, i) {
172
+ return -_this._width(d, i) / 2;
173
+ }).attr("y", function(d, i) {
174
+ return -_this._height(d, i) / 2;
175
+ });
176
+ }
177
+ },
178
+ {
179
+ /**
180
+ @memberof Rect
181
+ @desc If *value* is specified, sets the height accessor to the specified function or number and returns the current class instance.
182
+ @param {Function|Number} [*value*]
183
+ @chainable
184
+ @example
185
+ function(d) {
186
+ return d.height;
187
+ }
188
+ */ key: "height",
189
+ value: function height(_) {
190
+ return arguments.length ? (this._height = typeof _ === "function" ? _ : constant(_), this) : this._height;
191
+ }
192
+ },
193
+ {
194
+ /**
195
+ @memberof Rect
196
+ @desc If *value* is specified, sets the width accessor to the specified function or number and returns the current class instance.
197
+ @param {Function|Number} [*value*]
198
+ @chainable
199
+ @example
200
+ function(d) {
201
+ return d.width;
202
+ }
203
+ */ key: "width",
204
+ value: function width(_) {
205
+ return arguments.length ? (this._width = typeof _ === "function" ? _ : constant(_), this) : this._width;
206
+ }
207
+ }
208
+ ]);
209
+ return Rect;
210
+ }(Shape);
211
+ /**
212
+ @class Rect
213
+ @extends Shape
214
+ @desc Creates SVG rectangles based on an array of data. See [this example](https://d3plus.org/examples/d3plus-shape/getting-started/) for help getting started using the rectangle generator.
215
+ */ export { Rect as default };