Skip to content

Commit

Permalink
[@mantine/charts] Sparkline: Fix incorrect data prop type (#6352)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtivital committed Jul 12, 2024
1 parent 308761e commit 392880f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/@mantine/charts/src/Sparkline/Sparkline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface SparklineProps
StylesApiProps<SparklineFactory>,
ElementProps<'div'> {
/** Data used to render the chart */
data: number[];
data: (number | null)[];

/** Key of `theme.colors` or any valid CSS color, `theme.primaryColor` by default */
color?: MantineColor;
Expand Down Expand Up @@ -75,10 +75,14 @@ const defaultProps: Partial<SparklineProps> = {
curveType: 'linear',
};

function getTrendColor(data: number[], trendColors: SparklineTrendColors) {
function getTrendColor(data: (number | null)[], trendColors: SparklineTrendColors) {
const first = data[0];
const last = data[data.length - 1];

if (first === null || last === null) {
return trendColors.neutral || trendColors.positive;
}

if (first < last) {
return trendColors.positive;
}
Expand Down

0 comments on commit 392880f

Please sign in to comment.