@semcore/d3-chart 18.1.0-prerelease.3 → 18.2.0-prerelease.0
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 +37 -0
- package/lib/cjs/Area.js +12 -12
- package/lib/cjs/Axis.js +15 -15
- package/lib/cjs/Bar.js +206 -21
- package/lib/cjs/Bar.js.map +1 -1
- package/lib/cjs/Bubble.js +85 -38
- package/lib/cjs/Bubble.js.map +1 -1
- package/lib/cjs/CompactHorizontalBar.js +16 -16
- package/lib/cjs/Donut.js +65 -152
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +13 -13
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +32 -25
- package/lib/cjs/HorizontalBar.js.map +1 -1
- package/lib/cjs/Hover.js +64 -153
- package/lib/cjs/Hover.js.map +1 -1
- package/lib/cjs/Line.js +9 -9
- package/lib/cjs/Pattern.js +267 -273
- package/lib/cjs/Pattern.js.map +1 -1
- package/lib/cjs/Plot.js +4 -4
- 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 +31 -29
- package/lib/cjs/Reference.js.map +1 -1
- package/lib/cjs/ScatterPlot.js +9 -9
- package/lib/cjs/StackBar.js +7 -2
- package/lib/cjs/StackBar.js.map +1 -1
- package/lib/cjs/Tooltip.js +14 -13
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/Venn.js +9 -9
- package/lib/cjs/a11y/DataAccessibilityTable.js +1 -1
- package/lib/cjs/a11y/DataAccessibilityTable.js.map +1 -1
- package/lib/cjs/a11y/PlotA11yModule.js +2 -2
- package/lib/cjs/a11y/PlotA11yView.js +2 -2
- package/lib/cjs/component/Chart/AbstractChart.js +28 -21
- package/lib/cjs/component/Chart/AbstractChart.js.map +1 -1
- package/lib/cjs/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/BarChart.js +51 -0
- 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 +104 -20
- package/lib/cjs/component/Chart/BubbleChart.js.map +1 -1
- package/lib/cjs/component/Chart/DonutChart.js +27 -3
- 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/LineChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarChart.js +165 -0
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarChart.js.map +1 -0
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarChart.type.js +2 -0
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarItem.js +147 -0
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarItem.js.map +1 -0
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarItem.type.js +2 -0
- package/lib/cjs/component/Chart/ScoreBar/ScoreBarItem.type.js.map +1 -0
- package/lib/cjs/component/Chart/ScoreBar/scoreBarChart.shadow.css +130 -0
- package/lib/cjs/component/Chart/ScoreDonutChart.js +196 -0
- package/lib/cjs/component/Chart/ScoreDonutChart.js.map +1 -0
- package/lib/cjs/component/Chart/ScoreDonutChart.type.js +2 -0
- package/lib/cjs/component/Chart/ScoreDonutChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/index.js +8 -1
- package/lib/cjs/component/Chart/index.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +7 -7
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +18 -21
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendItem/legend-item.shadow.css +7 -4
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +11 -11
- package/lib/cjs/component/Hover/HoverLine.js +144 -0
- package/lib/cjs/component/Hover/HoverLine.js.map +1 -0
- package/lib/cjs/component/Hover/HoverLine.type.js +2 -0
- package/lib/cjs/component/Hover/HoverLine.type.js.map +1 -0
- package/lib/cjs/component/Hover/HoveredTick.js +77 -0
- package/lib/cjs/component/Hover/HoveredTick.js.map +1 -0
- package/lib/cjs/component/Hover/hover.shadow.css +4 -0
- package/lib/cjs/component/Hover/hoveredTick.shadow.css +34 -0
- package/lib/cjs/style/area.shadow.css +5 -4
- package/lib/cjs/style/bar.shadow.css +1 -1
- package/lib/cjs/style/bubble.shadow.css +29 -24
- package/lib/cjs/style/donut.shadow.css +7 -9
- package/lib/cjs/style/dot.shadow.css +1 -1
- package/lib/cjs/style/hover.shadow.css +0 -40
- package/lib/cjs/style/line.shadow.css +1 -1
- package/lib/cjs/style/radar.shadow.css +2 -2
- package/lib/cjs/style/radial-tree.shadow.css +4 -4
- package/lib/cjs/style/scatterplot.shadow.css +2 -2
- package/lib/cjs/style/venn.shadow.css +3 -3
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +2 -0
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/types/Bar.d.js.map +1 -1
- package/lib/cjs/types/Bubble.d.js.map +1 -1
- package/lib/cjs/types/Donut.d.js.map +1 -1
- package/lib/cjs/types/HorizontalBar.d.js.map +1 -1
- package/lib/cjs/types/Plot.d.js.map +1 -1
- package/lib/cjs/types/index.d.js +24 -0
- package/lib/cjs/types/index.d.js.map +1 -1
- package/lib/cjs/utils.js +78 -30
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/Area.js +12 -12
- package/lib/es6/Axis.js +15 -15
- package/lib/es6/Bar.js +207 -22
- package/lib/es6/Bar.js.map +1 -1
- package/lib/es6/Bubble.js +86 -39
- package/lib/es6/Bubble.js.map +1 -1
- package/lib/es6/CompactHorizontalBar.js +16 -16
- package/lib/es6/Donut.js +65 -152
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +13 -13
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/HorizontalBar.js +32 -25
- package/lib/es6/HorizontalBar.js.map +1 -1
- package/lib/es6/Hover.js +64 -153
- package/lib/es6/Hover.js.map +1 -1
- package/lib/es6/Line.js +9 -9
- package/lib/es6/Pattern.js +266 -272
- package/lib/es6/Pattern.js.map +1 -1
- package/lib/es6/Plot.js +4 -4
- 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 +31 -29
- package/lib/es6/Reference.js.map +1 -1
- package/lib/es6/ScatterPlot.js +9 -9
- package/lib/es6/StackBar.js +7 -2
- package/lib/es6/StackBar.js.map +1 -1
- package/lib/es6/Tooltip.js +14 -13
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/Venn.js +9 -9
- package/lib/es6/a11y/DataAccessibilityTable.js +1 -1
- package/lib/es6/a11y/DataAccessibilityTable.js.map +1 -1
- package/lib/es6/a11y/PlotA11yModule.js +2 -2
- package/lib/es6/a11y/PlotA11yView.js +2 -2
- package/lib/es6/component/Chart/AbstractChart.js +29 -22
- package/lib/es6/component/Chart/AbstractChart.js.map +1 -1
- package/lib/es6/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/es6/component/Chart/BarChart.js +51 -1
- 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 +105 -21
- package/lib/es6/component/Chart/BubbleChart.js.map +1 -1
- package/lib/es6/component/Chart/DonutChart.js +27 -3
- 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/LineChart.type.js.map +1 -1
- package/lib/es6/component/Chart/ScoreBar/ScoreBarChart.js +161 -0
- package/lib/es6/component/Chart/ScoreBar/ScoreBarChart.js.map +1 -0
- package/lib/es6/component/Chart/ScoreBar/ScoreBarChart.type.js +2 -0
- package/lib/es6/component/Chart/ScoreBar/ScoreBarChart.type.js.map +1 -0
- package/lib/es6/component/Chart/ScoreBar/ScoreBarItem.js +141 -0
- package/lib/es6/component/Chart/ScoreBar/ScoreBarItem.js.map +1 -0
- package/lib/es6/component/Chart/ScoreBar/ScoreBarItem.type.js +2 -0
- package/lib/es6/component/Chart/ScoreBar/ScoreBarItem.type.js.map +1 -0
- package/lib/es6/component/Chart/ScoreBar/scoreBarChart.shadow.css +130 -0
- package/lib/es6/component/Chart/ScoreDonutChart.js +189 -0
- package/lib/es6/component/Chart/ScoreDonutChart.js.map +1 -0
- package/lib/es6/component/Chart/ScoreDonutChart.type.js +2 -0
- package/lib/es6/component/Chart/ScoreDonutChart.type.js.map +1 -0
- package/lib/es6/component/Chart/index.js +8 -1
- package/lib/es6/component/Chart/index.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +7 -7
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +24 -26
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendItem/legend-item.shadow.css +7 -4
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +11 -11
- package/lib/es6/component/Hover/HoverLine.js +138 -0
- package/lib/es6/component/Hover/HoverLine.js.map +1 -0
- package/lib/es6/component/Hover/HoverLine.type.js +2 -0
- package/lib/es6/component/Hover/HoverLine.type.js.map +1 -0
- package/lib/es6/component/Hover/HoveredTick.js +71 -0
- package/lib/es6/component/Hover/HoveredTick.js.map +1 -0
- package/lib/es6/component/Hover/hover.shadow.css +4 -0
- package/lib/es6/component/Hover/hoveredTick.shadow.css +34 -0
- package/lib/es6/style/area.shadow.css +5 -4
- package/lib/es6/style/bar.shadow.css +1 -1
- package/lib/es6/style/bubble.shadow.css +29 -24
- package/lib/es6/style/donut.shadow.css +7 -9
- package/lib/es6/style/dot.shadow.css +1 -1
- package/lib/es6/style/hover.shadow.css +0 -40
- package/lib/es6/style/line.shadow.css +1 -1
- package/lib/es6/style/radar.shadow.css +2 -2
- package/lib/es6/style/radial-tree.shadow.css +4 -4
- package/lib/es6/style/scatterplot.shadow.css +2 -2
- package/lib/es6/style/venn.shadow.css +3 -3
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -0
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/types/Bar.d.js.map +1 -1
- package/lib/es6/types/Bubble.d.js.map +1 -1
- package/lib/es6/types/Donut.d.js.map +1 -1
- package/lib/es6/types/HorizontalBar.d.js.map +1 -1
- package/lib/es6/types/Plot.d.js.map +1 -1
- package/lib/es6/types/index.d.js +2 -0
- package/lib/es6/types/index.d.js.map +1 -1
- package/lib/es6/utils.js +71 -28
- package/lib/es6/utils.js.map +1 -1
- package/lib/esm/Area.mjs +13 -13
- package/lib/esm/Axis.mjs +16 -16
- package/lib/esm/Bar.mjs +205 -22
- package/lib/esm/Bubble.mjs +87 -40
- package/lib/esm/CompactHorizontalBar.mjs +17 -17
- package/lib/esm/Donut.mjs +66 -151
- package/lib/esm/Dots.mjs +14 -14
- package/lib/esm/HorizontalBar.mjs +33 -26
- package/lib/esm/Hover.mjs +65 -154
- package/lib/esm/Line.mjs +10 -10
- package/lib/esm/Pattern.mjs +268 -273
- package/lib/esm/Plot.mjs +5 -5
- package/lib/esm/Radar.mjs +20 -20
- package/lib/esm/RadialTree.mjs +13 -13
- package/lib/esm/Reference.mjs +33 -30
- package/lib/esm/ScatterPlot.mjs +10 -10
- package/lib/esm/StackBar.mjs +7 -2
- package/lib/esm/Tooltip.mjs +15 -14
- package/lib/esm/Venn.mjs +10 -10
- package/lib/esm/a11y/DataAccessibilityTable.mjs +1 -1
- package/lib/esm/a11y/PlotA11yModule.mjs +3 -3
- package/lib/esm/a11y/PlotA11yView.mjs +3 -3
- package/lib/esm/component/Chart/AbstractChart.mjs +30 -23
- package/lib/esm/component/Chart/BarChart.mjs +49 -0
- package/lib/esm/component/Chart/BubbleChart.mjs +104 -20
- package/lib/esm/component/Chart/DonutChart.mjs +27 -3
- package/lib/esm/component/Chart/ScoreBar/ScoreBarChart.mjs +160 -0
- package/lib/esm/component/Chart/ScoreBar/ScoreBarItem.mjs +149 -0
- package/lib/esm/component/Chart/ScoreBar/scoreBarChart.shadow.css +130 -0
- package/lib/esm/component/Chart/ScoreDonutChart.mjs +186 -0
- package/lib/esm/component/Chart/index.mjs +8 -1
- package/lib/esm/component/ChartLegend/LegendFlex/LegendFlex.mjs +8 -8
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.mjs +19 -22
- package/lib/esm/component/ChartLegend/LegendItem/legend-item.shadow.css +7 -4
- package/lib/esm/component/ChartLegend/LegendTable/LegendTable.mjs +12 -12
- package/lib/esm/component/Hover/HoverLine.mjs +146 -0
- package/lib/esm/component/Hover/HoveredTick.mjs +79 -0
- package/lib/esm/component/Hover/hover.shadow.css +4 -0
- package/lib/esm/component/Hover/hoveredTick.shadow.css +34 -0
- package/lib/esm/style/area.shadow.css +5 -4
- package/lib/esm/style/bar.shadow.css +1 -1
- package/lib/esm/style/bubble.shadow.css +29 -24
- package/lib/esm/style/donut.shadow.css +7 -9
- package/lib/esm/style/dot.shadow.css +1 -1
- package/lib/esm/style/hover.shadow.css +0 -40
- package/lib/esm/style/line.shadow.css +1 -1
- package/lib/esm/style/radar.shadow.css +2 -2
- package/lib/esm/style/radial-tree.shadow.css +4 -4
- package/lib/esm/style/scatterplot.shadow.css +2 -2
- package/lib/esm/style/venn.shadow.css +3 -3
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -0
- package/lib/esm/translations/de.json.mjs +12 -0
- package/lib/esm/utils.mjs +75 -28
- package/lib/types/Bar.d.ts +3 -0
- package/lib/types/Bubble.d.ts +4 -1
- package/lib/types/Donut.d.ts +0 -4
- package/lib/types/HorizontalBar.d.ts +3 -0
- package/lib/types/Pattern.d.ts +10 -8
- package/lib/types/Pattern.d.ts.map +1 -1
- package/lib/types/Plot.d.ts +6 -1
- package/lib/types/component/Chart/AbstractChart.d.ts +15 -1
- package/lib/types/component/Chart/AbstractChart.d.ts.map +1 -1
- package/lib/types/component/Chart/AbstractChart.type.d.ts +28 -0
- package/lib/types/component/Chart/AbstractChart.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 +9 -1
- 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/DonutChart.d.ts.map +1 -1
- package/lib/types/component/Chart/DonutChart.type.d.ts +5 -2
- package/lib/types/component/Chart/DonutChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/LineChart.type.d.ts +2 -30
- package/lib/types/component/Chart/LineChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/ScoreBar/ScoreBarChart.d.ts +8 -0
- package/lib/types/component/Chart/ScoreBar/ScoreBarChart.d.ts.map +1 -0
- package/lib/types/component/Chart/ScoreBar/ScoreBarChart.type.d.ts +80 -0
- package/lib/types/component/Chart/ScoreBar/ScoreBarChart.type.d.ts.map +1 -0
- package/lib/types/component/Chart/ScoreBar/ScoreBarItem.d.ts +3 -0
- package/lib/types/component/Chart/ScoreBar/ScoreBarItem.d.ts.map +1 -0
- package/lib/types/component/Chart/ScoreBar/ScoreBarItem.type.d.ts +20 -0
- package/lib/types/component/Chart/ScoreBar/ScoreBarItem.type.d.ts.map +1 -0
- package/lib/types/component/Chart/ScoreDonutChart.d.ts +8 -0
- package/lib/types/component/Chart/ScoreDonutChart.d.ts.map +1 -0
- package/lib/types/component/Chart/ScoreDonutChart.type.d.ts +40 -0
- package/lib/types/component/Chart/ScoreDonutChart.type.d.ts.map +1 -0
- package/lib/types/component/Chart/index.d.ts +5 -0
- package/lib/types/component/Chart/index.d.ts.map +1 -1
- package/lib/types/component/Hover/HoverLine.d.ts +2 -0
- package/lib/types/component/Hover/HoverLine.d.ts.map +1 -0
- package/lib/types/component/Hover/HoverLine.type.d.ts +17 -0
- package/lib/types/component/Hover/HoverLine.type.d.ts.map +1 -0
- package/lib/types/component/Hover/HoveredTick.d.ts +21 -0
- package/lib/types/component/Hover/HoveredTick.d.ts.map +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +5 -0
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts.map +1 -1
- package/lib/types/utils.d.ts +11 -2
- package/lib/types/utils.d.ts.map +1 -1
- package/package.json +15 -16
|
@@ -6,6 +6,7 @@ import { scaleTime, scaleBand, scaleLinear } from "d3-scale";
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { AbstractChart } from "./AbstractChart.mjs";
|
|
8
8
|
import "../../index.mjs";
|
|
9
|
+
import { ReferenceLine, ReferenceArea } from "../../Reference.mjs";
|
|
9
10
|
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
10
11
|
import Line from "../../Line.mjs";
|
|
11
12
|
import GroupBar from "../../GroupBar.mjs";
|
|
@@ -180,6 +181,31 @@ class BarChartComponent extends AbstractChart {
|
|
|
180
181
|
};
|
|
181
182
|
});
|
|
182
183
|
}
|
|
184
|
+
renderReference() {
|
|
185
|
+
const {
|
|
186
|
+
referenceLine,
|
|
187
|
+
referenceArea,
|
|
188
|
+
invertAxis
|
|
189
|
+
} = this.asProps;
|
|
190
|
+
if (!referenceLine && !referenceArea || invertAxis) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, referenceLine && (Array.isArray(referenceLine) ? referenceLine.map((refLineItem) => {
|
|
194
|
+
return /* @__PURE__ */ React.createElement(ReferenceLine, {
|
|
195
|
+
key: refLineItem.value.toString(),
|
|
196
|
+
value: refLineItem.value,
|
|
197
|
+
area: refLineItem.area
|
|
198
|
+
});
|
|
199
|
+
}) : /* @__PURE__ */ React.createElement(ReferenceLine, {
|
|
200
|
+
value: referenceLine.value,
|
|
201
|
+
area: referenceLine.area
|
|
202
|
+
})), referenceArea && /* @__PURE__ */ React.createElement(ReferenceArea, {
|
|
203
|
+
positionProps: this.getReferenceAreaPosition(referenceArea),
|
|
204
|
+
use: referenceArea.use,
|
|
205
|
+
title: referenceArea.title,
|
|
206
|
+
subTitle: referenceArea.subTitle
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
183
209
|
renderAxis() {
|
|
184
210
|
const {
|
|
185
211
|
invertAxis,
|
|
@@ -264,6 +290,29 @@ class BarChartComponent extends AbstractChart {
|
|
|
264
290
|
const max = type === "stack" ? super.maxStackedValue : Math.max(...super.flatValues);
|
|
265
291
|
return scaleLinear().range(invertAxis ? [marginY, plotWidth - this.plotPadding] : [plotHeight - marginX, this.plotPadding]).domain([0, max]);
|
|
266
292
|
}
|
|
293
|
+
getReferenceAreaPosition(referenceArea) {
|
|
294
|
+
const xBand = this.xScale;
|
|
295
|
+
if ("bandwidth" in xBand) {
|
|
296
|
+
const xPaddingInner = xBand.paddingInner();
|
|
297
|
+
const startPoint = xBand(referenceArea.value[0]) ?? 0;
|
|
298
|
+
const endPoint = xBand(referenceArea.value[1]) ?? 0;
|
|
299
|
+
const yRange = this.yScale.range();
|
|
300
|
+
const x = startPoint - xBand.step() * xPaddingInner / 2;
|
|
301
|
+
const width = endPoint + xBand.step() * xPaddingInner * 2 - x;
|
|
302
|
+
return {
|
|
303
|
+
x,
|
|
304
|
+
y: yRange[1],
|
|
305
|
+
width,
|
|
306
|
+
height: yRange[0] - yRange[1]
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
x: 0,
|
|
311
|
+
y: 0,
|
|
312
|
+
width: 0,
|
|
313
|
+
height: 0
|
|
314
|
+
};
|
|
315
|
+
}
|
|
267
316
|
}
|
|
268
317
|
_defineProperty(BarChartComponent, "displayName", "Chart.Bar");
|
|
269
318
|
_defineProperty(BarChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
@@ -10,10 +10,20 @@ import { AbstractChart } from "./AbstractChart.mjs";
|
|
|
10
10
|
import { localizedMessages } from "../../translations/__intergalactic-dynamic-locales.mjs";
|
|
11
11
|
import { calculateBubbleDomain } from "../../utils.mjs";
|
|
12
12
|
import Bubble from "../../Bubble.mjs";
|
|
13
|
+
import { YAxis, XAxis } from "../../Axis.mjs";
|
|
14
|
+
const uniqKey = /* @__PURE__ */ Symbol("uniqKey");
|
|
13
15
|
class BubbleChartComponent extends AbstractChart {
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
16
18
|
_defineProperty(this, "plotPadding", 8);
|
|
19
|
+
_defineProperty(this, "cachedData", []);
|
|
20
|
+
this.cachedData = this.getSortedData(props.data);
|
|
21
|
+
}
|
|
22
|
+
componentDidUpdate(prevProps) {
|
|
23
|
+
super.componentDidUpdate(prevProps);
|
|
24
|
+
if (prevProps.data !== this.props.data) {
|
|
25
|
+
this.cachedData = this.getSortedData(this.props.data);
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
get dataKeys() {
|
|
19
29
|
const {
|
|
@@ -87,27 +97,38 @@ class BubbleChartComponent extends AbstractChart {
|
|
|
87
97
|
shape: "Circle"
|
|
88
98
|
};
|
|
89
99
|
}
|
|
100
|
+
get data() {
|
|
101
|
+
return this.cachedData;
|
|
102
|
+
}
|
|
90
103
|
renderChart() {
|
|
91
104
|
const {
|
|
92
|
-
onClickBubble
|
|
105
|
+
onClickBubble,
|
|
106
|
+
axisXValueFormatter,
|
|
107
|
+
axisYValueFormatter
|
|
93
108
|
} = this.asProps;
|
|
94
109
|
const {
|
|
95
|
-
dataDefinitions
|
|
110
|
+
dataDefinitions,
|
|
111
|
+
highlightedItem
|
|
96
112
|
} = this.state;
|
|
97
|
-
return /* @__PURE__ */ React.createElement(Bubble, {
|
|
98
|
-
onClick: onClickBubble,
|
|
113
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Bubble, {
|
|
99
114
|
x: "x",
|
|
100
115
|
y: "y",
|
|
101
116
|
value: "value",
|
|
102
117
|
color: "color",
|
|
103
|
-
label: "label"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
id
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
label: "label",
|
|
119
|
+
formatValue: [axisXValueFormatter, axisYValueFormatter]
|
|
120
|
+
}, this.data.map((item, index) => {
|
|
121
|
+
const dataDefinition = dataDefinitions.find((dataDef) => dataDef.id === item[uniqKey]);
|
|
122
|
+
if (!dataDefinition) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return /* @__PURE__ */ React.createElement(Bubble.Circle, {
|
|
126
|
+
visible: dataDefinition.checked,
|
|
127
|
+
hovered: highlightedItem !== -1 && highlightedItem.toString() === dataDefinition.id,
|
|
128
|
+
key: dataDefinition.id,
|
|
129
|
+
index,
|
|
130
|
+
onClick: onClickBubble ? (e) => onClickBubble(Number(dataDefinition.id), e) : void 0
|
|
131
|
+
});
|
|
111
132
|
})));
|
|
112
133
|
}
|
|
113
134
|
renderTooltip() {
|
|
@@ -149,15 +170,78 @@ class BubbleChartComponent extends AbstractChart {
|
|
|
149
170
|
chartType: "Bubble"
|
|
150
171
|
});
|
|
151
172
|
}
|
|
173
|
+
renderAxis() {
|
|
174
|
+
const {
|
|
175
|
+
showXAxis,
|
|
176
|
+
showYAxis,
|
|
177
|
+
data,
|
|
178
|
+
axisXValueFormatter,
|
|
179
|
+
axisYValueFormatter,
|
|
180
|
+
multilineXTicks,
|
|
181
|
+
multilineYTicks
|
|
182
|
+
} = this.asProps;
|
|
183
|
+
if (!Array.isArray(data)) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const xTicks = this.xTicks;
|
|
187
|
+
const yTicks = this.yTicks;
|
|
188
|
+
const childrenX = axisXValueFormatter ? ({
|
|
189
|
+
value
|
|
190
|
+
}) => ({
|
|
191
|
+
children: axisXValueFormatter(value)
|
|
192
|
+
}) : void 0;
|
|
193
|
+
const childrenY = axisYValueFormatter ? ({
|
|
194
|
+
value
|
|
195
|
+
}) => ({
|
|
196
|
+
children: axisYValueFormatter(value)
|
|
197
|
+
}) : void 0;
|
|
198
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, showYAxis && /* @__PURE__ */ React.createElement(YAxis, null, yTicks ? /* @__PURE__ */ React.createElement(YAxis.Ticks, {
|
|
199
|
+
multiline: multilineYTicks,
|
|
200
|
+
ticks: yTicks
|
|
201
|
+
}, childrenY) : /* @__PURE__ */ React.createElement(YAxis.Ticks, {
|
|
202
|
+
multiline: multilineYTicks
|
|
203
|
+
}, childrenY), /* @__PURE__ */ React.createElement(YAxis.Grid, {
|
|
204
|
+
ticks: yTicks
|
|
205
|
+
})), showXAxis && /* @__PURE__ */ React.createElement(XAxis, null, xTicks ? /* @__PURE__ */ React.createElement(XAxis.Ticks, {
|
|
206
|
+
multiline: multilineXTicks,
|
|
207
|
+
ticks: xTicks
|
|
208
|
+
}, childrenX) : /* @__PURE__ */ React.createElement(XAxis.Ticks, {
|
|
209
|
+
multiline: multilineXTicks
|
|
210
|
+
}, childrenX), /* @__PURE__ */ React.createElement(XAxis.Grid, {
|
|
211
|
+
ticks: xTicks
|
|
212
|
+
})));
|
|
213
|
+
}
|
|
214
|
+
getSortedData(data) {
|
|
215
|
+
const sortedData = data.toSorted((a, b) => {
|
|
216
|
+
return b.value - a.value;
|
|
217
|
+
});
|
|
218
|
+
const result = [];
|
|
219
|
+
sortedData.forEach((dataItem) => {
|
|
220
|
+
const initIndex = data.findIndex((item) => {
|
|
221
|
+
return Object.keys(item).every((key) => {
|
|
222
|
+
return item[key] === dataItem[key];
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
result.push({
|
|
226
|
+
...dataItem,
|
|
227
|
+
[uniqKey]: initIndex.toString()
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
152
232
|
}
|
|
153
233
|
_defineProperty(BubbleChartComponent, "displayName", "Chart.Bubble");
|
|
154
234
|
_defineProperty(BubbleChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
155
|
-
_defineProperty(BubbleChartComponent, "defaultProps", {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
235
|
+
_defineProperty(BubbleChartComponent, "defaultProps", (props) => {
|
|
236
|
+
return {
|
|
237
|
+
direction: "column",
|
|
238
|
+
showXAxis: true,
|
|
239
|
+
showYAxis: true,
|
|
240
|
+
showTooltip: true,
|
|
241
|
+
locale: "en",
|
|
242
|
+
xTicksCount: props.data.length,
|
|
243
|
+
yTicksCount: props.data.length
|
|
244
|
+
};
|
|
161
245
|
});
|
|
162
246
|
const BubbleChart = createComponent(BubbleChartComponent);
|
|
163
247
|
export {
|
|
@@ -49,15 +49,39 @@ class DonutChartComponent extends AbstractChart {
|
|
|
49
49
|
onClick: onClickPie,
|
|
50
50
|
halfsize,
|
|
51
51
|
innerRadius
|
|
52
|
-
}, checkedLegendItems.length === 0 && /* @__PURE__ */ React.createElement(Donut.EmptyData, null),
|
|
52
|
+
}, checkedLegendItems.length === 0 && /* @__PURE__ */ React.createElement(Donut.EmptyData, null), dataDefinitions.map((item, index) => {
|
|
53
|
+
if (!item.checked) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
53
56
|
return /* @__PURE__ */ React.createElement(Donut.Pie, {
|
|
54
57
|
key: item.id,
|
|
55
58
|
dataKey: item.id,
|
|
56
59
|
name: item.label,
|
|
57
60
|
color: item.color,
|
|
58
|
-
|
|
61
|
+
transparent: highlightedItem !== -1 && highlightedItem !== index,
|
|
62
|
+
onMouseOver: () => {
|
|
63
|
+
this.setState({
|
|
64
|
+
highlightedItem: index
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
onMouseOut: () => {
|
|
68
|
+
this.setState({
|
|
69
|
+
highlightedItem: -1
|
|
70
|
+
});
|
|
71
|
+
}
|
|
59
72
|
});
|
|
60
|
-
}), innerLabel && /* @__PURE__ */ React.createElement(Donut.Label,
|
|
73
|
+
}), innerLabel && /* @__PURE__ */ React.createElement(Donut.Label, {
|
|
74
|
+
innerFlexHeight: this.plotHeight
|
|
75
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
76
|
+
size: 500,
|
|
77
|
+
semibold: true,
|
|
78
|
+
style: {
|
|
79
|
+
fontVariantNumeric: "lining-nums tabular-nums"
|
|
80
|
+
}
|
|
81
|
+
}, innerLabel[0]), /* @__PURE__ */ React.createElement(Text, {
|
|
82
|
+
size: 200,
|
|
83
|
+
use: "secondary"
|
|
84
|
+
}, innerLabel[1])));
|
|
61
85
|
}
|
|
62
86
|
renderTooltip() {
|
|
63
87
|
const {
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { sstyled, assignProps, createComponent } from "@semcore/core";
|
|
3
|
+
import { Box } from "@semcore/base-components";
|
|
4
|
+
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
5
|
+
import resolveColorEnhance from "@semcore/core/lib/utils/enhances/resolveColorEnhance";
|
|
6
|
+
import EventEmitter from "@semcore/core/lib/utils/eventEmitter";
|
|
7
|
+
import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
|
|
8
|
+
import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
|
|
9
|
+
import { scaleLinear } from "d3-scale";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { AbstractChart } from "../AbstractChart.mjs";
|
|
12
|
+
import { ScoreBarItem } from "./ScoreBarItem.mjs";
|
|
13
|
+
import "../../../index.mjs";
|
|
14
|
+
import { localizedMessages } from "../../../translations/__intergalactic-dynamic-locales.mjs";
|
|
15
|
+
import Tooltip from "../../../Tooltip.mjs";
|
|
16
|
+
/*!__reshadow-styles__:"./scoreBarChart.shadow.css"*/
|
|
17
|
+
const style = (
|
|
18
|
+
/*__reshadow_css_start__*/
|
|
19
|
+
(sstyled.insert(
|
|
20
|
+
/*__inner_css_start__*/
|
|
21
|
+
'@keyframes valueWidthAnimation_1x5go{0%{width:0}to{width:calc(1%*var(--global-target-width))}}@keyframes bgWidthAnimation_1x5go{0%{width:100%}to{width:calc(1%*(100 - var(--global-target-width)))}}.___SChart_1x5go_gg_{display:grid;grid-template-columns:1fr max-content max-content;grid-column-gap:var(--intergalactic-spacing-4x,16px);-moz-column-gap:var(--intergalactic-spacing-4x,16px);column-gap:var(--intergalactic-spacing-4x,16px);grid-row-gap:var(--intergalactic-spacing-4x,16px);row-gap:var(--intergalactic-spacing-4x,16px);width:100%;padding:var(--intergalactic-spacing-2x,8px);box-sizing:border-box}.___SChart_1x5go_gg_._mode_compact_1x5go_gg_{grid-template-columns:max-content 1fr max-content max-content}.___SItem_1x5go_gg_{display:contents}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_{all:unset;grid-column:1/-1;display:grid;grid-template-columns:subgrid;grid-template-rows:auto auto;grid-row-gap:var(--intergalactic-spacing-2x,8px);row-gap:var(--intergalactic-spacing-2x,8px);align-items:center;position:relative;color:var(--intergalactic-text-link-primary,oklch(.23 .009 245))}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._mode_compact_1x5go_gg_{grid-template-rows:auto}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._tabIndex_0_1x5go_gg_:before{content:"";opacity:0;position:absolute;top:calc(var(--intergalactic-spacing-2x, 8px)*-1);right:calc(var(--intergalactic-spacing-2x, 8px)*-1);bottom:calc(var(--intergalactic-spacing-2x, 8px)*-1);left:calc(var(--intergalactic-spacing-2x, 8px)*-1);background-color:var(--intergalactic-chart-grid-bar-hover,oklch(.375 .09 242.7/.05));border-radius:var(--intergalactic-rounded-medium,6px);z-index:-1;pointer-events:none}@media (hover:hover){.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._tabIndex_0_1x5go_gg_:hover{cursor:pointer;color:var(--intergalactic-text-link-primary-hover-active,oklch(.23 .009 245))}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._tabIndex_0_1x5go_gg_:hover:before{opacity:1}}.___SCategory_1x5go_gg_{grid-area:1}.___SPercent_1x5go_gg_{grid-column:-2/-3}.___SValueLink_1x5go_gg_,.___SValue_1x5go_gg_{grid-column:-1/-2;justify-self:end}.___SBar_1x5go_gg_{grid-column:1/-1;height:var(--intergalactic-spacing-3x,12px);overflow:hidden;display:flex;position:relative}.___SBar_1x5go_gg_._mode_compact_1x5go_gg_{grid-row:1;grid-column:2}.___SBar_1x5go_gg_.__duration_1x5go_gg_ :is(.___SBarBackground_1x5go_gg_,.___SBarValue_1x5go_gg_){animation-duration:calc(var(--duration_1x5go)*1ms)}.___SBar_1x5go_gg_ .___SBarValue_1x5go_gg_{height:100%;border-radius:2px;animation-name:valueWidthAnimation_1x5go;animation-timing-function:ease-in-out;animation-fill-mode:forwards}.___SBar_1x5go_gg_ .___SBarValue_1x5go_gg_.__color_1x5go_gg_{background-color:var(--color_1x5go)}.___SBar_1x5go_gg_ .___SBarBackground_1x5go_gg_{height:100%;background-color:var(--intergalactic-chart-data-null,oklch(.9 .009 234));background-image:repeating-linear-gradient(154deg,#0000 0,#0000 3px,var(--intergalactic-chart-grid-bar-base-bg,oklch(.92 .008 233.5)) 3px,var(--intergalactic-chart-grid-bar-base-bg,oklch(.92 .008 233.5)) 6px);border-radius:var(--intergalactic-chart-rounded,2px);margin-left:var(--intergalactic-spacing-05x,2px);animation-name:bgWidthAnimation_1x5go;animation-timing-function:ease-in-out;animation-fill-mode:forwards}@supports (background:repeating-linear-gradient(red 0%,red 0% 1%,red 2%)) and (color:oklab(0% 0 0%)){.___SBar_1x5go_gg_ .___SBarBackground_1x5go_gg_{background-image:repeating-linear-gradient(154deg,#0000 0 3px,var(--intergalactic-chart-grid-bar-base-bg,oklch(.92 .008 233.5)) 3px 6px)}}',
|
|
22
|
+
/*__inner_css_end__*/
|
|
23
|
+
"1x5go_gg_"
|
|
24
|
+
), /*__reshadow_css_end__*/
|
|
25
|
+
{
|
|
26
|
+
"@valueWidthAnimation": "valueWidthAnimation_1x5go",
|
|
27
|
+
"@bgWidthAnimation": "bgWidthAnimation_1x5go",
|
|
28
|
+
"__SCategory": "___SCategory_1x5go_gg_",
|
|
29
|
+
"__SPercent": "___SPercent_1x5go_gg_",
|
|
30
|
+
"__SValue": "___SValue_1x5go_gg_",
|
|
31
|
+
"__SValueLink": "___SValueLink_1x5go_gg_",
|
|
32
|
+
"__SChart": "___SChart_1x5go_gg_",
|
|
33
|
+
"_mode_compact": "_mode_compact_1x5go_gg_",
|
|
34
|
+
"__SItem": "___SItem_1x5go_gg_",
|
|
35
|
+
"__SContainer": "___SContainer_1x5go_gg_",
|
|
36
|
+
"_tabIndex_0": "_tabIndex_0_1x5go_gg_",
|
|
37
|
+
"__SBar": "___SBar_1x5go_gg_",
|
|
38
|
+
"_duration": "__duration_1x5go_gg_",
|
|
39
|
+
"__SBarValue": "___SBarValue_1x5go_gg_",
|
|
40
|
+
"__SBarBackground": "___SBarBackground_1x5go_gg_",
|
|
41
|
+
"--duration": "--duration_1x5go",
|
|
42
|
+
"_color": "__color_1x5go_gg_",
|
|
43
|
+
"--color": "--color_1x5go"
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
class ScoreBarChartComponent extends AbstractChart {
|
|
47
|
+
constructor(props) {
|
|
48
|
+
super(props);
|
|
49
|
+
_defineProperty(this, "eventEmitter", void 0);
|
|
50
|
+
this.eventEmitter = props.eventEmitter || new EventEmitter();
|
|
51
|
+
}
|
|
52
|
+
render() {
|
|
53
|
+
var _ref = this.asProps, _ref2;
|
|
54
|
+
const SChart = Box;
|
|
55
|
+
const {
|
|
56
|
+
mode,
|
|
57
|
+
data,
|
|
58
|
+
styles,
|
|
59
|
+
onClickItem,
|
|
60
|
+
uid,
|
|
61
|
+
duration,
|
|
62
|
+
valueFormatter,
|
|
63
|
+
titleFormatter,
|
|
64
|
+
resolveColor,
|
|
65
|
+
locale
|
|
66
|
+
} = this.asProps;
|
|
67
|
+
return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(SChart, _ref2.cn("SChart", {
|
|
68
|
+
...assignProps({
|
|
69
|
+
"tag": "ul",
|
|
70
|
+
"__excludeProps": ["data", "eventEmitter"],
|
|
71
|
+
"ref": this.chartRef,
|
|
72
|
+
"mode": mode
|
|
73
|
+
}, _ref)
|
|
74
|
+
}), data.map((item, index) => {
|
|
75
|
+
const color = this.resolveColor(item.category);
|
|
76
|
+
return /* @__PURE__ */ React.createElement(ScoreBarItem, {
|
|
77
|
+
key: item.category,
|
|
78
|
+
onClick: onClickItem,
|
|
79
|
+
index,
|
|
80
|
+
item,
|
|
81
|
+
totalValue: this.totalValue(),
|
|
82
|
+
mode,
|
|
83
|
+
eventEmitter: this.eventEmitter,
|
|
84
|
+
uid,
|
|
85
|
+
duration,
|
|
86
|
+
valueFormatter: valueFormatter ?? this.valueFormatter,
|
|
87
|
+
titleFormatter,
|
|
88
|
+
locale,
|
|
89
|
+
color: resolveColor(color)
|
|
90
|
+
});
|
|
91
|
+
}), this.renderTooltip());
|
|
92
|
+
}
|
|
93
|
+
resolveColor(id) {
|
|
94
|
+
return this.props.colorMap?.[id] ?? `chart-palette-order-1`;
|
|
95
|
+
}
|
|
96
|
+
renderTooltip() {
|
|
97
|
+
const {
|
|
98
|
+
data,
|
|
99
|
+
uid,
|
|
100
|
+
showTooltip
|
|
101
|
+
} = this.asProps;
|
|
102
|
+
if (showTooltip === false) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return /* @__PURE__ */ React.createElement(Tooltip, {
|
|
106
|
+
eventEmitter: this.eventEmitter,
|
|
107
|
+
plotId: uid
|
|
108
|
+
}, ({
|
|
109
|
+
index
|
|
110
|
+
}) => {
|
|
111
|
+
const item = data[index];
|
|
112
|
+
const color = this.resolveColor(item.category);
|
|
113
|
+
return {
|
|
114
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Tooltip.Title, null, this.tooltipTitleFormatter(item.category)), /* @__PURE__ */ React.createElement(Tooltip.Dot, {
|
|
115
|
+
color
|
|
116
|
+
}, this.tooltipValueFormatter(item.value)))
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
totalValue() {
|
|
121
|
+
const {
|
|
122
|
+
totalValue
|
|
123
|
+
} = this.asProps;
|
|
124
|
+
return totalValue ?? [...super.flatValues.values()].reduce((acc, d) => acc + d, 0);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* ===== not used; simply implementations of stubs for abstract methods
|
|
128
|
+
*/
|
|
129
|
+
get xScale() {
|
|
130
|
+
return scaleLinear();
|
|
131
|
+
}
|
|
132
|
+
get yScale() {
|
|
133
|
+
return scaleLinear();
|
|
134
|
+
}
|
|
135
|
+
renderChart() {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
defaultLegendProps() {
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
getLegendAriaLabel() {
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
_defineProperty(ScoreBarChartComponent, "style", style);
|
|
146
|
+
_defineProperty(ScoreBarChartComponent, "displayName", "Chart.ScoreBar");
|
|
147
|
+
_defineProperty(ScoreBarChartComponent, "defaultProps", {
|
|
148
|
+
showTooltip: true,
|
|
149
|
+
locale: "en"
|
|
150
|
+
});
|
|
151
|
+
_defineProperty(ScoreBarChartComponent, "enhance", [i18nEnhance(localizedMessages), uniqueIDEnhancement(), resolveColorEnhance(), cssVariableEnhance({
|
|
152
|
+
variable: "--intergalactic-duration-medium",
|
|
153
|
+
fallback: "300",
|
|
154
|
+
map: (value) => `${Number.parseInt(value)}`,
|
|
155
|
+
prop: "duration"
|
|
156
|
+
})]);
|
|
157
|
+
const ScoreBarChart = createComponent(ScoreBarChartComponent);
|
|
158
|
+
export {
|
|
159
|
+
ScoreBarChart
|
|
160
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { sstyled, Component, createComponent } from "@semcore/core";
|
|
3
|
+
import { Box } from "@semcore/base-components";
|
|
4
|
+
import trottle from "@semcore/core/lib/utils/rafTrottle";
|
|
5
|
+
import { Text } from "@semcore/typography";
|
|
6
|
+
import React from "react";
|
|
7
|
+
/*!__reshadow-styles__:"./scoreBarChart.shadow.css"*/
|
|
8
|
+
const style = (
|
|
9
|
+
/*__reshadow_css_start__*/
|
|
10
|
+
(sstyled.insert(
|
|
11
|
+
/*__inner_css_start__*/
|
|
12
|
+
'@keyframes valueWidthAnimation_1x5go{0%{width:0}to{width:calc(1%*var(--global-target-width))}}@keyframes bgWidthAnimation_1x5go{0%{width:100%}to{width:calc(1%*(100 - var(--global-target-width)))}}.___SChart_1x5go_gg_{display:grid;grid-template-columns:1fr max-content max-content;grid-column-gap:var(--intergalactic-spacing-4x,16px);-moz-column-gap:var(--intergalactic-spacing-4x,16px);column-gap:var(--intergalactic-spacing-4x,16px);grid-row-gap:var(--intergalactic-spacing-4x,16px);row-gap:var(--intergalactic-spacing-4x,16px);width:100%;padding:var(--intergalactic-spacing-2x,8px);box-sizing:border-box}.___SChart_1x5go_gg_._mode_compact_1x5go_gg_{grid-template-columns:max-content 1fr max-content max-content}.___SItem_1x5go_gg_{display:contents}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_{all:unset;grid-column:1/-1;display:grid;grid-template-columns:subgrid;grid-template-rows:auto auto;grid-row-gap:var(--intergalactic-spacing-2x,8px);row-gap:var(--intergalactic-spacing-2x,8px);align-items:center;position:relative;color:var(--intergalactic-text-link-primary,oklch(.23 .009 245))}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._mode_compact_1x5go_gg_{grid-template-rows:auto}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._tabIndex_0_1x5go_gg_:before{content:"";opacity:0;position:absolute;top:calc(var(--intergalactic-spacing-2x, 8px)*-1);right:calc(var(--intergalactic-spacing-2x, 8px)*-1);bottom:calc(var(--intergalactic-spacing-2x, 8px)*-1);left:calc(var(--intergalactic-spacing-2x, 8px)*-1);background-color:var(--intergalactic-chart-grid-bar-hover,oklch(.375 .09 242.7/.05));border-radius:var(--intergalactic-rounded-medium,6px);z-index:-1;pointer-events:none}@media (hover:hover){.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._tabIndex_0_1x5go_gg_:hover{cursor:pointer;color:var(--intergalactic-text-link-primary-hover-active,oklch(.23 .009 245))}.___SItem_1x5go_gg_ .___SContainer_1x5go_gg_._tabIndex_0_1x5go_gg_:hover:before{opacity:1}}.___SCategory_1x5go_gg_{grid-area:1}.___SPercent_1x5go_gg_{grid-column:-2/-3}.___SValueLink_1x5go_gg_,.___SValue_1x5go_gg_{grid-column:-1/-2;justify-self:end}.___SBar_1x5go_gg_{grid-column:1/-1;height:var(--intergalactic-spacing-3x,12px);overflow:hidden;display:flex;position:relative}.___SBar_1x5go_gg_._mode_compact_1x5go_gg_{grid-row:1;grid-column:2}.___SBar_1x5go_gg_.__duration_1x5go_gg_ :is(.___SBarBackground_1x5go_gg_,.___SBarValue_1x5go_gg_){animation-duration:calc(var(--duration_1x5go)*1ms)}.___SBar_1x5go_gg_ .___SBarValue_1x5go_gg_{height:100%;border-radius:2px;animation-name:valueWidthAnimation_1x5go;animation-timing-function:ease-in-out;animation-fill-mode:forwards}.___SBar_1x5go_gg_ .___SBarValue_1x5go_gg_.__color_1x5go_gg_{background-color:var(--color_1x5go)}.___SBar_1x5go_gg_ .___SBarBackground_1x5go_gg_{height:100%;background-color:var(--intergalactic-chart-data-null,oklch(.9 .009 234));background-image:repeating-linear-gradient(154deg,#0000 0,#0000 3px,var(--intergalactic-chart-grid-bar-base-bg,oklch(.92 .008 233.5)) 3px,var(--intergalactic-chart-grid-bar-base-bg,oklch(.92 .008 233.5)) 6px);border-radius:var(--intergalactic-chart-rounded,2px);margin-left:var(--intergalactic-spacing-05x,2px);animation-name:bgWidthAnimation_1x5go;animation-timing-function:ease-in-out;animation-fill-mode:forwards}@supports (background:repeating-linear-gradient(red 0%,red 0% 1%,red 2%)) and (color:oklab(0% 0 0%)){.___SBar_1x5go_gg_ .___SBarBackground_1x5go_gg_{background-image:repeating-linear-gradient(154deg,#0000 0 3px,var(--intergalactic-chart-grid-bar-base-bg,oklch(.92 .008 233.5)) 3px 6px)}}',
|
|
13
|
+
/*__inner_css_end__*/
|
|
14
|
+
"1x5go_gg_"
|
|
15
|
+
), /*__reshadow_css_end__*/
|
|
16
|
+
{
|
|
17
|
+
"@valueWidthAnimation": "valueWidthAnimation_1x5go",
|
|
18
|
+
"@bgWidthAnimation": "bgWidthAnimation_1x5go",
|
|
19
|
+
"__SCategory": "___SCategory_1x5go_gg_",
|
|
20
|
+
"__SPercent": "___SPercent_1x5go_gg_",
|
|
21
|
+
"__SValue": "___SValue_1x5go_gg_",
|
|
22
|
+
"__SValueLink": "___SValueLink_1x5go_gg_",
|
|
23
|
+
"__SChart": "___SChart_1x5go_gg_",
|
|
24
|
+
"_mode_compact": "_mode_compact_1x5go_gg_",
|
|
25
|
+
"__SItem": "___SItem_1x5go_gg_",
|
|
26
|
+
"__SContainer": "___SContainer_1x5go_gg_",
|
|
27
|
+
"_tabIndex_0": "_tabIndex_0_1x5go_gg_",
|
|
28
|
+
"__SBar": "___SBar_1x5go_gg_",
|
|
29
|
+
"_duration": "__duration_1x5go_gg_",
|
|
30
|
+
"__SBarValue": "___SBarValue_1x5go_gg_",
|
|
31
|
+
"__SBarBackground": "___SBarBackground_1x5go_gg_",
|
|
32
|
+
"--duration": "--duration_1x5go",
|
|
33
|
+
"_color": "__color_1x5go_gg_",
|
|
34
|
+
"--color": "--color_1x5go"
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
class ScoreBarItemComponent extends Component {
|
|
38
|
+
constructor(...args) {
|
|
39
|
+
super(...args);
|
|
40
|
+
_defineProperty(this, "handleClick", (event) => {
|
|
41
|
+
const {
|
|
42
|
+
item,
|
|
43
|
+
index,
|
|
44
|
+
onClick
|
|
45
|
+
} = this.asProps;
|
|
46
|
+
onClick?.({
|
|
47
|
+
...item,
|
|
48
|
+
index
|
|
49
|
+
}, event);
|
|
50
|
+
});
|
|
51
|
+
_defineProperty(this, "handleMouseMove", trottle((event) => {
|
|
52
|
+
const {
|
|
53
|
+
eventEmitter,
|
|
54
|
+
index,
|
|
55
|
+
uid
|
|
56
|
+
} = this.asProps;
|
|
57
|
+
const {
|
|
58
|
+
clientX,
|
|
59
|
+
clientY
|
|
60
|
+
} = event;
|
|
61
|
+
eventEmitter.emit(`setTooltipPosition_${uid}`, clientX, clientY);
|
|
62
|
+
eventEmitter.emit(`setTooltipRenderingProps_${uid}`, {}, {
|
|
63
|
+
index
|
|
64
|
+
});
|
|
65
|
+
eventEmitter.emit(`setTooltipVisible_${uid}`, index !== null);
|
|
66
|
+
}));
|
|
67
|
+
_defineProperty(this, "handleMouseLeave", trottle(() => {
|
|
68
|
+
const {
|
|
69
|
+
uid
|
|
70
|
+
} = this.asProps;
|
|
71
|
+
this.asProps.eventEmitter.emit(`setTooltipVisible_${uid}`, false);
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
percentFormatter(value) {
|
|
75
|
+
if (value < 0 || value > 100) {
|
|
76
|
+
return `${value}%`;
|
|
77
|
+
}
|
|
78
|
+
return new Intl.NumberFormat(this.asProps.locale, {
|
|
79
|
+
style: "percent"
|
|
80
|
+
}).format(value / 100);
|
|
81
|
+
}
|
|
82
|
+
renderContent() {
|
|
83
|
+
var _ref;
|
|
84
|
+
const {
|
|
85
|
+
item,
|
|
86
|
+
mode,
|
|
87
|
+
totalValue,
|
|
88
|
+
valueFormatter,
|
|
89
|
+
duration,
|
|
90
|
+
titleFormatter,
|
|
91
|
+
color
|
|
92
|
+
} = this.asProps;
|
|
93
|
+
const SCategory = Text;
|
|
94
|
+
const SPercent = Text;
|
|
95
|
+
const SValue = Text;
|
|
96
|
+
const SBar = Box;
|
|
97
|
+
const SBarValue = Box;
|
|
98
|
+
const SBarBackground = Box;
|
|
99
|
+
const percent = parseInt((100 * (item.value / totalValue)).toFixed(0));
|
|
100
|
+
const bg = 100 - percent;
|
|
101
|
+
const displayValue = valueFormatter(item.value);
|
|
102
|
+
const displayCategory = titleFormatter ? titleFormatter(item.category) : item.category;
|
|
103
|
+
const displayPercent = this.percentFormatter(percent);
|
|
104
|
+
return _ref = sstyled(style), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SCategory, _ref.cn("SCategory", {}), displayCategory), /* @__PURE__ */ React.createElement(SPercent, _ref.cn("SPercent", {
|
|
105
|
+
"use": "secondary"
|
|
106
|
+
}), displayPercent), /* @__PURE__ */ React.createElement(SValue, _ref.cn("SValue", {}), displayValue), /* @__PURE__ */ React.createElement(SBar, _ref.cn("SBar", {
|
|
107
|
+
"mode": mode,
|
|
108
|
+
"aria-hidden": "true",
|
|
109
|
+
"duration": duration
|
|
110
|
+
}), /* @__PURE__ */ React.createElement(SBarValue, _ref.cn("SBarValue", {
|
|
111
|
+
"color": color
|
|
112
|
+
})), /* @__PURE__ */ React.createElement(SBarBackground, _ref.cn("SBarBackground", {
|
|
113
|
+
"style": {
|
|
114
|
+
width: `${bg}%`
|
|
115
|
+
}
|
|
116
|
+
}))));
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
var _ref2;
|
|
120
|
+
const {
|
|
121
|
+
item,
|
|
122
|
+
mode,
|
|
123
|
+
totalValue,
|
|
124
|
+
onClick
|
|
125
|
+
} = this.asProps;
|
|
126
|
+
const SItem = Box;
|
|
127
|
+
const SContainer = Box;
|
|
128
|
+
const percent = parseInt((100 * (item.value / totalValue)).toFixed(0));
|
|
129
|
+
return _ref2 = sstyled(style), /* @__PURE__ */ React.createElement(SItem, _ref2.cn("SItem", {
|
|
130
|
+
"tag": "li",
|
|
131
|
+
"style": {
|
|
132
|
+
"--global-target-width": percent
|
|
133
|
+
}
|
|
134
|
+
}), /* @__PURE__ */ React.createElement(SContainer, _ref2.cn("SContainer", {
|
|
135
|
+
"tag": item.href ? "a" : onClick ? "button" : void 0,
|
|
136
|
+
"onClick": this.handleClick,
|
|
137
|
+
"onMouseMove": this.handleMouseMove,
|
|
138
|
+
"onMouseLeave": this.handleMouseLeave,
|
|
139
|
+
"tabIndex": Boolean(onClick) || Boolean(item.href) ? 0 : void 0,
|
|
140
|
+
"mode": mode,
|
|
141
|
+
"href": item.href
|
|
142
|
+
}), this.renderContent()));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
_defineProperty(ScoreBarItemComponent, "displayName", "Chart.ScoreBar.Item");
|
|
146
|
+
const ScoreBarItem = createComponent(ScoreBarItemComponent);
|
|
147
|
+
export {
|
|
148
|
+
ScoreBarItem
|
|
149
|
+
};
|