@redsift/charts 9.2.3-patch → 9.2.3
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/coverage/clover.xml +1096 -0
- package/coverage/coverage-final.json +60 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/components/Arc/Arc.tsx.html +304 -0
- package/coverage/lcov-report/components/Arc/index.html +146 -0
- package/coverage/lcov-report/components/Arc/index.ts.html +94 -0
- package/coverage/lcov-report/components/Arc/styles.ts.html +208 -0
- package/coverage/lcov-report/components/Arcs/Arcs.tsx.html +409 -0
- package/coverage/lcov-report/components/Arcs/index.html +146 -0
- package/coverage/lcov-report/components/Arcs/index.ts.html +94 -0
- package/coverage/lcov-report/components/Arcs/styles.ts.html +106 -0
- package/coverage/lcov-report/components/Axis/Axis.tsx.html +754 -0
- package/coverage/lcov-report/components/Axis/computeTicks.ts.html +481 -0
- package/coverage/lcov-report/components/Axis/index.html +176 -0
- package/coverage/lcov-report/components/Axis/index.ts.html +94 -0
- package/coverage/lcov-report/components/Axis/styles.ts.html +148 -0
- package/coverage/lcov-report/components/Axis/types.ts.html +253 -0
- package/coverage/lcov-report/components/Bar/Bar.tsx.html +421 -0
- package/coverage/lcov-report/components/Bar/index.html +161 -0
- package/coverage/lcov-report/components/Bar/index.ts.html +94 -0
- package/coverage/lcov-report/components/Bar/styles.ts.html +247 -0
- package/coverage/lcov-report/components/Bar/types.ts.html +178 -0
- package/coverage/lcov-report/components/BarChart/BarChart.tsx.html +352 -0
- package/coverage/lcov-report/components/BarChart/EmptyBarChart.tsx.html +259 -0
- package/coverage/lcov-report/components/BarChart/LoadingBarChart.tsx.html +145 -0
- package/coverage/lcov-report/components/BarChart/RenderedBarChart.tsx.html +430 -0
- package/coverage/lcov-report/components/BarChart/index.html +206 -0
- package/coverage/lcov-report/components/BarChart/index.ts.html +94 -0
- package/coverage/lcov-report/components/BarChart/styles.ts.html +190 -0
- package/coverage/lcov-report/components/BarChart/utils.ts.html +145 -0
- package/coverage/lcov-report/components/BottomAxis/BottomAxis.tsx.html +247 -0
- package/coverage/lcov-report/components/BottomAxis/index.html +146 -0
- package/coverage/lcov-report/components/BottomAxis/index.ts.html +94 -0
- package/coverage/lcov-report/components/BottomAxis/styles.ts.html +139 -0
- package/coverage/lcov-report/components/ChartContainer/ChartContainer.tsx.html +361 -0
- package/coverage/lcov-report/components/ChartContainer/index.html +146 -0
- package/coverage/lcov-report/components/ChartContainer/index.ts.html +94 -0
- package/coverage/lcov-report/components/ChartContainer/intl/index.html +116 -0
- package/coverage/lcov-report/components/ChartContainer/intl/index.ts.html +106 -0
- package/coverage/lcov-report/components/ChartContainer/styles.ts.html +208 -0
- package/coverage/lcov-report/components/DataPoint/DataPoint.tsx.html +391 -0
- package/coverage/lcov-report/components/DataPoint/index.html +146 -0
- package/coverage/lcov-report/components/DataPoint/index.ts.html +94 -0
- package/coverage/lcov-report/components/DataPoint/styles.ts.html +109 -0
- package/coverage/lcov-report/components/Dot/Dot.tsx.html +232 -0
- package/coverage/lcov-report/components/Dot/index.html +146 -0
- package/coverage/lcov-report/components/Dot/index.ts.html +94 -0
- package/coverage/lcov-report/components/Dot/styles.ts.html +184 -0
- package/coverage/lcov-report/components/HorizontalBar/HorizontalBar.tsx.html +541 -0
- package/coverage/lcov-report/components/HorizontalBar/index.html +161 -0
- package/coverage/lcov-report/components/HorizontalBar/index.ts.html +94 -0
- package/coverage/lcov-report/components/HorizontalBar/styles.ts.html +187 -0
- package/coverage/lcov-report/components/HorizontalBar/types.ts.html +301 -0
- package/coverage/lcov-report/components/HorizontalBarChart/HorizontalBarChart.tsx.html +691 -0
- package/coverage/lcov-report/components/HorizontalBarChart/index.html +146 -0
- package/coverage/lcov-report/components/HorizontalBarChart/index.ts.html +94 -0
- package/coverage/lcov-report/components/HorizontalBarChart/styles.ts.html +196 -0
- package/coverage/lcov-report/components/HorizontalBarChart/types.ts.html +301 -0
- package/coverage/lcov-report/components/Legend/Legend.tsx.html +268 -0
- package/coverage/lcov-report/components/Legend/index.html +146 -0
- package/coverage/lcov-report/components/Legend/index.ts.html +94 -0
- package/coverage/lcov-report/components/Legend/styles.ts.html +130 -0
- package/coverage/lcov-report/components/LegendItem/LegendItem.tsx.html +325 -0
- package/coverage/lcov-report/components/LegendItem/index.html +146 -0
- package/coverage/lcov-report/components/LegendItem/index.ts.html +94 -0
- package/coverage/lcov-report/components/LegendItem/styles.ts.html +205 -0
- package/coverage/lcov-report/components/PieChart/EmptyPieChart.tsx.html +343 -0
- package/coverage/lcov-report/components/PieChart/LoadingPieChart.tsx.html +145 -0
- package/coverage/lcov-report/components/PieChart/PieChart.tsx.html +385 -0
- package/coverage/lcov-report/components/PieChart/RenderedPieChart.tsx.html +607 -0
- package/coverage/lcov-report/components/PieChart/index.html +221 -0
- package/coverage/lcov-report/components/PieChart/index.ts.html +94 -0
- package/coverage/lcov-report/components/PieChart/styles.ts.html +370 -0
- package/coverage/lcov-report/components/PieChart/types.ts.html +367 -0
- package/coverage/lcov-report/components/PieChart/utils.ts.html +199 -0
- package/coverage/lcov-report/components/ScatterPlot/EmptyScatterPlot.tsx.html +295 -0
- package/coverage/lcov-report/components/ScatterPlot/LoadingScatterPlot.tsx.html +145 -0
- package/coverage/lcov-report/components/ScatterPlot/RenderedScatterPlot.tsx.html +1048 -0
- package/coverage/lcov-report/components/ScatterPlot/ScatterPlot.tsx.html +367 -0
- package/coverage/lcov-report/components/ScatterPlot/index.html +221 -0
- package/coverage/lcov-report/components/ScatterPlot/index.ts.html +94 -0
- package/coverage/lcov-report/components/ScatterPlot/styles.ts.html +190 -0
- package/coverage/lcov-report/components/ScatterPlot/types.ts.html +394 -0
- package/coverage/lcov-report/components/ScatterPlot/utils.ts.html +388 -0
- package/coverage/lcov-report/core/Arc/Arc.tsx.html +304 -0
- package/coverage/lcov-report/core/Arc/index.html +146 -0
- package/coverage/lcov-report/core/Arc/index.ts.html +94 -0
- package/coverage/lcov-report/core/Arc/styles.ts.html +202 -0
- package/coverage/lcov-report/core/Arcs/Arcs.tsx.html +421 -0
- package/coverage/lcov-report/core/Arcs/index.html +146 -0
- package/coverage/lcov-report/core/Arcs/index.ts.html +94 -0
- package/coverage/lcov-report/core/Arcs/styles.ts.html +106 -0
- package/coverage/lcov-report/core/Axis/Axis.tsx.html +754 -0
- package/coverage/lcov-report/core/Axis/computeTicks.ts.html +481 -0
- package/coverage/lcov-report/core/Axis/index.html +176 -0
- package/coverage/lcov-report/core/Axis/index.ts.html +94 -0
- package/coverage/lcov-report/core/Axis/styles.ts.html +145 -0
- package/coverage/lcov-report/core/Axis/types.ts.html +253 -0
- package/coverage/lcov-report/core/Bar/Bar.tsx.html +421 -0
- package/coverage/lcov-report/core/Bar/index.html +161 -0
- package/coverage/lcov-report/core/Bar/index.ts.html +94 -0
- package/coverage/lcov-report/core/Bar/styles.ts.html +190 -0
- package/coverage/lcov-report/core/Bar/types.ts.html +178 -0
- package/coverage/lcov-report/core/BottomAxis/BottomAxis.tsx.html +277 -0
- package/coverage/lcov-report/core/BottomAxis/index.html +146 -0
- package/coverage/lcov-report/core/BottomAxis/index.ts.html +94 -0
- package/coverage/lcov-report/core/BottomAxis/styles.ts.html +139 -0
- package/coverage/lcov-report/core/ChartConfig/ChartConfig.ts.html +97 -0
- package/coverage/lcov-report/core/ChartConfig/index.html +131 -0
- package/coverage/lcov-report/core/ChartConfig/index.ts.html +88 -0
- package/coverage/lcov-report/core/ChartContainer/ChartContainer.tsx.html +421 -0
- package/coverage/lcov-report/core/ChartContainer/index.html +146 -0
- package/coverage/lcov-report/core/ChartContainer/index.ts.html +94 -0
- package/coverage/lcov-report/core/ChartContainer/intl/index.html +116 -0
- package/coverage/lcov-report/core/ChartContainer/intl/index.ts.html +106 -0
- package/coverage/lcov-report/core/ChartContainer/styles.ts.html +205 -0
- package/coverage/lcov-report/core/DataPoint/DataPoint.tsx.html +442 -0
- package/coverage/lcov-report/core/DataPoint/index.html +146 -0
- package/coverage/lcov-report/core/DataPoint/index.ts.html +94 -0
- package/coverage/lcov-report/core/DataPoint/styles.ts.html +109 -0
- package/coverage/lcov-report/core/Dot/Dot.tsx.html +232 -0
- package/coverage/lcov-report/core/Dot/index.html +146 -0
- package/coverage/lcov-report/core/Dot/index.ts.html +94 -0
- package/coverage/lcov-report/core/Dot/styles.ts.html +184 -0
- package/coverage/lcov-report/core/Legend/Legend.tsx.html +277 -0
- package/coverage/lcov-report/core/Legend/index.html +146 -0
- package/coverage/lcov-report/core/Legend/index.ts.html +94 -0
- package/coverage/lcov-report/core/Legend/styles.ts.html +172 -0
- package/coverage/lcov-report/core/Point/Point.tsx.html +484 -0
- package/coverage/lcov-report/core/Point/index.html +146 -0
- package/coverage/lcov-report/core/Point/index.ts.html +94 -0
- package/coverage/lcov-report/core/Point/styles.ts.html +169 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/gallery/HorizontalBarChart/HorizontalBarChart.tsx.html +706 -0
- package/coverage/lcov-report/gallery/HorizontalBarChart/index.html +161 -0
- package/coverage/lcov-report/gallery/HorizontalBarChart/index.ts.html +94 -0
- package/coverage/lcov-report/gallery/HorizontalBarChart/styles.ts.html +316 -0
- package/coverage/lcov-report/gallery/HorizontalBarChart/types.ts.html +310 -0
- package/coverage/lcov-report/gallery/PieChart/PieChart.tsx.html +1252 -0
- package/coverage/lcov-report/gallery/PieChart/index.html +161 -0
- package/coverage/lcov-report/gallery/PieChart/index.ts.html +94 -0
- package/coverage/lcov-report/gallery/PieChart/styles.ts.html +517 -0
- package/coverage/lcov-report/gallery/PieChart/types.ts.html +388 -0
- package/coverage/lcov-report/gallery/ScatterPlot/index.html +146 -0
- package/coverage/lcov-report/gallery/ScatterPlot/index.ts.html +94 -0
- package/coverage/lcov-report/gallery/ScatterPlot/styles.ts.html +343 -0
- package/coverage/lcov-report/gallery/ScatterPlot/types.ts.html +433 -0
- package/coverage/lcov-report/hooks/index.html +176 -0
- package/coverage/lcov-report/hooks/index.ts.html +97 -0
- package/coverage/lcov-report/hooks/useBrush.tsx.html +430 -0
- package/coverage/lcov-report/hooks/useColor.tsx.html +163 -0
- package/coverage/lcov-report/hooks/useFormatCategoricalData.tsx.html +289 -0
- package/coverage/lcov-report/hooks/useIsEmpty.tsx.html +118 -0
- package/coverage/lcov-report/hooks/useZoom.tsx.html +235 -0
- package/coverage/lcov-report/index.html +311 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +2345 -0
- package/coverage/storybook/coverage-storybook.json +79382 -0
- package/dist/package.json +98 -0
- package/index.ts +1 -0
- package/jest.config.js +3 -0
- package/package.json +2 -3
- package/rollup.config.js +13 -0
- package/src/components/Arc/Arc.test.tsx +80 -0
- package/src/components/Arc/Arc.tsx +73 -0
- package/src/components/Arc/index.ts +3 -0
- package/src/components/Arc/styles.ts +41 -0
- package/src/components/Arc/types.ts +18 -0
- package/src/components/Arcs/Arcs.stories.tsx +177 -0
- package/src/components/Arcs/Arcs.tsx +108 -0
- package/src/components/Arcs/index.ts +3 -0
- package/src/components/Arcs/styles.ts +7 -0
- package/src/components/Arcs/types.ts +26 -0
- package/src/components/Axis/Axis.stories.tsx +297 -0
- package/src/components/Axis/Axis.tsx +223 -0
- package/src/components/Axis/computeTicks.ts +132 -0
- package/src/components/Axis/index.ts +3 -0
- package/src/components/Axis/styles.ts +21 -0
- package/src/components/Axis/types.ts +56 -0
- package/src/components/Bar/Bar.stories.tsx +152 -0
- package/src/components/Bar/Bar.test.tsx +156 -0
- package/src/components/Bar/Bar.tsx +112 -0
- package/src/components/Bar/index.ts +3 -0
- package/src/components/Bar/styles.ts +54 -0
- package/src/components/Bar/types.ts +31 -0
- package/src/components/BarChart/BarChart.stories.tsx +74 -0
- package/src/components/BarChart/BarChart.test.tsx +178 -0
- package/src/components/BarChart/BarChart.tsx +89 -0
- package/src/components/BarChart/EmptyBarChart.tsx +58 -0
- package/src/components/BarChart/LoadingBarChart.tsx +20 -0
- package/src/components/BarChart/RenderedBarChart.tsx +115 -0
- package/src/components/BarChart/__snapshots__/BarChart.test.tsx.snap +7028 -0
- package/src/components/BarChart/index.ts +3 -0
- package/src/components/BarChart/styles.ts +35 -0
- package/src/components/BarChart/types.ts +58 -0
- package/src/components/BarChart/utils.ts +20 -0
- package/src/components/ChartContainer/ChartContainer.stories.tsx +81 -0
- package/src/components/ChartContainer/ChartContainer.test.tsx +71 -0
- package/src/components/ChartContainer/ChartContainer.tsx +92 -0
- package/src/components/ChartContainer/index.ts +3 -0
- package/src/components/ChartContainer/intl/en-US.json +3 -0
- package/src/components/ChartContainer/intl/fr-FR.json +3 -0
- package/src/components/ChartContainer/intl/index.ts +7 -0
- package/src/components/ChartContainer/styles.ts +41 -0
- package/src/components/ChartContainer/types.ts +26 -0
- package/src/components/DataPoint/DataPoint.tsx +102 -0
- package/src/components/DataPoint/index.ts +3 -0
- package/src/components/DataPoint/styles.ts +8 -0
- package/src/components/DataPoint/types.ts +33 -0
- package/src/components/Dot/Dot.stories.tsx +157 -0
- package/src/components/Dot/Dot.test.tsx +136 -0
- package/src/components/Dot/Dot.tsx +49 -0
- package/src/components/Dot/index.ts +3 -0
- package/src/components/Dot/styles.ts +33 -0
- package/src/components/Dot/types.ts +16 -0
- package/src/components/Legend/Legend.stories.tsx +108 -0
- package/src/components/Legend/Legend.tsx +61 -0
- package/src/components/Legend/index.ts +3 -0
- package/src/components/Legend/styles.ts +15 -0
- package/src/components/Legend/types.ts +27 -0
- package/src/components/LegendItem/LegendItem.test.tsx +69 -0
- package/src/components/LegendItem/LegendItem.tsx +80 -0
- package/src/components/LegendItem/index.ts +3 -0
- package/src/components/LegendItem/styles.ts +40 -0
- package/src/components/LegendItem/types.ts +30 -0
- package/src/components/PieChart/EmptyPieChart.tsx +86 -0
- package/src/components/PieChart/LoadingPieChart.tsx +20 -0
- package/src/components/PieChart/PieChart.stories.tsx +85 -0
- package/src/components/PieChart/PieChart.test.tsx +183 -0
- package/src/components/PieChart/PieChart.tsx +100 -0
- package/src/components/PieChart/RenderedPieChart.tsx +174 -0
- package/src/components/PieChart/__snapshots__/PieChart.test.tsx.snap +21020 -0
- package/src/components/PieChart/index.ts +3 -0
- package/src/components/PieChart/styles.ts +95 -0
- package/src/components/PieChart/types.ts +94 -0
- package/src/components/PieChart/utils.ts +38 -0
- package/src/components/ScatterPlot/EmptyScatterPlot.tsx +70 -0
- package/src/components/ScatterPlot/LoadingScatterPlot.tsx +20 -0
- package/src/components/ScatterPlot/RenderedScatterPlot.tsx +321 -0
- package/src/components/ScatterPlot/ScatterPlot.stories.tsx +101 -0
- package/src/components/ScatterPlot/ScatterPlot.test.tsx +61 -0
- package/src/components/ScatterPlot/ScatterPlot.tsx +94 -0
- package/src/components/ScatterPlot/__snapshots__/ScatterPlot.test.tsx.snap +91712 -0
- package/src/components/ScatterPlot/index.ts +3 -0
- package/src/components/ScatterPlot/styles.ts +35 -0
- package/src/components/ScatterPlot/types.ts +103 -0
- package/src/components/ScatterPlot/utils.ts +101 -0
- package/src/config.ts +10 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useBrush.tsx +115 -0
- package/src/hooks/useColor.tsx +26 -0
- package/src/hooks/useFormatCategoricalData.tsx +68 -0
- package/src/hooks/useZoom.tsx +50 -0
- package/src/index.ts +15 -0
- package/src/scheme.ts +213 -0
- package/src/types/data.ts +52 -0
- package/src/types/index.ts +5 -0
- package/src/types/legend.ts +19 -0
- package/src/types/scale.ts +79 -0
- package/src/types/size.ts +17 -0
- package/src/types/theme.ts +27 -0
- package/tsconfig.json +3 -0
- /package/{CONTRIBUTING.md → dist/CONTRIBUTING.md} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{index.js.map → dist/index.js.map} +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import mock from '../../../../../.storybook/static/mocks/bakery-trimmed.json';
|
|
4
|
+
|
|
5
|
+
import { PresentationColorPalette } from '@redsift/design-system';
|
|
6
|
+
import { ScatterPlot } from '.';
|
|
7
|
+
import { ScatterPlotLabelVariant, ScatterPlotVariant } from './types';
|
|
8
|
+
import { ChartSize, ColorTheme, CoordinatesCategoryData, CoordinatesCategoryDim, TooltipVariant } from '../../types';
|
|
9
|
+
import { AxisVariant } from '../Axis';
|
|
10
|
+
|
|
11
|
+
const themes = {
|
|
12
|
+
...ColorTheme,
|
|
13
|
+
'success-warning-danger': {
|
|
14
|
+
success: 'Bread',
|
|
15
|
+
warning: 'Tea',
|
|
16
|
+
danger: 'Coffee',
|
|
17
|
+
},
|
|
18
|
+
'success-warning-danger-neutral': {
|
|
19
|
+
success: 'Bread',
|
|
20
|
+
warning: 'Tea',
|
|
21
|
+
danger: 'Coffee',
|
|
22
|
+
neutral: 'Pastry',
|
|
23
|
+
},
|
|
24
|
+
custom: {
|
|
25
|
+
Coffee: PresentationColorPalette.purple,
|
|
26
|
+
Bread: PresentationColorPalette.pink,
|
|
27
|
+
Tea: PresentationColorPalette.aqua,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const meta: Meta<typeof ScatterPlot> = {
|
|
32
|
+
title: 'Charts/ScatterPlot',
|
|
33
|
+
component: ScatterPlot as any,
|
|
34
|
+
argTypes: {
|
|
35
|
+
variant: {
|
|
36
|
+
options: Object.values(ScatterPlotVariant),
|
|
37
|
+
control: { type: 'select' },
|
|
38
|
+
},
|
|
39
|
+
labelVariant: {
|
|
40
|
+
options: Object.values(ScatterPlotLabelVariant),
|
|
41
|
+
control: { type: 'select' },
|
|
42
|
+
},
|
|
43
|
+
tooltipVariant: {
|
|
44
|
+
options: Object.values(TooltipVariant),
|
|
45
|
+
control: { type: 'select' },
|
|
46
|
+
},
|
|
47
|
+
size: {
|
|
48
|
+
options: Object.values(ChartSize),
|
|
49
|
+
control: { type: 'select' },
|
|
50
|
+
},
|
|
51
|
+
theme: {
|
|
52
|
+
options: Object.keys(themes),
|
|
53
|
+
mapping: themes,
|
|
54
|
+
control: {
|
|
55
|
+
type: 'select',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
xAxisVariant: {
|
|
59
|
+
options: Object.values(AxisVariant),
|
|
60
|
+
control: { type: 'select' },
|
|
61
|
+
},
|
|
62
|
+
yAxisVariant: {
|
|
63
|
+
options: Object.values(AxisVariant),
|
|
64
|
+
control: { type: 'select' },
|
|
65
|
+
},
|
|
66
|
+
xAxisPlacement: {
|
|
67
|
+
options: ['bottom', 'top', 'both'],
|
|
68
|
+
control: { type: 'select' },
|
|
69
|
+
},
|
|
70
|
+
yAxisPlacement: {
|
|
71
|
+
options: ['left', 'right', 'both'],
|
|
72
|
+
control: { type: 'select' },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
export default meta;
|
|
77
|
+
type Story = StoryObj<typeof ScatterPlot>;
|
|
78
|
+
|
|
79
|
+
const data: CoordinatesCategoryData = mock.map((d) => ({
|
|
80
|
+
key: [+d.x!, +d.y!, d.Items] as CoordinatesCategoryDim,
|
|
81
|
+
value: 1,
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
export const Controls: Story = {
|
|
85
|
+
args: {
|
|
86
|
+
title: 'Scatter Plot',
|
|
87
|
+
variant: 'gridded',
|
|
88
|
+
labelVariant: 'externalLabelValue',
|
|
89
|
+
tooltipVariant: 'value',
|
|
90
|
+
size: 'large',
|
|
91
|
+
theme: 'default',
|
|
92
|
+
isBrushable: true,
|
|
93
|
+
xAxisVariant: 'default',
|
|
94
|
+
yAxisVariant: 'default',
|
|
95
|
+
xAxisPlacement: 'bottom',
|
|
96
|
+
yAxisPlacement: 'left',
|
|
97
|
+
caption:
|
|
98
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet odio eu ex ornare sagittis egestas non massa.',
|
|
99
|
+
data: data,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import { composeStory } from '@storybook/react';
|
|
5
|
+
import Meta, { Controls } from './ScatterPlot.stories';
|
|
6
|
+
|
|
7
|
+
import { ScatterPlotLabelVariant, ScatterPlotVariant } from './types';
|
|
8
|
+
import { ChartSize, ChartTheme, ColorTheme, TooltipVariant } from '../../types';
|
|
9
|
+
import { PresentationColorPalette } from '@redsift/design-system';
|
|
10
|
+
|
|
11
|
+
const themes = {
|
|
12
|
+
...ColorTheme,
|
|
13
|
+
'success-warning-danger': {
|
|
14
|
+
success: 'Bread',
|
|
15
|
+
warning: 'Tea',
|
|
16
|
+
danger: 'Coffee',
|
|
17
|
+
},
|
|
18
|
+
'success-warning-danger-neutral': {
|
|
19
|
+
success: 'Bread',
|
|
20
|
+
warning: 'Tea',
|
|
21
|
+
danger: 'Coffee',
|
|
22
|
+
neutral: 'Pastry',
|
|
23
|
+
},
|
|
24
|
+
custom: {
|
|
25
|
+
Coffee: PresentationColorPalette.purple,
|
|
26
|
+
Bread: PresentationColorPalette.pink,
|
|
27
|
+
Tea: PresentationColorPalette.aqua,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe('ScatterPlot', () => {
|
|
32
|
+
it('should match snapshot', () => {
|
|
33
|
+
const ComposedStory = composeStory(Controls, Meta);
|
|
34
|
+
const tree = render(
|
|
35
|
+
<>
|
|
36
|
+
{Object.values(ScatterPlotVariant).map((variant, i) =>
|
|
37
|
+
Object.values(ChartSize).map((size, j) =>
|
|
38
|
+
Object.values(ScatterPlotLabelVariant).map((labelVariant, k) => (
|
|
39
|
+
<ComposedStory
|
|
40
|
+
key={`${variant}-${size}-${labelVariant}-${Object.values(TooltipVariant)[k]}`}
|
|
41
|
+
variant={variant}
|
|
42
|
+
labelVariant={labelVariant}
|
|
43
|
+
tooltipVariant={Object.values(TooltipVariant)[k]}
|
|
44
|
+
size={size}
|
|
45
|
+
theme={
|
|
46
|
+
Object.keys(themes)[
|
|
47
|
+
(i * Object.values(ChartSize).length + j * Object.values(ScatterPlotLabelVariant).length + k) %
|
|
48
|
+
Object.keys(themes).length
|
|
49
|
+
] as ChartTheme
|
|
50
|
+
}
|
|
51
|
+
xAxisVariant="default"
|
|
52
|
+
yAxisVariant="default"
|
|
53
|
+
/>
|
|
54
|
+
))
|
|
55
|
+
)
|
|
56
|
+
)}
|
|
57
|
+
</>
|
|
58
|
+
);
|
|
59
|
+
expect(tree).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { Comp, useId } from '@redsift/design-system';
|
|
5
|
+
|
|
6
|
+
import { ChartSize, ColorTheme, TooltipVariant } from '../../types';
|
|
7
|
+
import { ScatterPlotLabelVariant, ScatterPlotProps, ScatterPlotVariant } from './types';
|
|
8
|
+
import { LoadingScatterPlot } from './LoadingScatterPlot';
|
|
9
|
+
import { EmptyScatterPlot } from './EmptyScatterPlot';
|
|
10
|
+
import { RenderedScatterPlot } from './RenderedScatterPlot';
|
|
11
|
+
import { AxisVariant } from '../Axis';
|
|
12
|
+
|
|
13
|
+
const COMPONENT_NAME = 'ScatterPlot';
|
|
14
|
+
const CLASSNAME = 'redsift-scatterplot';
|
|
15
|
+
const DEFAULT_PROPS: Partial<ScatterPlotProps> = {
|
|
16
|
+
hideControlKeyPanel: false,
|
|
17
|
+
labelVariant: ScatterPlotLabelVariant.externalLabel,
|
|
18
|
+
localeText: {
|
|
19
|
+
emptyChartText: 'No Data',
|
|
20
|
+
},
|
|
21
|
+
size: ChartSize.medium,
|
|
22
|
+
theme: ColorTheme.default,
|
|
23
|
+
tooltipVariant: TooltipVariant.none,
|
|
24
|
+
variant: ScatterPlotVariant.default,
|
|
25
|
+
xAxisVariant: AxisVariant.default,
|
|
26
|
+
xAxisPlacement: 'bottom',
|
|
27
|
+
yAxisVariant: AxisVariant.default,
|
|
28
|
+
yAxisPlacement: 'left',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const ScatterPlot: Comp<ScatterPlotProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
32
|
+
const {
|
|
33
|
+
className,
|
|
34
|
+
data: propsData,
|
|
35
|
+
dotRole,
|
|
36
|
+
emptyComponent,
|
|
37
|
+
id: propsId,
|
|
38
|
+
isDotSelected,
|
|
39
|
+
labelVariant,
|
|
40
|
+
localeText,
|
|
41
|
+
onBrush,
|
|
42
|
+
onBrushEnd,
|
|
43
|
+
onDotClick,
|
|
44
|
+
size,
|
|
45
|
+
theme,
|
|
46
|
+
tooltipVariant,
|
|
47
|
+
variant,
|
|
48
|
+
|
|
49
|
+
...forwardedProps
|
|
50
|
+
} = props;
|
|
51
|
+
const [_id] = useId();
|
|
52
|
+
const id = propsId ?? _id;
|
|
53
|
+
|
|
54
|
+
if (propsData === undefined || propsData === null) {
|
|
55
|
+
return <LoadingScatterPlot id={id} {...forwardedProps} ref={ref} />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (propsData.length === 0) {
|
|
59
|
+
return (
|
|
60
|
+
<EmptyScatterPlot
|
|
61
|
+
data={propsData}
|
|
62
|
+
emptyComponent={emptyComponent}
|
|
63
|
+
localeText={localeText}
|
|
64
|
+
size={size}
|
|
65
|
+
{...forwardedProps}
|
|
66
|
+
ref={ref}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<RenderedScatterPlot
|
|
73
|
+
className={classNames(ScatterPlot.className, className)}
|
|
74
|
+
data={propsData}
|
|
75
|
+
dotRole={dotRole}
|
|
76
|
+
id={id}
|
|
77
|
+
isDotSelected={isDotSelected}
|
|
78
|
+
labelVariant={labelVariant}
|
|
79
|
+
localeText={localeText}
|
|
80
|
+
onBrush={onBrush}
|
|
81
|
+
onBrushEnd={onBrushEnd}
|
|
82
|
+
onDotClick={onDotClick}
|
|
83
|
+
size={size}
|
|
84
|
+
theme={theme}
|
|
85
|
+
tooltipVariant={tooltipVariant}
|
|
86
|
+
variant={variant}
|
|
87
|
+
{...forwardedProps}
|
|
88
|
+
ref={ref}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
ScatterPlot.className = CLASSNAME;
|
|
93
|
+
ScatterPlot.defaultProps = DEFAULT_PROPS;
|
|
94
|
+
ScatterPlot.displayName = COMPONENT_NAME;
|