@semcore/d3-chart 18.0.0-prerelease.0 → 18.0.0-prerelease.2
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 +10 -1
- package/lib/cjs/Area.js +123 -23
- package/lib/cjs/Area.js.map +1 -1
- package/lib/cjs/Axis.js +109 -97
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +16 -16
- package/lib/cjs/Bubble.js +14 -14
- package/lib/cjs/ChartMetaData.js +44 -0
- package/lib/cjs/ChartMetaData.js.map +1 -0
- package/lib/cjs/CompactHorizontalBar.js +16 -16
- package/lib/cjs/Donut.js +18 -19
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +67 -13
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +16 -16
- package/lib/cjs/Hover.js +66 -52
- package/lib/cjs/Hover.js.map +1 -1
- package/lib/cjs/Line.js +82 -17
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Pattern.js +113 -2
- package/lib/cjs/Pattern.js.map +1 -1
- package/lib/cjs/Plot.js +5 -2
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/Radar.js +19 -19
- package/lib/cjs/RadialTree.js +12 -12
- package/lib/cjs/Reference.js +55 -18
- package/lib/cjs/Reference.js.map +1 -1
- package/lib/cjs/ScatterPlot.js +9 -9
- package/lib/cjs/Tooltip.js +16 -14
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/a11y/PlotA11yView.js +2 -2
- package/lib/cjs/component/Chart/AbstractChart.js +21 -18
- package/lib/cjs/component/Chart/AbstractChart.js.map +1 -1
- package/lib/cjs/component/Chart/AbstractChart.type.js +19 -0
- package/lib/cjs/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/AreaChart.js +21 -7
- package/lib/cjs/component/Chart/AreaChart.js.map +1 -1
- package/lib/cjs/component/Chart/AreaChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/BarChart.js +6 -3
- package/lib/cjs/component/Chart/BarChart.js.map +1 -1
- package/lib/cjs/component/Chart/BarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/BubbleChart.js +4 -0
- package/lib/cjs/component/Chart/BubbleChart.js.map +1 -1
- package/lib/cjs/component/Chart/BubbleChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/CigaretteChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/CompactHorizontalBarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/DonutChart.js +0 -1
- package/lib/cjs/component/Chart/DonutChart.js.map +1 -1
- package/lib/cjs/component/Chart/DonutChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/HistogramChart.js +6 -3
- package/lib/cjs/component/Chart/HistogramChart.js.map +1 -1
- package/lib/cjs/component/Chart/HistogramChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/LineChart.js +16 -6
- package/lib/cjs/component/Chart/LineChart.js.map +1 -1
- package/lib/cjs/component/Chart/LineChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/RadarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/ScatterPlotChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/VennChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/index.js +43 -0
- package/lib/cjs/component/Chart/index.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/cjs/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +16 -16
- package/lib/cjs/component/ChartLegend/LegendItem/legend-item.shadow.css +11 -11
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +7 -7
- package/lib/cjs/component/ChartLegend/LegendTable/legend-table.shadow.css +2 -2
- package/lib/cjs/index.js +55 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/abstract-chart.shadow.css +13 -3
- package/lib/cjs/style/area.shadow.css +8 -5
- package/lib/cjs/style/axis.shadow.css +51 -60
- package/lib/cjs/style/bar.shadow.css +6 -6
- package/lib/cjs/style/bubble.shadow.css +3 -3
- package/lib/cjs/style/donut.shadow.css +2 -2
- package/lib/cjs/style/dot.shadow.css +37 -2
- package/lib/cjs/style/hover.shadow.css +30 -13
- package/lib/cjs/style/line.shadow.css +3 -3
- package/lib/cjs/style/pattern.shadow.css +10 -0
- package/lib/cjs/style/plotA11yView.shadow.css +3 -3
- package/lib/cjs/style/radar.shadow.css +7 -7
- package/lib/cjs/style/radial-tree.shadow.css +2 -2
- package/lib/cjs/style/reference.shadow.css +4 -4
- package/lib/cjs/style/scatterplot.shadow.css +1 -1
- package/lib/cjs/style/tooltip.shadow.css +12 -12
- package/lib/cjs/types/Axis.d.js.map +1 -1
- package/lib/cjs/types/Donut.d.js.map +1 -1
- package/lib/cjs/types/Hover.d.js.map +1 -1
- package/lib/cjs/utils.js +21 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/Area.js +125 -25
- package/lib/es6/Area.js.map +1 -1
- package/lib/es6/Axis.js +109 -97
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +16 -16
- package/lib/es6/Bubble.js +14 -14
- package/lib/es6/ChartMetaData.js +36 -0
- package/lib/es6/ChartMetaData.js.map +1 -0
- package/lib/es6/CompactHorizontalBar.js +16 -16
- package/lib/es6/Donut.js +18 -19
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +68 -14
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/HorizontalBar.js +16 -16
- package/lib/es6/Hover.js +66 -52
- package/lib/es6/Hover.js.map +1 -1
- package/lib/es6/Line.js +84 -19
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Pattern.js +108 -2
- package/lib/es6/Pattern.js.map +1 -1
- package/lib/es6/Plot.js +5 -2
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/Radar.js +19 -19
- package/lib/es6/RadialTree.js +12 -12
- package/lib/es6/Reference.js +55 -18
- package/lib/es6/Reference.js.map +1 -1
- package/lib/es6/ScatterPlot.js +9 -9
- package/lib/es6/Tooltip.js +16 -14
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/a11y/PlotA11yView.js +2 -2
- package/lib/es6/component/Chart/AbstractChart.js +21 -18
- package/lib/es6/component/Chart/AbstractChart.js.map +1 -1
- package/lib/es6/component/Chart/AbstractChart.type.js +14 -1
- package/lib/es6/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/es6/component/Chart/AreaChart.js +21 -7
- package/lib/es6/component/Chart/AreaChart.js.map +1 -1
- package/lib/es6/component/Chart/AreaChart.type.js.map +1 -1
- package/lib/es6/component/Chart/BarChart.js +6 -3
- package/lib/es6/component/Chart/BarChart.js.map +1 -1
- package/lib/es6/component/Chart/BarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/BubbleChart.js +4 -0
- package/lib/es6/component/Chart/BubbleChart.js.map +1 -1
- package/lib/es6/component/Chart/BubbleChart.type.js.map +1 -1
- package/lib/es6/component/Chart/CigaretteChart.type.js.map +1 -1
- package/lib/es6/component/Chart/CompactHorizontalBarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/DonutChart.js +0 -1
- package/lib/es6/component/Chart/DonutChart.js.map +1 -1
- package/lib/es6/component/Chart/DonutChart.type.js.map +1 -1
- package/lib/es6/component/Chart/HistogramChart.js +6 -3
- package/lib/es6/component/Chart/HistogramChart.js.map +1 -1
- package/lib/es6/component/Chart/HistogramChart.type.js.map +1 -1
- package/lib/es6/component/Chart/LineChart.js +14 -4
- package/lib/es6/component/Chart/LineChart.js.map +1 -1
- package/lib/es6/component/Chart/LineChart.type.js.map +1 -1
- package/lib/es6/component/Chart/RadarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/ScatterPlotChart.type.js.map +1 -1
- package/lib/es6/component/Chart/VennChart.type.js.map +1 -1
- package/lib/es6/component/Chart/index.js +2 -0
- package/lib/es6/component/Chart/index.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/es6/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +16 -16
- package/lib/es6/component/ChartLegend/LegendItem/legend-item.shadow.css +11 -11
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +7 -7
- package/lib/es6/component/ChartLegend/LegendTable/legend-table.shadow.css +2 -2
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/abstract-chart.shadow.css +13 -3
- package/lib/es6/style/area.shadow.css +8 -5
- package/lib/es6/style/axis.shadow.css +51 -60
- package/lib/es6/style/bar.shadow.css +6 -6
- package/lib/es6/style/bubble.shadow.css +3 -3
- package/lib/es6/style/donut.shadow.css +2 -2
- package/lib/es6/style/dot.shadow.css +37 -2
- package/lib/es6/style/hover.shadow.css +30 -13
- package/lib/es6/style/line.shadow.css +3 -3
- package/lib/es6/style/pattern.shadow.css +10 -0
- package/lib/es6/style/plotA11yView.shadow.css +3 -3
- package/lib/es6/style/radar.shadow.css +7 -7
- package/lib/es6/style/radial-tree.shadow.css +2 -2
- package/lib/es6/style/reference.shadow.css +4 -4
- package/lib/es6/style/scatterplot.shadow.css +1 -1
- package/lib/es6/style/tooltip.shadow.css +12 -12
- package/lib/es6/types/Axis.d.js.map +1 -1
- package/lib/es6/types/Donut.d.js.map +1 -1
- package/lib/es6/types/Hover.d.js.map +1 -1
- package/lib/es6/utils.js +18 -0
- package/lib/es6/utils.js.map +1 -1
- package/lib/esm/Area.mjs +127 -26
- package/lib/esm/Axis.mjs +110 -98
- package/lib/esm/Bar.mjs +17 -17
- package/lib/esm/Bubble.mjs +15 -15
- package/lib/esm/ChartMetaData.mjs +38 -0
- package/lib/esm/CompactHorizontalBar.mjs +17 -17
- package/lib/esm/Donut.mjs +19 -20
- package/lib/esm/Dots.mjs +66 -15
- package/lib/esm/HorizontalBar.mjs +17 -17
- package/lib/esm/Hover.mjs +67 -53
- package/lib/esm/Line.mjs +86 -20
- package/lib/esm/Pattern.mjs +119 -0
- package/lib/esm/Plot.mjs +6 -3
- package/lib/esm/Radar.mjs +20 -20
- package/lib/esm/RadialTree.mjs +13 -13
- package/lib/esm/Reference.mjs +56 -19
- package/lib/esm/ScatterPlot.mjs +10 -10
- package/lib/esm/Tooltip.mjs +17 -15
- package/lib/esm/a11y/PlotA11yView.mjs +3 -3
- package/lib/esm/component/Chart/AbstractChart.mjs +22 -19
- package/lib/esm/component/Chart/AbstractChart.type.mjs +16 -0
- package/lib/esm/component/Chart/AreaChart.mjs +21 -7
- package/lib/esm/component/Chart/BarChart.mjs +6 -3
- package/lib/esm/component/Chart/BubbleChart.mjs +4 -0
- package/lib/esm/component/Chart/DonutChart.mjs +0 -1
- package/lib/esm/component/Chart/HistogramChart.mjs +6 -3
- package/lib/esm/component/Chart/LineChart.mjs +14 -4
- package/lib/esm/component/Chart/index.mjs +8 -0
- package/lib/esm/component/ChartLegend/LegendFlex/LegendFlex.mjs +5 -5
- package/lib/esm/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.mjs +17 -17
- package/lib/esm/component/ChartLegend/LegendItem/legend-item.shadow.css +11 -11
- package/lib/esm/component/ChartLegend/LegendTable/LegendTable.mjs +8 -8
- package/lib/esm/component/ChartLegend/LegendTable/legend-table.shadow.css +2 -2
- package/lib/esm/index.mjs +8 -0
- package/lib/esm/style/abstract-chart.shadow.css +13 -3
- package/lib/esm/style/area.shadow.css +8 -5
- package/lib/esm/style/axis.shadow.css +51 -60
- package/lib/esm/style/bar.shadow.css +6 -6
- package/lib/esm/style/bubble.shadow.css +3 -3
- package/lib/esm/style/donut.shadow.css +2 -2
- package/lib/esm/style/dot.shadow.css +37 -2
- package/lib/esm/style/hover.shadow.css +30 -13
- package/lib/esm/style/line.shadow.css +3 -3
- package/lib/esm/style/pattern.shadow.css +10 -0
- package/lib/esm/style/plotA11yView.shadow.css +3 -3
- package/lib/esm/style/radar.shadow.css +7 -7
- package/lib/esm/style/radial-tree.shadow.css +2 -2
- package/lib/esm/style/reference.shadow.css +4 -4
- package/lib/esm/style/scatterplot.shadow.css +1 -1
- package/lib/esm/style/tooltip.shadow.css +12 -12
- package/lib/esm/utils.mjs +20 -0
- package/lib/types/Axis.d.ts +3 -2
- package/lib/types/ChartMetaData.d.ts +17 -0
- package/lib/types/ChartMetaData.d.ts.map +1 -0
- package/lib/types/Donut.d.ts +1 -1
- package/lib/types/Hover.d.ts +2 -0
- package/lib/types/Pattern.d.ts +18 -0
- package/lib/types/Pattern.d.ts.map +1 -1
- package/lib/types/component/Chart/AbstractChart.d.ts.map +1 -1
- package/lib/types/component/Chart/AbstractChart.type.d.ts +22 -4
- package/lib/types/component/Chart/AbstractChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/AreaChart.d.ts.map +1 -1
- package/lib/types/component/Chart/AreaChart.type.d.ts +8 -4
- package/lib/types/component/Chart/AreaChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/BarChart.d.ts.map +1 -1
- package/lib/types/component/Chart/BarChart.type.d.ts +1 -0
- package/lib/types/component/Chart/BarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/BubbleChart.d.ts.map +1 -1
- package/lib/types/component/Chart/BubbleChart.type.d.ts +1 -1
- package/lib/types/component/Chart/BubbleChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/CigaretteChart.type.d.ts +1 -1
- package/lib/types/component/Chart/CigaretteChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/CompactHorizontalBarChart.type.d.ts +1 -1
- package/lib/types/component/Chart/CompactHorizontalBarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/DonutChart.d.ts.map +1 -1
- package/lib/types/component/Chart/DonutChart.type.d.ts +1 -2
- package/lib/types/component/Chart/DonutChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/HistogramChart.d.ts.map +1 -1
- package/lib/types/component/Chart/HistogramChart.type.d.ts +1 -0
- package/lib/types/component/Chart/HistogramChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/LineChart.d.ts.map +1 -1
- package/lib/types/component/Chart/LineChart.type.d.ts +1 -0
- package/lib/types/component/Chart/LineChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/RadarChart.type.d.ts +1 -1
- package/lib/types/component/Chart/RadarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts +1 -1
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/VennChart.type.d.ts +1 -1
- package/lib/types/component/Chart/VennChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/index.d.ts +2 -0
- package/lib/types/component/Chart/index.d.ts.map +1 -1
- package/lib/types/utils.d.ts +4 -1
- package/lib/types/utils.d.ts.map +1 -1
- package/package.json +15 -15
- package/lib/esm/utils/TextMeasurer.mjs +0 -27
package/lib/esm/Dots.mjs
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
1
1
|
import { sstyled } from "@semcore/core";
|
|
2
2
|
import trottle from "@semcore/core/lib/utils/rafTrottle";
|
|
3
|
+
import { useUID } from "@semcore/core/lib/utils/uniqueID";
|
|
3
4
|
import { bisector } from "d3-array";
|
|
4
5
|
import React from "react";
|
|
6
|
+
import { INSIGHTFUL, BAD, GOOD, HIGHLIGHT_DOT } from "./component/Chart/AbstractChart.type.mjs";
|
|
5
7
|
import createElement from "./createElement.mjs";
|
|
6
|
-
import { getPatternSymbolSize, PatternSymbol } from "./Pattern.mjs";
|
|
8
|
+
import { getPatternSymbolSize, PotentialGradient, PatternSymbol } from "./Pattern.mjs";
|
|
7
9
|
import { getChartDefaultColorName, interpolateValue, eventToPoint, invert } from "./utils.mjs";
|
|
8
10
|
/*!__reshadow-styles__:"./style/dot.shadow.css"*/
|
|
9
11
|
const style = (
|
|
10
12
|
/*__reshadow_css_start__*/
|
|
11
13
|
(sstyled.insert(
|
|
12
14
|
/*__inner_css_start__*/
|
|
13
|
-
".
|
|
15
|
+
".___SDots_17cog_gg_ .___SDot_17cog_gg_{transition-duration:var(--duration_17cog)}.___SDot_17cog_gg_{stroke-width:1px;stroke:var(--intergalactic-chart-grid-border,#fff);fill:var(--intergalactic-chart-palette-order-1,oklch(.23 .009 245));transition-property:cx,cy,x,y,filter;transition-timing-function:ease-in-out}.___SDot_17cog_gg_.__active_17cog_gg_{filter:drop-shadow(0 0 1px rgba(0,12,8,.161)) drop-shadow(0 1px 1px rgba(0,12,8,.161))}@media (color-gamut:p3){.___SDot_17cog_gg_.__active_17cog_gg_{filter:drop-shadow(0 0 1px oklch(.137 .026 175.7/.161)) drop-shadow(0 1px 1px oklch(.137 .026 175.7/.161))}}.___SDot_17cog_gg_.__hide_17cog_gg_{display:none}.___SDot_17cog_gg_.__color_17cog_gg_{fill:var(--color_17cog)}.___SDotHighlight_17cog_gg_.__color_17cog_gg_{opacity:.4;fill:var(--color_17cog)}.___SDotHighlight_17cog_gg_.__transparent_17cog_gg_{opacity:.12}.___SDotBorder_17cog_gg_{fill:none;stroke-width:1px;stroke:var(--intergalactic-chart-grid-dot-outer-border,#191d211a);stroke-dasharray:2}.___SDotBorder_17cog_gg_.__transparent_17cog_gg_{opacity:.03}.___SDot_17cog_gg_.__transparent_17cog_gg_{opacity:.3}.___SDotBackdrop_17cog_gg_{stroke-width:1px;stroke:var(--intergalactic-chart-grid-border,#fff);fill:var(--intergalactic-chart-grid-border,#fff);transition-property:cx,cy;transition-duration:var(--duration_17cog);transition-timing-function:ease-in-out}.___SDotBackdrop_17cog_gg_.__hide_17cog_gg_{display:none}",
|
|
14
16
|
/*__inner_css_end__*/
|
|
15
|
-
"
|
|
17
|
+
"17cog_gg_"
|
|
16
18
|
), /*__reshadow_css_end__*/
|
|
17
19
|
{
|
|
18
|
-
"__SDot": "
|
|
19
|
-
"_active": "
|
|
20
|
-
"_hide": "
|
|
21
|
-
"_color": "
|
|
22
|
-
"--color": "--
|
|
23
|
-
"_transparent": "
|
|
24
|
-
"__SDots": "
|
|
25
|
-
"--duration": "--
|
|
20
|
+
"__SDot": "___SDot_17cog_gg_",
|
|
21
|
+
"_active": "__active_17cog_gg_",
|
|
22
|
+
"_hide": "__hide_17cog_gg_",
|
|
23
|
+
"_color": "__color_17cog_gg_",
|
|
24
|
+
"--color": "--color_17cog",
|
|
25
|
+
"_transparent": "__transparent_17cog_gg_",
|
|
26
|
+
"__SDots": "___SDots_17cog_gg_",
|
|
27
|
+
"--duration": "--duration_17cog",
|
|
28
|
+
"__SDotHighlight": "___SDotHighlight_17cog_gg_",
|
|
29
|
+
"__SDotBorder": "___SDotBorder_17cog_gg_",
|
|
30
|
+
"__SDotBackdrop": "___SDotBackdrop_17cog_gg_"
|
|
26
31
|
})
|
|
27
32
|
);
|
|
28
33
|
const BASE_RADIUS = 3.5;
|
|
29
34
|
const ACTIVE_RADIUS = 4.5;
|
|
30
35
|
function Dots(props) {
|
|
31
36
|
var _ref3;
|
|
37
|
+
const SDotHighlight = "circle";
|
|
38
|
+
const SDotBorder = "circle";
|
|
39
|
+
const SDotBackdrop = "circle";
|
|
32
40
|
const {
|
|
33
41
|
Element: SDot,
|
|
34
42
|
styles,
|
|
@@ -48,6 +56,7 @@ function Dots(props) {
|
|
|
48
56
|
patterns,
|
|
49
57
|
onClick
|
|
50
58
|
} = props;
|
|
59
|
+
const uid = useUID();
|
|
51
60
|
const bisect = bisector((d) => d[x]).center;
|
|
52
61
|
const [activeIndex, setActiveIndex] = React.useState(null);
|
|
53
62
|
const patternKey = color || getChartDefaultColorName(0);
|
|
@@ -71,6 +80,21 @@ function Dots(props) {
|
|
|
71
80
|
const index = bisect(data, vX);
|
|
72
81
|
onClick(index, e);
|
|
73
82
|
}, [scale, data, onClick]);
|
|
83
|
+
const resolveHighlightColor = React.useCallback((highlight) => {
|
|
84
|
+
switch (highlight) {
|
|
85
|
+
case GOOD: {
|
|
86
|
+
return resolveColor("--intergalactic-chart-data-success");
|
|
87
|
+
}
|
|
88
|
+
case BAD: {
|
|
89
|
+
return resolveColor("--intergalactic-chart-data-critical");
|
|
90
|
+
}
|
|
91
|
+
case INSIGHTFUL: {
|
|
92
|
+
return `url(#dotGradient_${uid})`;
|
|
93
|
+
}
|
|
94
|
+
default:
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
}, [uid, resolveColor]);
|
|
74
98
|
React.useEffect(() => {
|
|
75
99
|
const unsubscribeMouseMoveRoot = eventEmitter.subscribe("onMouseMoveChart", (e) => {
|
|
76
100
|
e.persist();
|
|
@@ -90,13 +114,38 @@ function Dots(props) {
|
|
|
90
114
|
const isPrev = d3.defined()(data[i - 1] || {});
|
|
91
115
|
const isNext = d3.defined()(data[i + 1] || {});
|
|
92
116
|
const active = i === activeIndex;
|
|
93
|
-
const visible = typeof display === "function" ? display(i,
|
|
117
|
+
const visible = typeof display === "function" ? display(i, active, !isPrev && !isNext, d) : display || active || !isPrev && !isNext;
|
|
94
118
|
const radius = active ? ACTIVE_RADIUS : radiusBase;
|
|
95
119
|
if (!d3.defined()(d)) return acc;
|
|
96
120
|
if (!visible) return acc;
|
|
97
121
|
if (!patterns) {
|
|
98
122
|
var _ref;
|
|
99
|
-
acc.push((_ref = sstyled(styles), /* @__PURE__ */ React.createElement(
|
|
123
|
+
acc.push((_ref = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
124
|
+
key: i
|
|
125
|
+
}, d[HIGHLIGHT_DOT] && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SDotBorder, _ref.cn("SDotBorder", {
|
|
126
|
+
"visible": visible,
|
|
127
|
+
"active": active,
|
|
128
|
+
"hide": hide,
|
|
129
|
+
"transparent": transparent,
|
|
130
|
+
"cx": d3.x()(d),
|
|
131
|
+
"cy": d3.y()(d),
|
|
132
|
+
"r": 11.5
|
|
133
|
+
})), /* @__PURE__ */ React.createElement(SDotHighlight, _ref.cn("SDotHighlight", {
|
|
134
|
+
"color": resolveHighlightColor(d[HIGHLIGHT_DOT]),
|
|
135
|
+
"value": d,
|
|
136
|
+
"visible": visible,
|
|
137
|
+
"active": active,
|
|
138
|
+
"hide": hide,
|
|
139
|
+
"transparent": transparent,
|
|
140
|
+
"cx": d3.x()(d),
|
|
141
|
+
"cy": d3.y()(d),
|
|
142
|
+
"r": 8.5
|
|
143
|
+
}))), transparent && /* @__PURE__ */ React.createElement(SDotBackdrop, _ref.cn("SDotBackdrop", {
|
|
144
|
+
"hide": hide,
|
|
145
|
+
"cx": d3.x()(d),
|
|
146
|
+
"cy": d3.y()(d),
|
|
147
|
+
"r": radius
|
|
148
|
+
})), /* @__PURE__ */ React.createElement(SDot, _ref.cn("SDot", {
|
|
100
149
|
"render": "circle",
|
|
101
150
|
"color": resolveColor(color),
|
|
102
151
|
"patternKey": patternKey,
|
|
@@ -111,7 +160,7 @@ function Dots(props) {
|
|
|
111
160
|
"cy": d3.y()(d),
|
|
112
161
|
"r": radius,
|
|
113
162
|
"__excludeProps": ["display", "data", "scale"]
|
|
114
|
-
}))));
|
|
163
|
+
})))));
|
|
115
164
|
} else {
|
|
116
165
|
var _ref2;
|
|
117
166
|
acc.push((_ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SDot, _ref2.cn("SDot", {
|
|
@@ -135,7 +184,9 @@ function Dots(props) {
|
|
|
135
184
|
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(SDots, _ref3.cn("SDots", {
|
|
136
185
|
"duration": `${duration}ms`,
|
|
137
186
|
"onClickCapture": handlerOnClick
|
|
138
|
-
}),
|
|
187
|
+
}), /* @__PURE__ */ React.createElement(PotentialGradient, _ref3.cn("PotentialGradient", {
|
|
188
|
+
"id": `dotGradient_${uid}`
|
|
189
|
+
})), patterns && /* @__PURE__ */ React.createElement(PatternSymbol, _ref3.cn("PatternSymbol", {
|
|
139
190
|
"color": resolveColor(color),
|
|
140
191
|
"patternKey": color,
|
|
141
192
|
"id": svgPatternId,
|
|
@@ -11,26 +11,26 @@ const style = (
|
|
|
11
11
|
/*__reshadow_css_start__*/
|
|
12
12
|
(sstyled.insert(
|
|
13
13
|
/*__inner_css_start__*/
|
|
14
|
-
".
|
|
14
|
+
".___SBar_avucd_gg_{fill:var(--intergalactic-chart-palette-order-1,oklch(.23 .009 245));transition-property:height,width,y;transition-duration:var(--duration_avucd);transition-timing-function:ease-in-out}.___SBar_avucd_gg_.__color_avucd_gg_{fill:var(--color_avucd)}.___SBar_avucd_gg_.__pattern_avucd_gg_.__color_avucd_gg_{fill:var(--pattern_avucd);stroke:var(--color_avucd);stroke-width:1px}.___SBar_avucd_gg_.__hide_avucd_gg_{display:none}.___SBar_avucd_gg_.__transparent_avucd_gg_{opacity:.3}.___SBar_avucd_gg_.__onClick_avucd_gg_{cursor:pointer}.___SBackground_avucd_gg_{fill:var(--intergalactic-chart-grid-bar-base-bg,oklch(.92 .008 233.5));opacity:.4}.___SBackground_avucd_gg_.__onClick_avucd_gg_{cursor:pointer}.___SBarAnnotation_avucd_gg_{display:flex;justify-content:space-between}.___SBarLabel_avucd_gg_{color:var(--intergalactic-text-primary,oklch(.23 .009 245));margin-right:auto}.___SBarLabel_avucd_gg_,.___SBarPercent_avucd_gg_{font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,1.4286)}.___SBarPercent_avucd_gg_{color:var(--intergalactic-text-secondary,oklch(.182 .045 244.8/.593));margin-right:var(--intergalactic-spacing-2x,8px)}.___SBarValue_avucd_gg_{min-width:52px;display:flex;justify-content:flex-end;color:var(--intergalactic-text-primary,oklch(.23 .009 245));font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,1.4286);text-align:right}.___SCompactHorizontalBarHoverRect_avucd_gg_{fill:var(--intergalactic-chart-grid-bar-hover,oklch(.375 .09 242.7/.05))}",
|
|
15
15
|
/*__inner_css_end__*/
|
|
16
|
-
"
|
|
16
|
+
"avucd_gg_"
|
|
17
17
|
), /*__reshadow_css_end__*/
|
|
18
18
|
{
|
|
19
|
-
"__SBar": "
|
|
20
|
-
"--duration": "--
|
|
21
|
-
"_color": "
|
|
22
|
-
"--color": "--
|
|
23
|
-
"_pattern": "
|
|
24
|
-
"--pattern": "--
|
|
25
|
-
"_hide": "
|
|
26
|
-
"_transparent": "
|
|
27
|
-
"_onClick": "
|
|
28
|
-
"__SBackground": "
|
|
29
|
-
"__SBarAnnotation": "
|
|
30
|
-
"__SBarLabel": "
|
|
31
|
-
"__SBarPercent": "
|
|
32
|
-
"__SBarValue": "
|
|
33
|
-
"__SCompactHorizontalBarHoverRect": "
|
|
19
|
+
"__SBar": "___SBar_avucd_gg_",
|
|
20
|
+
"--duration": "--duration_avucd",
|
|
21
|
+
"_color": "__color_avucd_gg_",
|
|
22
|
+
"--color": "--color_avucd",
|
|
23
|
+
"_pattern": "__pattern_avucd_gg_",
|
|
24
|
+
"--pattern": "--pattern_avucd",
|
|
25
|
+
"_hide": "__hide_avucd_gg_",
|
|
26
|
+
"_transparent": "__transparent_avucd_gg_",
|
|
27
|
+
"_onClick": "__onClick_avucd_gg_",
|
|
28
|
+
"__SBackground": "___SBackground_avucd_gg_",
|
|
29
|
+
"__SBarAnnotation": "___SBarAnnotation_avucd_gg_",
|
|
30
|
+
"__SBarLabel": "___SBarLabel_avucd_gg_",
|
|
31
|
+
"__SBarPercent": "___SBarPercent_avucd_gg_",
|
|
32
|
+
"__SBarValue": "___SBarValue_avucd_gg_",
|
|
33
|
+
"__SCompactHorizontalBarHoverRect": "___SCompactHorizontalBarHoverRect_avucd_gg_"
|
|
34
34
|
})
|
|
35
35
|
);
|
|
36
36
|
const MIN_WIDTH = 2;
|
package/lib/esm/Hover.mjs
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { sstyled, Component, assignProps } from "@semcore/core";
|
|
3
3
|
import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
|
|
4
|
+
import { getFocusableIn } from "@semcore/core/lib/utils/focus-lock/getFocusableIn";
|
|
4
5
|
import { hasParent } from "@semcore/core/lib/utils/hasParent";
|
|
5
6
|
import trottle from "@semcore/core/lib/utils/rafTrottle";
|
|
7
|
+
import useEnhancedEffect from "@semcore/core/lib/utils/use/useEnhancedEffect";
|
|
6
8
|
import React from "react";
|
|
7
9
|
import createElement from "./createElement.mjs";
|
|
8
10
|
import Tooltip from "./Tooltip.mjs";
|
|
9
11
|
import { eventToPoint, invert, getIndexFromData, scaleOfBandwidth, scaleToBand } from "./utils.mjs";
|
|
10
|
-
import { TextMeasurer } from "./utils/TextMeasurer.mjs";
|
|
11
12
|
/*!__reshadow-styles__:"./style/hover.shadow.css"*/
|
|
12
13
|
const style = (
|
|
13
14
|
/*__reshadow_css_start__*/
|
|
14
15
|
(sstyled.insert(
|
|
15
16
|
/*__inner_css_start__*/
|
|
16
|
-
|
|
17
|
+
'.___SHoverLine_zj7nr_gg_,.___SHoverLine_zj7nr_gg_:focus-visible{outline:none;stroke:var(--intergalactic-chart-grid-x-axis,oklch(.88 .011 234.9))}.___SHoverRect_zj7nr_gg_,.___SHoverRect_zj7nr_gg_:focus-visible{outline:none;fill:var(--intergalactic-chart-grid-bar-hover,oklch(.375 .09 242.7/.05))}.___SHoveredTickWrapper_zj7nr_gg_{font-size:var(--intergalactic-fs-100,12px);font-feature-settings:"tnum";font-variant-numeric:tabular-nums;line-height:var(--intergalactic-lh-100,1.3334);color:var(--intergalactic-chart-grid-text-label,#00132466);text-align:center}.___SHoveredTickWrapper_zj7nr_gg_[data-is-first=true]{text-align:left}.___SHoveredTickWrapper_zj7nr_gg_[data-is-last=true]{text-align:right}.___SHoveredTickWrapper_zj7nr_gg_._position_top_zj7nr_gg_ .___SHoveredTickContent_zj7nr_gg_{align-content:end}.___SHoveredTickWrapper_zj7nr_gg_ .___SHoveredTickContent_zj7nr_gg_{height:100%}.___SHoveredTickWrapper_zj7nr_gg_ .___SHoveredTick_zj7nr_gg_{display:inline-block;padding:3px 12px;border-radius:6px;background-color:var(--intergalactic-chart-x-axis-accent-tick,oklch(.96 .005 232.5))}',
|
|
17
18
|
/*__inner_css_end__*/
|
|
18
|
-
"
|
|
19
|
+
"zj7nr_gg_"
|
|
19
20
|
), /*__reshadow_css_end__*/
|
|
20
21
|
{
|
|
21
|
-
"__SHoverLine": "
|
|
22
|
-
"__SHoverRect": "
|
|
23
|
-
"
|
|
24
|
-
"
|
|
22
|
+
"__SHoverLine": "___SHoverLine_zj7nr_gg_",
|
|
23
|
+
"__SHoverRect": "___SHoverRect_zj7nr_gg_",
|
|
24
|
+
"__SHoveredTickWrapper": "___SHoveredTickWrapper_zj7nr_gg_",
|
|
25
|
+
"_position_top": "_position_top_zj7nr_gg_",
|
|
26
|
+
"__SHoveredTickContent": "___SHoveredTickContent_zj7nr_gg_",
|
|
27
|
+
"__SHoveredTick": "___SHoveredTick_zj7nr_gg_"
|
|
25
28
|
})
|
|
26
29
|
);
|
|
27
30
|
const STROKE_WIDTH = 1;
|
|
28
31
|
const NOTCH_WIDTH = 9;
|
|
29
32
|
const NOTCH_DELTA = NOTCH_WIDTH / 2 - STROKE_WIDTH / 4;
|
|
30
|
-
function formatValue(value) {
|
|
33
|
+
function formatValue(locale, value) {
|
|
31
34
|
if (value instanceof Date) {
|
|
32
|
-
return
|
|
35
|
+
return new Intl.DateTimeFormat(locale ?? "en", {
|
|
36
|
+
day: "numeric",
|
|
37
|
+
month: "short"
|
|
38
|
+
}).format(value);
|
|
33
39
|
}
|
|
34
40
|
return value;
|
|
35
41
|
}
|
|
@@ -40,7 +46,6 @@ class Hover extends Component {
|
|
|
40
46
|
xIndex: null,
|
|
41
47
|
yIndex: null
|
|
42
48
|
});
|
|
43
|
-
_defineProperty(this, "measurer", new TextMeasurer());
|
|
44
49
|
_defineProperty(this, "virtualElement", canUseDOM() ? document.createElement("div") : {});
|
|
45
50
|
_defineProperty(this, "handlerMouseMoveRoot", trottle((e, currentTarget, isTickUnder) => {
|
|
46
51
|
const {
|
|
@@ -130,7 +135,9 @@ class HoverLineRoot extends Hover {
|
|
|
130
135
|
render() {
|
|
131
136
|
var _ref3;
|
|
132
137
|
const {
|
|
133
|
-
hideHoverLine
|
|
138
|
+
hideHoverLine,
|
|
139
|
+
meta,
|
|
140
|
+
locale
|
|
134
141
|
} = this.asProps;
|
|
135
142
|
const {
|
|
136
143
|
xIndex,
|
|
@@ -176,14 +183,15 @@ class HoverLineRoot extends Hover {
|
|
|
176
183
|
"y1": yRange[1],
|
|
177
184
|
"y2": yRange[1]
|
|
178
185
|
}))), !hideTickHover && /* @__PURE__ */ React.createElement(HoveredTick, _ref3.cn("HoveredTick", {
|
|
179
|
-
"
|
|
186
|
+
"size": meta.getTicksSize("horizontal"),
|
|
187
|
+
"position": meta.getTicksPosition("horizontal"),
|
|
188
|
+
"tickFormatter": dataHints.titles.getHorizontalAxesTitle ?? formatValue.bind(null, locale),
|
|
180
189
|
"value": data[xIndex]?.[x],
|
|
181
190
|
"isFirstTick": xIndex === 0,
|
|
182
191
|
"isLastTick": xIndex === data.length - 1,
|
|
183
|
-
"textMeasurer": this.measurer,
|
|
184
192
|
"styles": styles,
|
|
185
193
|
"x": x1,
|
|
186
|
-
"
|
|
194
|
+
"yRange": yRange
|
|
187
195
|
}))) : null, yIndex !== null ? /* @__PURE__ */ React.createElement(SHoverLine, _ref3.cn("SHoverLine", {
|
|
188
196
|
"render": "g",
|
|
189
197
|
"index": yIndex,
|
|
@@ -212,7 +220,8 @@ class HoverRectRoot extends Hover {
|
|
|
212
220
|
render() {
|
|
213
221
|
var _ref4;
|
|
214
222
|
const {
|
|
215
|
-
hideHoverLine
|
|
223
|
+
hideHoverLine,
|
|
224
|
+
meta
|
|
216
225
|
} = this.asProps;
|
|
217
226
|
if (hideHoverLine) {
|
|
218
227
|
return null;
|
|
@@ -225,7 +234,8 @@ class HoverRectRoot extends Hover {
|
|
|
225
234
|
data,
|
|
226
235
|
scale,
|
|
227
236
|
dataHints,
|
|
228
|
-
hideTickHover
|
|
237
|
+
hideTickHover,
|
|
238
|
+
locale
|
|
229
239
|
} = this.asProps;
|
|
230
240
|
const {
|
|
231
241
|
xIndex,
|
|
@@ -249,12 +259,13 @@ class HoverRectRoot extends Hover {
|
|
|
249
259
|
"x": xScale(data[xIndex][x]) - xStep * xPaddingInner / 2,
|
|
250
260
|
"y": yRange[1]
|
|
251
261
|
})), !hideTickHover && /* @__PURE__ */ React.createElement(HoveredTick, _ref4.cn("HoveredTick", {
|
|
252
|
-
"
|
|
262
|
+
"size": meta.getTicksSize("horizontal"),
|
|
263
|
+
"position": meta.getTicksPosition("horizontal"),
|
|
264
|
+
"tickFormatter": dataHints.titles.getHorizontalAxesTitle ?? formatValue.bind(null, locale),
|
|
253
265
|
"value": data[xIndex]?.[x],
|
|
254
|
-
"textMeasurer": this.measurer,
|
|
255
266
|
"styles": styles,
|
|
256
267
|
"x": xScale(data[xIndex][x]) + xStep * (1 - xPaddingInner) / 2,
|
|
257
|
-
"
|
|
268
|
+
"yRange": yRange
|
|
258
269
|
}))), yIndex !== null && /* @__PURE__ */ React.createElement(SHoverRect, _ref4.cn("SHoverRect", {
|
|
259
270
|
"aria-hidden": true,
|
|
260
271
|
"render": "rect",
|
|
@@ -267,53 +278,56 @@ class HoverRectRoot extends Hover {
|
|
|
267
278
|
}
|
|
268
279
|
}
|
|
269
280
|
_defineProperty(HoverRectRoot, "displayName", "HoverRect");
|
|
281
|
+
const HOVERED_TICK_MARGIN_Y = 8;
|
|
282
|
+
const HOVERED_TICK_PADDING_Y = 3;
|
|
270
283
|
const HOVERED_TICK_PADDING_X = 12;
|
|
271
|
-
const HOVERED_TICK_PADDING_Y = 4;
|
|
272
|
-
const HOVERED_TOCK_BORDER_RADIUS = 6;
|
|
273
284
|
function HoveredTick(props) {
|
|
274
285
|
var _ref5;
|
|
275
286
|
const {
|
|
276
|
-
paddingX = HOVERED_TICK_PADDING_X,
|
|
277
|
-
paddingY = HOVERED_TICK_PADDING_Y,
|
|
278
|
-
borderRadius = HOVERED_TOCK_BORDER_RADIUS,
|
|
279
287
|
tickFormatter,
|
|
280
288
|
value,
|
|
281
289
|
isFirstTick = false,
|
|
282
290
|
isLastTick = false,
|
|
283
|
-
textMeasurer,
|
|
284
291
|
styles,
|
|
285
292
|
x,
|
|
286
|
-
|
|
293
|
+
yRange,
|
|
294
|
+
size,
|
|
295
|
+
position
|
|
287
296
|
} = props;
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
const STick = "text";
|
|
297
|
+
const contentRef = React.useRef(null);
|
|
298
|
+
const [interactive, setInteractive] = React.useState(false);
|
|
291
299
|
const formattedValue = tickFormatter(value);
|
|
300
|
+
const isMightBeInteractive = formattedValue !== null && typeof formattedValue === "object";
|
|
301
|
+
useEnhancedEffect(() => {
|
|
302
|
+
if (!isMightBeInteractive || !contentRef.current) {
|
|
303
|
+
setInteractive(false);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
setInteractive(getFocusableIn(contentRef.current).length > 0);
|
|
307
|
+
});
|
|
308
|
+
if (size?.width === void 0 || size?.height === void 0 || position === null) return null;
|
|
292
309
|
const {
|
|
293
|
-
width
|
|
294
|
-
height
|
|
295
|
-
} =
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
const tickX = isFirstTick ? x
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
})), /* @__PURE__ */ React.createElement(STick, _ref5.cn("STick", {
|
|
315
|
-
...tickPos
|
|
316
|
-
}), formattedValue));
|
|
310
|
+
width,
|
|
311
|
+
height
|
|
312
|
+
} = size;
|
|
313
|
+
const SHoveredTickWrapper = "foreignObject";
|
|
314
|
+
const SHoveredTickContent = "div";
|
|
315
|
+
const SHoveredTick = "span";
|
|
316
|
+
const w = width + HOVERED_TICK_PADDING_X * 2;
|
|
317
|
+
const tickX = isFirstTick ? x : isLastTick ? x - w : x - w / 2;
|
|
318
|
+
const tickY = position === "top" ? yRange[1] - height - HOVERED_TICK_MARGIN_Y + HOVERED_TICK_PADDING_Y : yRange[0] + HOVERED_TICK_MARGIN_Y - HOVERED_TICK_PADDING_Y;
|
|
319
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SHoveredTickWrapper, _ref5.cn("SHoveredTickWrapper", {
|
|
320
|
+
"x": tickX,
|
|
321
|
+
"y": tickY,
|
|
322
|
+
"width": w,
|
|
323
|
+
"height": height,
|
|
324
|
+
"data-is-first": isFirstTick,
|
|
325
|
+
"data-is-last": isLastTick,
|
|
326
|
+
"position": position,
|
|
327
|
+
"aria-hidden": interactive ? void 0 : true
|
|
328
|
+
}), /* @__PURE__ */ React.createElement(SHoveredTickContent, _ref5.cn("SHoveredTickContent", {
|
|
329
|
+
"ref": contentRef
|
|
330
|
+
}), /* @__PURE__ */ React.createElement(SHoveredTick, _ref5.cn("SHoveredTick", {}), formattedValue)));
|
|
317
331
|
}
|
|
318
332
|
function HoverLineTooltip(props) {
|
|
319
333
|
var _ref = arguments[0], _ref6;
|
package/lib/esm/Line.mjs
CHANGED
|
@@ -5,28 +5,31 @@ import { bisector } from "d3-array";
|
|
|
5
5
|
import { line, curveLinear, curveCardinal, area } from "d3-shape";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import AnimatedClipPath from "./AnimatedClipPath.mjs";
|
|
8
|
+
import "./component/Chart/index.mjs";
|
|
9
|
+
import { SvgElement } from "./component/SvgElement.mjs";
|
|
8
10
|
import createElement from "./createElement.mjs";
|
|
9
11
|
import Dots from "./Dots.mjs";
|
|
10
|
-
import { resolvePatternDasharray } from "./Pattern.mjs";
|
|
11
|
-
import { interpolateValue, getNullData, definedNullData, eventToPoint, invert, getChartDefaultColorName, definedData, scaleOfBandwidth } from "./utils.mjs";
|
|
12
|
+
import { ForecastGradient, StrokeMask, PotentialGradient, resolvePatternDasharray } from "./Pattern.mjs";
|
|
13
|
+
import { interpolateValue, getNullData, definedNullData, eventToPoint, invert, getDataOfType, getChartDefaultColorName, definedData, scaleOfBandwidth } from "./utils.mjs";
|
|
14
|
+
import { FORECAST, POTENTIAL, DATA_TYPE } from "./component/Chart/AbstractChart.type.mjs";
|
|
12
15
|
/*!__reshadow-styles__:"./style/line.shadow.css"*/
|
|
13
16
|
const style = (
|
|
14
17
|
/*__reshadow_css_start__*/
|
|
15
18
|
(sstyled.insert(
|
|
16
19
|
/*__inner_css_start__*/
|
|
17
|
-
".
|
|
20
|
+
".___SLine_1g38p_gg_{fill:#0000;stroke-width:2;stroke:var(--intergalactic-chart-palette-order-1,oklch(.23 .009 245));transition-property:d;transition-duration:var(--duration_1g38p);transition-timing-function:ease-in-out}.___SLine_1g38p_gg_.__color_1g38p_gg_{stroke:var(--color_1g38p)}.___SLine_1g38p_gg_.__hide_1g38p_gg_{display:none}.___SLine_1g38p_gg_.__transparent_1g38p_gg_{opacity:.3}.___SNull_1g38p_gg_{fill:#0000;stroke:var(--intergalactic-chart-palette-order-null,oklch(.9 .009 234));stroke-dasharray:4}.___SNull_1g38p_gg_.__hide_1g38p_gg_{display:none}.___SLineArea_1g38p_gg_{transition-property:d;transition-duration:var(--duration_1g38p);transition-timing-function:ease-in-out;opacity:.3;fill:var(--intergalactic-chart-palette-order-1,oklch(.23 .009 245))}.___SLineArea_1g38p_gg_.__color_1g38p_gg_{fill:var(--color_1g38p)}",
|
|
18
21
|
/*__inner_css_end__*/
|
|
19
|
-
"
|
|
22
|
+
"1g38p_gg_"
|
|
20
23
|
), /*__reshadow_css_end__*/
|
|
21
24
|
{
|
|
22
|
-
"__SLine": "
|
|
23
|
-
"--duration": "--
|
|
24
|
-
"_color": "
|
|
25
|
-
"--color": "--
|
|
26
|
-
"_hide": "
|
|
27
|
-
"_transparent": "
|
|
28
|
-
"__SNull": "
|
|
29
|
-
"__SLineArea": "
|
|
25
|
+
"__SLine": "___SLine_1g38p_gg_",
|
|
26
|
+
"--duration": "--duration_1g38p",
|
|
27
|
+
"_color": "__color_1g38p_gg_",
|
|
28
|
+
"--color": "--color_1g38p",
|
|
29
|
+
"_hide": "__hide_1g38p_gg_",
|
|
30
|
+
"_transparent": "__transparent_1g38p_gg_",
|
|
31
|
+
"__SNull": "___SNull_1g38p_gg_",
|
|
32
|
+
"__SLineArea": "___SLineArea_1g38p_gg_"
|
|
30
33
|
})
|
|
31
34
|
);
|
|
32
35
|
class LineRoot extends Component {
|
|
@@ -106,8 +109,71 @@ class LineRoot extends Component {
|
|
|
106
109
|
const index = bisector((d) => d[x]).center(data, vX);
|
|
107
110
|
onClick(index, e);
|
|
108
111
|
}
|
|
109
|
-
|
|
112
|
+
renderForecast() {
|
|
110
113
|
var _ref;
|
|
114
|
+
const SLine = SvgElement;
|
|
115
|
+
const {
|
|
116
|
+
styles,
|
|
117
|
+
hide,
|
|
118
|
+
color,
|
|
119
|
+
resolveColor,
|
|
120
|
+
uid,
|
|
121
|
+
d3,
|
|
122
|
+
duration,
|
|
123
|
+
y,
|
|
124
|
+
transparent
|
|
125
|
+
} = this.asProps;
|
|
126
|
+
const data = getDataOfType(this.asProps.data, FORECAST, y);
|
|
127
|
+
return _ref = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SLine, _ref.cn("SLine", {
|
|
128
|
+
"aria-hidden": true,
|
|
129
|
+
"clipPath": `url(#${uid})`,
|
|
130
|
+
"tag": "path",
|
|
131
|
+
"hide": hide,
|
|
132
|
+
"color": resolveColor(color),
|
|
133
|
+
"transparent": transparent,
|
|
134
|
+
"d": d3(data),
|
|
135
|
+
"use:duration": `${duration}ms`,
|
|
136
|
+
"strokeDasharray": "4 4",
|
|
137
|
+
"onClickCapture": this.handlerOnClick.bind(this),
|
|
138
|
+
"pointerEvents": "stroke"
|
|
139
|
+
})), /* @__PURE__ */ React.createElement(ForecastGradient, _ref.cn("ForecastGradient", {
|
|
140
|
+
"id": `${uid}-forecast-gradient`
|
|
141
|
+
})), /* @__PURE__ */ React.createElement(StrokeMask, _ref.cn("StrokeMask", {
|
|
142
|
+
"id": `${uid}-forecast-mask`
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
renderPotential() {
|
|
146
|
+
var _ref2;
|
|
147
|
+
const SLine = SvgElement;
|
|
148
|
+
const {
|
|
149
|
+
styles,
|
|
150
|
+
hide,
|
|
151
|
+
uid,
|
|
152
|
+
d3,
|
|
153
|
+
duration,
|
|
154
|
+
y,
|
|
155
|
+
transparent
|
|
156
|
+
} = this.asProps;
|
|
157
|
+
const data = getDataOfType(this.asProps.data, POTENTIAL, y);
|
|
158
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SLine, _ref2.cn("SLine", {
|
|
159
|
+
"aria-hidden": true,
|
|
160
|
+
"clipPath": `url(#${uid})`,
|
|
161
|
+
"tag": "path",
|
|
162
|
+
"hide": hide,
|
|
163
|
+
"color": `url(#${uid}-potential-gradient-line)`,
|
|
164
|
+
"transparent": transparent,
|
|
165
|
+
"d": d3(data),
|
|
166
|
+
"use:duration": `${duration}ms`,
|
|
167
|
+
"onClickCapture": this.handlerOnClick.bind(this),
|
|
168
|
+
"pointerEvents": "stroke",
|
|
169
|
+
"strokeDasharray": "4 4"
|
|
170
|
+
})), /* @__PURE__ */ React.createElement(PotentialGradient, _ref2.cn("PotentialGradient", {
|
|
171
|
+
"id": `${uid}-potential-gradient-line`,
|
|
172
|
+
"type": "line"
|
|
173
|
+
})));
|
|
174
|
+
}
|
|
175
|
+
render() {
|
|
176
|
+
var _ref3;
|
|
111
177
|
const SLine = this.Element;
|
|
112
178
|
const {
|
|
113
179
|
styles,
|
|
@@ -123,11 +189,11 @@ class LineRoot extends Component {
|
|
|
123
189
|
transparent,
|
|
124
190
|
patterns
|
|
125
191
|
} = this.asProps;
|
|
126
|
-
const data = this.asProps.data.filter((item) => item[y] !== interpolateValue);
|
|
192
|
+
const data = this.asProps.data.filter((item) => item[y] !== interpolateValue && item[DATA_TYPE] !== FORECAST && item[DATA_TYPE] !== POTENTIAL);
|
|
127
193
|
this.asProps.dataHintsHandler.specifyDataRowFields(x, y);
|
|
128
194
|
this.asProps.dataHintsHandler.establishDataType("time-series");
|
|
129
195
|
const patternKey = color || getChartDefaultColorName(0);
|
|
130
|
-
return
|
|
196
|
+
return _ref3 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, this.renderForecast(), this.renderPotential(), /* @__PURE__ */ React.createElement(SLine, _ref3.cn("SLine", {
|
|
131
197
|
"aria-hidden": true,
|
|
132
198
|
"clipPath": `url(#${uid})`,
|
|
133
199
|
"render": "path",
|
|
@@ -139,7 +205,7 @@ class LineRoot extends Component {
|
|
|
139
205
|
"strokeDasharray": patterns ? resolvePatternDasharray(patternKey, patterns) : void 0,
|
|
140
206
|
"onClickCapture": this.handlerOnClick.bind(this),
|
|
141
207
|
"pointerEvents": "stroke"
|
|
142
|
-
})), duration && /* @__PURE__ */ React.createElement(AnimatedClipPath,
|
|
208
|
+
})), duration && /* @__PURE__ */ React.createElement(AnimatedClipPath, _ref3.cn("AnimatedClipPath", {
|
|
143
209
|
"aria-hidden": true,
|
|
144
210
|
"duration": duration,
|
|
145
211
|
"id": uid,
|
|
@@ -167,7 +233,7 @@ _defineProperty(LineRoot, "defaultProps", ({
|
|
|
167
233
|
};
|
|
168
234
|
});
|
|
169
235
|
function Null(props) {
|
|
170
|
-
var
|
|
236
|
+
var _ref4;
|
|
171
237
|
const {
|
|
172
238
|
Element: SNull,
|
|
173
239
|
styles,
|
|
@@ -175,7 +241,7 @@ function Null(props) {
|
|
|
175
241
|
data,
|
|
176
242
|
hide
|
|
177
243
|
} = props;
|
|
178
|
-
return
|
|
244
|
+
return _ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(SNull, _ref4.cn("SNull", {
|
|
179
245
|
"render": "path",
|
|
180
246
|
"d": d3(data),
|
|
181
247
|
"hide": hide
|
|
@@ -217,9 +283,9 @@ function Area(props) {
|
|
|
217
283
|
return chunked;
|
|
218
284
|
}, [data, y0, y1, area$1, autoInterpolate]);
|
|
219
285
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, dataToArea.map((chunk, index) => {
|
|
220
|
-
var
|
|
286
|
+
var _ref5;
|
|
221
287
|
const d3 = area().curve(curve).x((data2) => xScale(data2[x])).y0((data2) => yScale(data2[y0])).y1((data2) => yScale(data2[y1]));
|
|
222
|
-
return
|
|
288
|
+
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SLineArea, _ref5.cn("SLineArea", {
|
|
223
289
|
"key": `${chunk.length}-${index}`,
|
|
224
290
|
"aria-hidden": true,
|
|
225
291
|
"clipPath": `url(#${uid})`,
|