@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,144 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
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 _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import createComponent from "@semcore/core";
|
|
10
|
+
import { scaleTime, scaleLinear } from "d3-scale";
|
|
11
|
+
import ScatterPlot from "../../ScatterPlot.mjs";
|
|
12
|
+
import { getScatterPlotRadius, minMax } from "../../utils.mjs";
|
|
13
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
14
|
+
import { Text } from "@semcore/typography";
|
|
15
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
16
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
17
|
+
var ScatterPlotChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
18
|
+
_inherits(ScatterPlotChartComponent2, _AbstractChart);
|
|
19
|
+
var _super = _createSuper(ScatterPlotChartComponent2);
|
|
20
|
+
function ScatterPlotChartComponent2() {
|
|
21
|
+
_classCallCheck(this, ScatterPlotChartComponent2);
|
|
22
|
+
return _super.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
_createClass(ScatterPlotChartComponent2, [{
|
|
25
|
+
key: "dataKeys",
|
|
26
|
+
get: function get() {
|
|
27
|
+
var _this$props = this.props, data = _this$props.data, groupKey = _this$props.groupKey, valueKey = _this$props.valueKey;
|
|
28
|
+
return Object.keys(data[0]).filter(function(key) {
|
|
29
|
+
return key !== groupKey && key !== valueKey;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "xScale",
|
|
34
|
+
get: function get() {
|
|
35
|
+
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, valueKey = _this$asProps.valueKey;
|
|
36
|
+
if (xScale) {
|
|
37
|
+
return xScale;
|
|
38
|
+
}
|
|
39
|
+
var radius = getScatterPlotRadius(valueKey) / this.getValueScale(_toConsumableArray(this.flatValues));
|
|
40
|
+
var testItem = data[0][groupKey];
|
|
41
|
+
var range = [marginY, plotWidth - this.plotPadding];
|
|
42
|
+
var domain = minMax(data, groupKey);
|
|
43
|
+
if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
|
|
44
|
+
return scaleTime([domain[0] - radius, domain[1] + radius], range);
|
|
45
|
+
}
|
|
46
|
+
return scaleLinear([domain[0] - radius, domain[1] + radius], range);
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "yScale",
|
|
50
|
+
get: function get() {
|
|
51
|
+
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, valueKey = _this$asProps2.valueKey;
|
|
52
|
+
if (yScale) {
|
|
53
|
+
return yScale;
|
|
54
|
+
}
|
|
55
|
+
var flatValues = this.flatValues;
|
|
56
|
+
var radius = getScatterPlotRadius(valueKey) / this.getValueScale(_toConsumableArray(flatValues));
|
|
57
|
+
var max = Math.max.apply(Math, _toConsumableArray(flatValues)) + radius;
|
|
58
|
+
var min = Math.min.apply(Math, _toConsumableArray(flatValues)) - radius;
|
|
59
|
+
return scaleLinear().range([plotHeight - marginX, this.plotPadding]).domain([min, max]);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "flatValues",
|
|
63
|
+
get: function get() {
|
|
64
|
+
var _this$asProps3 = this.asProps, data = _this$asProps3.data, groupKey = _this$asProps3.groupKey, valueKey = _this$asProps3.valueKey;
|
|
65
|
+
var flatValues = data.reduce(function(result, item) {
|
|
66
|
+
Object.entries(item).forEach(function(_ref) {
|
|
67
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
68
|
+
if (key !== groupKey && key !== valueKey && typeof value === "number") {
|
|
69
|
+
result.add(value);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return result;
|
|
73
|
+
}, /* @__PURE__ */ new Set());
|
|
74
|
+
return flatValues;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "renderChart",
|
|
78
|
+
value: function renderChart() {
|
|
79
|
+
var _this$asProps4 = this.asProps, groupKey = _this$asProps4.groupKey, valueKey = _this$asProps4.valueKey;
|
|
80
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
81
|
+
return dataDefinitions.map(function(item) {
|
|
82
|
+
return item.checked && /* @__PURE__ */ React.createElement(ScatterPlot, {
|
|
83
|
+
x: groupKey,
|
|
84
|
+
y: item.id,
|
|
85
|
+
key: item.id,
|
|
86
|
+
color: item.color,
|
|
87
|
+
value: valueKey
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "renderTooltip",
|
|
93
|
+
value: function renderTooltip() {
|
|
94
|
+
var _this = this;
|
|
95
|
+
var _this$asProps5 = this.asProps, data = _this$asProps5.data, groupKey = _this$asProps5.groupKey, showTooltip = _this$asProps5.showTooltip;
|
|
96
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
97
|
+
if (!showTooltip) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
return dataDefinitions.filter(function(item) {
|
|
101
|
+
return item.checked;
|
|
102
|
+
}).map(function(item) {
|
|
103
|
+
return /* @__PURE__ */ React.createElement(ScatterPlot.Tooltip, {
|
|
104
|
+
key: item.id,
|
|
105
|
+
x: groupKey,
|
|
106
|
+
y: item.id,
|
|
107
|
+
wMin: 100
|
|
108
|
+
}, function(_ref3) {
|
|
109
|
+
var index = _ref3.index, x = _ref3.x, y = _ref3.y;
|
|
110
|
+
return {
|
|
111
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ScatterPlot.Tooltip.Dot, {
|
|
112
|
+
color: item.color
|
|
113
|
+
}, "Data"), /* @__PURE__ */ React.createElement(Text, {
|
|
114
|
+
tag: "div"
|
|
115
|
+
}, "X axis ", _this.tooltipValueFormatter(data[index][x])), /* @__PURE__ */ React.createElement(Text, {
|
|
116
|
+
tag: "div"
|
|
117
|
+
}, "Y axis ", _this.tooltipValueFormatter(data[index][y])))
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "getLegendAriaLabel",
|
|
124
|
+
value: function getLegendAriaLabel() {
|
|
125
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
126
|
+
chartType: "ScatterPlot"
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}]);
|
|
130
|
+
return ScatterPlotChartComponent2;
|
|
131
|
+
}(AbstractChart);
|
|
132
|
+
_defineProperty(ScatterPlotChartComponent, "displayName", "Chart.ScatterPlot");
|
|
133
|
+
_defineProperty(ScatterPlotChartComponent, "defaultProps", {
|
|
134
|
+
direction: "column",
|
|
135
|
+
showXAxis: true,
|
|
136
|
+
showYAxis: true,
|
|
137
|
+
showTooltip: true,
|
|
138
|
+
showLegend: false
|
|
139
|
+
});
|
|
140
|
+
_defineProperty(ScatterPlotChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
141
|
+
var ScatterPlotChart = createComponent(ScatterPlotChartComponent);
|
|
142
|
+
export {
|
|
143
|
+
ScatterPlotChart
|
|
144
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
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 Venn from "../../Venn.mjs";
|
|
10
|
+
import { AbstractChart } from "./AbstractChart.mjs";
|
|
11
|
+
import { Text } from "@semcore/typography";
|
|
12
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
13
|
+
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
14
|
+
var VennChartComponent = /* @__PURE__ */ function(_AbstractChart) {
|
|
15
|
+
_inherits(VennChartComponent2, _AbstractChart);
|
|
16
|
+
var _super = _createSuper(VennChartComponent2);
|
|
17
|
+
function VennChartComponent2() {
|
|
18
|
+
_classCallCheck(this, VennChartComponent2);
|
|
19
|
+
return _super.apply(this, arguments);
|
|
20
|
+
}
|
|
21
|
+
_createClass(VennChartComponent2, [{
|
|
22
|
+
key: "xScale",
|
|
23
|
+
get: function get() {
|
|
24
|
+
var xScale = this.asProps.xScale;
|
|
25
|
+
if (xScale) {
|
|
26
|
+
return xScale;
|
|
27
|
+
}
|
|
28
|
+
return scaleLinear();
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "yScale",
|
|
32
|
+
get: function get() {
|
|
33
|
+
var yScale = this.asProps.yScale;
|
|
34
|
+
if (yScale) {
|
|
35
|
+
return yScale;
|
|
36
|
+
}
|
|
37
|
+
return scaleLinear();
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "dataKeys",
|
|
41
|
+
get: function get() {
|
|
42
|
+
var data = this.props.data;
|
|
43
|
+
var legendKeys = Object.keys(data).filter(function(item) {
|
|
44
|
+
var isIntersection = /\//.test(item);
|
|
45
|
+
return !isIntersection;
|
|
46
|
+
});
|
|
47
|
+
return legendKeys;
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "defaultLegendProps",
|
|
51
|
+
value: function defaultLegendProps() {
|
|
52
|
+
return {
|
|
53
|
+
legendType: "Table"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "renderChart",
|
|
58
|
+
value: function renderChart() {
|
|
59
|
+
var data = this.asProps.data;
|
|
60
|
+
var _this$state = this.state, dataDefinitions = _this$state.dataDefinitions, highlightedLine = _this$state.highlightedLine;
|
|
61
|
+
var checkedLegendItems = dataDefinitions.filter(function(item) {
|
|
62
|
+
return item.checked;
|
|
63
|
+
});
|
|
64
|
+
var checkedLegendItemsMap = checkedLegendItems.reduce(function(result, item) {
|
|
65
|
+
result[item.id] = item;
|
|
66
|
+
return result;
|
|
67
|
+
}, {});
|
|
68
|
+
var intersections = Object.keys(data).reduce(function(result, dataKey) {
|
|
69
|
+
var isIntersection = /\//.test(dataKey);
|
|
70
|
+
if (isIntersection) {
|
|
71
|
+
result.push(dataKey);
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}, []);
|
|
75
|
+
return /* @__PURE__ */ React.createElement(Venn, null, checkedLegendItems.map(function(item, index) {
|
|
76
|
+
return /* @__PURE__ */ React.createElement(Venn.Circle, {
|
|
77
|
+
key: item.id,
|
|
78
|
+
dataKey: item.id,
|
|
79
|
+
name: item.label,
|
|
80
|
+
color: item.color,
|
|
81
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index
|
|
82
|
+
});
|
|
83
|
+
}), intersections.map(function(intersectionKey) {
|
|
84
|
+
var intersectionKeys = intersectionKey.split("/");
|
|
85
|
+
var hasDisabledItems = intersectionKeys.some(function(key) {
|
|
86
|
+
return checkedLegendItemsMap[key] === void 0;
|
|
87
|
+
});
|
|
88
|
+
if (hasDisabledItems) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
var name = intersectionKeys.map(function(id) {
|
|
92
|
+
var _dataDefinitions$find;
|
|
93
|
+
return ((_dataDefinitions$find = dataDefinitions.find(function(legendItem) {
|
|
94
|
+
return legendItem.id === id;
|
|
95
|
+
})) === null || _dataDefinitions$find === void 0 ? void 0 : _dataDefinitions$find.label) || "";
|
|
96
|
+
}).join(" & ");
|
|
97
|
+
return /* @__PURE__ */ React.createElement(Venn.Intersection, {
|
|
98
|
+
key: intersectionKey,
|
|
99
|
+
dataKey: intersectionKey,
|
|
100
|
+
name
|
|
101
|
+
});
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "renderTooltip",
|
|
106
|
+
value: function renderTooltip() {
|
|
107
|
+
var showTooltip = this.asProps.showTooltip;
|
|
108
|
+
if (!showTooltip) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
return /* @__PURE__ */ React.createElement(Venn.Tooltip, null, function(_ref) {
|
|
112
|
+
var name = _ref.name, dataKey = _ref.dataKey, data = _ref.data;
|
|
113
|
+
return {
|
|
114
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Venn.Tooltip.Title, null, name), /* @__PURE__ */ React.createElement(Text, {
|
|
115
|
+
bold: true
|
|
116
|
+
}, data[dataKey]))
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "getLegendAriaLabel",
|
|
122
|
+
value: function getLegendAriaLabel() {
|
|
123
|
+
return this.asProps.getI18nText("legendForChart", {
|
|
124
|
+
chartType: "Venn"
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}]);
|
|
128
|
+
return VennChartComponent2;
|
|
129
|
+
}(AbstractChart);
|
|
130
|
+
_defineProperty(VennChartComponent, "displayName", "Chart.Venn");
|
|
131
|
+
_defineProperty(VennChartComponent, "defaultProps", {
|
|
132
|
+
direction: "row-reverse",
|
|
133
|
+
alignItems: "flex-start",
|
|
134
|
+
marginY: 0,
|
|
135
|
+
marginX: 0
|
|
136
|
+
});
|
|
137
|
+
_defineProperty(VennChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
138
|
+
var VennChart = createComponent(VennChartComponent);
|
|
139
|
+
export {
|
|
140
|
+
VennChart
|
|
141
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LineChart } from "./LineChart.mjs";
|
|
2
|
+
import { BarChart } from "./BarChart.mjs";
|
|
3
|
+
import { CompactHorizontalBarChart } from "./CompactHorizontalBarChart.mjs";
|
|
4
|
+
import { HistogramChart } from "./HistogramChart.mjs";
|
|
5
|
+
import { ScatterPlotChart } from "./ScatterPlotChart.mjs";
|
|
6
|
+
import { AreaChart } from "./AreaChart.mjs";
|
|
7
|
+
import { BubbleChart } from "./BubbleChart.mjs";
|
|
8
|
+
import { DonutChart } from "./DonutChart.mjs";
|
|
9
|
+
import { VennChart } from "./VennChart.mjs";
|
|
10
|
+
import { RadarChart } from "./RadarChart.mjs";
|
|
11
|
+
import { CigaretteChart } from "./CigaretteChart.mjs";
|
|
12
|
+
const index = {
|
|
13
|
+
Line: LineChart,
|
|
14
|
+
Bar: BarChart,
|
|
15
|
+
Histogram: HistogramChart,
|
|
16
|
+
ScatterPlot: ScatterPlotChart,
|
|
17
|
+
Area: AreaChart,
|
|
18
|
+
Bubble: BubbleChart,
|
|
19
|
+
Donut: DonutChart,
|
|
20
|
+
Venn: VennChart,
|
|
21
|
+
Radar: RadarChart,
|
|
22
|
+
Cigarette: CigaretteChart,
|
|
23
|
+
CompactHorizontalBar: CompactHorizontalBarChart
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
index as default
|
|
27
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
import { Component } from "@semcore/core";
|
|
9
|
+
import { makeDataHintsHandlers } from "../../a11y/hints.mjs";
|
|
10
|
+
var BaseLegend = /* @__PURE__ */ function(_Component) {
|
|
11
|
+
_inherits(BaseLegend2, _Component);
|
|
12
|
+
var _super = _createSuper(BaseLegend2);
|
|
13
|
+
function BaseLegend2() {
|
|
14
|
+
var _this;
|
|
15
|
+
_classCallCheck(this, BaseLegend2);
|
|
16
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
|
+
args[_key] = arguments[_key];
|
|
18
|
+
}
|
|
19
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
20
|
+
_defineProperty(_assertThisInitialized(_this), "onChangeLegendItem", function(id, checked) {
|
|
21
|
+
var _this$props$onChangeV, _this$props;
|
|
22
|
+
(_this$props$onChangeV = (_this$props = _this.props).onChangeVisibleItem) === null || _this$props$onChangeV === void 0 ? void 0 : _this$props$onChangeV.call(_this$props, id, checked);
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(_assertThisInitialized(_this), "bindOnMouseEnterItem", function(id) {
|
|
25
|
+
return function(e) {
|
|
26
|
+
var _this$props$onMouseEn, _this$props2;
|
|
27
|
+
(_this$props$onMouseEn = (_this$props2 = _this.props).onMouseEnterItem) === null || _this$props$onMouseEn === void 0 ? void 0 : _this$props$onMouseEn.call(_this$props2, id, e);
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "bindOnMouseLeaveItem", function(id) {
|
|
31
|
+
return function(e) {
|
|
32
|
+
var _this$props$onMouseLe, _this$props3;
|
|
33
|
+
(_this$props$onMouseLe = (_this$props3 = _this.props).onMouseLeaveItem) === null || _this$props$onMouseLe === void 0 ? void 0 : _this$props$onMouseLe.call(_this$props3, id, e);
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
return _this;
|
|
37
|
+
}
|
|
38
|
+
_createClass(BaseLegend2, [{
|
|
39
|
+
key: "componentDidMount",
|
|
40
|
+
value: function componentDidMount() {
|
|
41
|
+
this.setHints();
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "componentDidUpdate",
|
|
45
|
+
value: function componentDidUpdate(prevProps) {
|
|
46
|
+
if (prevProps.items !== this.props.items || prevProps.dataHints !== this.props.dataHints) {
|
|
47
|
+
this.setHints();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "setHints",
|
|
52
|
+
value: function setHints() {
|
|
53
|
+
var _this$asProps = this.asProps, items = _this$asProps.items, dataHints = _this$asProps.dataHints;
|
|
54
|
+
var dataHintsHandler = dataHints ? makeDataHintsHandlers(dataHints) : void 0;
|
|
55
|
+
items.forEach(function(legendItem) {
|
|
56
|
+
dataHintsHandler === null || dataHintsHandler === void 0 ? void 0 : dataHintsHandler.labelKey("value", legendItem.id, legendItem.label);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "getItem",
|
|
61
|
+
value: function getItem(index) {
|
|
62
|
+
var line = this.asProps.items[index];
|
|
63
|
+
if (line === void 0) {
|
|
64
|
+
throw new Error('No index "'.concat(index, '" in lines'));
|
|
65
|
+
}
|
|
66
|
+
return line;
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "getLegendItemProps",
|
|
70
|
+
value: function getLegendItemProps(_, index) {
|
|
71
|
+
var _this$asProps2 = this.asProps, _this$asProps2$shape = _this$asProps2.shape, shape = _this$asProps2$shape === void 0 ? "Checkbox" : _this$asProps2$shape, _this$asProps2$size = _this$asProps2.size, size = _this$asProps2$size === void 0 ? "m" : _this$asProps2$size, patterns = _this$asProps2.patterns;
|
|
72
|
+
var line = this.getItem(index);
|
|
73
|
+
return _objectSpread(_objectSpread({}, line), {}, {
|
|
74
|
+
shape,
|
|
75
|
+
size,
|
|
76
|
+
onChangeLegendItem: this.onChangeLegendItem,
|
|
77
|
+
onMouseEnter: this.bindOnMouseEnterItem(line.id),
|
|
78
|
+
onMouseLeave: this.bindOnMouseLeaveItem(line.id),
|
|
79
|
+
style: {
|
|
80
|
+
gridRowStart: "".concat(index + 1),
|
|
81
|
+
gridRowEnd: "".concat(index + 2)
|
|
82
|
+
},
|
|
83
|
+
patterns
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}]);
|
|
87
|
+
return BaseLegend2;
|
|
88
|
+
}(Component);
|
|
89
|
+
export {
|
|
90
|
+
BaseLegend
|
|
91
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
8
|
+
import createComponent, { sstyled as sstyled$1, assignProps } from "@semcore/core";
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { Flex } from "@semcore/flex-box";
|
|
11
|
+
import { LegendItemComponent } from "../LegendItem/LegendItem.mjs";
|
|
12
|
+
import Divider from "@semcore/divider";
|
|
13
|
+
import Checkbox from "@semcore/checkbox";
|
|
14
|
+
import { BaseLegend } from "../BaseLegend.mjs";
|
|
15
|
+
import { localizedMessages } from "../../../translations/__intergalactic-dynamic-locales.mjs";
|
|
16
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
17
|
+
/*!__reshadow-styles__:"./legend-flex.shadow.css"*/
|
|
18
|
+
var style = (
|
|
19
|
+
/*__reshadow_css_start__*/
|
|
20
|
+
(sstyled.insert(
|
|
21
|
+
/*__inner_css_start__*/
|
|
22
|
+
".___SLegendFlex_v8y85_gg_._direction_row_v8y85_gg_{align-items:flex-start;align-content:flex-start;flex-wrap:wrap;gap:8px 16px}.___SLegendFlex_v8y85_gg_._direction_column_v8y85_gg_{align-items:flex-start;flex-wrap:wrap;gap:8px}",
|
|
23
|
+
/*__inner_css_end__*/
|
|
24
|
+
"v8y85_gg_"
|
|
25
|
+
), /*__reshadow_css_end__*/
|
|
26
|
+
{
|
|
27
|
+
"__SLegendFlex": "___SLegendFlex_v8y85_gg_",
|
|
28
|
+
"_direction_row": "_direction_row_v8y85_gg_",
|
|
29
|
+
"_direction_column": "_direction_column_v8y85_gg_"
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
var LegendFlexRoot = /* @__PURE__ */ function(_BaseLegend) {
|
|
33
|
+
_inherits(LegendFlexRoot2, _BaseLegend);
|
|
34
|
+
var _super = _createSuper(LegendFlexRoot2);
|
|
35
|
+
function LegendFlexRoot2() {
|
|
36
|
+
_classCallCheck(this, LegendFlexRoot2);
|
|
37
|
+
return _super.apply(this, arguments);
|
|
38
|
+
}
|
|
39
|
+
_createClass(LegendFlexRoot2, [{
|
|
40
|
+
key: "renderTrend",
|
|
41
|
+
value: function renderTrend() {
|
|
42
|
+
var _ref3 = this.asProps, onTrendIsVisibleChange = _ref3.onTrendIsVisibleChange, trendIsVisible = _ref3.trendIsVisible, trendLabel = _ref3.trendLabel, size = _ref3.size, getI18nText = _ref3.getI18nText;
|
|
43
|
+
return /* @__PURE__ */ React.createElement(Checkbox, {
|
|
44
|
+
checked: trendIsVisible,
|
|
45
|
+
onChange: onTrendIsVisibleChange,
|
|
46
|
+
theme: "gray-400",
|
|
47
|
+
label: trendLabel !== null && trendLabel !== void 0 ? trendLabel : getI18nText("trend"),
|
|
48
|
+
size
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "render",
|
|
53
|
+
value: function render() {
|
|
54
|
+
var _ref = this.asProps, _ref2;
|
|
55
|
+
var SLegendFlex = Flex;
|
|
56
|
+
var _this$asProps = this.asProps, styles = _this$asProps.styles, Children = _this$asProps.Children, direction = _this$asProps.direction, withTrend = _this$asProps.withTrend, suffix = _this$asProps.suffix, items = _this$asProps.items;
|
|
57
|
+
var orientation = direction === "row" ? "vertical" : "horizontal";
|
|
58
|
+
return _ref2 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SLegendFlex, _ref2.cn("SLegendFlex", _objectSpread({}, assignProps({
|
|
59
|
+
"role": "group"
|
|
60
|
+
}, _ref))), items.map(function(_ref4) {
|
|
61
|
+
var id = _ref4.id;
|
|
62
|
+
return /* @__PURE__ */ React.createElement(Children, {
|
|
63
|
+
key: id
|
|
64
|
+
});
|
|
65
|
+
}), (withTrend || suffix) && /* @__PURE__ */ React.createElement(Divider, _ref2.cn("Divider", {
|
|
66
|
+
"orientation": orientation
|
|
67
|
+
})), withTrend && this.renderTrend(), suffix ? suffix : null);
|
|
68
|
+
}
|
|
69
|
+
}]);
|
|
70
|
+
return LegendFlexRoot2;
|
|
71
|
+
}(BaseLegend);
|
|
72
|
+
_defineProperty(LegendFlexRoot, "displayName", "LegendFlex");
|
|
73
|
+
_defineProperty(LegendFlexRoot, "style", style);
|
|
74
|
+
_defineProperty(LegendFlexRoot, "enhance", [i18nEnhance(localizedMessages)]);
|
|
75
|
+
_defineProperty(LegendFlexRoot, "defaultProps", function() {
|
|
76
|
+
return {
|
|
77
|
+
direction: "row",
|
|
78
|
+
children: /* @__PURE__ */ React.createElement(LegendFlex.LegendItem, null)
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
var LegendFlex = createComponent(LegendFlexRoot, {
|
|
82
|
+
LegendItem: LegendItemComponent
|
|
83
|
+
});
|
|
84
|
+
export {
|
|
85
|
+
LegendFlex
|
|
86
|
+
};
|