@semcore/d3-chart 3.60.0 → 3.60.1
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/CHANGELOG.md +6 -0
- package/lib/cjs/Area.js +14 -12
- package/lib/cjs/Area.js.map +1 -1
- package/lib/cjs/Axis.js +17 -15
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +19 -17
- package/lib/cjs/Bar.js.map +1 -1
- package/lib/cjs/Bubble.js +15 -13
- package/lib/cjs/Bubble.js.map +1 -1
- package/lib/cjs/CompactHorizontalBar.js +19 -17
- package/lib/cjs/CompactHorizontalBar.js.map +1 -1
- package/lib/cjs/Donut.js +12 -10
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +11 -9
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +19 -17
- package/lib/cjs/HorizontalBar.js.map +1 -1
- package/lib/cjs/Hover.js +6 -4
- package/lib/cjs/Hover.js.map +1 -1
- package/lib/cjs/Line.js +12 -10
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Plot.js +6 -4
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/Radar.js +22 -20
- package/lib/cjs/Radar.js.map +1 -1
- package/lib/cjs/RadialTree.js +15 -13
- package/lib/cjs/RadialTree.js.map +1 -1
- package/lib/cjs/Reference.js +15 -13
- package/lib/cjs/Reference.js.map +1 -1
- package/lib/cjs/ScatterPlot.js +12 -10
- package/lib/cjs/ScatterPlot.js.map +1 -1
- package/lib/cjs/Tooltip.js +12 -10
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/Venn.js +12 -10
- package/lib/cjs/Venn.js.map +1 -1
- package/lib/cjs/a11y/PlotA11yModule.js +5 -3
- package/lib/cjs/a11y/PlotA11yModule.js.map +1 -1
- package/lib/cjs/a11y/PlotA11yView.js +5 -3
- package/lib/cjs/a11y/PlotA11yView.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +7 -5
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +20 -18
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +9 -7
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/es6/Area.js +14 -12
- package/lib/es6/Area.js.map +1 -1
- package/lib/es6/Axis.js +17 -15
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +19 -17
- package/lib/es6/Bar.js.map +1 -1
- package/lib/es6/Bubble.js +15 -13
- package/lib/es6/Bubble.js.map +1 -1
- package/lib/es6/CompactHorizontalBar.js +19 -17
- package/lib/es6/CompactHorizontalBar.js.map +1 -1
- package/lib/es6/Donut.js +12 -10
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +11 -9
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/HorizontalBar.js +19 -17
- package/lib/es6/HorizontalBar.js.map +1 -1
- package/lib/es6/Hover.js +6 -4
- package/lib/es6/Hover.js.map +1 -1
- package/lib/es6/Line.js +12 -10
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Plot.js +6 -4
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/Radar.js +22 -20
- package/lib/es6/Radar.js.map +1 -1
- package/lib/es6/RadialTree.js +15 -13
- package/lib/es6/RadialTree.js.map +1 -1
- package/lib/es6/Reference.js +15 -13
- package/lib/es6/Reference.js.map +1 -1
- package/lib/es6/ScatterPlot.js +12 -10
- package/lib/es6/ScatterPlot.js.map +1 -1
- package/lib/es6/Tooltip.js +12 -10
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/Venn.js +12 -10
- package/lib/es6/Venn.js.map +1 -1
- package/lib/es6/a11y/PlotA11yModule.js +5 -3
- package/lib/es6/a11y/PlotA11yModule.js.map +1 -1
- package/lib/es6/a11y/PlotA11yView.js +5 -3
- package/lib/es6/a11y/PlotA11yView.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +7 -5
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +20 -18
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +9 -7
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/esm/AnimatedClipPath.mjs +54 -0
- package/lib/esm/Area.mjs +189 -0
- package/lib/esm/Axis.mjs +406 -0
- package/lib/esm/Bar.mjs +201 -0
- package/lib/esm/Bubble.mjs +216 -0
- package/lib/esm/CompactHorizontalBar.mjs +518 -0
- package/lib/esm/Donut.mjs +415 -0
- package/lib/esm/Dots.mjs +120 -0
- package/lib/esm/GroupBar.mjs +94 -0
- package/lib/esm/HorizontalBar.mjs +181 -0
- package/lib/esm/Hover.mjs +217 -0
- package/lib/esm/Line.mjs +199 -0
- package/lib/esm/Pattern.mjs +520 -0
- package/lib/esm/Plot.mjs +137 -0
- package/lib/esm/Radar.mjs +706 -0
- package/lib/esm/RadialTree.mjs +565 -0
- package/lib/esm/Reference.mjs +243 -0
- package/lib/esm/ResponsiveContainer.mjs +99 -0
- package/lib/esm/ScatterPlot.mjs +194 -0
- package/lib/esm/StackBar.mjs +177 -0
- package/lib/esm/StackedArea.mjs +84 -0
- package/lib/esm/Tooltip.mjs +255 -0
- package/lib/esm/Venn.mjs +234 -0
- package/lib/esm/a11y/DataAccessibilityTable.mjs +100 -0
- package/lib/esm/a11y/PlotA11yModule.mjs +117 -0
- package/lib/esm/a11y/PlotA11yView.mjs +146 -0
- package/lib/esm/a11y/bezier.mjs +32 -0
- package/lib/esm/a11y/focus.mjs +44 -0
- package/lib/esm/a11y/hints.mjs +122 -0
- package/lib/esm/a11y/insights.mjs +700 -0
- package/lib/esm/a11y/intl.mjs +17 -0
- package/lib/esm/a11y/locale.mjs +39 -0
- package/lib/esm/a11y/serialize.mjs +363 -0
- package/lib/esm/a11y/summarize.mjs +14 -0
- package/lib/esm/a11y/translations/module/__intergalactic-dynamic-locales.mjs +33 -0
- package/lib/esm/a11y/translations/module/de.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/en.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/es.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/fr.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/it.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/ja.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/ko.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/nl.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/pl.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/pt.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/sv.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/tr.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/vi.json.mjs +14 -0
- package/lib/esm/a11y/translations/module/zh.json.mjs +14 -0
- package/lib/esm/a11y/translations/view/__intergalactic-dynamic-locales.mjs +33 -0
- package/lib/esm/a11y/translations/view/de.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/en.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/es.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/fr.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/it.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/ja.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/ko.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/nl.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/pl.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/pt.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/sv.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/tr.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/vi.json.mjs +48 -0
- package/lib/esm/a11y/translations/view/zh.json.mjs +48 -0
- package/lib/esm/color.mjs +127 -0
- package/lib/esm/component/Chart/AbstractChart.mjs +408 -0
- package/lib/esm/component/Chart/AreaChart.mjs +145 -0
- package/lib/esm/component/Chart/BarChart.mjs +240 -0
- package/lib/esm/component/Chart/BubbleChart.mjs +135 -0
- package/lib/esm/component/Chart/CigaretteChart.mjs +294 -0
- package/lib/esm/component/Chart/CompactHorizontalBarChart.mjs +113 -0
- package/lib/esm/component/Chart/DonutChart.mjs +113 -0
- package/lib/esm/component/Chart/HistogramChart.mjs +166 -0
- package/lib/esm/component/Chart/LineChart.mjs +131 -0
- package/lib/esm/component/Chart/RadarChart.mjs +115 -0
- package/lib/esm/component/Chart/ScatterPlotChart.mjs +144 -0
- package/lib/esm/component/Chart/VennChart.mjs +141 -0
- package/lib/esm/component/Chart/index.mjs +27 -0
- package/lib/esm/component/ChartLegend/BaseLegend.mjs +91 -0
- package/lib/esm/component/ChartLegend/LegendFlex/LegendFlex.mjs +86 -0
- package/lib/esm/component/ChartLegend/LegendFlex/legend-flex.shadow.css +12 -0
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.mjs +240 -0
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.type.mjs +4 -0
- package/lib/esm/component/ChartLegend/LegendItem/legend-item.shadow.css +129 -0
- package/lib/esm/component/ChartLegend/LegendTable/LegendTable.mjs +90 -0
- package/lib/esm/component/ChartLegend/LegendTable/legend-table.shadow.css +19 -0
- package/lib/esm/component/ChartLegend/index.mjs +5 -0
- package/lib/esm/component/Cigarette/Cigarette.mjs +139 -0
- package/lib/esm/component/StackGroupBar/StackGroupBar.mjs +141 -0
- package/lib/esm/createElement.mjs +104 -0
- package/lib/esm/index.mjs +70 -0
- package/lib/esm/style/area.shadow.css +50 -0
- package/lib/esm/style/axis.shadow.css +88 -0
- package/lib/esm/style/bar.shadow.css +66 -0
- package/lib/esm/style/bubble.shadow.css +64 -0
- package/lib/esm/style/donut.shadow.css +36 -0
- package/lib/esm/style/dot.shadow.css +27 -0
- package/lib/esm/style/hover.shadow.css +9 -0
- package/lib/esm/style/line.shadow.css +43 -0
- package/lib/esm/style/plot.shadow.css +19 -0
- package/lib/esm/style/plotA11yModule.shadow.css +12 -0
- package/lib/esm/style/plotA11yView.shadow.css +39 -0
- package/lib/esm/style/radar.shadow.css +80 -0
- package/lib/esm/style/radial-tree.shadow.css +54 -0
- package/lib/esm/style/reference.shadow.css +43 -0
- package/lib/esm/style/scatterplot.shadow.css +41 -0
- package/lib/esm/style/tooltip.shadow.css +42 -0
- package/lib/esm/style/venn.shadow.css +48 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +31 -0
- package/lib/esm/translations/en.json.mjs +12 -0
- package/lib/esm/translations/es.json.mjs +11 -0
- package/lib/esm/translations/fr.json.mjs +11 -0
- package/lib/esm/translations/it.json.mjs +11 -0
- package/lib/esm/translations/ja.json.mjs +11 -0
- package/lib/esm/translations/ko.json.mjs +11 -0
- package/lib/esm/translations/nl.json.mjs +11 -0
- package/lib/esm/translations/pl.json.mjs +11 -0
- package/lib/esm/translations/pt.json.mjs +11 -0
- package/lib/esm/translations/sv.json.mjs +11 -0
- package/lib/esm/translations/tr.json.mjs +11 -0
- package/lib/esm/translations/vi.json.mjs +11 -0
- package/lib/esm/translations/zh.json.mjs +11 -0
- package/lib/esm/utils.mjs +266 -0
- package/package.json +11 -11
- package/vite.config.ts +2 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
10
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
11
|
+
import { Component, sstyled as sstyled$1, assignProps } from "@semcore/core";
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { arc, pie } from "d3-shape";
|
|
14
|
+
import { interpolate } from "d3-interpolate";
|
|
15
|
+
import { transition } from "d3-transition";
|
|
16
|
+
import canUseDOM from "@semcore/utils/lib/canUseDOM";
|
|
17
|
+
import getOriginChildren from "@semcore/utils/lib/getOriginChildren";
|
|
18
|
+
import uniqueIDEnhancement from "@semcore/utils/lib/uniqueID";
|
|
19
|
+
import createElement from "./createElement.mjs";
|
|
20
|
+
import { getChartDefaultColorName } from "./utils.mjs";
|
|
21
|
+
import Tooltip from "./Tooltip.mjs";
|
|
22
|
+
import { PatternFill } from "./Pattern.mjs";
|
|
23
|
+
var _excluded = ["Element", "styles", "d3Arc", "data", "color", "$animationActivePie", "active", "d3ArcOut", "name", "dataKey", "dataHintsHandler", "transparent", "innerRadius", "outerRadius", "resolveColor", "halfsize", "uid", "patterns"];
|
|
24
|
+
/*!__reshadow-styles__:"./style/donut.shadow.css"*/
|
|
25
|
+
var style = (
|
|
26
|
+
/*__reshadow_css_start__*/
|
|
27
|
+
(sstyled.insert(
|
|
28
|
+
/*__inner_css_start__*/
|
|
29
|
+
".___SPie_qq3rk_gg_{stroke:var(--intergalactic-chart-grid-border, #ffffff);fill:var(--intergalactic-chart-palette-order-1, #2bb3ff)}.___SPie_qq3rk_gg_.__color_qq3rk_gg_{fill:var(--color_qq3rk)}.___SPie_qq3rk_gg_.__pattern_qq3rk_gg_.__color_qq3rk_gg_{fill:var(--pattern_qq3rk);stroke:var(--color_qq3rk);stroke-width:1px}.___SPie_qq3rk_gg_.__transparent_qq3rk_gg_{opacity:.3}.___SEmptyData_qq3rk_gg_{fill:var(--intergalactic-chart-palette-order-null, #e0e1e9)}.___SEmptyData_qq3rk_gg_.__color_qq3rk_gg_{fill:var(--color_qq3rk)}.___SLabel_qq3rk_gg_{text-anchor:middle;vertical-anchor:middle;font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}",
|
|
30
|
+
/*__inner_css_end__*/
|
|
31
|
+
"qq3rk_gg_"
|
|
32
|
+
), /*__reshadow_css_end__*/
|
|
33
|
+
{
|
|
34
|
+
"__SPie": "___SPie_qq3rk_gg_",
|
|
35
|
+
"_color": "__color_qq3rk_gg_",
|
|
36
|
+
"--color": "--color_qq3rk",
|
|
37
|
+
"_pattern": "__pattern_qq3rk_gg_",
|
|
38
|
+
"--pattern": "--pattern_qq3rk",
|
|
39
|
+
"_transparent": "__transparent_qq3rk_gg_",
|
|
40
|
+
"__SEmptyData": "___SEmptyData_qq3rk_gg_",
|
|
41
|
+
"__SLabel": "___SLabel_qq3rk_gg_"
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
var DEFAULT_INSTANCE = Symbol("DEFAULT_INSTANCE");
|
|
45
|
+
function transitionAnglePie(_ref6) {
|
|
46
|
+
var selector = _ref6.selector, duration = _ref6.duration, halfsize = _ref6.halfsize, d3Arc = _ref6.d3Arc, d3ArcOut = _ref6.d3ArcOut, arcs = _ref6.arcs, activeIndexPie = _ref6.activeIndexPie;
|
|
47
|
+
return transition().selection().selectAll(selector).interrupt().transition().duration(duration).attrTween("d", function(_, ind) {
|
|
48
|
+
if (!arcs[ind]) return function() {
|
|
49
|
+
return "";
|
|
50
|
+
};
|
|
51
|
+
var d = Object.assign({}, arcs[ind]);
|
|
52
|
+
var self = this;
|
|
53
|
+
var initAngle = halfsize ? -Math.PI / 2 : 0;
|
|
54
|
+
var prevStartAngle = initAngle;
|
|
55
|
+
var prevEndAngle = initAngle;
|
|
56
|
+
if (self.arc) {
|
|
57
|
+
prevStartAngle = self.arc.startAngle;
|
|
58
|
+
prevEndAngle = self.arc.endAngle;
|
|
59
|
+
}
|
|
60
|
+
var iStartAngle = interpolate(prevStartAngle, d.startAngle);
|
|
61
|
+
var iEndAngle = interpolate(prevEndAngle, d.endAngle);
|
|
62
|
+
return function(t) {
|
|
63
|
+
d.startAngle = iStartAngle(t);
|
|
64
|
+
d.endAngle = iEndAngle(t);
|
|
65
|
+
self.arc = d;
|
|
66
|
+
return ind === activeIndexPie ? d3ArcOut(self.arc) : d3Arc(self.arc);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function transitionRadiusPie(_ref7) {
|
|
71
|
+
var data = _ref7.data, selector = _ref7.selector, element = _ref7.element, duration = _ref7.duration, innerRadius = _ref7.innerRadius, outerRadiusStartEnd = _ref7.outerRadiusStartEnd, paddingAngle = _ref7.paddingAngle;
|
|
72
|
+
return transition().selection().select(selector).interrupt().transition().duration(duration).attrTween("d", function() {
|
|
73
|
+
var _outerRadiusStartEnd = _slicedToArray(outerRadiusStartEnd, 2), start = _outerRadiusStartEnd[0], end = _outerRadiusStartEnd[1];
|
|
74
|
+
var iOuterRadius = interpolate(start, end);
|
|
75
|
+
return function(t) {
|
|
76
|
+
var outerRadiusPX = iOuterRadius(t);
|
|
77
|
+
element.dataset["currentRadius"] = outerRadiusPX;
|
|
78
|
+
var d3ArcOut = arc().innerRadius(innerRadius).outerRadius(outerRadiusPX).padAngle(paddingAngle);
|
|
79
|
+
return d3ArcOut(data);
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var increaseFactor = 8;
|
|
84
|
+
function getOuterRadius(_ref8) {
|
|
85
|
+
var size = _ref8.size, halfsize = _ref8.halfsize;
|
|
86
|
+
var _size = _slicedToArray(size, 2), width = _size[0], height = _size[1];
|
|
87
|
+
var minORmax = halfsize ? Math.max : Math.min;
|
|
88
|
+
return minORmax(width - increaseFactor * 2, height - increaseFactor * 2) / 2;
|
|
89
|
+
}
|
|
90
|
+
var DonutRoot = /* @__PURE__ */ function(_Component) {
|
|
91
|
+
_inherits(DonutRoot2, _Component);
|
|
92
|
+
var _super = _createSuper(DonutRoot2);
|
|
93
|
+
function DonutRoot2() {
|
|
94
|
+
var _this;
|
|
95
|
+
_classCallCheck(this, DonutRoot2);
|
|
96
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
97
|
+
args[_key] = arguments[_key];
|
|
98
|
+
}
|
|
99
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "virtualElement", canUseDOM() ? document.createElement("div") : {});
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "activeIndexPie", void 0);
|
|
102
|
+
_defineProperty(_assertThisInitialized(_this), "canAnimatedHover", false);
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerTooltip", function(visible, props, tooltipProps) {
|
|
104
|
+
return function(_ref9) {
|
|
105
|
+
var clientX = _ref9.clientX, clientY = _ref9.clientY;
|
|
106
|
+
var eventEmitter = _this.asProps.eventEmitter;
|
|
107
|
+
eventEmitter.emit("setTooltipPosition", clientX, clientY);
|
|
108
|
+
eventEmitter.emit("setTooltipRenderingProps", props, tooltipProps);
|
|
109
|
+
eventEmitter.emit("setTooltipVisible", visible);
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
_defineProperty(_assertThisInitialized(_this), "animationActivePie", function(_ref10) {
|
|
113
|
+
var data = _ref10.data, active = _ref10.active, selector = _ref10.selector, element = _ref10.element;
|
|
114
|
+
var _this$asProps = _this.asProps, duration = _this$asProps.duration, innerRadius = _this$asProps.innerRadius, d3Arc = _this$asProps.d3Arc, paddingAngle = _this$asProps.paddingAngle;
|
|
115
|
+
var outerRadius = d3Arc.outerRadius()();
|
|
116
|
+
var outerRadiusStartEnd = active ? [+element.dataset["currentRadius"] || outerRadius, outerRadius + increaseFactor] : [+element.dataset["currentRadius"] || outerRadius, outerRadius];
|
|
117
|
+
if (_this.canAnimatedHover && duration > 0) {
|
|
118
|
+
transitionRadiusPie({
|
|
119
|
+
data,
|
|
120
|
+
selector: "#".concat(_this.id, " ").concat(selector),
|
|
121
|
+
element,
|
|
122
|
+
duration: duration === 0 ? 0 : 300,
|
|
123
|
+
innerRadius,
|
|
124
|
+
outerRadiusStartEnd,
|
|
125
|
+
paddingAngle
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
_defineProperty(_assertThisInitialized(_this), "animationTimeout", null);
|
|
130
|
+
_defineProperty(_assertThisInitialized(_this), "animationUpdatePie", function() {
|
|
131
|
+
clearTimeout(_this.animationTimeout);
|
|
132
|
+
_this.animationTimeout = setTimeout(function() {
|
|
133
|
+
var _this$asProps2 = _this.asProps, duration = _this$asProps2.duration, d3Arc = _this$asProps2.d3Arc, halfsize = _this$asProps2.halfsize, d3ArcOut = _this$asProps2.d3ArcOut;
|
|
134
|
+
_this.canAnimatedHover = false;
|
|
135
|
+
if (duration > 0) {
|
|
136
|
+
transitionAnglePie({
|
|
137
|
+
selector: "#".concat(_this.id, ' [data-ui-name="Donut.Pie"]'),
|
|
138
|
+
duration,
|
|
139
|
+
arcs: _this.arcs,
|
|
140
|
+
halfsize,
|
|
141
|
+
d3Arc,
|
|
142
|
+
d3ArcOut,
|
|
143
|
+
activeIndexPie: _this.activeIndexPie
|
|
144
|
+
}).on("end", function() {
|
|
145
|
+
_this.canAnimatedHover = true;
|
|
146
|
+
});
|
|
147
|
+
} else {
|
|
148
|
+
_this.canAnimatedHover = true;
|
|
149
|
+
}
|
|
150
|
+
}, 0);
|
|
151
|
+
});
|
|
152
|
+
return _this;
|
|
153
|
+
}
|
|
154
|
+
_createClass(DonutRoot2, [{
|
|
155
|
+
key: "id",
|
|
156
|
+
get: function get() {
|
|
157
|
+
var _this$asProps3 = this.asProps, uid = _this$asProps3.uid, id = _this$asProps3.id;
|
|
158
|
+
return id || uid;
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "generateGetBoundingClientRect",
|
|
162
|
+
value: function generateGetBoundingClientRect() {
|
|
163
|
+
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
164
|
+
var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
165
|
+
return function() {
|
|
166
|
+
return {
|
|
167
|
+
width: 0,
|
|
168
|
+
height: 0,
|
|
169
|
+
top: y,
|
|
170
|
+
right: x,
|
|
171
|
+
bottom: y,
|
|
172
|
+
left: x
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "getArcs",
|
|
178
|
+
value: function getArcs() {
|
|
179
|
+
var _this$asProps4 = this.asProps, Children = _this$asProps4.Children, data = _this$asProps4.data, d3Pie = _this$asProps4.d3Pie;
|
|
180
|
+
var pieData = Object.entries(data);
|
|
181
|
+
if (d3Pie[DEFAULT_INSTANCE]) {
|
|
182
|
+
var keys = React.Children.toArray(getOriginChildren(Children)).reduce(function(acc, child) {
|
|
183
|
+
if (/* @__PURE__ */ React.isValidElement(child) && child.type === Donut.Pie) {
|
|
184
|
+
acc.push(child.props.dataKey);
|
|
185
|
+
}
|
|
186
|
+
return acc;
|
|
187
|
+
}, []);
|
|
188
|
+
pieData = Object.entries(data).filter(function(_ref11) {
|
|
189
|
+
var _ref12 = _slicedToArray(_ref11, 2), key = _ref12[0], value = _ref12[1];
|
|
190
|
+
return keys.includes(key) && value > 0;
|
|
191
|
+
}).sort(function(_ref13, _ref14) {
|
|
192
|
+
var _ref15 = _slicedToArray(_ref13, 1), a = _ref15[0];
|
|
193
|
+
var _ref16 = _slicedToArray(_ref14, 1), b = _ref16[0];
|
|
194
|
+
return keys.indexOf(a) > keys.indexOf(b) ? 1 : -1;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
var minValue = pieData.reduce(function(acc, cur) {
|
|
198
|
+
if (cur[1]) acc += cur[1];
|
|
199
|
+
return acc;
|
|
200
|
+
}, 0) / 100;
|
|
201
|
+
pieData = pieData.map(function(d) {
|
|
202
|
+
if (d[1] && d[1] < minValue) d[1] = minValue;
|
|
203
|
+
return d;
|
|
204
|
+
});
|
|
205
|
+
return d3Pie(pieData);
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "getPieProps",
|
|
209
|
+
value: function getPieProps(props, index) {
|
|
210
|
+
var _this2 = this;
|
|
211
|
+
var _this$asProps5 = this.asProps, d3Arc = _this$asProps5.d3Arc, d3ArcOut = _this$asProps5.d3ArcOut, innerRadius = _this$asProps5.innerRadius, outerRadius = _this$asProps5.outerRadius, halfsize = _this$asProps5.halfsize, resolveColor = _this$asProps5.resolveColor, uid = _this$asProps5.uid, patterns = _this$asProps5.patterns;
|
|
212
|
+
var active = props.active;
|
|
213
|
+
var data = this.arcs.find(function(arc2) {
|
|
214
|
+
return arc2.data[0] === props.dataKey;
|
|
215
|
+
});
|
|
216
|
+
if (active) {
|
|
217
|
+
this.activeIndexPie = index;
|
|
218
|
+
}
|
|
219
|
+
var tooltipProps = {
|
|
220
|
+
dataKey: props.dataKey,
|
|
221
|
+
name: props.name,
|
|
222
|
+
resolveColor,
|
|
223
|
+
color: props.color || getChartDefaultColorName(index),
|
|
224
|
+
active: props.active,
|
|
225
|
+
transparent: props.transparent,
|
|
226
|
+
patterns
|
|
227
|
+
};
|
|
228
|
+
return {
|
|
229
|
+
data,
|
|
230
|
+
d3Arc,
|
|
231
|
+
d3ArcOut,
|
|
232
|
+
innerRadius,
|
|
233
|
+
outerRadius,
|
|
234
|
+
uid: "".concat(uid, "-").concat(index),
|
|
235
|
+
patterns,
|
|
236
|
+
halfsize,
|
|
237
|
+
color: props.color || getChartDefaultColorName(index),
|
|
238
|
+
resolveColor,
|
|
239
|
+
$animationActivePie: this.animationActivePie,
|
|
240
|
+
onMouseMove: this.bindHandlerTooltip(true, props, tooltipProps),
|
|
241
|
+
onMouseLeave: this.bindHandlerTooltip(false, props, tooltipProps),
|
|
242
|
+
onMouseOver: function onMouseOver(e) {
|
|
243
|
+
if (!active) {
|
|
244
|
+
_this2.animationActivePie({
|
|
245
|
+
active: true,
|
|
246
|
+
data,
|
|
247
|
+
selector: '[d="'.concat(e.target.getAttribute("d"), '"]'),
|
|
248
|
+
element: e.target
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
onMouseOut: function onMouseOut(e) {
|
|
253
|
+
if (!active) {
|
|
254
|
+
_this2.animationActivePie({
|
|
255
|
+
active: false,
|
|
256
|
+
data,
|
|
257
|
+
selector: '[d="'.concat(e.target.getAttribute("d"), '"]'),
|
|
258
|
+
element: e.target
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
}, {
|
|
265
|
+
key: "getEmptyDataProps",
|
|
266
|
+
value: function getEmptyDataProps() {
|
|
267
|
+
var d3Arc = this.asProps.d3Arc;
|
|
268
|
+
return {
|
|
269
|
+
d3Arc
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
273
|
+
key: "componentDidUpdate",
|
|
274
|
+
value: function componentDidUpdate(prevProps) {
|
|
275
|
+
var data = this.asProps.data;
|
|
276
|
+
if (prevProps.$rootProps.data !== data) {
|
|
277
|
+
this.animationUpdatePie();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}, {
|
|
281
|
+
key: "componentDidMount",
|
|
282
|
+
value: function componentDidMount() {
|
|
283
|
+
this.animationUpdatePie();
|
|
284
|
+
}
|
|
285
|
+
}, {
|
|
286
|
+
key: "render",
|
|
287
|
+
value: function render() {
|
|
288
|
+
var _this$asProps6 = this.asProps, halfsize = _this$asProps6.halfsize, size = _this$asProps6.size;
|
|
289
|
+
this.asProps.dataHintsHandler.establishDataType("values-set");
|
|
290
|
+
var _size2 = _slicedToArray(size, 2), width = _size2[0], height = _size2[1];
|
|
291
|
+
var Element = this.Element;
|
|
292
|
+
var k = halfsize ? 1 : 2;
|
|
293
|
+
this.arcs = this.getArcs();
|
|
294
|
+
return /* @__PURE__ */ React.createElement(Element, {
|
|
295
|
+
"aria-hidden": true,
|
|
296
|
+
id: this.id,
|
|
297
|
+
render: "g",
|
|
298
|
+
childrenPosition: "inside",
|
|
299
|
+
transform: "translate(".concat(width / 2, ",").concat(height / k, ")")
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}]);
|
|
303
|
+
return DonutRoot2;
|
|
304
|
+
}(Component);
|
|
305
|
+
_defineProperty(DonutRoot, "displayName", "Donut");
|
|
306
|
+
_defineProperty(DonutRoot, "style", style);
|
|
307
|
+
_defineProperty(DonutRoot, "enhance", [uniqueIDEnhancement()]);
|
|
308
|
+
_defineProperty(DonutRoot, "defaultProps", function(_ref20) {
|
|
309
|
+
var _ref20$innerRadius = _ref20.innerRadius, innerRadius = _ref20$innerRadius === void 0 ? 0 : _ref20$innerRadius, _ref20$paddingAngle = _ref20.paddingAngle, paddingAngle = _ref20$paddingAngle === void 0 ? 0 : _ref20$paddingAngle, outerRadius = _ref20.outerRadius, _ref20$halfsize = _ref20.halfsize, halfsize = _ref20$halfsize === void 0 ? false : _ref20$halfsize, size = _ref20.$rootProps.size;
|
|
310
|
+
var d3Arc = arc().outerRadius(outerRadius || getOuterRadius({
|
|
311
|
+
size,
|
|
312
|
+
halfsize,
|
|
313
|
+
outerRadius
|
|
314
|
+
})).innerRadius(innerRadius).padAngle(paddingAngle);
|
|
315
|
+
var d3ArcOut = arc().outerRadius((outerRadius || getOuterRadius({
|
|
316
|
+
size,
|
|
317
|
+
halfsize
|
|
318
|
+
})) + increaseFactor).innerRadius(innerRadius).padAngle(paddingAngle);
|
|
319
|
+
var d3Pie = pie().sort(null).value(function(_ref21) {
|
|
320
|
+
var _ref22 = _slicedToArray(_ref21, 2), value = _ref22[1];
|
|
321
|
+
return value;
|
|
322
|
+
});
|
|
323
|
+
d3Pie[DEFAULT_INSTANCE] = true;
|
|
324
|
+
if (halfsize) {
|
|
325
|
+
d3Pie = d3Pie.startAngle(-Math.PI / 2).endAngle(Math.PI / 2);
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
d3Pie,
|
|
329
|
+
d3Arc,
|
|
330
|
+
d3ArcOut,
|
|
331
|
+
duration: 500,
|
|
332
|
+
paddingAngle
|
|
333
|
+
};
|
|
334
|
+
});
|
|
335
|
+
function Pie(_ref17) {
|
|
336
|
+
var _ref2;
|
|
337
|
+
var SPie = _ref17.Element, styles = _ref17.styles, d3Arc = _ref17.d3Arc, data = _ref17.data, color = _ref17.color, $animationActivePie = _ref17.$animationActivePie, active = _ref17.active, d3ArcOut = _ref17.d3ArcOut, name = _ref17.name, dataKey = _ref17.dataKey, dataHintsHandler = _ref17.dataHintsHandler, transparent = _ref17.transparent, innerRadius = _ref17.innerRadius, outerRadius = _ref17.outerRadius, resolveColor = _ref17.resolveColor, halfsize = _ref17.halfsize, uid = _ref17.uid, patterns = _ref17.patterns, other = _objectWithoutProperties(_ref17, _excluded);
|
|
338
|
+
var _React$useState = React.useState(false), _React$useState2 = _slicedToArray(_React$useState, 2), isMount = _React$useState2[0], setIsMount = _React$useState2[1];
|
|
339
|
+
var pieRef = React.useRef(null);
|
|
340
|
+
React.useEffect(function() {
|
|
341
|
+
if (!pieRef.current) return;
|
|
342
|
+
pieRef.current.dataset["currentRadius"] = (active ? d3ArcOut : d3Arc).outerRadius()();
|
|
343
|
+
if (!isMount) {
|
|
344
|
+
setIsMount(true);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (active !== void 0 && active !== null) {
|
|
348
|
+
$animationActivePie({
|
|
349
|
+
active,
|
|
350
|
+
data,
|
|
351
|
+
selector: '[name="'.concat(other.name, '"]'),
|
|
352
|
+
element: pieRef.current
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}, [active, Boolean(data)]);
|
|
356
|
+
React.useEffect(function() {
|
|
357
|
+
if (!pieRef.current) return;
|
|
358
|
+
pieRef.current.dataset["currentRadius"] = (active ? d3ArcOut : d3Arc).outerRadius()();
|
|
359
|
+
}, [active, innerRadius, outerRadius, halfsize, Boolean(data)]);
|
|
360
|
+
if (!data) return null;
|
|
361
|
+
dataHintsHandler.establishDataType("values-set");
|
|
362
|
+
dataHintsHandler.describeValueEntity(dataKey, name);
|
|
363
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, (_ref2 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SPie, _ref2.cn("SPie", {
|
|
364
|
+
"render": "path",
|
|
365
|
+
"ref": pieRef,
|
|
366
|
+
"color": resolveColor(color),
|
|
367
|
+
"pattern": patterns ? "url(#".concat(uid, "-pattern)") : void 0,
|
|
368
|
+
"d": active ? d3ArcOut(data) : d3Arc(data),
|
|
369
|
+
"transparent": transparent
|
|
370
|
+
}))), patterns && /* @__PURE__ */ React.createElement(PatternFill, _ref2.cn("PatternFill", {
|
|
371
|
+
"id": "".concat(uid, "-pattern"),
|
|
372
|
+
"patternKey": color,
|
|
373
|
+
"color": resolveColor(color),
|
|
374
|
+
"patterns": patterns
|
|
375
|
+
})));
|
|
376
|
+
}
|
|
377
|
+
function EmptyData(_ref18) {
|
|
378
|
+
var _ref3;
|
|
379
|
+
var SEmptyData = _ref18.Element, styles = _ref18.styles, d3Arc = _ref18.d3Arc, color = _ref18.color, resolveColor = _ref18.resolveColor;
|
|
380
|
+
return _ref3 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SEmptyData, _ref3.cn("SEmptyData", {
|
|
381
|
+
"render": "path",
|
|
382
|
+
"color": resolveColor(color),
|
|
383
|
+
"d": d3Arc({
|
|
384
|
+
endAngle: Math.PI * 2,
|
|
385
|
+
startAngle: 0
|
|
386
|
+
})
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
function Label(_ref19) {
|
|
390
|
+
var _ref4;
|
|
391
|
+
var SLabel = _ref19.Element, styles = _ref19.styles, Children = _ref19.Children, children = _ref19.children, label = _ref19.label, dataHintsHandler = _ref19.dataHintsHandler, _ref19$x = _ref19.x, x = _ref19$x === void 0 ? 0 : _ref19$x, _ref19$y = _ref19.y, y = _ref19$y === void 0 ? 0 : _ref19$y;
|
|
392
|
+
dataHintsHandler.setTitle("vertical", label || children);
|
|
393
|
+
return _ref4 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SLabel, _ref4.cn("SLabel", {
|
|
394
|
+
"render": "text",
|
|
395
|
+
"x": x,
|
|
396
|
+
"y": y,
|
|
397
|
+
"aria-hidden": true
|
|
398
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref4.cn("Children", {})));
|
|
399
|
+
}
|
|
400
|
+
var DonutTooltip = function DonutTooltip2(props) {
|
|
401
|
+
var _ref = arguments[0], _ref5;
|
|
402
|
+
var SDonutTooltip = Tooltip;
|
|
403
|
+
return _ref5 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SDonutTooltip, _ref5.cn("SDonutTooltip", _objectSpread({}, assignProps({
|
|
404
|
+
"excludeAnchorProps": true
|
|
405
|
+
}, _ref))));
|
|
406
|
+
};
|
|
407
|
+
var Donut = createElement(DonutRoot, {
|
|
408
|
+
Pie,
|
|
409
|
+
Label,
|
|
410
|
+
EmptyData,
|
|
411
|
+
Tooltip: [DonutTooltip, Tooltip._______childrenComponents]
|
|
412
|
+
});
|
|
413
|
+
export {
|
|
414
|
+
Donut as default
|
|
415
|
+
};
|
package/lib/esm/Dots.mjs
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
3
|
+
import { bisector } from "d3-array";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { sstyled as sstyled$1 } from "@semcore/core";
|
|
6
|
+
import trottle from "@semcore/utils/lib/rafTrottle";
|
|
7
|
+
import createElement from "./createElement.mjs";
|
|
8
|
+
import { interpolateValue, eventToPoint, invert, getChartDefaultColorName } from "./utils.mjs";
|
|
9
|
+
import { getPatternSymbolSize, PatternSymbol } from "./Pattern.mjs";
|
|
10
|
+
/*!__reshadow-styles__:"./style/dot.shadow.css"*/
|
|
11
|
+
var style = (
|
|
12
|
+
/*__reshadow_css_start__*/
|
|
13
|
+
(sstyled.insert(
|
|
14
|
+
/*__inner_css_start__*/
|
|
15
|
+
".___SDots_5i5ei_gg_ .___SDot_5i5ei_gg_{transition-duration:var(--duration_5i5ei)}.___SDot_5i5ei_gg_{stroke-width:1px;stroke:var(--intergalactic-chart-grid-border, #ffffff);fill:var(--intergalactic-chart-palette-order-1, #2bb3ff);transition-property:cx,cy,x,y;transition-timing-function:ease-in-out}.___SDot_5i5ei_gg_.__hide_5i5ei_gg_{display:none}.___SDot_5i5ei_gg_.__color_5i5ei_gg_{fill:var(--color_5i5ei)}.___SDot_5i5ei_gg_.__transparent_5i5ei_gg_{opacity:.3}",
|
|
16
|
+
/*__inner_css_end__*/
|
|
17
|
+
"5i5ei_gg_"
|
|
18
|
+
), /*__reshadow_css_end__*/
|
|
19
|
+
{
|
|
20
|
+
"__SDot": "___SDot_5i5ei_gg_",
|
|
21
|
+
"_hide": "__hide_5i5ei_gg_",
|
|
22
|
+
"_color": "__color_5i5ei_gg_",
|
|
23
|
+
"--color": "--color_5i5ei",
|
|
24
|
+
"_transparent": "__transparent_5i5ei_gg_",
|
|
25
|
+
"__SDots": "___SDots_5i5ei_gg_",
|
|
26
|
+
"--duration": "--duration_5i5ei"
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
function Dots(props) {
|
|
30
|
+
var _ref3;
|
|
31
|
+
var SDot = props.Element, styles = props.styles, color = props.color, d3 = props.d3, x = props.x, y = props.y, eventEmitter = props.eventEmitter, display = props.display, hide = props.hide, rootRef = props.rootRef, scale = props.scale, _props$duration = props.duration, duration = _props$duration === void 0 ? 500 : _props$duration, transparent = props.transparent, _props$radius = props.radius, radiusBase = _props$radius === void 0 ? 4 : _props$radius, resolveColor = props.resolveColor, patterns = props.patterns;
|
|
32
|
+
var bisect = bisector(function(d) {
|
|
33
|
+
return d[x];
|
|
34
|
+
}).center;
|
|
35
|
+
var _React$useState = React.useState(null), _React$useState2 = _slicedToArray(_React$useState, 2), activeIndex = _React$useState2[0], setActiveIndex = _React$useState2[1];
|
|
36
|
+
var data = React.useMemo(function() {
|
|
37
|
+
return props.data.filter(function(item) {
|
|
38
|
+
return item[y] !== interpolateValue;
|
|
39
|
+
});
|
|
40
|
+
}, [props.data]);
|
|
41
|
+
var handlerMouseMoveRoot = React.useCallback(trottle(function(e) {
|
|
42
|
+
var _scale = _slicedToArray(scale, 1), xScale = _scale[0];
|
|
43
|
+
var _eventToPoint = eventToPoint(e, rootRef.current), _eventToPoint2 = _slicedToArray(_eventToPoint, 1), pX = _eventToPoint2[0];
|
|
44
|
+
var vX = invert(xScale, pX);
|
|
45
|
+
setActiveIndex(bisect(data, vX));
|
|
46
|
+
}), [scale, data]);
|
|
47
|
+
var handlerMouseLeaveRoot = React.useCallback(trottle(function() {
|
|
48
|
+
setActiveIndex(null);
|
|
49
|
+
}), []);
|
|
50
|
+
React.useEffect(function() {
|
|
51
|
+
var unsubscribeMouseMoveRoot = eventEmitter.subscribe("onMouseMoveChart", function(e) {
|
|
52
|
+
e.persist();
|
|
53
|
+
handlerMouseMoveRoot(e);
|
|
54
|
+
});
|
|
55
|
+
var unsubscribeMouseLeaveRoot = eventEmitter.subscribe("onMouseLeaveChart", handlerMouseLeaveRoot);
|
|
56
|
+
return function() {
|
|
57
|
+
unsubscribeMouseMoveRoot();
|
|
58
|
+
unsubscribeMouseLeaveRoot();
|
|
59
|
+
};
|
|
60
|
+
}, [eventEmitter, scale, data, x, y]);
|
|
61
|
+
var dots = data.reduce(function(acc, d, i) {
|
|
62
|
+
var isPrev = d3.defined()(data[i - 1] || {});
|
|
63
|
+
var isNext = d3.defined()(data[i + 1] || {});
|
|
64
|
+
var active = i === activeIndex;
|
|
65
|
+
var visible = typeof display === "function" ? display(i, i === activeIndex, !isPrev && !isNext) : display || i === activeIndex || !isPrev && !isNext;
|
|
66
|
+
var radius = radiusBase * (active ? 5 / 4 : 1);
|
|
67
|
+
if (!d3.defined()(d)) return acc;
|
|
68
|
+
if (!visible) return acc;
|
|
69
|
+
var patternKey = color || getChartDefaultColorName(0);
|
|
70
|
+
var _getPatternSymbolSize = getPatternSymbolSize({
|
|
71
|
+
patternKey,
|
|
72
|
+
patterns
|
|
73
|
+
}), _getPatternSymbolSize2 = _slicedToArray(_getPatternSymbolSize, 2), width = _getPatternSymbolSize2[0], height = _getPatternSymbolSize2[1];
|
|
74
|
+
if (!patterns) {
|
|
75
|
+
var _ref;
|
|
76
|
+
acc.push((_ref = sstyled$1(styles), /* @__PURE__ */ React.createElement(SDot, _ref.cn("SDot", {
|
|
77
|
+
"render": "circle",
|
|
78
|
+
"color": resolveColor(color),
|
|
79
|
+
"patternKey": patternKey,
|
|
80
|
+
"patterns": patterns,
|
|
81
|
+
"key": "".concat(i),
|
|
82
|
+
"value": d,
|
|
83
|
+
"visible": visible,
|
|
84
|
+
"active": active,
|
|
85
|
+
"hide": hide,
|
|
86
|
+
"transparent": transparent,
|
|
87
|
+
"cx": d3.x()(d),
|
|
88
|
+
"cy": d3.y()(d),
|
|
89
|
+
"r": radius
|
|
90
|
+
}))));
|
|
91
|
+
} else {
|
|
92
|
+
var _ref2;
|
|
93
|
+
acc.push((_ref2 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SDot, _ref2.cn("SDot", {
|
|
94
|
+
"render": PatternSymbol,
|
|
95
|
+
"color": resolveColor(color),
|
|
96
|
+
"patternKey": patternKey,
|
|
97
|
+
"patterns": patterns,
|
|
98
|
+
"key": "".concat(i),
|
|
99
|
+
"value": d,
|
|
100
|
+
"visible": visible,
|
|
101
|
+
"active": active,
|
|
102
|
+
"hide": hide,
|
|
103
|
+
"transparent": transparent,
|
|
104
|
+
"x": d3.x()(d) - width / 2,
|
|
105
|
+
"y": d3.y()(d) - height / 2,
|
|
106
|
+
"radius": radius
|
|
107
|
+
}))));
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
}, []);
|
|
111
|
+
var SDots = "g";
|
|
112
|
+
return _ref3 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SDots, _ref3.cn("SDots", {
|
|
113
|
+
"duration": "".concat(duration, "ms")
|
|
114
|
+
}), dots);
|
|
115
|
+
}
|
|
116
|
+
Dots.style = style;
|
|
117
|
+
const Dots$1 = createElement(Dots);
|
|
118
|
+
export {
|
|
119
|
+
Dots$1 as default
|
|
120
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { Component } from "@semcore/core";
|
|
8
|
+
import getOriginChildren from "@semcore/utils/lib/getOriginChildren";
|
|
9
|
+
import createElement from "./createElement.mjs";
|
|
10
|
+
import Bar from "./Bar.mjs";
|
|
11
|
+
import HorizontalBar from "./HorizontalBar.mjs";
|
|
12
|
+
import { scaleBand } from "d3-scale";
|
|
13
|
+
import { scaleToBand, getChartDefaultColorName } from "./utils.mjs";
|
|
14
|
+
var GroupBarRoot = /* @__PURE__ */ function(_Component) {
|
|
15
|
+
_inherits(GroupBarRoot2, _Component);
|
|
16
|
+
var _super = _createSuper(GroupBarRoot2);
|
|
17
|
+
function GroupBarRoot2() {
|
|
18
|
+
_classCallCheck(this, GroupBarRoot2);
|
|
19
|
+
return _super.apply(this, arguments);
|
|
20
|
+
}
|
|
21
|
+
_createClass(GroupBarRoot2, [{
|
|
22
|
+
key: "getScaleGroup",
|
|
23
|
+
value: function getScaleGroup() {
|
|
24
|
+
var _this$asProps = this.asProps, Children = _this$asProps.Children, scale = _this$asProps.scale, scaleGroup = _this$asProps.scaleGroup, x = _this$asProps.x;
|
|
25
|
+
var xyScale = x ? scale[0] : scale[1];
|
|
26
|
+
if (scaleGroup) return scaleGroup;
|
|
27
|
+
var domain = React.Children.toArray(getOriginChildren(Children)).reduce(function(acc, child) {
|
|
28
|
+
if (/* @__PURE__ */ React.isValidElement(child) && child.type === GroupBar.Bar && !child.props.hide) {
|
|
29
|
+
acc.push(child.props.y);
|
|
30
|
+
}
|
|
31
|
+
if (/* @__PURE__ */ React.isValidElement(child) && child.type === GroupBar.HorizontalBar && !child.props.hide) {
|
|
32
|
+
acc.push(child.props.x);
|
|
33
|
+
}
|
|
34
|
+
return acc;
|
|
35
|
+
}, []);
|
|
36
|
+
return scaleBand().range([0, scaleToBand(xyScale).bandwidth()]).domain(domain).paddingInner(0.1).paddingOuter(0.1);
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "getBarProps",
|
|
40
|
+
value: function getBarProps(_ref, index) {
|
|
41
|
+
var y = _ref.y;
|
|
42
|
+
var _this$asProps2 = this.asProps, x = _this$asProps2.x, _this$asProps2$maxBar = _this$asProps2.maxBarSize, maxBarSize = _this$asProps2$maxBar === void 0 ? Infinity : _this$asProps2$maxBar, patterns = _this$asProps2.patterns;
|
|
43
|
+
var bandWidth = this.scaleGroup.bandwidth();
|
|
44
|
+
var width = Math.min(bandWidth, maxBarSize);
|
|
45
|
+
var offsetX = this.scaleGroup(y) + bandWidth / 2 - width / 2;
|
|
46
|
+
return {
|
|
47
|
+
offset: [offsetX, 0],
|
|
48
|
+
width,
|
|
49
|
+
color: getChartDefaultColorName(index),
|
|
50
|
+
x,
|
|
51
|
+
groupKey: x,
|
|
52
|
+
patterns
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "getHorizontalBarProps",
|
|
57
|
+
value: function getHorizontalBarProps(_ref2, index) {
|
|
58
|
+
var x = _ref2.x;
|
|
59
|
+
var _this$asProps3 = this.asProps, y = _this$asProps3.y, _this$asProps3$maxBar = _this$asProps3.maxBarSize, maxBarSize = _this$asProps3$maxBar === void 0 ? Infinity : _this$asProps3$maxBar;
|
|
60
|
+
var bandWidth = this.scaleGroup.bandwidth();
|
|
61
|
+
var height = Math.min(bandWidth, maxBarSize);
|
|
62
|
+
var offsetY = this.scaleGroup(x) + bandWidth / 2 - height / 2;
|
|
63
|
+
return {
|
|
64
|
+
offset: [0, offsetY],
|
|
65
|
+
height,
|
|
66
|
+
color: getChartDefaultColorName(index),
|
|
67
|
+
y,
|
|
68
|
+
groupKey: y
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "render",
|
|
73
|
+
value: function render() {
|
|
74
|
+
var Element = this.Element;
|
|
75
|
+
this.scaleGroup = this.getScaleGroup();
|
|
76
|
+
this.asProps.dataHintsHandler.establishDataType("grouped-values");
|
|
77
|
+
return /* @__PURE__ */ React.createElement(Element, {
|
|
78
|
+
"aria-hidden": true,
|
|
79
|
+
render: "g",
|
|
80
|
+
childrenPosition: "inside",
|
|
81
|
+
scaleGroup: this.scaleGroup
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}]);
|
|
85
|
+
return GroupBarRoot2;
|
|
86
|
+
}(Component);
|
|
87
|
+
_defineProperty(GroupBarRoot, "displayName", "GroupBar");
|
|
88
|
+
var GroupBar = createElement(GroupBarRoot, {
|
|
89
|
+
Bar,
|
|
90
|
+
HorizontalBar
|
|
91
|
+
});
|
|
92
|
+
export {
|
|
93
|
+
GroupBar as default
|
|
94
|
+
};
|