@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,113 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _get from "@babel/runtime/helpers/esm/get";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
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 React from "react";
|
|
10
|
+
import createComponent from "@semcore/core";
|
|
11
|
+
import { scaleBand, scaleLinear } from "d3-scale";
|
|
12
|
+
import CompactHorizontalBar from "../../CompactHorizontalBar.mjs";
|
|
13
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
14
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
15
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
16
|
+
var CompactHorizontalBarChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
17
|
+
_inherits(CompactHorizontalBarChartComponent2, _AbstractChart);
|
|
18
|
+
var _super = _createSuper(CompactHorizontalBarChartComponent2);
|
|
19
|
+
function CompactHorizontalBarChartComponent2() {
|
|
20
|
+
_classCallCheck(this, CompactHorizontalBarChartComponent2);
|
|
21
|
+
return _super.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
_createClass(CompactHorizontalBarChartComponent2, [{
|
|
24
|
+
key: "xScale",
|
|
25
|
+
get: function get() {
|
|
26
|
+
var _this$asProps$xScale;
|
|
27
|
+
return (_this$asProps$xScale = this.asProps.xScale) !== null && _this$asProps$xScale !== void 0 ? _this$asProps$xScale : this.valueScale;
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
key: "yScale",
|
|
31
|
+
get: function get() {
|
|
32
|
+
var _this$asProps$yScale;
|
|
33
|
+
return (_this$asProps$yScale = this.asProps.yScale) !== null && _this$asProps$yScale !== void 0 ? _this$asProps$yScale : this.categoryScale;
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
key: "defaultLegendProps",
|
|
37
|
+
value: function defaultLegendProps() {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "renderChart",
|
|
42
|
+
value: function renderChart() {
|
|
43
|
+
var _this$asProps = this.asProps, x = _this$asProps.x, y = _this$asProps.y, onClickHoverRect = _this$asProps.onClickHoverRect, onClickBar = _this$asProps.onClickBar;
|
|
44
|
+
return /* @__PURE__ */ React.createElement(CompactHorizontalBar, {
|
|
45
|
+
x,
|
|
46
|
+
y
|
|
47
|
+
}, this.renderCompactHorizontalBarTooltip(), /* @__PURE__ */ React.createElement(CompactHorizontalBar.Hover, {
|
|
48
|
+
onClick: onClickHoverRect
|
|
49
|
+
}), /* @__PURE__ */ React.createElement(CompactHorizontalBar.Annotation, null, /* @__PURE__ */ React.createElement(CompactHorizontalBar.Label, null), /* @__PURE__ */ React.createElement(CompactHorizontalBar.Percent, null), /* @__PURE__ */ React.createElement(CompactHorizontalBar.Value, null)), /* @__PURE__ */ React.createElement(CompactHorizontalBar.Bar, {
|
|
50
|
+
onClick: onClickBar
|
|
51
|
+
}, /* @__PURE__ */ React.createElement(CompactHorizontalBar.Bar.Background, null), /* @__PURE__ */ React.createElement(CompactHorizontalBar.Bar.Fill, null)));
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "renderCompactHorizontalBarTooltip",
|
|
55
|
+
value: function renderCompactHorizontalBarTooltip() {
|
|
56
|
+
var _this$asProps2 = this.asProps, data = _this$asProps2.data, x = _this$asProps2.x, y = _this$asProps2.y, showTooltip = _this$asProps2.showTooltip;
|
|
57
|
+
if (!showTooltip) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ React.createElement(CompactHorizontalBar.Tooltip, {
|
|
61
|
+
wMin: 100
|
|
62
|
+
}, function(_ref) {
|
|
63
|
+
var index = _ref.index;
|
|
64
|
+
return {
|
|
65
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CompactHorizontalBar.Tooltip.Title, null, data[index][y]), /* @__PURE__ */ React.createElement(CompactHorizontalBar.Tooltip.Dot, null, data[index][x]))
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "renderTooltip",
|
|
71
|
+
value: function renderTooltip() {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "getLegendAriaLabel",
|
|
76
|
+
value: function getLegendAriaLabel() {
|
|
77
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
78
|
+
chartType: "CompactHorizontalBar"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "categoryScale",
|
|
83
|
+
get: function get() {
|
|
84
|
+
var _this$asProps3 = this.asProps, _this$asProps3$margin = _this$asProps3.marginY, marginY = _this$asProps3$margin === void 0 ? 40 : _this$asProps3$margin, plotHeight = _this$asProps3.plotHeight, data = _this$asProps3.data, y = _this$asProps3.y;
|
|
85
|
+
return scaleBand().range([plotHeight - marginY, marginY]).domain(_toConsumableArray(data).reverse().map(function(d) {
|
|
86
|
+
return d[y];
|
|
87
|
+
})).paddingInner(0.6).paddingOuter(0.2);
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "valueScale",
|
|
91
|
+
get: function get() {
|
|
92
|
+
var _this$asProps4 = this.asProps, _this$asProps4$margin = _this$asProps4.marginY, marginY = _this$asProps4$margin === void 0 ? 0 : _this$asProps4$margin, plotWidth = _this$asProps4.plotWidth;
|
|
93
|
+
var sum = _toConsumableArray(_get(_getPrototypeOf(CompactHorizontalBarChartComponent2.prototype), "flatValues", this).values()).reduce(function(acc, d) {
|
|
94
|
+
return acc + d;
|
|
95
|
+
}, 0);
|
|
96
|
+
return scaleLinear().range([marginY, plotWidth]).domain([marginY, sum]);
|
|
97
|
+
}
|
|
98
|
+
}]);
|
|
99
|
+
return CompactHorizontalBarChartComponent2;
|
|
100
|
+
}(AbstractChart);
|
|
101
|
+
_defineProperty(CompactHorizontalBarChartComponent, "displayName", "Chart.CompactHorizontalBar");
|
|
102
|
+
_defineProperty(CompactHorizontalBarChartComponent, "defaultProps", {
|
|
103
|
+
direction: "column",
|
|
104
|
+
showXAxis: false,
|
|
105
|
+
showYAxis: false,
|
|
106
|
+
showTooltip: true,
|
|
107
|
+
showLegend: false
|
|
108
|
+
});
|
|
109
|
+
_defineProperty(CompactHorizontalBarChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
110
|
+
var CompactHorizontalBarChart = createComponent(CompactHorizontalBarChartComponent);
|
|
111
|
+
export {
|
|
112
|
+
CompactHorizontalBarChart
|
|
113
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
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 Donut from "../../Donut.mjs";
|
|
10
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
11
|
+
import { Text } from "@semcore/typography";
|
|
12
|
+
import { Flex } from "@semcore/flex-box";
|
|
13
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
14
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
15
|
+
var DonutChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
16
|
+
_inherits(DonutChartComponent2, _AbstractChart);
|
|
17
|
+
var _super = _createSuper(DonutChartComponent2);
|
|
18
|
+
function DonutChartComponent2() {
|
|
19
|
+
_classCallCheck(this, DonutChartComponent2);
|
|
20
|
+
return _super.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
_createClass(DonutChartComponent2, [{
|
|
23
|
+
key: "xScale",
|
|
24
|
+
get: function get() {
|
|
25
|
+
var xScale = this.asProps.xScale;
|
|
26
|
+
if (xScale) {
|
|
27
|
+
return xScale;
|
|
28
|
+
}
|
|
29
|
+
return scaleLinear();
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
key: "yScale",
|
|
33
|
+
get: function get() {
|
|
34
|
+
var yScale = this.asProps.yScale;
|
|
35
|
+
if (yScale) {
|
|
36
|
+
return yScale;
|
|
37
|
+
}
|
|
38
|
+
return scaleLinear();
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "defaultLegendProps",
|
|
42
|
+
value: function defaultLegendProps() {
|
|
43
|
+
return {
|
|
44
|
+
legendType: "Table"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "renderChart",
|
|
49
|
+
value: function renderChart() {
|
|
50
|
+
var _this$asProps = this.asProps, innerRadius = _this$asProps.innerRadius, halfsize = _this$asProps.halfsize, innerLabel = _this$asProps.innerLabel;
|
|
51
|
+
var _this$state = this.state, dataDefinitions = _this$state.dataDefinitions, highlightedLine = _this$state.highlightedLine;
|
|
52
|
+
var checkedLegendItems = dataDefinitions.filter(function(item) {
|
|
53
|
+
return item.checked;
|
|
54
|
+
});
|
|
55
|
+
return /* @__PURE__ */ React.createElement(Donut, {
|
|
56
|
+
halfsize,
|
|
57
|
+
innerRadius
|
|
58
|
+
}, checkedLegendItems.length === 0 && /* @__PURE__ */ React.createElement(Donut.EmptyData, null), checkedLegendItems.map(function(item, index) {
|
|
59
|
+
return /* @__PURE__ */ React.createElement(Donut.Pie, {
|
|
60
|
+
key: item.id,
|
|
61
|
+
dataKey: item.id,
|
|
62
|
+
name: item.label,
|
|
63
|
+
color: item.color,
|
|
64
|
+
active: highlightedLine === index
|
|
65
|
+
});
|
|
66
|
+
}), innerLabel && /* @__PURE__ */ React.createElement(Donut.Label, null, innerLabel));
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "renderTooltip",
|
|
70
|
+
value: function renderTooltip() {
|
|
71
|
+
var _this = this;
|
|
72
|
+
var _this$asProps2 = this.asProps, data = _this$asProps2.data, showTooltip = _this$asProps2.showTooltip;
|
|
73
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
74
|
+
if (!showTooltip) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return /* @__PURE__ */ React.createElement(Donut.Tooltip, null, function(_ref) {
|
|
78
|
+
var dataKey = _ref.dataKey;
|
|
79
|
+
var title = dataDefinitions.find(function(item) {
|
|
80
|
+
return item.id === dataKey;
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Donut.Tooltip.Title, null, (title === null || title === void 0 ? void 0 : title.label) || dataKey), /* @__PURE__ */ React.createElement(Flex, {
|
|
84
|
+
justifyContent: "space-between"
|
|
85
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
86
|
+
bold: true
|
|
87
|
+
}, _this.tooltipValueFormatter(data[dataKey]))))
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "getLegendAriaLabel",
|
|
93
|
+
value: function getLegendAriaLabel() {
|
|
94
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
95
|
+
chartType: "Donut"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}]);
|
|
99
|
+
return DonutChartComponent2;
|
|
100
|
+
}(AbstractChart);
|
|
101
|
+
_defineProperty(DonutChartComponent, "displayName", "Chart.Donut");
|
|
102
|
+
_defineProperty(DonutChartComponent, "defaultProps", {
|
|
103
|
+
direction: "row-reverse",
|
|
104
|
+
alignItems: "flex-start",
|
|
105
|
+
innerRadius: 100,
|
|
106
|
+
marginX: 0,
|
|
107
|
+
marginY: 0
|
|
108
|
+
});
|
|
109
|
+
_defineProperty(DonutChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
110
|
+
var DonutChart = createComponent(DonutChartComponent);
|
|
111
|
+
export {
|
|
112
|
+
DonutChart
|
|
113
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
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 _get from "@babel/runtime/helpers/esm/get";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import createComponent from "@semcore/core";
|
|
12
|
+
import { scaleTime, scaleBand, scaleLinear } from "d3-scale";
|
|
13
|
+
import Bar from "../../Bar.mjs";
|
|
14
|
+
import StackBar from "../../StackBar.mjs";
|
|
15
|
+
import { HoverRect } from "../../Hover.mjs";
|
|
16
|
+
import { minMax } from "../../utils.mjs";
|
|
17
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
18
|
+
import { Flex, Box } from "@semcore/flex-box";
|
|
19
|
+
import { Text } from "@semcore/typography";
|
|
20
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
21
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
22
|
+
var HistogramChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
23
|
+
_inherits(HistogramChartComponent2, _AbstractChart);
|
|
24
|
+
var _super = _createSuper(HistogramChartComponent2);
|
|
25
|
+
function HistogramChartComponent2() {
|
|
26
|
+
_classCallCheck(this, HistogramChartComponent2);
|
|
27
|
+
return _super.apply(this, arguments);
|
|
28
|
+
}
|
|
29
|
+
_createClass(HistogramChartComponent2, [{
|
|
30
|
+
key: "xScale",
|
|
31
|
+
get: function get() {
|
|
32
|
+
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, _this$asProps$marginX = _this$asProps.marginX, marginX = _this$asProps$marginX === void 0 ? 30 : _this$asProps$marginX, plotWidth = _this$asProps.plotWidth, plotHeight = _this$asProps.plotHeight, invertAxis = _this$asProps.invertAxis, data = _this$asProps.data, groupKey = _this$asProps.groupKey;
|
|
33
|
+
if (xScale) {
|
|
34
|
+
return xScale;
|
|
35
|
+
}
|
|
36
|
+
var testItem = data[0][groupKey];
|
|
37
|
+
var range = invertAxis ? [plotHeight - marginX, this.plotPadding] : [marginY, plotWidth - this.plotPadding];
|
|
38
|
+
if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
|
|
39
|
+
var _domain = minMax(data, groupKey);
|
|
40
|
+
return scaleTime(_domain, range);
|
|
41
|
+
}
|
|
42
|
+
var domain = data.map(function(item) {
|
|
43
|
+
return item[groupKey];
|
|
44
|
+
});
|
|
45
|
+
return scaleBand(domain, range).paddingInner(0.05).paddingOuter(0.2);
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "yScale",
|
|
49
|
+
get: function get() {
|
|
50
|
+
var _this$asProps2 = this.asProps, yScale = _this$asProps2.yScale, _this$asProps2$margin = _this$asProps2.marginY, marginY = _this$asProps2$margin === void 0 ? 30 : _this$asProps2$margin, _this$asProps2$margin2 = _this$asProps2.marginX, marginX = _this$asProps2$margin2 === void 0 ? 30 : _this$asProps2$margin2, plotHeight = _this$asProps2.plotHeight, plotWidth = _this$asProps2.plotWidth, invertAxis = _this$asProps2.invertAxis, data = _this$asProps2.data;
|
|
51
|
+
var max;
|
|
52
|
+
if (this.isStack) {
|
|
53
|
+
max = data.reduce(function(max2, item) {
|
|
54
|
+
var barSum = Object.values(item).reduce(function(sum, val) {
|
|
55
|
+
if (val instanceof Date && !Number.isNaN(val.getMilliseconds())) {
|
|
56
|
+
return sum + val.getMilliseconds();
|
|
57
|
+
}
|
|
58
|
+
return sum + val;
|
|
59
|
+
}, 0);
|
|
60
|
+
if (barSum > max2) {
|
|
61
|
+
max2 = barSum;
|
|
62
|
+
}
|
|
63
|
+
return max2;
|
|
64
|
+
}, 0);
|
|
65
|
+
} else {
|
|
66
|
+
var flatValues = _get(_getPrototypeOf(HistogramChartComponent2.prototype), "flatValues", this);
|
|
67
|
+
max = Math.max.apply(Math, _toConsumableArray(flatValues));
|
|
68
|
+
}
|
|
69
|
+
return yScale !== null && yScale !== void 0 ? yScale : scaleLinear().range(invertAxis ? [marginY, plotWidth - this.plotPadding] : [plotHeight - marginX, this.plotPadding]).domain([0, max]);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "isStack",
|
|
73
|
+
get: function get() {
|
|
74
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
75
|
+
return dataDefinitions.length > 1;
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "renderChart",
|
|
79
|
+
value: function renderChart() {
|
|
80
|
+
var _this$asProps3 = this.asProps, groupKey = _this$asProps3.groupKey, invertAxis = _this$asProps3.invertAxis;
|
|
81
|
+
var _this$state = this.state, dataDefinitions = _this$state.dataDefinitions, highlightedLine = _this$state.highlightedLine;
|
|
82
|
+
if (this.isStack) {
|
|
83
|
+
return /* @__PURE__ */ React.createElement(StackBar, {
|
|
84
|
+
x: invertAxis ? void 0 : groupKey,
|
|
85
|
+
y: invertAxis ? groupKey : void 0
|
|
86
|
+
}, dataDefinitions.map(function(item2, index) {
|
|
87
|
+
var BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;
|
|
88
|
+
var commonBarComponentProps = {
|
|
89
|
+
color: item2.color,
|
|
90
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index
|
|
91
|
+
};
|
|
92
|
+
if (invertAxis) {
|
|
93
|
+
commonBarComponentProps.x = item2.id;
|
|
94
|
+
} else {
|
|
95
|
+
commonBarComponentProps.y = item2.id;
|
|
96
|
+
}
|
|
97
|
+
return item2.checked && /* @__PURE__ */ React.createElement(BarComponent, _extends({
|
|
98
|
+
key: item2.id
|
|
99
|
+
}, commonBarComponentProps));
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
var item = dataDefinitions[0];
|
|
103
|
+
return /* @__PURE__ */ React.createElement(Bar, {
|
|
104
|
+
x: invertAxis ? item.id : groupKey,
|
|
105
|
+
y: invertAxis ? groupKey : item.id,
|
|
106
|
+
key: item.id,
|
|
107
|
+
color: item.color
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "renderTooltip",
|
|
112
|
+
value: function renderTooltip() {
|
|
113
|
+
var _this = this;
|
|
114
|
+
var _this$asProps4 = this.asProps, data = _this$asProps4.data, groupKey = _this$asProps4.groupKey, showTotalInTooltip = _this$asProps4.showTotalInTooltip, showTooltip = _this$asProps4.showTooltip, invertAxis = _this$asProps4.invertAxis;
|
|
115
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
116
|
+
if (!showTooltip) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return /* @__PURE__ */ React.createElement(HoverRect.Tooltip, {
|
|
120
|
+
x: invertAxis ? void 0 : groupKey,
|
|
121
|
+
y: invertAxis ? groupKey : void 0,
|
|
122
|
+
wMin: 100
|
|
123
|
+
}, function(_ref) {
|
|
124
|
+
var _dataItem$groupKey;
|
|
125
|
+
var xIndex = _ref.xIndex, yIndex = _ref.yIndex;
|
|
126
|
+
var index = invertAxis ? yIndex : xIndex;
|
|
127
|
+
var dataItem = data[index];
|
|
128
|
+
var total = _this.totalValue(dataItem);
|
|
129
|
+
return {
|
|
130
|
+
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) {
|
|
131
|
+
return item.checked && /* @__PURE__ */ React.createElement(Flex, {
|
|
132
|
+
justifyContent: "space-between",
|
|
133
|
+
key: item.id
|
|
134
|
+
}, /* @__PURE__ */ React.createElement(HoverRect.Tooltip.Dot, {
|
|
135
|
+
mr: 4,
|
|
136
|
+
color: item.color
|
|
137
|
+
}, item.label), /* @__PURE__ */ React.createElement(Text, {
|
|
138
|
+
bold: true
|
|
139
|
+
}, _this.tooltipValueFormatter(dataItem[item.id])));
|
|
140
|
+
}), showTotalInTooltip === true && /* @__PURE__ */ React.createElement(Flex, {
|
|
141
|
+
mt: 2,
|
|
142
|
+
justifyContent: "space-between"
|
|
143
|
+
}, /* @__PURE__ */ React.createElement(Box, {
|
|
144
|
+
mr: 4
|
|
145
|
+
}, "Total"), /* @__PURE__ */ React.createElement(Text, {
|
|
146
|
+
bold: true
|
|
147
|
+
}, total)))
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "getLegendAriaLabel",
|
|
153
|
+
value: function getLegendAriaLabel() {
|
|
154
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
155
|
+
chartType: "Histogram"
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}]);
|
|
159
|
+
return HistogramChartComponent2;
|
|
160
|
+
}(AbstractChart);
|
|
161
|
+
_defineProperty(HistogramChartComponent, "displayName", "Chart.Histogram");
|
|
162
|
+
_defineProperty(HistogramChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
163
|
+
var HistogramChart = createComponent(HistogramChartComponent);
|
|
164
|
+
export {
|
|
165
|
+
HistogramChart
|
|
166
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _get from "@babel/runtime/helpers/esm/get";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
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 React from "react";
|
|
10
|
+
import createComponent from "@semcore/core";
|
|
11
|
+
import { scaleTime, scaleLinear } from "d3-scale";
|
|
12
|
+
import Line from "../../Line.mjs";
|
|
13
|
+
import { HoverLine } from "../../Hover.mjs";
|
|
14
|
+
import { minMax } from "../../utils.mjs";
|
|
15
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
16
|
+
import { Flex, Box } from "@semcore/flex-box";
|
|
17
|
+
import { Text } from "@semcore/typography";
|
|
18
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
19
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
20
|
+
var LineChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
21
|
+
_inherits(LineChartComponent2, _AbstractChart);
|
|
22
|
+
var _super = _createSuper(LineChartComponent2);
|
|
23
|
+
function LineChartComponent2() {
|
|
24
|
+
_classCallCheck(this, LineChartComponent2);
|
|
25
|
+
return _super.apply(this, arguments);
|
|
26
|
+
}
|
|
27
|
+
_createClass(LineChartComponent2, [{
|
|
28
|
+
key: "xScale",
|
|
29
|
+
get: function get() {
|
|
30
|
+
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, groupKey = _this$asProps.groupKey;
|
|
31
|
+
if (xScale) {
|
|
32
|
+
return xScale;
|
|
33
|
+
}
|
|
34
|
+
var testItem = data[0][groupKey];
|
|
35
|
+
var range = [marginY, plotWidth - this.plotPadding];
|
|
36
|
+
var domain = minMax(data, groupKey);
|
|
37
|
+
if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
|
|
38
|
+
return scaleTime(domain, range);
|
|
39
|
+
}
|
|
40
|
+
return scaleLinear(domain, range);
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "yScale",
|
|
44
|
+
get: function get() {
|
|
45
|
+
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;
|
|
46
|
+
if (yScale) {
|
|
47
|
+
return yScale;
|
|
48
|
+
}
|
|
49
|
+
var flatValues = _get(_getPrototypeOf(LineChartComponent2.prototype), "flatValues", this);
|
|
50
|
+
var max = Math.max.apply(Math, _toConsumableArray(flatValues));
|
|
51
|
+
var min = Math.min.apply(Math, _toConsumableArray(flatValues));
|
|
52
|
+
return scaleLinear().range([plotHeight - marginX, this.plotPadding]).domain([min, max]);
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "renderChart",
|
|
56
|
+
value: function renderChart() {
|
|
57
|
+
var _this$asProps3 = this.asProps, groupKey = _this$asProps3.groupKey, curve = _this$asProps3.curve, showDots = _this$asProps3.showDots, area = _this$asProps3.area, areaCurve = _this$asProps3.areaCurve;
|
|
58
|
+
var _this$state = this.state, dataDefinitions = _this$state.dataDefinitions, highlightedLine = _this$state.highlightedLine;
|
|
59
|
+
return dataDefinitions.map(function(item, index) {
|
|
60
|
+
return item.checked && /* @__PURE__ */ React.createElement(Line, {
|
|
61
|
+
x: groupKey.toString(),
|
|
62
|
+
y: item.id,
|
|
63
|
+
key: item.id,
|
|
64
|
+
color: item.color,
|
|
65
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index,
|
|
66
|
+
curve
|
|
67
|
+
}, showDots && /* @__PURE__ */ React.createElement(Line.Dots, {
|
|
68
|
+
display: true
|
|
69
|
+
}), (area === null || area === void 0 ? void 0 : area[item.id]) && /* @__PURE__ */ React.createElement(Line.Area, {
|
|
70
|
+
area: area[item.id],
|
|
71
|
+
y0: "y0",
|
|
72
|
+
y1: "y1",
|
|
73
|
+
curve: areaCurve
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "renderTooltip",
|
|
79
|
+
value: function renderTooltip() {
|
|
80
|
+
var _this = this;
|
|
81
|
+
var _this$asProps4 = this.asProps, data = _this$asProps4.data, groupKey = _this$asProps4.groupKey, showTotalInTooltip = _this$asProps4.showTotalInTooltip, showTooltip = _this$asProps4.showTooltip;
|
|
82
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
83
|
+
if (!showTooltip) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ React.createElement(HoverLine.Tooltip, {
|
|
87
|
+
x: groupKey,
|
|
88
|
+
wMin: 100
|
|
89
|
+
}, function(_ref) {
|
|
90
|
+
var _dataItem$groupKey;
|
|
91
|
+
var xIndex = _ref.xIndex;
|
|
92
|
+
var dataItem = data[xIndex];
|
|
93
|
+
var total = _this.totalValue(dataItem);
|
|
94
|
+
return {
|
|
95
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(HoverLine.Tooltip.Title, null, (_dataItem$groupKey = dataItem[groupKey]) === null || _dataItem$groupKey === void 0 ? void 0 : _dataItem$groupKey.toString()), dataDefinitions.map(function(item) {
|
|
96
|
+
return item.checked && /* @__PURE__ */ React.createElement(Flex, {
|
|
97
|
+
justifyContent: "space-between",
|
|
98
|
+
key: item.id
|
|
99
|
+
}, /* @__PURE__ */ React.createElement(HoverLine.Tooltip.Dot, {
|
|
100
|
+
mr: 4,
|
|
101
|
+
color: item.color
|
|
102
|
+
}, item.label), /* @__PURE__ */ React.createElement(Text, {
|
|
103
|
+
bold: true
|
|
104
|
+
}, _this.tooltipValueFormatter(dataItem[item.id])));
|
|
105
|
+
}), showTotalInTooltip === true && /* @__PURE__ */ React.createElement(Flex, {
|
|
106
|
+
mt: 2,
|
|
107
|
+
justifyContent: "space-between"
|
|
108
|
+
}, /* @__PURE__ */ React.createElement(Box, {
|
|
109
|
+
mr: 4
|
|
110
|
+
}, "Total"), /* @__PURE__ */ React.createElement(Text, {
|
|
111
|
+
bold: true
|
|
112
|
+
}, total)))
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
key: "getLegendAriaLabel",
|
|
118
|
+
value: function getLegendAriaLabel() {
|
|
119
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
120
|
+
chartType: "Line"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}]);
|
|
124
|
+
return LineChartComponent2;
|
|
125
|
+
}(AbstractChart);
|
|
126
|
+
_defineProperty(LineChartComponent, "displayName", "Chart.Line");
|
|
127
|
+
_defineProperty(LineChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
128
|
+
var LineChart = createComponent(LineChartComponent);
|
|
129
|
+
export {
|
|
130
|
+
LineChart
|
|
131
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _get from "@babel/runtime/helpers/esm/get";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
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 React from "react";
|
|
10
|
+
import createComponent from "@semcore/core";
|
|
11
|
+
import { scaleLinear } from "d3-scale";
|
|
12
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
13
|
+
import Radar from "../../Radar.mjs";
|
|
14
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
15
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
16
|
+
var RadarChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
17
|
+
_inherits(RadarChartComponent2, _AbstractChart);
|
|
18
|
+
var _super = _createSuper(RadarChartComponent2);
|
|
19
|
+
function RadarChartComponent2() {
|
|
20
|
+
_classCallCheck(this, RadarChartComponent2);
|
|
21
|
+
return _super.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
_createClass(RadarChartComponent2, [{
|
|
24
|
+
key: "renderChart",
|
|
25
|
+
value: function renderChart() {
|
|
26
|
+
var _this$asProps = this.asProps, groupKey = _this$asProps.groupKey, showDots = _this$asProps.showDots, circle = _this$asProps.circle;
|
|
27
|
+
var _this$state = this.state, dataDefinitions = _this$state.dataDefinitions;
|
|
28
|
+
_this$state.highlightedLine;
|
|
29
|
+
return /* @__PURE__ */ React.createElement(Radar, {
|
|
30
|
+
scale: this.xScale,
|
|
31
|
+
type: circle ? "circle" : void 0
|
|
32
|
+
}, /* @__PURE__ */ React.createElement(Radar.Axis, {
|
|
33
|
+
dataKey: groupKey
|
|
34
|
+
}, /* @__PURE__ */ React.createElement(Radar.Axis.Ticks, null), /* @__PURE__ */ React.createElement(Radar.Axis.Labels, null)), this.renderRadarTooltip(), dataDefinitions.map(function(item) {
|
|
35
|
+
return item.checked && /* @__PURE__ */ React.createElement(Radar.Polygon, {
|
|
36
|
+
dataKey: item.id,
|
|
37
|
+
key: item.id,
|
|
38
|
+
color: item.color
|
|
39
|
+
}, /* @__PURE__ */ React.createElement(Radar.Polygon.Line, null), showDots && /* @__PURE__ */ React.createElement(Radar.Polygon.Dots, null));
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "renderRadarTooltip",
|
|
44
|
+
value: function renderRadarTooltip() {
|
|
45
|
+
var _this = this;
|
|
46
|
+
var _this$asProps2 = this.asProps, data = _this$asProps2.data, groupKey = _this$asProps2.groupKey, showTooltip = _this$asProps2.showTooltip;
|
|
47
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
48
|
+
if (!showTooltip) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ React.createElement(Radar.Tooltip, {
|
|
52
|
+
wMin: 100
|
|
53
|
+
}, function(_ref) {
|
|
54
|
+
var _data$groupKey;
|
|
55
|
+
var index = _ref.index;
|
|
56
|
+
return {
|
|
57
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Radar.Tooltip.Title, null, (_data$groupKey = data[groupKey]) === null || _data$groupKey === void 0 ? void 0 : _data$groupKey[index]), dataDefinitions.map(function(item) {
|
|
58
|
+
var _data$item$id;
|
|
59
|
+
var value = (_data$item$id = data[item.id]) === null || _data$item$id === void 0 ? void 0 : _data$item$id[index];
|
|
60
|
+
return item.checked && /* @__PURE__ */ React.createElement(Radar.Tooltip.Dot, {
|
|
61
|
+
color: item.color,
|
|
62
|
+
key: item.id
|
|
63
|
+
}, _this.tooltipValueFormatter(value));
|
|
64
|
+
}))
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// By default, tooltip will render in Plot component.
|
|
69
|
+
// In RadarChart, we need to render it in Radar component, so we use renderRadarTooltip method
|
|
70
|
+
}, {
|
|
71
|
+
key: "renderTooltip",
|
|
72
|
+
value: function renderTooltip() {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "dataKeys",
|
|
77
|
+
get: function get() {
|
|
78
|
+
var _this$props = this.props, data = _this$props.data, groupKey = _this$props.groupKey;
|
|
79
|
+
var legendKeys = Object.keys(data).filter(function(key) {
|
|
80
|
+
return key !== groupKey;
|
|
81
|
+
});
|
|
82
|
+
return legendKeys;
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "xScale",
|
|
86
|
+
get: function get() {
|
|
87
|
+
var _this$asProps$scale;
|
|
88
|
+
return (_this$asProps$scale = this.asProps.scale) !== null && _this$asProps$scale !== void 0 ? _this$asProps$scale : scaleLinear().domain(this.domain);
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "yScale",
|
|
92
|
+
get: function get() {
|
|
93
|
+
var _this$asProps$scale2;
|
|
94
|
+
return (_this$asProps$scale2 = this.asProps.scale) !== null && _this$asProps$scale2 !== void 0 ? _this$asProps$scale2 : scaleLinear().domain(this.domain);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "getLegendAriaLabel",
|
|
98
|
+
value: function getLegendAriaLabel() {
|
|
99
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
100
|
+
chartType: "Radar"
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "domain",
|
|
105
|
+
get: function get() {
|
|
106
|
+
return [Math.min.apply(Math, _toConsumableArray(_get(_getPrototypeOf(RadarChartComponent2.prototype), "flatValues", this))), Math.max.apply(Math, _toConsumableArray(_get(_getPrototypeOf(RadarChartComponent2.prototype), "flatValues", this)))];
|
|
107
|
+
}
|
|
108
|
+
}]);
|
|
109
|
+
return RadarChartComponent2;
|
|
110
|
+
}(AbstractChart);
|
|
111
|
+
_defineProperty(RadarChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
112
|
+
var RadarChart = createComponent(RadarChartComponent);
|
|
113
|
+
export {
|
|
114
|
+
RadarChart
|
|
115
|
+
};
|