@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,181 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
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 React from "react";
|
|
9
|
+
import { sstyled as sstyled$1, Component } from "@semcore/core";
|
|
10
|
+
import uniqueIDEnhancement from "@semcore/utils/lib/uniqueID";
|
|
11
|
+
import createElement from "./createElement.mjs";
|
|
12
|
+
import AnimatedClipPath from "./AnimatedClipPath.mjs";
|
|
13
|
+
import { scaleToBand, roundedPath } from "./utils.mjs";
|
|
14
|
+
import { PatternFill } from "./Pattern.mjs";
|
|
15
|
+
/*!__reshadow-styles__:"./style/bar.shadow.css"*/
|
|
16
|
+
var style = (
|
|
17
|
+
/*__reshadow_css_start__*/
|
|
18
|
+
(sstyled.insert(
|
|
19
|
+
/*__inner_css_start__*/
|
|
20
|
+
".___SBar_1rv7u_gg_{fill:var(--intergalactic-chart-palette-order-1, #2bb3ff);transition-property:height,width,y;transition-duration:var(--duration_1rv7u);transition-timing-function:ease-in-out}.___SBar_1rv7u_gg_.__color_1rv7u_gg_{fill:var(--color_1rv7u)}.___SBar_1rv7u_gg_.__pattern_1rv7u_gg_.__color_1rv7u_gg_{fill:var(--pattern_1rv7u);stroke:var(--color_1rv7u);stroke-width:1px}.___SBar_1rv7u_gg_.__hide_1rv7u_gg_{display:none}.___SBar_1rv7u_gg_.__transparent_1rv7u_gg_{opacity:.3}.___SBackground_1rv7u_gg_.__onClick_1rv7u_gg_,.___SBar_1rv7u_gg_.__onClick_1rv7u_gg_{cursor:pointer}.___SBackground_1rv7u_gg_{fill:var(--intergalactic-chart-grid-bar-chart-base-bg, #e0e1e9)}.___SBarAnnotation_1rv7u_gg_{display:flex;justify-content:space-between}.___SBarLabel_1rv7u_gg_{color:var(--intergalactic-text-primary, #191b23);margin-right:auto}.___SBarLabel_1rv7u_gg_,.___SBarPercent_1rv7u_gg_,.___SBarValue_1rv7u_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SBarPercent_1rv7u_gg_{color:var(--intergalactic-text-secondary, #6c6e79);margin-right:var(--intergalactic-spacing-2x, 8px)}.___SBarValue_1rv7u_gg_{min-width:52px;display:flex;justify-content:flex-end;color:var(--intergalactic-text-primary, #191b23);text-align:right}.___SCompactHorizontalBarHoverRect_1rv7u_gg_{fill:var(--intergalactic-chart-grid-bar-chart-hover, rgba(196, 199, 207, 0.3))}",
|
|
21
|
+
/*__inner_css_end__*/
|
|
22
|
+
"1rv7u_gg_"
|
|
23
|
+
), /*__reshadow_css_end__*/
|
|
24
|
+
{
|
|
25
|
+
"__SBar": "___SBar_1rv7u_gg_",
|
|
26
|
+
"--duration": "--duration_1rv7u",
|
|
27
|
+
"_color": "__color_1rv7u_gg_",
|
|
28
|
+
"--color": "--color_1rv7u",
|
|
29
|
+
"_pattern": "__pattern_1rv7u_gg_",
|
|
30
|
+
"--pattern": "--pattern_1rv7u",
|
|
31
|
+
"_hide": "__hide_1rv7u_gg_",
|
|
32
|
+
"_transparent": "__transparent_1rv7u_gg_",
|
|
33
|
+
"_onClick": "__onClick_1rv7u_gg_",
|
|
34
|
+
"__SBackground": "___SBackground_1rv7u_gg_",
|
|
35
|
+
"__SBarAnnotation": "___SBarAnnotation_1rv7u_gg_",
|
|
36
|
+
"__SBarLabel": "___SBarLabel_1rv7u_gg_",
|
|
37
|
+
"__SBarPercent": "___SBarPercent_1rv7u_gg_",
|
|
38
|
+
"__SBarValue": "___SBarValue_1rv7u_gg_",
|
|
39
|
+
"__SCompactHorizontalBarHoverRect": "___SCompactHorizontalBarHoverRect_1rv7u_gg_"
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
var MIN_WIDTH = 2;
|
|
43
|
+
var calcPartBarX = function calcPartBarX2(x, minWidth, width) {
|
|
44
|
+
if (x <= 0) {
|
|
45
|
+
return width <= minWidth ? minWidth : 0;
|
|
46
|
+
}
|
|
47
|
+
return Object.is(x, 0) ? minWidth : 0;
|
|
48
|
+
};
|
|
49
|
+
var HorizontalBarRoot = /* @__PURE__ */ function(_Component) {
|
|
50
|
+
_inherits(HorizontalBarRoot2, _Component);
|
|
51
|
+
var _super = _createSuper(HorizontalBarRoot2);
|
|
52
|
+
function HorizontalBarRoot2() {
|
|
53
|
+
_classCallCheck(this, HorizontalBarRoot2);
|
|
54
|
+
return _super.apply(this, arguments);
|
|
55
|
+
}
|
|
56
|
+
_createClass(HorizontalBarRoot2, [{
|
|
57
|
+
key: "getBackgroundProps",
|
|
58
|
+
value: function getBackgroundProps(_props, index) {
|
|
59
|
+
var _this$asProps = this.asProps, data = _this$asProps.data, y = _this$asProps.y;
|
|
60
|
+
return {
|
|
61
|
+
value: data[index][y],
|
|
62
|
+
index
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "renderBar",
|
|
67
|
+
value: function renderBar(d, i) {
|
|
68
|
+
var _ref, _d$x, _d$x2, _d$x3;
|
|
69
|
+
var SBar = this.Element;
|
|
70
|
+
var _this$asProps2 = this.asProps, styles = _this$asProps2.styles, color = _this$asProps2.color, x = _this$asProps2.x, x0 = _this$asProps2.x0, y = _this$asProps2.y, scale = _this$asProps2.scale, hide = _this$asProps2.hide, offsetProps = _this$asProps2.offset, uid = _this$asProps2.uid, duration = _this$asProps2.duration, r = _this$asProps2.r, wMin = _this$asProps2.wMin, heightProps = _this$asProps2.height, onMouseMove = _this$asProps2.onMouseMove, onMouseLeave = _this$asProps2.onMouseLeave, groupKey = _this$asProps2.groupKey, transparent = _this$asProps2.transparent, _this$asProps2$maxBar = _this$asProps2.maxBarSize, maxBarSize = _this$asProps2$maxBar === void 0 ? Infinity : _this$asProps2$maxBar, resolveColor = _this$asProps2.resolveColor, patterns = _this$asProps2.patterns, onClick = _this$asProps2.onClick;
|
|
71
|
+
var offset = typeof offsetProps === "function" ? offsetProps(i) : offsetProps;
|
|
72
|
+
var _scale = _slicedToArray(scale, 2), xScale = _scale[0], yScale = _scale[1];
|
|
73
|
+
var absWidth = Math.abs(xScale(d[x]) - Math.max(xScale(xScale.domain()[0]), xScale((_d$x = d[x0]) !== null && _d$x !== void 0 ? _d$x : 0)));
|
|
74
|
+
var bandHeight = heightProps || scaleToBand(yScale).bandwidth();
|
|
75
|
+
var height = Math.min(bandHeight, maxBarSize);
|
|
76
|
+
var width = Number(d[x] - ((_d$x2 = d[x0]) !== null && _d$x2 !== void 0 ? _d$x2 : 0)) === 0 ? 0 : Math.max(absWidth, wMin);
|
|
77
|
+
var barY = yScale(d[y]) + bandHeight / 2 - height / 2 + offset[1];
|
|
78
|
+
var barX = xScale(Math.min((_d$x3 = d[x0]) !== null && _d$x3 !== void 0 ? _d$x3 : 0, width <= wMin && d[x] < 0 ? 0 : d[x])) + offset[0] - calcPartBarX(d[x], wMin, width);
|
|
79
|
+
var handleClick = function handleClick2(event) {
|
|
80
|
+
return onClick === null || onClick === void 0 ? void 0 : onClick(d, event, i, x);
|
|
81
|
+
};
|
|
82
|
+
var dSvg = getHorizontalRect({
|
|
83
|
+
x: barX,
|
|
84
|
+
y: barY,
|
|
85
|
+
width,
|
|
86
|
+
height,
|
|
87
|
+
radius: Array.isArray(r) ? r[i] : r,
|
|
88
|
+
position: d[x] > 0 || Object.is(d[x], 0) ? "right" : "left"
|
|
89
|
+
});
|
|
90
|
+
if (groupKey) {
|
|
91
|
+
this.asProps.dataHintsHandler.describeGroupedValues(groupKey, x);
|
|
92
|
+
} else {
|
|
93
|
+
this.asProps.dataHintsHandler.describeValueEntity("".concat(i, ".").concat(x), groupKey !== null && groupKey !== void 0 ? groupKey : d[y]);
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
96
|
+
key: "horizontal-bar-".concat(i)
|
|
97
|
+
}, (_ref = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBar, _ref.cn("SBar", {
|
|
98
|
+
"aria-hidden": true,
|
|
99
|
+
"render": "path",
|
|
100
|
+
"clipPath": "url(#".concat(uid, ")"),
|
|
101
|
+
"__excludeProps": ["data", "scale", "value", "onClick", "offset"],
|
|
102
|
+
"childrenPosition": "above",
|
|
103
|
+
"value": d,
|
|
104
|
+
"index": i,
|
|
105
|
+
"hide": hide,
|
|
106
|
+
"color": resolveColor(color),
|
|
107
|
+
"pattern": patterns ? "url(#".concat(uid, "-").concat(i, "-pattern)") : void 0,
|
|
108
|
+
"transparent": transparent,
|
|
109
|
+
"x": barX,
|
|
110
|
+
"y": barY,
|
|
111
|
+
"width": width,
|
|
112
|
+
"height": height,
|
|
113
|
+
"d": dSvg,
|
|
114
|
+
"onClickCapture": handleClick,
|
|
115
|
+
"use:duration": "".concat(duration, "ms"),
|
|
116
|
+
"onMouseMove": onMouseMove,
|
|
117
|
+
"onMouseLeave": onMouseLeave
|
|
118
|
+
}))), patterns && /* @__PURE__ */ React.createElement(PatternFill, _ref.cn("PatternFill", {
|
|
119
|
+
"id": "".concat(uid, "-").concat(i, "-pattern"),
|
|
120
|
+
"patternKey": color,
|
|
121
|
+
"color": resolveColor(color),
|
|
122
|
+
"patterns": patterns
|
|
123
|
+
})));
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "render",
|
|
127
|
+
value: function render() {
|
|
128
|
+
var _this$asProps3 = this.asProps, data = _this$asProps3.data, uid = _this$asProps3.uid, size = _this$asProps3.size, duration = _this$asProps3.duration;
|
|
129
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, data.map(this.renderBar.bind(this)), duration && /* @__PURE__ */ React.createElement(AnimatedClipPath, {
|
|
130
|
+
"aria-hidden": true,
|
|
131
|
+
duration,
|
|
132
|
+
id: uid,
|
|
133
|
+
x: "0",
|
|
134
|
+
y: "0",
|
|
135
|
+
width: 0,
|
|
136
|
+
height: size[1]
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
}]);
|
|
140
|
+
return HorizontalBarRoot2;
|
|
141
|
+
}(Component);
|
|
142
|
+
_defineProperty(HorizontalBarRoot, "displayName", "HorizontalBar");
|
|
143
|
+
_defineProperty(HorizontalBarRoot, "enhance", [uniqueIDEnhancement()]);
|
|
144
|
+
_defineProperty(HorizontalBarRoot, "style", style);
|
|
145
|
+
_defineProperty(HorizontalBarRoot, "defaultProps", {
|
|
146
|
+
offset: [0, 0],
|
|
147
|
+
duration: 500,
|
|
148
|
+
r: 2,
|
|
149
|
+
wMin: MIN_WIDTH
|
|
150
|
+
});
|
|
151
|
+
function Background(props) {
|
|
152
|
+
var _ref2;
|
|
153
|
+
var SBackground = props.Element, styles = props.styles, scale = props.scale, value = props.value;
|
|
154
|
+
var _scale2 = _slicedToArray(scale, 2), xScale = _scale2[0], yScale = _scale2[1];
|
|
155
|
+
var xRange = xScale.range();
|
|
156
|
+
return _ref2 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBackground, _ref2.cn("SBackground", {
|
|
157
|
+
"aria-hidden": true,
|
|
158
|
+
"render": "rect",
|
|
159
|
+
"childrenPosition": "above",
|
|
160
|
+
"width": xRange[1] - xRange[0],
|
|
161
|
+
"height": scaleToBand(yScale).bandwidth(),
|
|
162
|
+
"x": xRange[0],
|
|
163
|
+
"y": yScale(value)
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
function getHorizontalRect(_ref3) {
|
|
167
|
+
var x = _ref3.x, y = _ref3.y, width = _ref3.width, height = _ref3.height, radius = _ref3.radius, position = _ref3.position;
|
|
168
|
+
if (width < radius) radius = width;
|
|
169
|
+
if (radius) {
|
|
170
|
+
if (position === "right") return roundedPath(x, y, width, height, radius, false, true, false, true);
|
|
171
|
+
return roundedPath(x, y, width, height, radius, true, false, true, false);
|
|
172
|
+
}
|
|
173
|
+
return roundedPath(x, y, width, height, radius);
|
|
174
|
+
}
|
|
175
|
+
const HorizontalBar = createElement(HorizontalBarRoot, {
|
|
176
|
+
Background
|
|
177
|
+
});
|
|
178
|
+
export {
|
|
179
|
+
MIN_WIDTH,
|
|
180
|
+
HorizontalBar as default
|
|
181
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
10
|
+
import { Component, sstyled as sstyled$1, assignProps } from "@semcore/core";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import canUseDOM from "@semcore/utils/lib/canUseDOM";
|
|
13
|
+
import trottle from "@semcore/utils/lib/rafTrottle";
|
|
14
|
+
import createElement from "./createElement.mjs";
|
|
15
|
+
import { eventToPoint, invert, getIndexFromData, scaleOfBandwidth, scaleToBand } from "./utils.mjs";
|
|
16
|
+
import Tooltip from "./Tooltip.mjs";
|
|
17
|
+
/*!__reshadow-styles__:"./style/hover.shadow.css"*/
|
|
18
|
+
var style = (
|
|
19
|
+
/*__reshadow_css_start__*/
|
|
20
|
+
(sstyled.insert(
|
|
21
|
+
/*__inner_css_start__*/
|
|
22
|
+
".___SHoverLine_1kncu_gg_{outline:0;stroke:var(--intergalactic-chart-grid-x-axis, #c4c7cf)}.___SHoverRect_1kncu_gg_{outline:0;fill:var(--intergalactic-chart-grid-bar-chart-hover, rgba(196, 199, 207, 0.3))}",
|
|
23
|
+
/*__inner_css_end__*/
|
|
24
|
+
"1kncu_gg_"
|
|
25
|
+
), /*__reshadow_css_end__*/
|
|
26
|
+
{
|
|
27
|
+
"__SHoverLine": "___SHoverLine_1kncu_gg_",
|
|
28
|
+
"__SHoverRect": "___SHoverRect_1kncu_gg_"
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
var Hover = /* @__PURE__ */ function(_Component) {
|
|
32
|
+
_inherits(Hover2, _Component);
|
|
33
|
+
var _super = _createSuper(Hover2);
|
|
34
|
+
function Hover2() {
|
|
35
|
+
var _this;
|
|
36
|
+
_classCallCheck(this, Hover2);
|
|
37
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
|
+
args[_key] = arguments[_key];
|
|
39
|
+
}
|
|
40
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
42
|
+
xIndex: null,
|
|
43
|
+
yIndex: null
|
|
44
|
+
});
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "virtualElement", canUseDOM() ? document.createElement("div") : {});
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "handlerMouseMoveRoot", trottle(function(e) {
|
|
47
|
+
var _this$asProps = _this.asProps, eventEmitter = _this$asProps.eventEmitter, data = _this$asProps.data, scale = _this$asProps.scale, x = _this$asProps.x, y = _this$asProps.y, rootRef = _this$asProps.rootRef, patterns = _this$asProps.patterns;
|
|
48
|
+
var clientX = e.clientX, clientY = e.clientY;
|
|
49
|
+
var _scale = _slicedToArray(scale, 2), xScale = _scale[0], yScale = _scale[1];
|
|
50
|
+
var _eventToPoint = eventToPoint(e, rootRef.current), _eventToPoint2 = _slicedToArray(_eventToPoint, 2), pX = _eventToPoint2[0], pY = _eventToPoint2[1];
|
|
51
|
+
var vX = invert(xScale, pX);
|
|
52
|
+
var vY = invert(yScale, pY);
|
|
53
|
+
var xIndex = x === void 0 || vX === void 0 ? null : getIndexFromData(data, xScale, x, vX);
|
|
54
|
+
var yIndex = y === void 0 || vY === void 0 ? null : getIndexFromData(data, yScale, y, vY);
|
|
55
|
+
var state = {
|
|
56
|
+
xIndex,
|
|
57
|
+
yIndex,
|
|
58
|
+
patterns
|
|
59
|
+
};
|
|
60
|
+
_this.setState(state, function() {
|
|
61
|
+
eventEmitter.emit("setTooltipPosition", clientX, clientY);
|
|
62
|
+
eventEmitter.emit("setTooltipRenderingProps", {}, state);
|
|
63
|
+
eventEmitter.emit("setTooltipVisible", xIndex !== null || yIndex !== null);
|
|
64
|
+
});
|
|
65
|
+
}));
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "handlerMouseLeaveRoot", trottle(function() {
|
|
67
|
+
var state = {
|
|
68
|
+
xIndex: null,
|
|
69
|
+
yIndex: null,
|
|
70
|
+
patterns: _this.asProps.patterns
|
|
71
|
+
};
|
|
72
|
+
_this.setState(state, function() {
|
|
73
|
+
_this.asProps.eventEmitter.emit("setTooltipVisible", false);
|
|
74
|
+
});
|
|
75
|
+
}));
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
_createClass(Hover2, [{
|
|
79
|
+
key: "componentDidMount",
|
|
80
|
+
value: function componentDidMount() {
|
|
81
|
+
var _this2 = this;
|
|
82
|
+
var eventEmitter = this.asProps.eventEmitter;
|
|
83
|
+
this.unsubscribeMouseMoveRoot = eventEmitter.subscribe("onMouseMoveChart", function(e) {
|
|
84
|
+
e.persist();
|
|
85
|
+
_this2.handlerMouseMoveRoot(e);
|
|
86
|
+
});
|
|
87
|
+
this.unsubscribeMouseLeaveRoot = eventEmitter.subscribe("onMouseLeaveChart", this.handlerMouseLeaveRoot);
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "componentWillUnmount",
|
|
91
|
+
value: function componentWillUnmount() {
|
|
92
|
+
if (this.unsubscribeMouseMoveRoot) {
|
|
93
|
+
this.unsubscribeMouseMoveRoot();
|
|
94
|
+
}
|
|
95
|
+
if (this.unsubscribeMouseLeaveRoot) {
|
|
96
|
+
this.unsubscribeMouseLeaveRoot();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}]);
|
|
100
|
+
return Hover2;
|
|
101
|
+
}(Component);
|
|
102
|
+
_defineProperty(Hover, "style", style);
|
|
103
|
+
var HoverLineRoot = /* @__PURE__ */ function(_Hover) {
|
|
104
|
+
_inherits(HoverLineRoot2, _Hover);
|
|
105
|
+
var _super2 = _createSuper(HoverLineRoot2);
|
|
106
|
+
function HoverLineRoot2() {
|
|
107
|
+
_classCallCheck(this, HoverLineRoot2);
|
|
108
|
+
return _super2.apply(this, arguments);
|
|
109
|
+
}
|
|
110
|
+
_createClass(HoverLineRoot2, [{
|
|
111
|
+
key: "render",
|
|
112
|
+
value: function render() {
|
|
113
|
+
var _ref3;
|
|
114
|
+
var SHoverLine = this.Element;
|
|
115
|
+
var _this$asProps2 = this.asProps, styles = _this$asProps2.styles, x = _this$asProps2.x, y = _this$asProps2.y, data = _this$asProps2.data, scale = _this$asProps2.scale, hideHoverLine = _this$asProps2.hideHoverLine;
|
|
116
|
+
var _this$state = this.state, xIndex = _this$state.xIndex, yIndex = _this$state.yIndex;
|
|
117
|
+
var _scale2 = _slicedToArray(scale, 2), xScale = _scale2[0], yScale = _scale2[1];
|
|
118
|
+
var xRange = xScale.range();
|
|
119
|
+
var yRange = yScale.range();
|
|
120
|
+
var x1 = xIndex !== null ? scaleOfBandwidth(xScale, data[xIndex][x]) : void 0;
|
|
121
|
+
var y1 = yIndex !== null ? scaleOfBandwidth(yScale, data[yIndex][y]) : void 0;
|
|
122
|
+
var isHide = typeof hideHoverLine === "function" ? hideHoverLine(xIndex, yIndex) : hideHoverLine;
|
|
123
|
+
if (isHide) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return _ref3 = sstyled$1(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, xIndex !== null ? /* @__PURE__ */ React.createElement(SHoverLine, _ref3.cn("SHoverLine", {
|
|
127
|
+
"aria-hidden": true,
|
|
128
|
+
"render": "line",
|
|
129
|
+
"index": xIndex,
|
|
130
|
+
"x1": x1,
|
|
131
|
+
"y1": yRange[0],
|
|
132
|
+
"x2": x1,
|
|
133
|
+
"y2": yRange[1]
|
|
134
|
+
})) : null, yIndex !== null ? /* @__PURE__ */ React.createElement(SHoverLine, _ref3.cn("SHoverLine", {
|
|
135
|
+
"aria-hidden": true,
|
|
136
|
+
"render": "line",
|
|
137
|
+
"index": yIndex,
|
|
138
|
+
"x1": xRange[0],
|
|
139
|
+
"y1": y1,
|
|
140
|
+
"x2": xRange[1],
|
|
141
|
+
"y2": y1
|
|
142
|
+
})) : null);
|
|
143
|
+
}
|
|
144
|
+
}]);
|
|
145
|
+
return HoverLineRoot2;
|
|
146
|
+
}(Hover);
|
|
147
|
+
_defineProperty(HoverLineRoot, "displayName", "HoverLine");
|
|
148
|
+
var HoverRectRoot = /* @__PURE__ */ function(_Hover2) {
|
|
149
|
+
_inherits(HoverRectRoot2, _Hover2);
|
|
150
|
+
var _super3 = _createSuper(HoverRectRoot2);
|
|
151
|
+
function HoverRectRoot2() {
|
|
152
|
+
_classCallCheck(this, HoverRectRoot2);
|
|
153
|
+
return _super3.apply(this, arguments);
|
|
154
|
+
}
|
|
155
|
+
_createClass(HoverRectRoot2, [{
|
|
156
|
+
key: "render",
|
|
157
|
+
value: function render() {
|
|
158
|
+
var _ref4;
|
|
159
|
+
var SHoverRect = this.Element;
|
|
160
|
+
var _this$asProps3 = this.asProps, styles = _this$asProps3.styles, x = _this$asProps3.x, y = _this$asProps3.y, data = _this$asProps3.data, scale = _this$asProps3.scale, hideHoverLine = _this$asProps3.hideHoverLine;
|
|
161
|
+
var _this$state2 = this.state, xIndex = _this$state2.xIndex, yIndex = _this$state2.yIndex;
|
|
162
|
+
var _scale3 = _slicedToArray(scale, 2), xScale = _scale3[0], yScale = _scale3[1];
|
|
163
|
+
var xRange = xScale.range();
|
|
164
|
+
var yRange = yScale.range();
|
|
165
|
+
var xBand = scaleToBand(xScale);
|
|
166
|
+
var yBand = scaleToBand(yScale);
|
|
167
|
+
if (hideHoverLine) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return _ref4 = sstyled$1(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, xIndex !== null ? /* @__PURE__ */ React.createElement(SHoverRect, _ref4.cn("SHoverRect", {
|
|
171
|
+
"aria-hidden": true,
|
|
172
|
+
"render": "rect",
|
|
173
|
+
"index": xIndex,
|
|
174
|
+
"width": xBand.step() - xBand.paddingInner() / 2,
|
|
175
|
+
"height": yRange[0] - yRange[1],
|
|
176
|
+
"x": xScale(data[xIndex][x]) - xBand.step() * xBand.paddingInner() / 2,
|
|
177
|
+
"y": yRange[1]
|
|
178
|
+
})) : null, yIndex !== null ? /* @__PURE__ */ React.createElement(SHoverRect, _ref4.cn("SHoverRect", {
|
|
179
|
+
"aria-hidden": true,
|
|
180
|
+
"render": "rect",
|
|
181
|
+
"index": yIndex,
|
|
182
|
+
"width": xRange[1] - xRange[0],
|
|
183
|
+
"height": yBand.step() - yBand.paddingInner() / 2,
|
|
184
|
+
"x": xRange[0],
|
|
185
|
+
"y": yScale(data[yIndex][y]) - yBand.step() * yBand.paddingInner() / 2
|
|
186
|
+
})) : null);
|
|
187
|
+
}
|
|
188
|
+
}]);
|
|
189
|
+
return HoverRectRoot2;
|
|
190
|
+
}(Hover);
|
|
191
|
+
_defineProperty(HoverRectRoot, "displayName", "HoverRect");
|
|
192
|
+
var HoverLineTooltip = function HoverLineTooltip2(props) {
|
|
193
|
+
var _ref = arguments[0], _ref5;
|
|
194
|
+
var SHoverLineTooltip = Tooltip;
|
|
195
|
+
return _ref5 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SHoverLineTooltip, _ref5.cn("SHoverLineTooltip", _objectSpread({}, assignProps({
|
|
196
|
+
"tag": HoverLine,
|
|
197
|
+
"excludeAnchorProps": true
|
|
198
|
+
}, _ref))));
|
|
199
|
+
};
|
|
200
|
+
var HoverRectTooltip = function HoverRectTooltip2(props) {
|
|
201
|
+
var _ref2 = arguments[0], _ref6;
|
|
202
|
+
var SHoverRectTooltip = Tooltip;
|
|
203
|
+
return _ref6 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SHoverRectTooltip, _ref6.cn("SHoverRectTooltip", _objectSpread({}, assignProps({
|
|
204
|
+
"tag": HoverRect,
|
|
205
|
+
"excludeAnchorProps": true
|
|
206
|
+
}, _ref2))));
|
|
207
|
+
};
|
|
208
|
+
var HoverLine = createElement(HoverLineRoot, {
|
|
209
|
+
Tooltip: [HoverLineTooltip, Tooltip._______childrenComponents]
|
|
210
|
+
});
|
|
211
|
+
var HoverRect = createElement(HoverRectRoot, {
|
|
212
|
+
Tooltip: [HoverRectTooltip, Tooltip._______childrenComponents]
|
|
213
|
+
});
|
|
214
|
+
export {
|
|
215
|
+
HoverLine,
|
|
216
|
+
HoverRect
|
|
217
|
+
};
|
package/lib/esm/Line.mjs
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
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 React from "react";
|
|
9
|
+
import { line, curveLinear, area, curveCardinal } from "d3-shape";
|
|
10
|
+
import { sstyled as sstyled$1, Component } from "@semcore/core";
|
|
11
|
+
import uniqueIDEnhancement, { useUID } from "@semcore/utils/lib/uniqueID";
|
|
12
|
+
import createElement from "./createElement.mjs";
|
|
13
|
+
import { definedData, scaleOfBandwidth, interpolateValue, getNullData, definedNullData, getChartDefaultColorName } from "./utils.mjs";
|
|
14
|
+
import Dots from "./Dots.mjs";
|
|
15
|
+
import AnimatedClipPath from "./AnimatedClipPath.mjs";
|
|
16
|
+
import { resolvePatternDasharray } from "./Pattern.mjs";
|
|
17
|
+
/*!__reshadow-styles__:"./style/line.shadow.css"*/
|
|
18
|
+
var style = (
|
|
19
|
+
/*__reshadow_css_start__*/
|
|
20
|
+
(sstyled.insert(
|
|
21
|
+
/*__inner_css_start__*/
|
|
22
|
+
".___SLine_4cypd_gg_{fill:transparent;stroke-width:3;stroke:var(--intergalactic-chart-palette-order-1, #2bb3ff);transition-property:d;transition-duration:var(--duration_4cypd);transition-timing-function:ease-in-out}.___SLine_4cypd_gg_.__color_4cypd_gg_{stroke:var(--color_4cypd)}.___SLine_4cypd_gg_.__hide_4cypd_gg_{display:none}.___SLine_4cypd_gg_.__transparent_4cypd_gg_{opacity:.3}.___SNull_4cypd_gg_{fill:transparent;stroke:var(--intergalactic-border-primary, #c4c7cf);stroke-dasharray:4}.___SNull_4cypd_gg_.__hide_4cypd_gg_{display:none}.___SLineArea_4cypd_gg_{transition-property:d;transition-duration:var(--duration_4cypd);transition-timing-function:ease-in-out;opacity:.3;fill:var(--intergalactic-chart-palette-order-1, #2bb3ff)}.___SLineArea_4cypd_gg_.__color_4cypd_gg_{fill:var(--color_4cypd)}",
|
|
23
|
+
/*__inner_css_end__*/
|
|
24
|
+
"4cypd_gg_"
|
|
25
|
+
), /*__reshadow_css_end__*/
|
|
26
|
+
{
|
|
27
|
+
"__SLine": "___SLine_4cypd_gg_",
|
|
28
|
+
"--duration": "--duration_4cypd",
|
|
29
|
+
"_color": "__color_4cypd_gg_",
|
|
30
|
+
"--color": "--color_4cypd",
|
|
31
|
+
"_hide": "__hide_4cypd_gg_",
|
|
32
|
+
"_transparent": "__transparent_4cypd_gg_",
|
|
33
|
+
"__SNull": "___SNull_4cypd_gg_",
|
|
34
|
+
"__SLineArea": "___SLineArea_4cypd_gg_"
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
var LineRoot = /* @__PURE__ */ function(_Component) {
|
|
38
|
+
_inherits(LineRoot2, _Component);
|
|
39
|
+
var _super = _createSuper(LineRoot2);
|
|
40
|
+
function LineRoot2() {
|
|
41
|
+
_classCallCheck(this, LineRoot2);
|
|
42
|
+
return _super.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
_createClass(LineRoot2, [{
|
|
45
|
+
key: "getDotsProps",
|
|
46
|
+
value: function getDotsProps() {
|
|
47
|
+
var _this$asProps = this.asProps, x = _this$asProps.x, y = _this$asProps.y, d3 = _this$asProps.d3, color = _this$asProps.color, resolveColor = _this$asProps.resolveColor, duration = _this$asProps.duration, transparent = _this$asProps.transparent, patterns = _this$asProps.patterns;
|
|
48
|
+
return {
|
|
49
|
+
x,
|
|
50
|
+
y,
|
|
51
|
+
d3,
|
|
52
|
+
color,
|
|
53
|
+
resolveColor,
|
|
54
|
+
duration,
|
|
55
|
+
transparent,
|
|
56
|
+
patterns
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "getNullProps",
|
|
61
|
+
value: function getNullProps() {
|
|
62
|
+
var _this$asProps2 = this.asProps, x = _this$asProps2.x, y = _this$asProps2.y, d3 = _this$asProps2.d3, color = _this$asProps2.color, resolveColor = _this$asProps2.resolveColor;
|
|
63
|
+
var data = this.asProps.data.filter(function(item) {
|
|
64
|
+
return item[y] !== interpolateValue;
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
d3,
|
|
68
|
+
// TODO: vertical
|
|
69
|
+
data: getNullData(data, definedNullData(x, y), y),
|
|
70
|
+
color,
|
|
71
|
+
resolveColor
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "getAreaProps",
|
|
76
|
+
value: function getAreaProps() {
|
|
77
|
+
var _this$asProps3 = this.asProps, x = _this$asProps3.x, y = _this$asProps3.y, color = _this$asProps3.color, hide = _this$asProps3.hide, duration = _this$asProps3.duration, scale = _this$asProps3.scale;
|
|
78
|
+
var data = this.asProps.data.filter(function(item) {
|
|
79
|
+
return item[y] !== interpolateValue;
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
x,
|
|
83
|
+
y,
|
|
84
|
+
data,
|
|
85
|
+
color,
|
|
86
|
+
hide,
|
|
87
|
+
duration,
|
|
88
|
+
scale
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "render",
|
|
93
|
+
value: function render() {
|
|
94
|
+
var _ref;
|
|
95
|
+
var SLine = this.Element;
|
|
96
|
+
var _this$asProps4 = this.asProps, styles = _this$asProps4.styles, hide = _this$asProps4.hide, color = _this$asProps4.color, resolveColor = _this$asProps4.resolveColor, uid = _this$asProps4.uid, size = _this$asProps4.size, d3 = _this$asProps4.d3, duration = _this$asProps4.duration, x = _this$asProps4.x, y = _this$asProps4.y, transparent = _this$asProps4.transparent, patterns = _this$asProps4.patterns;
|
|
97
|
+
var data = this.asProps.data.filter(function(item) {
|
|
98
|
+
return item[y] !== interpolateValue;
|
|
99
|
+
});
|
|
100
|
+
this.asProps.dataHintsHandler.specifyDataRowFields(x, y);
|
|
101
|
+
this.asProps.dataHintsHandler.establishDataType("time-series");
|
|
102
|
+
var patternKey = color || getChartDefaultColorName(0);
|
|
103
|
+
return _ref = sstyled$1(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SLine, _ref.cn("SLine", {
|
|
104
|
+
"aria-hidden": true,
|
|
105
|
+
"clipPath": "url(#".concat(uid, ")"),
|
|
106
|
+
"render": "path",
|
|
107
|
+
"hide": hide,
|
|
108
|
+
"color": resolveColor(color),
|
|
109
|
+
"transparent": transparent,
|
|
110
|
+
"d": d3(data),
|
|
111
|
+
"use:duration": "".concat(duration, "ms"),
|
|
112
|
+
"strokeDasharray": patterns ? resolvePatternDasharray(patternKey, patterns) : void 0
|
|
113
|
+
})), duration && /* @__PURE__ */ React.createElement(AnimatedClipPath, _ref.cn("AnimatedClipPath", {
|
|
114
|
+
"aria-hidden": true,
|
|
115
|
+
"duration": duration,
|
|
116
|
+
"id": uid,
|
|
117
|
+
"x": "0",
|
|
118
|
+
"y": "0",
|
|
119
|
+
"width": 0,
|
|
120
|
+
"height": size[1]
|
|
121
|
+
})));
|
|
122
|
+
}
|
|
123
|
+
}]);
|
|
124
|
+
return LineRoot2;
|
|
125
|
+
}(Component);
|
|
126
|
+
_defineProperty(LineRoot, "displayName", "Line");
|
|
127
|
+
_defineProperty(LineRoot, "style", style);
|
|
128
|
+
_defineProperty(LineRoot, "enhance", [uniqueIDEnhancement()]);
|
|
129
|
+
_defineProperty(LineRoot, "defaultProps", function(_ref4) {
|
|
130
|
+
var x = _ref4.x, y = _ref4.y, $rootProps = _ref4.$rootProps, _ref4$curve = _ref4.curve, curve = _ref4$curve === void 0 ? curveLinear : _ref4$curve, scale = _ref4.scale;
|
|
131
|
+
var _ref5 = scale || $rootProps.scale, _ref6 = _slicedToArray(_ref5, 2), xScale = _ref6[0], yScale = _ref6[1];
|
|
132
|
+
return {
|
|
133
|
+
d3: line().defined(definedData(x, y)).curve(curve).x(function(p) {
|
|
134
|
+
return scaleOfBandwidth(xScale, p[x]);
|
|
135
|
+
}).y(function(p) {
|
|
136
|
+
return scaleOfBandwidth(yScale, p[y]);
|
|
137
|
+
}),
|
|
138
|
+
duration: 500
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
function Null(props) {
|
|
142
|
+
var _ref2;
|
|
143
|
+
var SNull = props.Element, styles = props.styles, d3 = props.d3, data = props.data, hide = props.hide;
|
|
144
|
+
return _ref2 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SNull, _ref2.cn("SNull", {
|
|
145
|
+
"render": "path",
|
|
146
|
+
"d": d3(data),
|
|
147
|
+
"hide": hide
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
function Area(props) {
|
|
151
|
+
var uid = useUID();
|
|
152
|
+
var SLineArea = props.Element, styles = props.styles, data = props.data, hide = props.hide, duration = props.duration, color = props.color, scale = props.scale, x = props.x, y0 = props.y0, y1 = props.y1, _props$curve = props.curve, curve = _props$curve === void 0 ? curveCardinal : _props$curve, area$1 = props.area, patterns = props.patterns, _props$autoInterpolat = props.autoInterpolate, autoInterpolate = _props$autoInterpolat === void 0 ? true : _props$autoInterpolat;
|
|
153
|
+
var _scale = _slicedToArray(scale, 2), xScale = _scale[0], yScale = _scale[1];
|
|
154
|
+
var dataToArea = React.useMemo(function() {
|
|
155
|
+
if (area$1) return area$1;
|
|
156
|
+
var chunked = data.reduce(function(acc, d) {
|
|
157
|
+
if (d[y0] === interpolateValue || d[y1] === interpolateValue) return acc;
|
|
158
|
+
if (definedData(y0, y1)(d)) {
|
|
159
|
+
acc[acc.length - 1].push(d);
|
|
160
|
+
} else if (acc[acc.length - 1].length > 0) {
|
|
161
|
+
acc.push([]);
|
|
162
|
+
}
|
|
163
|
+
return acc;
|
|
164
|
+
}, [[]]);
|
|
165
|
+
if (autoInterpolate) {
|
|
166
|
+
return [chunked.flat()];
|
|
167
|
+
}
|
|
168
|
+
return chunked;
|
|
169
|
+
}, [data, y0, y1, area$1, autoInterpolate]);
|
|
170
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, dataToArea.map(function(chunk, index) {
|
|
171
|
+
var _ref3;
|
|
172
|
+
var d3 = area().curve(curve).x(function(data2) {
|
|
173
|
+
return xScale(data2[x]);
|
|
174
|
+
}).y0(function(data2) {
|
|
175
|
+
return yScale(data2[y0]);
|
|
176
|
+
}).y1(function(data2) {
|
|
177
|
+
return yScale(data2[y1]);
|
|
178
|
+
});
|
|
179
|
+
return _ref3 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SLineArea, _ref3.cn("SLineArea", {
|
|
180
|
+
"key": "".concat(chunk.length, "-").concat(index),
|
|
181
|
+
"aria-hidden": true,
|
|
182
|
+
"clipPath": "url(#".concat(uid, ")"),
|
|
183
|
+
"render": "path",
|
|
184
|
+
"hide": hide,
|
|
185
|
+
"color": color,
|
|
186
|
+
"d": d3(chunk),
|
|
187
|
+
"use:duration": "".concat(duration, "ms"),
|
|
188
|
+
"patterns": patterns
|
|
189
|
+
}));
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
const Line = createElement(LineRoot, {
|
|
193
|
+
Dots,
|
|
194
|
+
Null,
|
|
195
|
+
Area
|
|
196
|
+
});
|
|
197
|
+
export {
|
|
198
|
+
Line as default
|
|
199
|
+
};
|