@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,518 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
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 { sstyled } from "@semcore/utils/lib/core/index";
|
|
10
|
+
import { sstyled as sstyled$1, Component, assignProps } from "@semcore/core";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import uniqueIDEnhancement from "@semcore/utils/lib/uniqueID";
|
|
13
|
+
import createElement from "./createElement.mjs";
|
|
14
|
+
import AnimatedClipPath from "./AnimatedClipPath.mjs";
|
|
15
|
+
import { scaleToBand, roundedPath, eventToPoint } from "./utils.mjs";
|
|
16
|
+
import { PatternFill } from "./Pattern.mjs";
|
|
17
|
+
import trottle from "@semcore/utils/lib/rafTrottle";
|
|
18
|
+
import Tooltip from "./Tooltip.mjs";
|
|
19
|
+
import { callAllEventHandlers } from "@semcore/utils/lib/assignProps";
|
|
20
|
+
import canUseDOM from "@semcore/utils/lib/canUseDOM";
|
|
21
|
+
import { Box } from "@semcore/flex-box";
|
|
22
|
+
/*!__reshadow-styles__:"./style/bar.shadow.css"*/
|
|
23
|
+
var style = (
|
|
24
|
+
/*__reshadow_css_start__*/
|
|
25
|
+
(sstyled.insert(
|
|
26
|
+
/*__inner_css_start__*/
|
|
27
|
+
".___SBar_1rv7u_gg_{fill:var(--intergalactic-chart-palette-order-1, #2bb3ff);transition-property:height,width,y;transition-duration:var(--duration_1rv7u);transition-timing-function:ease-in-out}.___SBar_1rv7u_gg_.__color_1rv7u_gg_{fill:var(--color_1rv7u)}.___SBar_1rv7u_gg_.__pattern_1rv7u_gg_.__color_1rv7u_gg_{fill:var(--pattern_1rv7u);stroke:var(--color_1rv7u);stroke-width:1px}.___SBar_1rv7u_gg_.__hide_1rv7u_gg_{display:none}.___SBar_1rv7u_gg_.__transparent_1rv7u_gg_{opacity:.3}.___SBackground_1rv7u_gg_.__onClick_1rv7u_gg_,.___SBar_1rv7u_gg_.__onClick_1rv7u_gg_{cursor:pointer}.___SBackground_1rv7u_gg_{fill:var(--intergalactic-chart-grid-bar-chart-base-bg, #e0e1e9)}.___SBarAnnotation_1rv7u_gg_{display:flex;justify-content:space-between}.___SBarLabel_1rv7u_gg_{color:var(--intergalactic-text-primary, #191b23);margin-right:auto}.___SBarLabel_1rv7u_gg_,.___SBarPercent_1rv7u_gg_,.___SBarValue_1rv7u_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SBarPercent_1rv7u_gg_{color:var(--intergalactic-text-secondary, #6c6e79);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SBarValue_1rv7u_gg_{min-width:52px;display:flex;justify-content:flex-end;color:var(--intergalactic-text-primary, #191b23);text-align:right}.___SCompactHorizontalBarHoverRect_1rv7u_gg_{fill:var(--intergalactic-chart-grid-bar-chart-hover, rgba(196, 199, 207, 0.3))}",
|
|
28
|
+
/*__inner_css_end__*/
|
|
29
|
+
"1rv7u_gg_"
|
|
30
|
+
), /*__reshadow_css_end__*/
|
|
31
|
+
{
|
|
32
|
+
"__SBar": "___SBar_1rv7u_gg_",
|
|
33
|
+
"--duration": "--duration_1rv7u",
|
|
34
|
+
"_color": "__color_1rv7u_gg_",
|
|
35
|
+
"--color": "--color_1rv7u",
|
|
36
|
+
"_pattern": "__pattern_1rv7u_gg_",
|
|
37
|
+
"--pattern": "--pattern_1rv7u",
|
|
38
|
+
"_hide": "__hide_1rv7u_gg_",
|
|
39
|
+
"_transparent": "__transparent_1rv7u_gg_",
|
|
40
|
+
"_onClick": "__onClick_1rv7u_gg_",
|
|
41
|
+
"__SBackground": "___SBackground_1rv7u_gg_",
|
|
42
|
+
"__SBarAnnotation": "___SBarAnnotation_1rv7u_gg_",
|
|
43
|
+
"__SBarLabel": "___SBarLabel_1rv7u_gg_",
|
|
44
|
+
"__SBarPercent": "___SBarPercent_1rv7u_gg_",
|
|
45
|
+
"__SBarValue": "___SBarValue_1rv7u_gg_",
|
|
46
|
+
"__SCompactHorizontalBarHoverRect": "___SCompactHorizontalBarHoverRect_1rv7u_gg_"
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
var MIN_WIDTH = 4;
|
|
50
|
+
var barHeight = 20;
|
|
51
|
+
var hoverOffset = 6;
|
|
52
|
+
var CompactHorizontalBarRoot = /* @__PURE__ */ function(_Component) {
|
|
53
|
+
_inherits(CompactHorizontalBarRoot2, _Component);
|
|
54
|
+
var _super = _createSuper(CompactHorizontalBarRoot2);
|
|
55
|
+
function CompactHorizontalBarRoot2() {
|
|
56
|
+
var _this;
|
|
57
|
+
_classCallCheck(this, CompactHorizontalBarRoot2);
|
|
58
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
|
+
args[_key] = arguments[_key];
|
|
60
|
+
}
|
|
61
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
62
|
+
_defineProperty(_assertThisInitialized(_this), "percentFormatter", null);
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "percentFormatterLocale", null);
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "valueFormatter", null);
|
|
65
|
+
_defineProperty(_assertThisInitialized(_this), "valueFormatterLocale", null);
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
_createClass(CompactHorizontalBarRoot2, [{
|
|
69
|
+
key: "getBarProps",
|
|
70
|
+
value: function getBarProps(_props, index) {
|
|
71
|
+
return {
|
|
72
|
+
index
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "getBarBackgroundProps",
|
|
77
|
+
value: function getBarBackgroundProps(_props, index) {
|
|
78
|
+
var _this$asProps = this.asProps, data = _this$asProps.data, scale = _this$asProps.scale;
|
|
79
|
+
var bar = this.computeBarData(data[index], index);
|
|
80
|
+
return {
|
|
81
|
+
scale,
|
|
82
|
+
index,
|
|
83
|
+
x: bar.x,
|
|
84
|
+
y: bar.y + bar.height - barHeight - hoverOffset,
|
|
85
|
+
height: barHeight,
|
|
86
|
+
width: bar.fullWidth
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "getBarFillProps",
|
|
91
|
+
value: function getBarFillProps(_props, index) {
|
|
92
|
+
var _this$asProps2 = this.asProps, data = _this$asProps2.data, uid = _this$asProps2.uid, patterns = _this$asProps2.patterns, color = _this$asProps2.color, transparent = _this$asProps2.transparent, hide = _this$asProps2.hide, scale = _this$asProps2.scale;
|
|
93
|
+
var bar = this.computeBarData(data[index], index);
|
|
94
|
+
return {
|
|
95
|
+
x: bar.x,
|
|
96
|
+
y: bar.y + bar.height - barHeight - hoverOffset,
|
|
97
|
+
height: barHeight,
|
|
98
|
+
width: bar.width,
|
|
99
|
+
i: index,
|
|
100
|
+
uid,
|
|
101
|
+
resolveColor: this.asProps.resolveColor,
|
|
102
|
+
patterns,
|
|
103
|
+
color,
|
|
104
|
+
transparent,
|
|
105
|
+
hide,
|
|
106
|
+
scale,
|
|
107
|
+
index
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "getAnnotationProps",
|
|
112
|
+
value: function getAnnotationProps(_props, index) {
|
|
113
|
+
var _this$asProps3 = this.asProps, data = _this$asProps3.data, size = _this$asProps3.size;
|
|
114
|
+
var bar = this.computeBarData(data[index], index);
|
|
115
|
+
return {
|
|
116
|
+
y: bar.y,
|
|
117
|
+
height: barHeight * 2,
|
|
118
|
+
width: size[0],
|
|
119
|
+
index
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "getLabelProps",
|
|
124
|
+
value: function getLabelProps(_props, index) {
|
|
125
|
+
var _this$asProps4 = this.asProps, data = _this$asProps4.data, y = _this$asProps4.y;
|
|
126
|
+
var label = data[index][y];
|
|
127
|
+
return {
|
|
128
|
+
children: label,
|
|
129
|
+
index
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "getPercentFormatter",
|
|
134
|
+
value: function getPercentFormatter() {
|
|
135
|
+
if (!this.percentFormatter || this.percentFormatterLocale !== this.asProps.locale) {
|
|
136
|
+
this.percentFormatter = new Intl.NumberFormat(this.asProps.locale, {
|
|
137
|
+
style: "percent"
|
|
138
|
+
});
|
|
139
|
+
this.percentFormatterLocale = this.asProps.locale;
|
|
140
|
+
}
|
|
141
|
+
return this.percentFormatter;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "getValueFormatter",
|
|
145
|
+
value: function getValueFormatter() {
|
|
146
|
+
if (!this.valueFormatter || this.valueFormatterLocale !== this.asProps.locale) {
|
|
147
|
+
this.valueFormatter = new Intl.NumberFormat(this.asProps.locale);
|
|
148
|
+
this.valueFormatterLocale = this.asProps.locale;
|
|
149
|
+
}
|
|
150
|
+
return this.valueFormatter;
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "getPercentProps",
|
|
154
|
+
value: function getPercentProps(_props, index) {
|
|
155
|
+
var _this$asProps5 = this.asProps, data = _this$asProps5.data, x = _this$asProps5.x, scale = _this$asProps5.scale;
|
|
156
|
+
var value = data[index][x];
|
|
157
|
+
var domain = scale[0].domain();
|
|
158
|
+
var percent = value / domain[1];
|
|
159
|
+
var formatter = this.getPercentFormatter();
|
|
160
|
+
var formatted = formatter.format(percent);
|
|
161
|
+
return {
|
|
162
|
+
children: formatted,
|
|
163
|
+
formatted,
|
|
164
|
+
percent
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "getValueProps",
|
|
169
|
+
value: function getValueProps(_props, index) {
|
|
170
|
+
var _this$asProps6 = this.asProps, data = _this$asProps6.data, x = _this$asProps6.x;
|
|
171
|
+
var value = data[index][x];
|
|
172
|
+
var formatter = this.getValueFormatter();
|
|
173
|
+
var formatted = formatter.format(value);
|
|
174
|
+
return {
|
|
175
|
+
children: formatted,
|
|
176
|
+
formatted,
|
|
177
|
+
value
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
key: "getHoverProps",
|
|
182
|
+
value: function getHoverProps(_props, index) {
|
|
183
|
+
var _this2 = this;
|
|
184
|
+
var data = this.asProps.data;
|
|
185
|
+
return {
|
|
186
|
+
data,
|
|
187
|
+
getBarData: function getBarData(index2) {
|
|
188
|
+
return _this2.computeBarData(data[index2], index2);
|
|
189
|
+
},
|
|
190
|
+
render: index === 0
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "getTooltipProps",
|
|
195
|
+
value: function getTooltipProps(_props, index) {
|
|
196
|
+
return {
|
|
197
|
+
render: index === 0,
|
|
198
|
+
index
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
key: "computeBarData",
|
|
203
|
+
value: function computeBarData(d) {
|
|
204
|
+
var _this$asProps7 = this.asProps, x = _this$asProps7.x, y = _this$asProps7.y, scale = _this$asProps7.scale, offsetProps = _this$asProps7.offset, wMin = _this$asProps7.wMin, heightProps = _this$asProps7.height, _this$asProps7$maxBar = _this$asProps7.maxBarSize, maxBarSize = _this$asProps7$maxBar === void 0 ? Infinity : _this$asProps7$maxBar, size = _this$asProps7.size;
|
|
205
|
+
var offset = typeof offsetProps === "function" ? offsetProps(i) : offsetProps;
|
|
206
|
+
var _scale = _slicedToArray(scale, 2), xScale = _scale[0], yScale = _scale[1];
|
|
207
|
+
var absWidth = xScale(d[x]);
|
|
208
|
+
var bandHeight = heightProps || scaleToBand(yScale).bandwidth();
|
|
209
|
+
var height = Math.min(bandHeight, maxBarSize);
|
|
210
|
+
var width = absWidth === 0 ? 0 : Math.max(absWidth, wMin);
|
|
211
|
+
var barY = yScale(d[y]) + bandHeight / 2 - height / 2 + offset[1];
|
|
212
|
+
return {
|
|
213
|
+
x: 0,
|
|
214
|
+
y: barY,
|
|
215
|
+
width,
|
|
216
|
+
fullWidth: size[0],
|
|
217
|
+
height
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "renderBar",
|
|
222
|
+
value: function renderBar(d, i2) {
|
|
223
|
+
var _ref5;
|
|
224
|
+
var SCompactHorizontalBarGroup = this.Element;
|
|
225
|
+
var _this$asProps8 = this.asProps, styles = _this$asProps8.styles, groupKey = _this$asProps8.groupKey;
|
|
226
|
+
var _this$computeBarData = this.computeBarData(d, i2), x = _this$computeBarData.x, y = _this$computeBarData.y;
|
|
227
|
+
this.asProps.dataHintsHandler.describeValueEntity("".concat(i2, ".").concat(x), groupKey !== null && groupKey !== void 0 ? groupKey : d[y]);
|
|
228
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
229
|
+
key: "horizontal-bar-".concat(i2)
|
|
230
|
+
}, (_ref5 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SCompactHorizontalBarGroup, _ref5.cn("SCompactHorizontalBarGroup", {
|
|
231
|
+
"render": "g"
|
|
232
|
+
}))));
|
|
233
|
+
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "renderBars",
|
|
236
|
+
value: function renderBars() {
|
|
237
|
+
var data = this.asProps.data;
|
|
238
|
+
return data.map(this.renderBar.bind(this));
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
key: "render",
|
|
242
|
+
value: function render() {
|
|
243
|
+
var _this$asProps9 = this.asProps, uid = _this$asProps9.uid, size = _this$asProps9.size, duration = _this$asProps9.duration;
|
|
244
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, this.renderBars(), duration && /* @__PURE__ */ React.createElement(AnimatedClipPath, {
|
|
245
|
+
"aria-hidden": true,
|
|
246
|
+
duration,
|
|
247
|
+
id: uid,
|
|
248
|
+
x: "0",
|
|
249
|
+
y: "0",
|
|
250
|
+
width: 0,
|
|
251
|
+
height: size[1]
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
}]);
|
|
255
|
+
return CompactHorizontalBarRoot2;
|
|
256
|
+
}(Component);
|
|
257
|
+
_defineProperty(CompactHorizontalBarRoot, "displayName", "CompactHorizontalBar");
|
|
258
|
+
_defineProperty(CompactHorizontalBarRoot, "enhance", [uniqueIDEnhancement()]);
|
|
259
|
+
_defineProperty(CompactHorizontalBarRoot, "style", style);
|
|
260
|
+
_defineProperty(CompactHorizontalBarRoot, "defaultProps", {
|
|
261
|
+
offset: [0, 0],
|
|
262
|
+
duration: 500,
|
|
263
|
+
wMin: MIN_WIDTH,
|
|
264
|
+
locale: "en",
|
|
265
|
+
color: "chart-palette-order-1"
|
|
266
|
+
});
|
|
267
|
+
function Annotation(props) {
|
|
268
|
+
var _ref6;
|
|
269
|
+
var Children = props.Children, y = props.y, height = props.height, width = props.width, styles = props.styles;
|
|
270
|
+
var SBarAnnotation = "div";
|
|
271
|
+
return _ref6 = sstyled$1(styles), /* @__PURE__ */ React.createElement("foreignObject", _ref6.cn("foreignObject", {
|
|
272
|
+
"x": "0",
|
|
273
|
+
"y": y - barHeight,
|
|
274
|
+
"height": height,
|
|
275
|
+
"width": width
|
|
276
|
+
}), /* @__PURE__ */ React.createElement(SBarAnnotation, _ref6.cn("SBarAnnotation", {}), /* @__PURE__ */ React.createElement(Children, _ref6.cn("Children", {}))));
|
|
277
|
+
}
|
|
278
|
+
var excludeProps = ["data", "scale", "value", "offset"];
|
|
279
|
+
function Label(props) {
|
|
280
|
+
var _ref = arguments[0], _ref7;
|
|
281
|
+
var SBarLabel = Box;
|
|
282
|
+
var styles = props.styles, Children = props.Children;
|
|
283
|
+
return _ref7 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBarLabel, _ref7.cn("SBarLabel", _objectSpread({}, assignProps({
|
|
284
|
+
"__excludeProps": excludeProps
|
|
285
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref7.cn("Children", {})));
|
|
286
|
+
}
|
|
287
|
+
function Percent(props) {
|
|
288
|
+
var _ref2 = arguments[0], _ref8;
|
|
289
|
+
var SBarPercent = Box;
|
|
290
|
+
var styles = props.styles, Children = props.Children;
|
|
291
|
+
return _ref8 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBarPercent, _ref8.cn("SBarPercent", _objectSpread({}, assignProps({
|
|
292
|
+
"__excludeProps": excludeProps
|
|
293
|
+
}, _ref2))), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {})));
|
|
294
|
+
}
|
|
295
|
+
function Value(props) {
|
|
296
|
+
var _ref3 = arguments[0], _ref9;
|
|
297
|
+
var SBarValue = Box;
|
|
298
|
+
var styles = props.styles, Children = props.Children;
|
|
299
|
+
return _ref9 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBarValue, _ref9.cn("SBarValue", _objectSpread({}, assignProps({
|
|
300
|
+
"__excludeProps": excludeProps
|
|
301
|
+
}, _ref3))), /* @__PURE__ */ React.createElement(Children, _ref9.cn("Children", {})));
|
|
302
|
+
}
|
|
303
|
+
var BarContext = /* @__PURE__ */ React.createContext({});
|
|
304
|
+
function Bar(props) {
|
|
305
|
+
var Children = props.Children, index = props.index, onClick = props.onClick, transparent = props.transparent, hide = props.hide;
|
|
306
|
+
var onClickHandler = React.useCallback(function(event) {
|
|
307
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(index, event);
|
|
308
|
+
}, [onClick, index]);
|
|
309
|
+
var contextValue = React.useMemo(function() {
|
|
310
|
+
return {
|
|
311
|
+
onClick: onClickHandler,
|
|
312
|
+
transparent,
|
|
313
|
+
hide
|
|
314
|
+
};
|
|
315
|
+
}, [onClickHandler, transparent, hide]);
|
|
316
|
+
return /* @__PURE__ */ React.createElement(BarContext.Provider, {
|
|
317
|
+
value: contextValue
|
|
318
|
+
}, /* @__PURE__ */ React.createElement(Children, null));
|
|
319
|
+
}
|
|
320
|
+
function BarFill(props) {
|
|
321
|
+
var _ref10;
|
|
322
|
+
var SBar = props.Element, styles = props.styles, color = props.color, x = props.x, y = props.y, width = props.width, height = props.height, uid = props.uid, duration = props.duration, resolveColor = props.resolveColor, patterns = props.patterns, i2 = props.i, scale = props.scale;
|
|
323
|
+
var _scale2 = _slicedToArray(scale, 1), xScale = _scale2[0];
|
|
324
|
+
var xRange = xScale.range();
|
|
325
|
+
var backgroundWidth = xRange[1] - xRange[0];
|
|
326
|
+
var radius = 0;
|
|
327
|
+
var pathD = React.useMemo(function() {
|
|
328
|
+
if (backgroundWidth - radius > width) {
|
|
329
|
+
return roundedPath(x, y, width, height, radius);
|
|
330
|
+
}
|
|
331
|
+
return roundedPath(x, y, width, height, radius, false, true, false, true);
|
|
332
|
+
}, [x, y, height, width, radius]);
|
|
333
|
+
var barProps = React.useContext(BarContext);
|
|
334
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, (_ref10 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBar, _ref10.cn("SBar", {
|
|
335
|
+
"aria-hidden": true,
|
|
336
|
+
"render": "path",
|
|
337
|
+
"d": pathD,
|
|
338
|
+
"clipPath": "url(#".concat(uid, ")"),
|
|
339
|
+
"__excludeProps": ["data", "scale", "value", "offset"],
|
|
340
|
+
"childrenPosition": "above",
|
|
341
|
+
"index": i2,
|
|
342
|
+
"color": resolveColor(color),
|
|
343
|
+
"pattern": patterns ? "url(#".concat(uid, "-").concat(i2, "-pattern)") : void 0,
|
|
344
|
+
"x": x,
|
|
345
|
+
"y": y,
|
|
346
|
+
"width": width,
|
|
347
|
+
"height": height,
|
|
348
|
+
"use:duration": "".concat(duration, "ms"),
|
|
349
|
+
"onClick": callAllEventHandlers(props.onClick, barProps.onClick),
|
|
350
|
+
"transparent": barProps.transparent || props.transparent,
|
|
351
|
+
"hide": barProps.hide || props.hide
|
|
352
|
+
}))), patterns && /* @__PURE__ */ React.createElement(PatternFill, _ref10.cn("PatternFill", {
|
|
353
|
+
"id": "".concat(uid, "-").concat(i2, "-pattern"),
|
|
354
|
+
"patternKey": color,
|
|
355
|
+
"color": resolveColor(color),
|
|
356
|
+
"patterns": patterns
|
|
357
|
+
})));
|
|
358
|
+
}
|
|
359
|
+
function BarBackground(props) {
|
|
360
|
+
var _ref11;
|
|
361
|
+
var SBackground = props.Element, styles = props.styles, scale = props.scale, y = props.y, x = props.x, height = props.height;
|
|
362
|
+
var _scale3 = _slicedToArray(scale, 1), xScale = _scale3[0];
|
|
363
|
+
var xRange = xScale.range();
|
|
364
|
+
var width = xRange[1] - xRange[0];
|
|
365
|
+
var radius = 0;
|
|
366
|
+
var pathD = React.useMemo(function() {
|
|
367
|
+
return roundedPath(x, y, width, height, radius, false, true, false, true);
|
|
368
|
+
}, [x, y, height, width, radius]);
|
|
369
|
+
var barProps = React.useContext(BarContext);
|
|
370
|
+
return _ref11 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBackground, _ref11.cn("SBackground", {
|
|
371
|
+
"aria-hidden": true,
|
|
372
|
+
"render": "path",
|
|
373
|
+
"d": pathD,
|
|
374
|
+
"childrenPosition": "above",
|
|
375
|
+
"width": xRange[1] - xRange[0],
|
|
376
|
+
"height": height,
|
|
377
|
+
"x": x,
|
|
378
|
+
"y": y,
|
|
379
|
+
"transparent": barProps.transparent,
|
|
380
|
+
"onClick": callAllEventHandlers(props.onClick, barProps.onClick)
|
|
381
|
+
}));
|
|
382
|
+
}
|
|
383
|
+
var Hover = /* @__PURE__ */ function(_Component2) {
|
|
384
|
+
_inherits(Hover2, _Component2);
|
|
385
|
+
var _super2 = _createSuper(Hover2);
|
|
386
|
+
function Hover2() {
|
|
387
|
+
var _this3;
|
|
388
|
+
_classCallCheck(this, Hover2);
|
|
389
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
390
|
+
args[_key2] = arguments[_key2];
|
|
391
|
+
}
|
|
392
|
+
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
393
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
394
|
+
index: null
|
|
395
|
+
});
|
|
396
|
+
_defineProperty(_assertThisInitialized(_this3), "virtualElement", canUseDOM() ? document.createElement("div") : {});
|
|
397
|
+
_defineProperty(_assertThisInitialized(_this3), "unsubscribeMouseMoveRoot", null);
|
|
398
|
+
_defineProperty(_assertThisInitialized(_this3), "unsubscribeMouseLeaveRoot", null);
|
|
399
|
+
_defineProperty(_assertThisInitialized(_this3), "handlerMouseMoveRoot", trottle(function(e) {
|
|
400
|
+
var _this3$asProps = _this3.asProps, eventEmitter = _this3$asProps.eventEmitter, rootRef = _this3$asProps.rootRef, patterns = _this3$asProps.patterns;
|
|
401
|
+
var point = eventToPoint(e, rootRef.current);
|
|
402
|
+
var clientX = e.clientX, clientY = e.clientY;
|
|
403
|
+
var index = _this3.getIndex(point);
|
|
404
|
+
_this3.setState({
|
|
405
|
+
index
|
|
406
|
+
}, function() {
|
|
407
|
+
eventEmitter.emit("setTooltipPosition", clientX, clientY);
|
|
408
|
+
eventEmitter.emit("setTooltipRenderingProps", {}, {
|
|
409
|
+
index,
|
|
410
|
+
patterns
|
|
411
|
+
});
|
|
412
|
+
eventEmitter.emit("setTooltipVisible", index !== null);
|
|
413
|
+
});
|
|
414
|
+
}));
|
|
415
|
+
_defineProperty(_assertThisInitialized(_this3), "handlerMouseLeaveRoot", trottle(function() {
|
|
416
|
+
_this3.setState({
|
|
417
|
+
index: null
|
|
418
|
+
}, function() {
|
|
419
|
+
_this3.asProps.eventEmitter.emit("setTooltipVisible", false);
|
|
420
|
+
});
|
|
421
|
+
}));
|
|
422
|
+
return _this3;
|
|
423
|
+
}
|
|
424
|
+
_createClass(Hover2, [{
|
|
425
|
+
key: "generateGetBoundingClientRect",
|
|
426
|
+
value: function generateGetBoundingClientRect() {
|
|
427
|
+
var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
|
428
|
+
var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
429
|
+
return function() {
|
|
430
|
+
return {
|
|
431
|
+
width: 0,
|
|
432
|
+
height: 0,
|
|
433
|
+
top: y,
|
|
434
|
+
right: x,
|
|
435
|
+
bottom: y,
|
|
436
|
+
left: x
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}, {
|
|
441
|
+
key: "getIndex",
|
|
442
|
+
value: function getIndex(point) {
|
|
443
|
+
var _this$asProps10 = this.asProps, data = _this$asProps10.data, getBarData = _this$asProps10.getBarData;
|
|
444
|
+
for (var _i = 0; _i < data.length; _i++) {
|
|
445
|
+
var bar = getBarData(_i);
|
|
446
|
+
if (point[0] >= bar.x && point[0] <= bar.x + bar.fullWidth && point[1] >= bar.y && point[1] <= bar.y + bar.height) {
|
|
447
|
+
return _i;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
}, {
|
|
453
|
+
key: "componentDidMount",
|
|
454
|
+
value: function componentDidMount() {
|
|
455
|
+
var _this4 = this;
|
|
456
|
+
var eventEmitter = this.asProps.eventEmitter;
|
|
457
|
+
this.unsubscribeMouseMoveRoot = eventEmitter.subscribe("onMouseMoveRoot", function(e) {
|
|
458
|
+
e.persist();
|
|
459
|
+
_this4.handlerMouseMoveRoot(e);
|
|
460
|
+
});
|
|
461
|
+
this.unsubscribeMouseLeaveRoot = eventEmitter.subscribe("onMouseLeaveRoot", this.handlerMouseLeaveRoot);
|
|
462
|
+
}
|
|
463
|
+
}, {
|
|
464
|
+
key: "componentWillUnmount",
|
|
465
|
+
value: function componentWillUnmount() {
|
|
466
|
+
if (this.unsubscribeMouseMoveRoot) {
|
|
467
|
+
this.unsubscribeMouseMoveRoot();
|
|
468
|
+
}
|
|
469
|
+
if (this.unsubscribeMouseLeaveRoot) {
|
|
470
|
+
this.unsubscribeMouseLeaveRoot();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}, {
|
|
474
|
+
key: "render",
|
|
475
|
+
value: function render() {
|
|
476
|
+
var _ref12;
|
|
477
|
+
var _this$asProps11 = this.asProps, styles = _this$asProps11.styles, getBarData = _this$asProps11.getBarData, render2 = _this$asProps11.render;
|
|
478
|
+
if (!render2) return null;
|
|
479
|
+
var index = this.state.index;
|
|
480
|
+
var SCompactHorizontalBarHoverRect = this.Element;
|
|
481
|
+
if (index === null) return null;
|
|
482
|
+
var bar = getBarData(index);
|
|
483
|
+
return _ref12 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SCompactHorizontalBarHoverRect, _ref12.cn("SCompactHorizontalBarHoverRect", {
|
|
484
|
+
"render": "rect",
|
|
485
|
+
"x": bar.x,
|
|
486
|
+
"y": bar.y + bar.height - barHeight - hoverOffset * 2,
|
|
487
|
+
"width": bar.fullWidth,
|
|
488
|
+
"height": barHeight + hoverOffset * 2
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
}]);
|
|
492
|
+
return Hover2;
|
|
493
|
+
}(Component);
|
|
494
|
+
var CompactHorizontalBarTooltip = function CompactHorizontalBarTooltip2(props) {
|
|
495
|
+
var _ref4 = arguments[0], _ref13;
|
|
496
|
+
if (!props.render) return null;
|
|
497
|
+
var SCompactHorizontalBarRadarTooltip = Tooltip;
|
|
498
|
+
return _ref13 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SCompactHorizontalBarRadarTooltip, _ref13.cn("SCompactHorizontalBarRadarTooltip", _objectSpread({}, assignProps({
|
|
499
|
+
"tag": CompactHorizontalBar.Hover,
|
|
500
|
+
"excludeAnchorProps": true
|
|
501
|
+
}, _ref4))));
|
|
502
|
+
};
|
|
503
|
+
var CompactHorizontalBar = createElement(CompactHorizontalBarRoot, {
|
|
504
|
+
Annotation,
|
|
505
|
+
Label,
|
|
506
|
+
Percent,
|
|
507
|
+
Value,
|
|
508
|
+
Bar: [Bar, {
|
|
509
|
+
Fill: BarFill,
|
|
510
|
+
Background: BarBackground
|
|
511
|
+
}],
|
|
512
|
+
Hover,
|
|
513
|
+
Tooltip: [CompactHorizontalBarTooltip, Tooltip._______childrenComponents]
|
|
514
|
+
});
|
|
515
|
+
export {
|
|
516
|
+
MIN_WIDTH,
|
|
517
|
+
CompactHorizontalBar as default
|
|
518
|
+
};
|