Skip to content

Commit

Permalink
Merge pull request #1768 from visualize-admin/fix/error-whisker-colors
Browse files Browse the repository at this point in the history
fix: Segmented line chart whisker colors
  • Loading branch information
bprusinowski authored Sep 27, 2024
2 parents e40632c + 6bcccf3 commit ff7cf15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ You can also check the
is not breaking the application anymore
- Axis titles now wrap
- Metadata panel is not longer shared between separate charts in a dashboard
- Segmented line charts' whiskers have now the same color as the line

# [4.8.0] - 2024-09-11

Expand Down
10 changes: 6 additions & 4 deletions app/charts/line/lines.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useTheme } from "@mui/material";
import { line } from "d3-shape";
import { Fragment, memo, useEffect, useMemo, useRef } from "react";

Expand All @@ -14,7 +13,6 @@ import { Observation } from "@/domain/data";
import { useTransitionStore } from "@/stores/transition";

export const ErrorWhiskers = () => {
const theme = useTheme();
const {
getX,
getYError,
Expand All @@ -23,6 +21,8 @@ export const ErrorWhiskers = () => {
yScale,
xScale,
showYStandardError,
colors,
getSegment,
bounds,
} = useChartState() as LinesState;
const { margins } = bounds;
Expand All @@ -36,6 +36,7 @@ export const ErrorWhiskers = () => {

return chartData.filter(filterWithoutErrors(getYError)).map((d, i) => {
const x0 = xScale(getX(d)) as number;
const segment = getSegment(d);
const barWidth = 15;
const [y1, y2] = getYErrorRange(d);
return {
Expand All @@ -44,17 +45,18 @@ export const ErrorWhiskers = () => {
y1: yScale(y1),
y2: yScale(y2),
width: barWidth,
fill: theme.palette.primary.main,
fill: colors(segment),
renderMiddleCircle: true,
} as RenderWhiskerDatum;
});
}, [
chartData,
colors,
getSegment,
getX,
getYError,
getYErrorRange,
showYStandardError,
theme.palette.primary.main,
xScale,
yScale,
]);
Expand Down

0 comments on commit ff7cf15

Please sign in to comment.