@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,240 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
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 _get from "@babel/runtime/helpers/esm/get";
|
|
7
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
9
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
10
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import createComponent from "@semcore/core";
|
|
13
|
+
import { scaleTime, scaleBand, scaleLinear } from "d3-scale";
|
|
14
|
+
import Line from "../../Line.mjs";
|
|
15
|
+
import GroupBar from "../../GroupBar.mjs";
|
|
16
|
+
import StackBar from "../../StackBar.mjs";
|
|
17
|
+
import { HoverRect } from "../../Hover.mjs";
|
|
18
|
+
import { minMax } from "../../utils.mjs";
|
|
19
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
20
|
+
import { Flex, Box } from "@semcore/flex-box";
|
|
21
|
+
import { Text } from "@semcore/typography";
|
|
22
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
23
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
24
|
+
var BarChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
25
|
+
_inherits(BarChartComponent2, _AbstractChart);
|
|
26
|
+
var _super = _createSuper(BarChartComponent2);
|
|
27
|
+
function BarChartComponent2() {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, BarChartComponent2);
|
|
30
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
+
args[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "handleClickBar", function(_data, e, barIndex, barKey) {
|
|
35
|
+
var onClickBar = _this.asProps.onClickBar;
|
|
36
|
+
if (onClickBar) {
|
|
37
|
+
onClickBar(barIndex, barKey, e);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
_createClass(BarChartComponent2, [{
|
|
43
|
+
key: "xScale",
|
|
44
|
+
get: function get() {
|
|
45
|
+
var _this$asProps = this.asProps, xScale = _this$asProps.xScale, invertAxis = _this$asProps.invertAxis;
|
|
46
|
+
if (xScale) {
|
|
47
|
+
return xScale;
|
|
48
|
+
}
|
|
49
|
+
return invertAxis ? this.valueScale : this.categoryScale;
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "yScale",
|
|
53
|
+
get: function get() {
|
|
54
|
+
var _this$asProps2 = this.asProps, yScale = _this$asProps2.yScale, invertAxis = _this$asProps2.invertAxis;
|
|
55
|
+
if (yScale) {
|
|
56
|
+
return yScale;
|
|
57
|
+
}
|
|
58
|
+
return invertAxis ? this.categoryScale : this.valueScale;
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "defaultLegendProps",
|
|
62
|
+
value: function defaultLegendProps() {
|
|
63
|
+
if (this.props.trend !== void 0) {
|
|
64
|
+
return {
|
|
65
|
+
withTrend: true
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "renderTrend",
|
|
72
|
+
value: function renderTrend(key) {
|
|
73
|
+
var _this$asProps3 = this.asProps, groupKey = _this$asProps3.groupKey;
|
|
74
|
+
_this$asProps3.type;
|
|
75
|
+
var invertAxis = _this$asProps3.invertAxis, trend = _this$asProps3.trend;
|
|
76
|
+
var withTrend = this.state.withTrend;
|
|
77
|
+
var trendItem = trend === null || trend === void 0 ? void 0 : trend[key];
|
|
78
|
+
if (withTrend && trendItem) {
|
|
79
|
+
return /* @__PURE__ */ React.createElement(Line, {
|
|
80
|
+
data: trendItem,
|
|
81
|
+
key: "".concat(key, "_").concat(groupKey),
|
|
82
|
+
x: invertAxis ? "y" : "x",
|
|
83
|
+
y: invertAxis ? "x" : "y",
|
|
84
|
+
color: "wall",
|
|
85
|
+
style: {
|
|
86
|
+
strokeWidth: 3,
|
|
87
|
+
strokeDasharray: 5
|
|
88
|
+
}
|
|
89
|
+
}, /* @__PURE__ */ React.createElement(Line.Dots, {
|
|
90
|
+
data: trendItem,
|
|
91
|
+
display: true
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "renderChart",
|
|
98
|
+
value: function renderChart() {
|
|
99
|
+
var _this2 = this;
|
|
100
|
+
var _this$asProps4 = this.asProps, groupKey = _this$asProps4.groupKey, _this$asProps4$type = _this$asProps4.type, type = _this$asProps4$type === void 0 ? "group" : _this$asProps4$type, invertAxis = _this$asProps4.invertAxis;
|
|
101
|
+
var _this$state = this.state, dataDefinitions = _this$state.dataDefinitions, highlightedLine = _this$state.highlightedLine;
|
|
102
|
+
if (dataDefinitions.length === 1) {
|
|
103
|
+
var item = dataDefinitions[0];
|
|
104
|
+
var BarComponent = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;
|
|
105
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(BarComponent, {
|
|
106
|
+
x: invertAxis ? item.id : groupKey,
|
|
107
|
+
y: invertAxis ? groupKey : item.id,
|
|
108
|
+
key: item.id,
|
|
109
|
+
color: item.color,
|
|
110
|
+
onClick: this.handleClickBar
|
|
111
|
+
}), this.renderTrend(item.id));
|
|
112
|
+
}
|
|
113
|
+
if (type === "group") {
|
|
114
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(GroupBar, {
|
|
115
|
+
x: invertAxis ? void 0 : groupKey,
|
|
116
|
+
y: invertAxis ? groupKey : void 0
|
|
117
|
+
}, dataDefinitions.map(function(item2, index) {
|
|
118
|
+
var BarComponent2 = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;
|
|
119
|
+
var commonBarComponentProps = {
|
|
120
|
+
color: item2.color,
|
|
121
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index,
|
|
122
|
+
onClick: _this2.handleClickBar
|
|
123
|
+
};
|
|
124
|
+
if (invertAxis) {
|
|
125
|
+
commonBarComponentProps.x = item2.id;
|
|
126
|
+
} else {
|
|
127
|
+
commonBarComponentProps.y = item2.id;
|
|
128
|
+
}
|
|
129
|
+
return item2.checked && /* @__PURE__ */ React.createElement(BarComponent2, _extends({
|
|
130
|
+
key: item2.id
|
|
131
|
+
}, commonBarComponentProps));
|
|
132
|
+
})), dataDefinitions.map(function(item2) {
|
|
133
|
+
return item2.checked && _this2.renderTrend(item2.id);
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
if (type === "stack") {
|
|
137
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(StackBar, {
|
|
138
|
+
x: invertAxis ? void 0 : groupKey,
|
|
139
|
+
y: invertAxis ? groupKey : void 0
|
|
140
|
+
}, dataDefinitions.map(function(item2, index) {
|
|
141
|
+
var BarComponent2 = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;
|
|
142
|
+
var commonBarComponentProps = {
|
|
143
|
+
color: item2.color,
|
|
144
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index,
|
|
145
|
+
onClick: _this2.handleClickBar
|
|
146
|
+
};
|
|
147
|
+
if (invertAxis) {
|
|
148
|
+
commonBarComponentProps.x = item2.id;
|
|
149
|
+
} else {
|
|
150
|
+
commonBarComponentProps.y = item2.id;
|
|
151
|
+
}
|
|
152
|
+
return item2.checked && /* @__PURE__ */ React.createElement(BarComponent2, _extends({
|
|
153
|
+
key: item2.id
|
|
154
|
+
}, commonBarComponentProps));
|
|
155
|
+
})), dataDefinitions.map(function(item2) {
|
|
156
|
+
return item2.checked && _this2.renderTrend(item2.id);
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "renderTooltip",
|
|
163
|
+
value: function renderTooltip() {
|
|
164
|
+
var _this3 = this;
|
|
165
|
+
var _this$asProps5 = this.asProps, data = _this$asProps5.data, groupKey = _this$asProps5.groupKey, showTotalInTooltip = _this$asProps5.showTotalInTooltip, showTooltip = _this$asProps5.showTooltip, invertAxis = _this$asProps5.invertAxis, onClickHoverRect = _this$asProps5.onClickHoverRect;
|
|
166
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
167
|
+
if (!showTooltip) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return /* @__PURE__ */ React.createElement(HoverRect.Tooltip, {
|
|
171
|
+
x: invertAxis ? void 0 : groupKey,
|
|
172
|
+
y: invertAxis ? groupKey : void 0,
|
|
173
|
+
wMin: 100,
|
|
174
|
+
onClick: onClickHoverRect
|
|
175
|
+
}, function(_ref) {
|
|
176
|
+
var _dataItem$groupKey;
|
|
177
|
+
var xIndex = _ref.xIndex, yIndex = _ref.yIndex;
|
|
178
|
+
var index = invertAxis ? yIndex : xIndex;
|
|
179
|
+
var dataItem = data[index];
|
|
180
|
+
var total = _this3.totalValue(dataItem);
|
|
181
|
+
return {
|
|
182
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(HoverRect.Tooltip.Title, null, (_dataItem$groupKey = dataItem[groupKey]) === null || _dataItem$groupKey === void 0 ? void 0 : _dataItem$groupKey.toString()), dataDefinitions.map(function(item) {
|
|
183
|
+
return item.checked && /* @__PURE__ */ React.createElement(Flex, {
|
|
184
|
+
justifyContent: "space-between",
|
|
185
|
+
key: item.id
|
|
186
|
+
}, /* @__PURE__ */ React.createElement(HoverRect.Tooltip.Dot, {
|
|
187
|
+
mr: 4,
|
|
188
|
+
color: item.color
|
|
189
|
+
}, item.label), /* @__PURE__ */ React.createElement(Text, {
|
|
190
|
+
bold: true
|
|
191
|
+
}, _this3.tooltipValueFormatter(dataItem[item.id])));
|
|
192
|
+
}), showTotalInTooltip === true && /* @__PURE__ */ React.createElement(Flex, {
|
|
193
|
+
mt: 2,
|
|
194
|
+
justifyContent: "space-between"
|
|
195
|
+
}, /* @__PURE__ */ React.createElement(Box, {
|
|
196
|
+
mr: 4
|
|
197
|
+
}, "Total"), /* @__PURE__ */ React.createElement(Text, {
|
|
198
|
+
bold: true
|
|
199
|
+
}, total)))
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "getLegendAriaLabel",
|
|
205
|
+
value: function getLegendAriaLabel() {
|
|
206
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
207
|
+
chartType: "Bar"
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "categoryScale",
|
|
212
|
+
get: function get() {
|
|
213
|
+
var _this$asProps6 = this.asProps, _this$asProps6$margin = _this$asProps6.marginY, marginY = _this$asProps6$margin === void 0 ? 40 : _this$asProps6$margin, _this$asProps6$margin2 = _this$asProps6.marginX, marginX = _this$asProps6$margin2 === void 0 ? 24 : _this$asProps6$margin2, plotWidth = _this$asProps6.plotWidth, plotHeight = _this$asProps6.plotHeight, invertAxis = _this$asProps6.invertAxis, data = _this$asProps6.data, groupKey = _this$asProps6.groupKey;
|
|
214
|
+
var testItem = data[0][groupKey];
|
|
215
|
+
var range = invertAxis ? [plotHeight - marginX, this.plotPadding] : [marginY, plotWidth - this.plotPadding];
|
|
216
|
+
if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
|
|
217
|
+
var _domain = minMax(data, groupKey);
|
|
218
|
+
return scaleTime(_domain, range);
|
|
219
|
+
}
|
|
220
|
+
var domain = data.map(function(item) {
|
|
221
|
+
return item[groupKey];
|
|
222
|
+
});
|
|
223
|
+
return scaleBand(domain, range).paddingInner(0.4).paddingOuter(0.2);
|
|
224
|
+
}
|
|
225
|
+
}, {
|
|
226
|
+
key: "valueScale",
|
|
227
|
+
get: function get() {
|
|
228
|
+
var _this$asProps7 = this.asProps, _this$asProps7$margin = _this$asProps7.marginY, marginY = _this$asProps7$margin === void 0 ? 40 : _this$asProps7$margin, _this$asProps7$margin2 = _this$asProps7.marginX, marginX = _this$asProps7$margin2 === void 0 ? 24 : _this$asProps7$margin2, plotWidth = _this$asProps7.plotWidth, plotHeight = _this$asProps7.plotHeight, invertAxis = _this$asProps7.invertAxis, type = _this$asProps7.type;
|
|
229
|
+
var max = type === "stack" ? _get(_getPrototypeOf(BarChartComponent2.prototype), "maxStackedValue", this) : Math.max.apply(Math, _toConsumableArray(_get(_getPrototypeOf(BarChartComponent2.prototype), "flatValues", this)));
|
|
230
|
+
return scaleLinear().range(invertAxis ? [marginY, plotWidth - this.plotPadding] : [plotHeight - marginX, this.plotPadding]).domain([0, max]);
|
|
231
|
+
}
|
|
232
|
+
}]);
|
|
233
|
+
return BarChartComponent2;
|
|
234
|
+
}(AbstractChart);
|
|
235
|
+
_defineProperty(BarChartComponent, "displayName", "Chart.Bar");
|
|
236
|
+
_defineProperty(BarChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
237
|
+
var BarChart = createComponent(BarChartComponent);
|
|
238
|
+
export {
|
|
239
|
+
BarChart
|
|
240
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
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 createComponent from "@semcore/core";
|
|
8
|
+
import { scaleLinear } from "d3-scale";
|
|
9
|
+
import Bubble from "../../Bubble.mjs";
|
|
10
|
+
import { calculateBubbleDomain } from "../../utils.mjs";
|
|
11
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
12
|
+
import { Text } from "@semcore/typography";
|
|
13
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
14
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
15
|
+
var BubbleChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
16
|
+
_inherits(BubbleChartComponent2, _AbstractChart);
|
|
17
|
+
var _super = _createSuper(BubbleChartComponent2);
|
|
18
|
+
function BubbleChartComponent2() {
|
|
19
|
+
_classCallCheck(this, BubbleChartComponent2);
|
|
20
|
+
return _super.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
_createClass(BubbleChartComponent2, [{
|
|
23
|
+
key: "dataKeys",
|
|
24
|
+
get: function get() {
|
|
25
|
+
var data = this.props.data;
|
|
26
|
+
return data.map(function(_, index) {
|
|
27
|
+
return index.toString();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "getDefaultDataDefinitions",
|
|
32
|
+
value: function getDefaultDataDefinitions() {
|
|
33
|
+
var _this = this;
|
|
34
|
+
var _this$props = this.props, legendProps = _this$props.legendProps, data = _this$props.data;
|
|
35
|
+
return data.map(function(item, index) {
|
|
36
|
+
var _legendProps$legendMa, _ref, _legendData$label, _legendData$icon, _legendData$defaultCh;
|
|
37
|
+
var key = index.toString();
|
|
38
|
+
var legendData = legendProps === null || legendProps === void 0 ? void 0 : (_legendProps$legendMa = legendProps.legendMap) === null || _legendProps$legendMa === void 0 ? void 0 : _legendProps$legendMa[key];
|
|
39
|
+
if (item.color === void 0) {
|
|
40
|
+
item.color = _this.resolveColor(key, index);
|
|
41
|
+
}
|
|
42
|
+
var dataDefinition = {
|
|
43
|
+
id: key,
|
|
44
|
+
label: (_ref = (_legendData$label = legendData === null || legendData === void 0 ? void 0 : legendData.label) !== null && _legendData$label !== void 0 ? _legendData$label : item.label) !== null && _ref !== void 0 ? _ref : key,
|
|
45
|
+
icon: (_legendData$icon = legendData === null || legendData === void 0 ? void 0 : legendData.icon) !== null && _legendData$icon !== void 0 ? _legendData$icon : void 0,
|
|
46
|
+
checked: (_legendData$defaultCh = legendData === null || legendData === void 0 ? void 0 : legendData.defaultChecked) !== null && _legendData$defaultCh !== void 0 ? _legendData$defaultCh : true,
|
|
47
|
+
color: item.color,
|
|
48
|
+
columns: []
|
|
49
|
+
};
|
|
50
|
+
if (legendData !== null && legendData !== void 0 && legendData.additionalInfo || legendData !== null && legendData !== void 0 && legendData.count) {
|
|
51
|
+
dataDefinition.additionalInfo = legendData.additionalInfo ? {
|
|
52
|
+
label: legendData.additionalInfo
|
|
53
|
+
} : legendData.count ? {
|
|
54
|
+
count: legendData.count
|
|
55
|
+
} : void 0;
|
|
56
|
+
}
|
|
57
|
+
return dataDefinition;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "xScale",
|
|
62
|
+
get: function get() {
|
|
63
|
+
var _this$asProps = this.asProps, xScale = _this$asProps.xScale, _this$asProps$marginY = _this$asProps.marginY, marginY = _this$asProps$marginY === void 0 ? 30 : _this$asProps$marginY, plotWidth = _this$asProps.plotWidth, data = _this$asProps.data;
|
|
64
|
+
if (xScale) {
|
|
65
|
+
return xScale;
|
|
66
|
+
}
|
|
67
|
+
var range = [marginY, plotWidth - this.plotPadding];
|
|
68
|
+
var domain = calculateBubbleDomain(data, "x", range);
|
|
69
|
+
return scaleLinear().domain(domain).range(range);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "yScale",
|
|
73
|
+
get: function get() {
|
|
74
|
+
var _this$asProps2 = this.asProps, yScale = _this$asProps2.yScale, _this$asProps2$margin = _this$asProps2.marginX, marginX = _this$asProps2$margin === void 0 ? 30 : _this$asProps2$margin, plotHeight = _this$asProps2.plotHeight, data = _this$asProps2.data;
|
|
75
|
+
if (yScale) {
|
|
76
|
+
return yScale;
|
|
77
|
+
}
|
|
78
|
+
var range = [plotHeight - marginX, this.plotPadding];
|
|
79
|
+
var domain = calculateBubbleDomain(data, "y", range);
|
|
80
|
+
return scaleLinear().domain(domain).range(range);
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "defaultLegendProps",
|
|
84
|
+
value: function defaultLegendProps() {
|
|
85
|
+
return {
|
|
86
|
+
shape: "Circle"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "renderChart",
|
|
91
|
+
value: function renderChart() {
|
|
92
|
+
return /* @__PURE__ */ React.createElement(Bubble, {
|
|
93
|
+
x: "x",
|
|
94
|
+
y: "y",
|
|
95
|
+
value: "value",
|
|
96
|
+
color: "color",
|
|
97
|
+
label: "label"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "renderTooltip",
|
|
102
|
+
value: function renderTooltip() {
|
|
103
|
+
var showTooltip = this.asProps.showTooltip;
|
|
104
|
+
if (!showTooltip) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return /* @__PURE__ */ React.createElement(Bubble.Tooltip, null, function(_ref2) {
|
|
108
|
+
var index = _ref2.index, data = _ref2.data;
|
|
109
|
+
return {
|
|
110
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Bubble.Tooltip.Title, null, "Data"), /* @__PURE__ */ React.createElement(Text, {
|
|
111
|
+
tag: "div"
|
|
112
|
+
}, "X axis ", data[index].x), /* @__PURE__ */ React.createElement(Text, {
|
|
113
|
+
tag: "div"
|
|
114
|
+
}, "Y axis ", data[index].y), /* @__PURE__ */ React.createElement(Text, {
|
|
115
|
+
tag: "div"
|
|
116
|
+
}, "Value ", data[index].value))
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "getLegendAriaLabel",
|
|
122
|
+
value: function getLegendAriaLabel() {
|
|
123
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
124
|
+
chartType: "Bubble"
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}]);
|
|
128
|
+
return BubbleChartComponent2;
|
|
129
|
+
}(AbstractChart);
|
|
130
|
+
_defineProperty(BubbleChartComponent, "displayName", "Chart.Bubble");
|
|
131
|
+
_defineProperty(BubbleChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
132
|
+
var BubbleChart = createComponent(BubbleChartComponent);
|
|
133
|
+
export {
|
|
134
|
+
BubbleChart
|
|
135
|
+
};
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
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 _get from "@babel/runtime/helpers/esm/get";
|
|
7
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
9
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
10
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
+
import createComponent, { sstyled, assignProps } from "@semcore/core";
|
|
12
|
+
import React from "react";
|
|
13
|
+
import Divider from "@semcore/divider";
|
|
14
|
+
import { Flex, Box } from "@semcore/flex-box";
|
|
15
|
+
import { Text } from "@semcore/typography";
|
|
16
|
+
import resolveColorEnhance from "@semcore/utils/lib/enhances/resolveColorEnhance";
|
|
17
|
+
import uniqueIDEnhancement from "@semcore/utils/lib/uniqueID";
|
|
18
|
+
import { scaleBand, scaleLinear } from "d3-scale";
|
|
19
|
+
import Plot from "../../Plot.mjs";
|
|
20
|
+
import { HoverRect } from "../../Hover.mjs";
|
|
21
|
+
import { interpolateValue, scaleToBand } from "../../utils.mjs";
|
|
22
|
+
import AnimatedClipPath from "../../AnimatedClipPath.mjs";
|
|
23
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
24
|
+
import Cigarette from "../Cigarette/Cigarette.mjs";
|
|
25
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
26
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
27
|
+
var wMin = 2;
|
|
28
|
+
var CigaretteChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
29
|
+
_inherits(CigaretteChartComponent2, _AbstractChart);
|
|
30
|
+
var _super = _createSuper(CigaretteChartComponent2);
|
|
31
|
+
function CigaretteChartComponent2() {
|
|
32
|
+
var _this;
|
|
33
|
+
_classCallCheck(this, CigaretteChartComponent2);
|
|
34
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35
|
+
args[_key] = arguments[_key];
|
|
36
|
+
}
|
|
37
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "plotPadding", 0);
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "offset", 0);
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
_createClass(CigaretteChartComponent2, [{
|
|
43
|
+
key: "resolveColor",
|
|
44
|
+
value: function resolveColor(id, index) {
|
|
45
|
+
var _this$props$colorMap$, _this$props$colorMap;
|
|
46
|
+
return (_this$props$colorMap$ = (_this$props$colorMap = this.props.colorMap) === null || _this$props$colorMap === void 0 ? void 0 : _this$props$colorMap[id]) !== null && _this$props$colorMap$ !== void 0 ? _this$props$colorMap$ : "blue-".concat(5 - index, "00");
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "getDefaultDataDefinitions",
|
|
50
|
+
value: function getDefaultDataDefinitions() {
|
|
51
|
+
var dataDefinitions = _get(_getPrototypeOf(CigaretteChartComponent2.prototype), "getDefaultDataDefinitions", this).call(this);
|
|
52
|
+
return dataDefinitions.map(function(dataDef) {
|
|
53
|
+
dataDef.columns = dataDef.columns.slice(1);
|
|
54
|
+
return dataDef;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "defaultLegendProps",
|
|
59
|
+
value: function defaultLegendProps() {
|
|
60
|
+
return {
|
|
61
|
+
legendType: "Table",
|
|
62
|
+
w: "fit-content"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "xScale",
|
|
67
|
+
get: function get() {
|
|
68
|
+
var invertAxis = this.asProps.invertAxis;
|
|
69
|
+
return invertAxis ? this.valueScale : this.categoryScale;
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "yScale",
|
|
73
|
+
get: function get() {
|
|
74
|
+
var invertAxis = this.asProps.invertAxis;
|
|
75
|
+
return invertAxis ? this.categoryScale : this.valueScale;
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "renderChart",
|
|
79
|
+
value: function renderChart() {
|
|
80
|
+
var _this2 = this;
|
|
81
|
+
var _this$asProps = this.asProps, invertAxis = _this$asProps.invertAxis, data = _this$asProps.data, uid = _this$asProps.uid, duration = _this$asProps.duration, patterns = _this$asProps.patterns, plotHeight = _this$asProps.plotHeight, plotWidth = _this$asProps.plotWidth, onClick = _this$asProps.onClick;
|
|
82
|
+
var _this$state = this.state, dataDefinitions = _this$state.dataDefinitions, highlightedLine = _this$state.highlightedLine;
|
|
83
|
+
this.offset = 0;
|
|
84
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, (invertAxis ? dataDefinitions : _toConsumableArray(dataDefinitions).reverse()).map(function(item, index) {
|
|
85
|
+
var value = data[item.id];
|
|
86
|
+
if (!item.checked || value === interpolateValue || value === null) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
var absWidth = Math.abs(_this2.valueScale(value) - Math.max(_this2.valueScale(_this2.valueScale.domain()[0]), _this2.valueScale(0)));
|
|
90
|
+
var height = scaleToBand(_this2.categoryScale).bandwidth() - 4;
|
|
91
|
+
var width = value === 0 ? 0 : Math.max(absWidth, wMin * 2) - wMin;
|
|
92
|
+
var y = 2;
|
|
93
|
+
var x = index === 0 ? 0 : _this2.offset;
|
|
94
|
+
var r = height < 28 ? 2 : 4;
|
|
95
|
+
_this2.offset = _this2.offset + width + wMin;
|
|
96
|
+
return /* @__PURE__ */ React.createElement(Cigarette, {
|
|
97
|
+
key: item.id,
|
|
98
|
+
dataKey: item.id,
|
|
99
|
+
index,
|
|
100
|
+
y: invertAxis ? y : x,
|
|
101
|
+
x: invertAxis ? x : y,
|
|
102
|
+
width: invertAxis ? width : height,
|
|
103
|
+
height: invertAxis ? height : width,
|
|
104
|
+
uid,
|
|
105
|
+
hide: !item.checked,
|
|
106
|
+
duration,
|
|
107
|
+
r: index === 0 || index === dataDefinitions.length - 1 ? r : 0,
|
|
108
|
+
color: item.color,
|
|
109
|
+
patterns,
|
|
110
|
+
direction: invertAxis ? "horizontal" : "vertical",
|
|
111
|
+
onClick,
|
|
112
|
+
hovered: highlightedLine === index ? true : highlightedLine === -1 ? void 0 : false
|
|
113
|
+
});
|
|
114
|
+
}), /* @__PURE__ */ React.createElement(AnimatedClipPath, {
|
|
115
|
+
"aria-hidden": true,
|
|
116
|
+
duration,
|
|
117
|
+
id: uid,
|
|
118
|
+
x: "0",
|
|
119
|
+
y: "0",
|
|
120
|
+
width: invertAxis ? 0 : plotWidth,
|
|
121
|
+
height: invertAxis ? plotHeight : 0
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "renderTooltip",
|
|
126
|
+
value: function renderTooltip() {
|
|
127
|
+
var _this3 = this;
|
|
128
|
+
var _this$asProps2 = this.asProps, data = _this$asProps2.data, showTotalInTooltip = _this$asProps2.showTotalInTooltip, showTooltip = _this$asProps2.showTooltip, invertAxis = _this$asProps2.invertAxis, tooltipTitle = _this$asProps2.tooltipTitle, tooltipViewType = _this$asProps2.tooltipViewType;
|
|
129
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
130
|
+
if (!showTooltip) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return /* @__PURE__ */ React.createElement(HoverRect.Tooltip, {
|
|
134
|
+
x: invertAxis ? "" : void 0,
|
|
135
|
+
y: invertAxis ? void 0 : "",
|
|
136
|
+
wMin: 100,
|
|
137
|
+
hideHoverLine: true
|
|
138
|
+
}, function(tooltipProps) {
|
|
139
|
+
var dataKey = invertAxis ? tooltipProps.xIndex : tooltipProps.yIndex;
|
|
140
|
+
var total = _this3.totalValue(data);
|
|
141
|
+
if (tooltipViewType === "single") {
|
|
142
|
+
var item = dataDefinitions.find(function(dataDefItem) {
|
|
143
|
+
return dataDefItem.id === dataKey;
|
|
144
|
+
});
|
|
145
|
+
if (!item) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
children: /* @__PURE__ */ React.createElement(Flex, {
|
|
150
|
+
justifyContent: "space-between",
|
|
151
|
+
key: dataKey
|
|
152
|
+
}, /* @__PURE__ */ React.createElement(HoverRect.Tooltip.Dot, {
|
|
153
|
+
mr: 4,
|
|
154
|
+
color: item.color
|
|
155
|
+
}, item.label), /* @__PURE__ */ React.createElement(Text, {
|
|
156
|
+
bold: true
|
|
157
|
+
}, _this3.tooltipValueFormatter(data[dataKey])))
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, tooltipTitle && /* @__PURE__ */ React.createElement(HoverRect.Tooltip.Title, null, "Some tooltip title"), dataDefinitions.map(function(item2) {
|
|
162
|
+
return item2.checked && /* @__PURE__ */ React.createElement(Flex, {
|
|
163
|
+
justifyContent: "space-between",
|
|
164
|
+
key: item2.id,
|
|
165
|
+
style: {
|
|
166
|
+
opacity: item2.id === dataKey ? 1 : 0.3
|
|
167
|
+
}
|
|
168
|
+
}, /* @__PURE__ */ React.createElement(HoverRect.Tooltip.Dot, {
|
|
169
|
+
mr: 4,
|
|
170
|
+
color: item2.color
|
|
171
|
+
}, item2.label), /* @__PURE__ */ React.createElement(Text, {
|
|
172
|
+
bold: true
|
|
173
|
+
}, _this3.tooltipValueFormatter(data[item2.id])));
|
|
174
|
+
}), showTotalInTooltip === true && /* @__PURE__ */ React.createElement(Flex, {
|
|
175
|
+
mt: 2,
|
|
176
|
+
justifyContent: "space-between"
|
|
177
|
+
}, /* @__PURE__ */ React.createElement(Box, {
|
|
178
|
+
mr: 4
|
|
179
|
+
}, "Total"), /* @__PURE__ */ React.createElement(Text, {
|
|
180
|
+
bold: true
|
|
181
|
+
}, total)))
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}, {
|
|
186
|
+
key: "renderHeader",
|
|
187
|
+
value: function renderHeader() {
|
|
188
|
+
var _this$asProps$header;
|
|
189
|
+
return (_this$asProps$header = this.asProps.header) !== null && _this$asProps$header !== void 0 ? _this$asProps$header : null;
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "render",
|
|
193
|
+
value: function render() {
|
|
194
|
+
var _ref = this.asProps, _ref3;
|
|
195
|
+
var SChart = Flex;
|
|
196
|
+
var _this$asProps3 = this.asProps, styles = _this$asProps3.styles, plotWidth = _this$asProps3.plotWidth, plotHeight = _this$asProps3.plotHeight, data = _this$asProps3.data, patterns = _this$asProps3.patterns, invertAxis = _this$asProps3.invertAxis, a11yAltTextConfig = _this$asProps3.a11yAltTextConfig;
|
|
197
|
+
var header = this.renderHeader();
|
|
198
|
+
if (invertAxis) {
|
|
199
|
+
var _ref2;
|
|
200
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SChart, _ref2.cn("SChart", _objectSpread({}, assignProps({
|
|
201
|
+
"gap": 6,
|
|
202
|
+
"direction": "column",
|
|
203
|
+
"__excludeProps": ["onClick", "data"]
|
|
204
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Flex, _ref2.cn("Flex", {
|
|
205
|
+
"direction": "column"
|
|
206
|
+
}), header, /* @__PURE__ */ React.createElement(Plot, _ref2.cn("Plot", {
|
|
207
|
+
"data": data,
|
|
208
|
+
"scale": [this.xScale, this.yScale],
|
|
209
|
+
"width": plotWidth,
|
|
210
|
+
"height": plotHeight,
|
|
211
|
+
"dataHints": this.dataHints,
|
|
212
|
+
"patterns": patterns,
|
|
213
|
+
"a11yAltTextConfig": a11yAltTextConfig
|
|
214
|
+
}), this.renderTooltip(), this.renderChart())), this.renderLegend());
|
|
215
|
+
}
|
|
216
|
+
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SChart, _ref3.cn("SChart", _objectSpread({}, assignProps({
|
|
217
|
+
"gap": 6,
|
|
218
|
+
"__excludeProps": ["onClick", "data"]
|
|
219
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Plot, _ref3.cn("Plot", {
|
|
220
|
+
"data": data,
|
|
221
|
+
"scale": [this.xScale, this.yScale],
|
|
222
|
+
"width": plotWidth,
|
|
223
|
+
"height": plotHeight,
|
|
224
|
+
"dataHints": this.dataHints,
|
|
225
|
+
"patterns": patterns,
|
|
226
|
+
"a11yAltTextConfig": a11yAltTextConfig
|
|
227
|
+
}), this.renderTooltip(), this.renderChart()), /* @__PURE__ */ React.createElement(Flex, _ref3.cn("Flex", {
|
|
228
|
+
"direction": "column",
|
|
229
|
+
"gap": 2
|
|
230
|
+
}), header && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, _ref3.cn("Box", {}), header), /* @__PURE__ */ React.createElement(Divider, _ref3.cn("Divider", {}))), this.renderLegend()));
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "getLegendAriaLabel",
|
|
234
|
+
value: function getLegendAriaLabel() {
|
|
235
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
236
|
+
chartType: "Cigarette"
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "selectedData",
|
|
241
|
+
get: function get() {
|
|
242
|
+
var data = this.asProps.data;
|
|
243
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
244
|
+
var result = /* @__PURE__ */ new Map();
|
|
245
|
+
dataDefinitions.forEach(function(dataDefItem) {
|
|
246
|
+
var value = data[dataDefItem.id];
|
|
247
|
+
if (dataDefItem.checked && value !== interpolateValue) {
|
|
248
|
+
result.set(dataDefItem.id, value);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
return result;
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "categoryScale",
|
|
255
|
+
get: function get() {
|
|
256
|
+
var _this$asProps4 = this.asProps, plotWidth = _this$asProps4.plotWidth, plotHeight = _this$asProps4.plotHeight, invertAxis = _this$asProps4.invertAxis;
|
|
257
|
+
var range = invertAxis ? [plotHeight, 0] : [0, plotWidth];
|
|
258
|
+
return scaleBand([0], range);
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "valueScale",
|
|
262
|
+
get: function get() {
|
|
263
|
+
var _this$asProps5 = this.asProps, plotWidth = _this$asProps5.plotWidth, plotHeight = _this$asProps5.plotHeight, invertAxis = _this$asProps5.invertAxis;
|
|
264
|
+
var max = 0;
|
|
265
|
+
this.selectedData.forEach(function(value) {
|
|
266
|
+
max = max + value;
|
|
267
|
+
});
|
|
268
|
+
return scaleLinear().range(invertAxis ? [0, plotWidth] : [plotHeight, 0]).domain([0, max]);
|
|
269
|
+
}
|
|
270
|
+
}]);
|
|
271
|
+
return CigaretteChartComponent2;
|
|
272
|
+
}(AbstractChart);
|
|
273
|
+
_defineProperty(CigaretteChartComponent, "displayName", "Cigarette.Bar");
|
|
274
|
+
_defineProperty(CigaretteChartComponent, "defaultProps", function(props) {
|
|
275
|
+
var _props$invertAxis;
|
|
276
|
+
var invertAxis = (_props$invertAxis = props.invertAxis) !== null && _props$invertAxis !== void 0 ? _props$invertAxis : true;
|
|
277
|
+
return {
|
|
278
|
+
invertAxis,
|
|
279
|
+
showXAxis: false,
|
|
280
|
+
showYAxis: false,
|
|
281
|
+
showTooltip: true,
|
|
282
|
+
showLegend: false,
|
|
283
|
+
marginX: 0,
|
|
284
|
+
marginY: 0,
|
|
285
|
+
duration: 500,
|
|
286
|
+
plotWidth: !invertAxis && !props.plotWidth ? 44 : props.plotWidth,
|
|
287
|
+
plotHeight: invertAxis && !props.plotHeight ? 28 : props.plotHeight
|
|
288
|
+
};
|
|
289
|
+
});
|
|
290
|
+
_defineProperty(CigaretteChartComponent, "enhance", [resolveColorEnhance(), uniqueIDEnhancement(), i18nEnhance(localizedMessages)]);
|
|
291
|
+
var CigaretteChart = createComponent(CigaretteChartComponent);
|
|
292
|
+
export {
|
|
293
|
+
CigaretteChart
|
|
294
|
+
};
|