Skip to content

Commit 129fffc

Browse files
committed
fix: Center whisker middle circle
1 parent 3d8a862 commit 129fffc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/charts/line/lines.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useTransitionStore } from "@/stores/transition";
1414
export const ErrorWhiskers = () => {
1515
const {
1616
getX,
17+
getY,
1718
getYErrorPresent,
1819
getYErrorRange,
1920
chartData,
@@ -37,10 +38,12 @@ export const ErrorWhiskers = () => {
3738
const x0 = xScale(getX(d)) as number;
3839
const segment = getSegment(d);
3940
const barWidth = 15;
41+
const y = getY(d) as number;
4042
const [y1, y2] = getYErrorRange(d);
4143
return {
4244
key: `${i}`,
4345
x: x0 - barWidth / 2,
46+
y: yScale(y),
4447
y1: yScale(y1),
4548
y2: yScale(y2),
4649
width: barWidth,
@@ -53,6 +56,7 @@ export const ErrorWhiskers = () => {
5356
colors,
5457
getSegment,
5558
getX,
59+
getY,
5660
getYErrorPresent,
5761
getYErrorRange,
5862
showYUncertainty,

app/charts/shared/rendering-utils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ const ERROR_WHISKER_MIDDLE_CIRCLE_RADIUS = 3.5;
155155
export type RenderWhiskerDatum = {
156156
key: string;
157157
x: number;
158+
y: number;
158159
y1: number;
159160
y2: number;
160161
width: number;
@@ -215,7 +216,7 @@ export const renderWhiskers = (
215216
.append("circle")
216217
.attr("class", "middle-circle")
217218
.attr("cx", (d) => d.x + d.width / 2)
218-
.attr("cy", (d) => (d.y1 + d.y2) / 2)
219+
.attr("cy", (d) => d.y)
219220
.attr("r", ERROR_WHISKER_MIDDLE_CIRCLE_RADIUS)
220221
.attr("fill", (d) => d.fill ?? "black")
221222
.attr("stroke", "none")
@@ -259,7 +260,7 @@ export const renderWhiskers = (
259260
g
260261
.select(".middle-circle")
261262
.attr("cx", (d) => d.x + d.width / 2)
262-
.attr("cy", (d) => (d.y1 + d.y2) / 2)
263+
.attr("cy", (d) => d.y)
263264
.attr("r", ERROR_WHISKER_MIDDLE_CIRCLE_RADIUS)
264265
.attr("fill", (d) => d.fill ?? "black")
265266
.attr("stroke", "none")

0 commit comments

Comments
 (0)