Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Segmented line chart whisker colors #1768

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading