diff --git a/.changeset/empty-lies-clap.md b/.changeset/empty-lies-clap.md new file mode 100644 index 00000000..f58cdff4 --- /dev/null +++ b/.changeset/empty-lies-clap.md @@ -0,0 +1,5 @@ +--- +"@igloo-ui/area-chart": patch +--- + +UI fix - Reverting to a solid colored line for complexity reasons diff --git a/packages/AreaChart/src/AreaChart.tsx b/packages/AreaChart/src/AreaChart.tsx index d054fc20..4602565d 100644 --- a/packages/AreaChart/src/AreaChart.tsx +++ b/packages/AreaChart/src/AreaChart.tsx @@ -88,7 +88,7 @@ export interface AreaChartProps extends React.ComponentProps<"div"> { /** Whether or not the chart should resize */ isResponsive?: boolean; /** Update the default locale - * @deprecated This prop is deprecated and will be removed + * @deprecated This prop is deprecated and will be removed * in the next major version in favor of Igloo's provider */ locale?: string; @@ -111,24 +111,6 @@ export interface AreaChartProps extends React.ComponentProps<"div"> { const DEFAULT_SKELETON_WIDTH = 24; const DEFAULT_SKELETON_HEIGHT = 8; -const getScores = (data: DataSet[]): number[] => { - const scores = data.filter(score => score !== null).map(dataSet => dataSet.score) as number[]; - - return scores; -}; - -const getScoreMin = (data: DataSet[]): number => { - const min = Math.min(...getScores(data)); - - return min; -}; - -const getScoreMax = (data: DataSet[]): number => { - const max = Math.max(...getScores(data)); - - return max; -}; - const AreaChart: React.FunctionComponent = ({ className, dataSet, @@ -419,50 +401,6 @@ const AreaChart: React.FunctionComponent = ({ fill: "none" }; - const getDataHue = (score: number, scoreRange: DataRange): string => { - const scoreMin = (typeof scoreRange.min === "number") ? scoreRange.min : getScoreMin(dataSet); - const scoreMax = (typeof scoreRange.max === "number") ? scoreRange.max : getScoreMax(dataSet); - const relativeScore = Math.round((score - scoreMin) * 100) / 100; - const scale = Math.round((scoreMax - scoreMin) * 100) / 100; - const ratio = relativeScore / scale; - - if (ratio <= 0.06) { return "var(--hop-dataviz-diverging-sequence-1-negative5)"; } - if (ratio <= 0.12) { return "var(--hop-dataviz-diverging-sequence-1-negative4)"; } - if (ratio <= 0.3) { return "var(--hop-dataviz-diverging-sequence-1-negative3)"; } - if (ratio <= 0.43) { return "var(--hop-dataviz-diverging-sequence-1-negative2)"; } - if (ratio <= 0.56) { return "var(--hop-dataviz-diverging-sequence-1-neutral)"; } - if (ratio <= 0.68) { return "var(--hop-dataviz-diverging-sequence-1-positive2)"; } - if (ratio <= 0.81) { return "var(--hop-dataviz-diverging-sequence-1-positive3)"; } - if (ratio <= 0.94) { return "var(--hop-dataviz-diverging-sequence-1-positive4)"; } - - return "var(--hop-dataviz-diverging-sequence-1-positive5)"; - }; - - const buildAreaDefs = (): JSX.Element => { - return ( - - - - - - - - - - - - - - ); - }; - React.useEffect(() => { let updatedAreaChartData = []; @@ -556,7 +494,6 @@ const AreaChart: React.FunctionComponent = ({ margin={{ right: 26, top: 10, bottom: 10, left: 0 }} ref={setChartRef} > - {buildAreaDefs()} @@ -581,7 +518,6 @@ const AreaChart: React.FunctionComponent = ({ dateFormatter={tooltipDateFormatter} scoreFormatter={tooltipScoreFormatter} unavailableDataMessage={unavailableDataMessage} - getDataScoreHue={score => getDataHue(score, range)} /> } /> diff --git a/packages/AreaChart/src/ChartTooltip.tsx b/packages/AreaChart/src/ChartTooltip.tsx index 2c39c0c8..7d3e3666 100644 --- a/packages/AreaChart/src/ChartTooltip.tsx +++ b/packages/AreaChart/src/ChartTooltip.tsx @@ -46,7 +46,7 @@ const ChartTooltip: React.FunctionComponent = ( const formattedScore = formatter ? formatter(score) : score; return ( -
= ({ barCategoryGap="15%" margin={{ top: 2, left: 2, right: 2, bottom: 2 }} width={800} - /* Width and height here are ignored because of ResponsiveContainer, + /* Width and height here are ignored because of ResponsiveContainer, but are useful for tests. */ height={height} >