@redsift/charts 10.3.0-alpha.7 → 10.3.0-alpha.8
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/index.d.ts +18 -19
- package/index.js +102 -31
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -386,16 +386,19 @@ declare const getColorScale: ({ colorTheme, domain, isEmpty, theme, }: {
|
|
|
386
386
|
theme: Theme;
|
|
387
387
|
}) => ScaleOrdinal<string, string>;
|
|
388
388
|
|
|
389
|
+
type AnchorProps = ComponentProps<'a'> & {
|
|
390
|
+
as?: any;
|
|
391
|
+
};
|
|
389
392
|
/**
|
|
390
393
|
* Component props.
|
|
391
394
|
*/
|
|
392
395
|
interface DataPointProps<T> extends Omit<ComponentProps<'g'>, 'onClick' | 'scale'> {
|
|
396
|
+
/** Anchor props to use when the component is a navigation link. */
|
|
397
|
+
anchorProps?: AnchorProps;
|
|
393
398
|
/** Color of the DataPoint. */
|
|
394
399
|
color?: string;
|
|
395
400
|
/** Data. Also state to which the component should end the animation, if any. */
|
|
396
401
|
data: T;
|
|
397
|
-
/** Href when the component is a navigation link. */
|
|
398
|
-
href?: string;
|
|
399
402
|
/** Id. Used for accessibility. */
|
|
400
403
|
id?: string;
|
|
401
404
|
/** Position in the list of siblings. Used for placement and selection. */
|
|
@@ -663,6 +666,8 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
|
|
|
663
666
|
areXLabelsRotated?: boolean;
|
|
664
667
|
/** Native HTML props to forward to each bar. */
|
|
665
668
|
barProps?: Omit<ComponentProps<'g'>, 'onClick' | 'orientation' | 'ref' | 'scale'>;
|
|
669
|
+
/** Bar role. If an onClick is provided, the bars will have the role `button`. For a navigation link, please use `getBarAnchorProps` instead. */
|
|
670
|
+
barRole?: BarProps['role'];
|
|
666
671
|
/** Number of categories to use, the rest being put into a new category called "Others". */
|
|
667
672
|
caping?: number;
|
|
668
673
|
/** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
|
|
@@ -671,12 +676,9 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
|
|
|
671
676
|
dataType?: 'TwoCategoryData' | 'LinearData' | 'CategoryData';
|
|
672
677
|
/** Component to use if the chart is empty (replacing the default one). */
|
|
673
678
|
emptyComponent?: ReactNode;
|
|
674
|
-
/** Method used to define the
|
|
675
|
-
getBarAnchorProps?: (datum: BarDatum) =>
|
|
676
|
-
|
|
677
|
-
target?: string;
|
|
678
|
-
};
|
|
679
|
-
/** Method to determine whether a slice is selected or not. */
|
|
679
|
+
/** Method used to define the anchor props to use when the bar is a navigation link. */
|
|
680
|
+
getBarAnchorProps?: (datum: BarDatum) => AnchorProps;
|
|
681
|
+
/** Method to determine whether a bar is selected or not. */
|
|
680
682
|
isBarSelected?: (datum: BarDatum) => void;
|
|
681
683
|
/** Method to override the data labels. */
|
|
682
684
|
labelDecorator?: (datum: BarDatum, props?: {
|
|
@@ -708,8 +710,6 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
|
|
|
708
710
|
size?: ChartSize | BarChartDimensions;
|
|
709
711
|
/** Define how to sort categories. */
|
|
710
712
|
sortingMethod?: SortingMethod;
|
|
711
|
-
/** Bar role. Used to indicate that bars are to be considered buttons or links. If an onClick is provided, the bars will have the role `button` unless specifically set to `link` with this prop. */
|
|
712
|
-
barRole?: BarProps['role'];
|
|
713
713
|
/** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
|
|
714
714
|
colorTheme?: ChartTheme;
|
|
715
715
|
/** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
|
|
@@ -818,10 +818,12 @@ type LineChartDimensions = ChartDimensions & {
|
|
|
818
818
|
interface LineChartProps extends ChartContainerProps, ChartAxesProps {
|
|
819
819
|
/** Dataset to use to generate the chart. */
|
|
820
820
|
data?: TwoCategoryData;
|
|
821
|
-
/**
|
|
821
|
+
/** Dot role. If an onClick is provided, the dots will have the role `button`. For a navigation link, please use `getSliceAnchorProps` instead. */
|
|
822
822
|
dotRole?: DotProps['role'];
|
|
823
823
|
/** Component to use if the chart is empty (replacing the default one). */
|
|
824
824
|
emptyComponent?: ReactNode;
|
|
825
|
+
/** Method used to define the anchor props to use when the dot is a navigation link. */
|
|
826
|
+
getDotAnchorProps?: (datum: DotDatum) => AnchorProps;
|
|
825
827
|
/** Method to determine whether a dot is selected or not. */
|
|
826
828
|
isDotSelected?: (datum: DotDatum) => boolean | undefined;
|
|
827
829
|
/** Method to override the data point labels. */
|
|
@@ -844,7 +846,7 @@ interface LineChartProps extends ChartContainerProps, ChartAxesProps {
|
|
|
844
846
|
localeText?: LocaleText$2;
|
|
845
847
|
/** Custom margins, used to give more space for axes labels and legend for instance. */
|
|
846
848
|
margins?: MarginProps;
|
|
847
|
-
/** Method to be called on a click on a dot. */
|
|
849
|
+
/** Method to be called on a click on a dot. For a navigation link, please use `getSliceAnchorProps` instead. */
|
|
848
850
|
onDotClick?: (datum: DotDatum) => void;
|
|
849
851
|
/** LineChart size. */
|
|
850
852
|
size?: ChartSize | LineChartDimensions;
|
|
@@ -919,11 +921,8 @@ interface PieChartProps extends ChartContainerProps {
|
|
|
919
921
|
data?: CategoryData;
|
|
920
922
|
/** Component to use if the chart is empty (replacing the default one). */
|
|
921
923
|
emptyComponent?: ReactNode;
|
|
922
|
-
/** Method used to define the
|
|
923
|
-
getSliceAnchorProps?: (datum: ArcDatum) =>
|
|
924
|
-
href: string;
|
|
925
|
-
target?: string;
|
|
926
|
-
};
|
|
924
|
+
/** Method used to define the anchor props to use when the slice is a navigation link. */
|
|
925
|
+
getSliceAnchorProps?: (datum: ArcDatum) => AnchorProps;
|
|
927
926
|
/** Whether the pie or donut is cut in half or not. */
|
|
928
927
|
isHalf?: boolean;
|
|
929
928
|
/** Method to determine whether a slice is selected or not. */
|
|
@@ -954,7 +953,7 @@ interface PieChartProps extends ChartContainerProps {
|
|
|
954
953
|
size?: ChartSize | PieChartDimensions;
|
|
955
954
|
/** Native HTML props to forward to each slice. */
|
|
956
955
|
sliceProps?: Omit<ComponentProps<'g'>, 'onClick' | 'ref' | 'width'>;
|
|
957
|
-
/** Slice role.
|
|
956
|
+
/** Slice role. If an onClick is provided, the slices will have the role `button`. For a navigation link, please use `getSliceAnchorProps` instead. */
|
|
958
957
|
sliceRole?: ArcProps['role'];
|
|
959
958
|
/** Define how to sort categories. */
|
|
960
959
|
sortingMethod?: SortingMethod;
|
|
@@ -1102,4 +1101,4 @@ declare const StyledScatterPlotEmptyText: styled_components.StyledComponent<"div
|
|
|
1102
1101
|
$theme: Theme;
|
|
1103
1102
|
}, never>;
|
|
1104
1103
|
|
|
1105
|
-
export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartLegendVariant, BarChartProps, BarDatum, BarOrientation, BarProps, CategoricalOrLinearDim, CategoryData, CategoryDatum, CategoryDim, ChartAxesProps, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, DotVariant, EmptyDatum, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, LegendVariant, Line, LineChart, LineChartDimensions, LineChartLegendVariant, LineChartProps, LinePointDatum, LineProps, LinearData, LinearDatum, LinearDim, MarginProps, NumericValue, PieChart, PieChartDimensions, PieChartLegendVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLegendVariant, ScatterPlotProps, ScatterPlotVariant, SortingMethod, Statistic, Statistics, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledLine, StyledLineChart, StyledLineChartEmptyText, StyledLineChartProps, StyledLineProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, TwoCategoryData, TwoCategoryDatum, TwoCategoryDim, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, XScaleType, empty, getColorScale, getSortingMethod, isValidDate, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
|
|
1104
|
+
export { AnchorProps, AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartLegendVariant, BarChartProps, BarDatum, BarOrientation, BarProps, CategoricalOrLinearDim, CategoryData, CategoryDatum, CategoryDim, ChartAxesProps, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, DotVariant, EmptyDatum, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, LegendVariant, Line, LineChart, LineChartDimensions, LineChartLegendVariant, LineChartProps, LinePointDatum, LineProps, LinearData, LinearDatum, LinearDim, MarginProps, NumericValue, PieChart, PieChartDimensions, PieChartLegendVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLegendVariant, ScatterPlotProps, ScatterPlotVariant, SortingMethod, Statistic, Statistics, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledLine, StyledLineChart, StyledLineChartEmptyText, StyledLineChartProps, StyledLineProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, TwoCategoryData, TwoCategoryDatum, TwoCategoryDim, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, XScaleType, empty, getColorScale, getSortingMethod, isValidDate, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
|
package/index.js
CHANGED
|
@@ -362,13 +362,17 @@ var k=/^--/;function I(t,e){return e==null||typeof e=="boolean"||e===""?"":typeo
|
|
|
362
362
|
*/
|
|
363
363
|
const StyledDataPoint = styled(it.g)``;
|
|
364
364
|
|
|
365
|
-
const _excluded$q = ["
|
|
365
|
+
const _excluded$q = ["as", "href"],
|
|
366
|
+
_excluded2$1 = ["anchorProps", "children", "className", "data", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipDecorator", "tooltipVariant", "theme"];
|
|
366
367
|
const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
367
368
|
const {
|
|
369
|
+
anchorProps: {
|
|
370
|
+
as,
|
|
371
|
+
href
|
|
372
|
+
} = {},
|
|
368
373
|
children,
|
|
369
374
|
className,
|
|
370
375
|
data,
|
|
371
|
-
href,
|
|
372
376
|
id: propsId,
|
|
373
377
|
index,
|
|
374
378
|
isSelected: propsIsSelected,
|
|
@@ -379,7 +383,8 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
379
383
|
tooltipVariant,
|
|
380
384
|
theme: propsTheme
|
|
381
385
|
} = props,
|
|
382
|
-
|
|
386
|
+
anchorProps = _objectWithoutProperties(props.anchorProps, _excluded$q),
|
|
387
|
+
forwardedProps = _objectWithoutProperties(props, _excluded2$1);
|
|
383
388
|
const [_id] = useId();
|
|
384
389
|
const id = propsId !== null && propsId !== void 0 ? propsId : _id;
|
|
385
390
|
const theme = useTheme(propsTheme);
|
|
@@ -406,9 +411,12 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
406
411
|
}
|
|
407
412
|
}
|
|
408
413
|
};
|
|
414
|
+
if (data.data.key === 'Line Chart') {
|
|
415
|
+
console.log(showTooltip, isEmpty, text);
|
|
416
|
+
}
|
|
409
417
|
const DataPointComponent = /*#__PURE__*/React__default.createElement(StyledDataPoint, _extends({
|
|
410
418
|
tabIndex: onClick ? 0 : undefined,
|
|
411
|
-
"aria-label": showTooltip && !isEmpty ? text : undefined,
|
|
419
|
+
"aria-label": showTooltip && !isEmpty ? labelDecorator ? text : `${data.data.key}, ${data.data.value}` : undefined,
|
|
412
420
|
"aria-labelledby": !showTooltip && !isEmpty ? `${id}-title` : undefined,
|
|
413
421
|
"aria-selected": isSelected ? true : isDeselected ? false : undefined,
|
|
414
422
|
onClick: onClick ? () => onClick(data) : undefined,
|
|
@@ -429,9 +437,9 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
429
437
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
430
438
|
placement: "right",
|
|
431
439
|
theme: theme
|
|
432
|
-
}, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, href !== undefined ? /*#__PURE__*/React__default.createElement(
|
|
433
|
-
href
|
|
434
|
-
}, DataPointComponent) : DataPointComponent), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, isTooltipCustom ? tooltipDecorator(data, {
|
|
440
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, href !== undefined ? /*#__PURE__*/React__default.createElement(as || 'a', _objectSpread2({
|
|
441
|
+
href
|
|
442
|
+
}, anchorProps), DataPointComponent) : DataPointComponent), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, isTooltipCustom ? tooltipDecorator(data, {
|
|
435
443
|
index,
|
|
436
444
|
isSelected: propsIsSelected,
|
|
437
445
|
color: props.color
|
|
@@ -1591,7 +1599,7 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1591
1599
|
const bars = data.filter(datum => datum.value);
|
|
1592
1600
|
return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({
|
|
1593
1601
|
mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? 'interactive' : 'static',
|
|
1594
|
-
definition: `Bar Chart with ${bars.length} bars.`,
|
|
1602
|
+
definition: `Ordinal Bar Chart with ${bars.length} bars.`,
|
|
1595
1603
|
dataTableRepresentation: {
|
|
1596
1604
|
header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
|
|
1597
1605
|
scope: "col"
|
|
@@ -1682,8 +1690,8 @@ const RenderedOrdinalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1682
1690
|
isSelected: Boolean(isBarSelected(to)),
|
|
1683
1691
|
key: `bar _${index}`,
|
|
1684
1692
|
labelDecorator: labelDecorator,
|
|
1685
|
-
maxHeight: isHorizontal ? undefined : chartHeight
|
|
1686
|
-
|
|
1693
|
+
maxHeight: isHorizontal ? undefined : chartHeight,
|
|
1694
|
+
anchorProps: getBarAnchorProps ? getBarAnchorProps(to) : undefined,
|
|
1687
1695
|
onClick: onBarClick,
|
|
1688
1696
|
orientation: orientation,
|
|
1689
1697
|
previousData: from,
|
|
@@ -2091,7 +2099,7 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2091
2099
|
}, []);
|
|
2092
2100
|
return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({
|
|
2093
2101
|
mode: typeof onBarClick === 'function' || typeof getBarAnchorProps === 'function' ? 'interactive' : 'static',
|
|
2094
|
-
definition: `Bar Chart with ${bars.length} bars.`,
|
|
2102
|
+
definition: `Linear Bar Chart with ${hasCategory ? `${categories.length} categories and ` : ''}${bars.length} bars.`,
|
|
2095
2103
|
xAxisDefinition: `The chart has 1 X axis displaying ${xScaleType === 'number' ? 'Numbers' : 'Dates'} from ${xScaleType === 'number' ? scaleX.domain()[0] : xAxisTickFormat ? xAxisTickFormat(scaleX.domain()[0]) : scaleX.domain()[0].toString()} to ${xScaleType === 'number' ? scaleX.domain()[1] : xAxisTickFormat ? xAxisTickFormat(scaleX.domain()[1]) : scaleX.domain()[1].toString()}.`,
|
|
2096
2104
|
yAxisDefinition: `The chart has 1 Y axis displaying numbers from ${scaleY.domain()[0]} to ${scaleY.domain()[1]}.`,
|
|
2097
2105
|
dataTableRepresentation: hasCategory ? {
|
|
@@ -2149,7 +2157,8 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2149
2157
|
'aria-label': `${category}, category ${index + 1} of ${categories.length} with ${filteredBars.length} bars`
|
|
2150
2158
|
} : {}), filteredBars.map((bar, index) => {
|
|
2151
2159
|
const to = {
|
|
2152
|
-
data: bar
|
|
2160
|
+
data: bar,
|
|
2161
|
+
category
|
|
2153
2162
|
};
|
|
2154
2163
|
const from = cache.current ? {
|
|
2155
2164
|
data: cache.current[index]
|
|
@@ -2163,8 +2172,8 @@ const RenderedLinearBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2163
2172
|
isSelected: Boolean(isBarSelected(to)),
|
|
2164
2173
|
key: `bar _${index}`,
|
|
2165
2174
|
labelDecorator: labelDecorator,
|
|
2166
|
-
maxHeight: scaleY(bar.cumulativeValue - bar.value)
|
|
2167
|
-
|
|
2175
|
+
maxHeight: scaleY(bar.cumulativeValue - bar.value),
|
|
2176
|
+
anchorProps: getBarAnchorProps ? getBarAnchorProps(to) : undefined,
|
|
2168
2177
|
onClick: onBarClick,
|
|
2169
2178
|
orientation: BarOrientation.vertical,
|
|
2170
2179
|
previousData: from,
|
|
@@ -2676,12 +2685,13 @@ const EmptyLineChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2676
2685
|
})))));
|
|
2677
2686
|
});
|
|
2678
2687
|
|
|
2679
|
-
const _excluded$9 = ["className", "data", "dotRole", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onDotClick", "size", "sortingMethod", "colorTheme", "tooltipDecorator", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "xAxisMinValue", "xAxisMaxValue", "xAxisTickRemodelling", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "yAxisMinValue", "yAxisMaxValue", "yAxisTickRemodelling", "dateParser"];
|
|
2688
|
+
const _excluded$9 = ["className", "data", "dotRole", "getDotAnchorProps", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "legendProps", "margins", "onDotClick", "size", "sortingMethod", "colorTheme", "tooltipDecorator", "tooltipVariant", "xAxisVariant", "xAxisPlacement", "xAxisTickFormat", "xAxisTickPadding", "xAxisTickRotation", "xAxisTickSize", "xAxisTickValues", "xAxisMinValue", "xAxisMaxValue", "xAxisTickRemodelling", "yAxisVariant", "yAxisPlacement", "yAxisTickFormat", "yAxisTickPadding", "yAxisTickRotation", "yAxisTickSize", "yAxisTickValues", "yAxisMinValue", "yAxisMaxValue", "yAxisTickRemodelling", "dateParser"];
|
|
2680
2689
|
const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
2681
2690
|
const {
|
|
2682
2691
|
className,
|
|
2683
2692
|
data: propsData,
|
|
2684
2693
|
dotRole,
|
|
2694
|
+
getDotAnchorProps,
|
|
2685
2695
|
id,
|
|
2686
2696
|
isDotSelected,
|
|
2687
2697
|
labelDecorator,
|
|
@@ -2799,16 +2809,19 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2799
2809
|
return 0;
|
|
2800
2810
|
}
|
|
2801
2811
|
return 0;
|
|
2802
|
-
}).filter(d => d.value !== null).map(d =>
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
+
}).filter(d => d.value !== null).map(d => {
|
|
2813
|
+
var _d$key$;
|
|
2814
|
+
return {
|
|
2815
|
+
category: (_d$key$ = d.key[1]) !== null && _d$key$ !== void 0 ? _d$key$ : 'default',
|
|
2816
|
+
x: xScaleType === 'dateString' ? dateParser ? dateParser(d.key[0]) : new Date(Date.parse(d.key[0])) : d.key[0],
|
|
2817
|
+
y: d.value,
|
|
2818
|
+
data: {
|
|
2819
|
+
key: d.key,
|
|
2820
|
+
value: d.value
|
|
2821
|
+
},
|
|
2822
|
+
points: [d]
|
|
2823
|
+
};
|
|
2824
|
+
});
|
|
2812
2825
|
const lines = hasCategory ? Object.values(circles.reduce((prev, curr) => {
|
|
2813
2826
|
if (!prev[curr.category]) {
|
|
2814
2827
|
prev[curr.category] = [];
|
|
@@ -2817,7 +2830,63 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2817
2830
|
return prev;
|
|
2818
2831
|
}, {})) : [circles];
|
|
2819
2832
|
const createLine = line().x(d => scaleX(d.x)).y(d => scaleY(d.y));
|
|
2820
|
-
|
|
2833
|
+
const categories = [];
|
|
2834
|
+
const pivotedTable = circles.reduce((acc, item) => {
|
|
2835
|
+
const {
|
|
2836
|
+
x,
|
|
2837
|
+
category,
|
|
2838
|
+
y
|
|
2839
|
+
} = item;
|
|
2840
|
+
if (!categories.includes(category)) {
|
|
2841
|
+
categories.push(category);
|
|
2842
|
+
}
|
|
2843
|
+
const formattedKey = xAxisTickFormat ? xAxisTickFormat(x) : x.toString();
|
|
2844
|
+
let entry = acc.find(e => e.key === formattedKey);
|
|
2845
|
+
if (!entry) {
|
|
2846
|
+
entry = {
|
|
2847
|
+
key: formattedKey
|
|
2848
|
+
};
|
|
2849
|
+
acc.push(entry);
|
|
2850
|
+
}
|
|
2851
|
+
entry[category] = y;
|
|
2852
|
+
return acc;
|
|
2853
|
+
}, []);
|
|
2854
|
+
return /*#__PURE__*/React__default.createElement(StyledLineChart, _extends({
|
|
2855
|
+
mode: typeof onDotClick === 'function' || typeof getDotAnchorProps === 'function' ? 'interactive' : 'static',
|
|
2856
|
+
definition: `Line Chart with ${hasCategory ? `${lines.length} lines and ` : ''}${circles.length} points.`,
|
|
2857
|
+
xAxisDefinition: `The chart has 1 X axis displaying ${xScaleType === 'number' ? 'Numbers' : 'Dates'} from ${xScaleType === 'number' ? scaleX.domain()[0] : xAxisTickFormat ? xAxisTickFormat(scaleX.domain()[0]) : scaleX.domain()[0].toString()} to ${xScaleType === 'number' ? scaleX.domain()[1] : xAxisTickFormat ? xAxisTickFormat(scaleX.domain()[1]) : scaleX.domain()[1].toString()}.`,
|
|
2858
|
+
yAxisDefinition: `The chart has 1 Y axis displaying numbers from ${scaleY.domain()[0]} to ${scaleY.domain()[1]}.`,
|
|
2859
|
+
dataTableRepresentation: hasCategory ? {
|
|
2860
|
+
header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
|
|
2861
|
+
scope: "col"
|
|
2862
|
+
}, xScaleType === 'Date' || xScaleType === 'dateString' ? 'Date' : 'Key'), categories.map(category => /*#__PURE__*/React__default.createElement("th", {
|
|
2863
|
+
key: category,
|
|
2864
|
+
scope: "col"
|
|
2865
|
+
}, category)))),
|
|
2866
|
+
body: /*#__PURE__*/React__default.createElement("tbody", null, pivotedTable.map(row => /*#__PURE__*/React__default.createElement("tr", {
|
|
2867
|
+
key: row.key
|
|
2868
|
+
}, /*#__PURE__*/React__default.createElement("th", {
|
|
2869
|
+
scope: "row"
|
|
2870
|
+
}, row.key), categories.map(category => /*#__PURE__*/React__default.createElement("th", {
|
|
2871
|
+
key: `${row.key}-${category}-${row[category]}`,
|
|
2872
|
+
scope: "col"
|
|
2873
|
+
}, row[category])))))
|
|
2874
|
+
} : {
|
|
2875
|
+
header: /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
|
|
2876
|
+
scope: "col"
|
|
2877
|
+
}, xScaleType === 'Date' || xScaleType === 'dateString' ? 'Date' : 'Key'), /*#__PURE__*/React__default.createElement("th", {
|
|
2878
|
+
scope: "col"
|
|
2879
|
+
}, "Value"))),
|
|
2880
|
+
body: /*#__PURE__*/React__default.createElement("tbody", null, circles.map(datum => {
|
|
2881
|
+
const key = xAxisTickFormat ? xAxisTickFormat(datum.x) : datum.x.toString();
|
|
2882
|
+
return /*#__PURE__*/React__default.createElement("tr", {
|
|
2883
|
+
key: key
|
|
2884
|
+
}, /*#__PURE__*/React__default.createElement("th", {
|
|
2885
|
+
scope: "row"
|
|
2886
|
+
}, key), /*#__PURE__*/React__default.createElement("td", null, datum.y));
|
|
2887
|
+
}))
|
|
2888
|
+
}
|
|
2889
|
+
}, forwardedProps, {
|
|
2821
2890
|
id: id,
|
|
2822
2891
|
className: className,
|
|
2823
2892
|
ref: ref
|
|
@@ -2853,6 +2922,7 @@ const RenderedLineChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2853
2922
|
color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(circle.category),
|
|
2854
2923
|
data: to,
|
|
2855
2924
|
isSelected: Boolean(isDotSelected === null || isDotSelected === void 0 ? void 0 : isDotSelected(to)),
|
|
2925
|
+
anchorProps: getDotAnchorProps ? getDotAnchorProps(to) : undefined,
|
|
2856
2926
|
key: `circle _${index}`,
|
|
2857
2927
|
labelDecorator: labelDecorator,
|
|
2858
2928
|
onClick: onDotClick,
|
|
@@ -3437,16 +3507,17 @@ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3437
3507
|
percent
|
|
3438
3508
|
})
|
|
3439
3509
|
});
|
|
3440
|
-
return
|
|
3510
|
+
return {
|
|
3441
3511
|
color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
|
|
3442
3512
|
createArc,
|
|
3443
3513
|
previousData: from,
|
|
3444
|
-
id: `id${id}
|
|
3514
|
+
id: `id${id}__arc-${index}`,
|
|
3445
3515
|
index,
|
|
3446
3516
|
isSelected: isSliceSelected(to),
|
|
3447
|
-
key: `id${id}
|
|
3448
|
-
data: to
|
|
3449
|
-
|
|
3517
|
+
key: `id${id}__arc-${index}`,
|
|
3518
|
+
data: to,
|
|
3519
|
+
anchorProps: getSliceAnchorProps ? getSliceAnchorProps(to) : undefined
|
|
3520
|
+
};
|
|
3450
3521
|
}),
|
|
3451
3522
|
hasLabels: legendVariant === PieChartLegendVariant.internal,
|
|
3452
3523
|
hasStroke: isSpaced,
|