Skip to content

Commit 8b20be1

Browse files
authored
chore(charts): update "alerts timeline" example so tooltips appear centered horizontally (#11379)
fixes #11378
1 parent 4d96440 commit 8b20be1

File tree

1 file changed

+8
-2
lines changed
  • packages/react-charts/src/victory/components/ChartBar/examples

1 file changed

+8
-2
lines changed

packages/react-charts/src/victory/components/ChartBar/examples/ChartBar.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class Timeline extends React.Component {
322322
[
323323
{ y0: new Date('2024-08-06T01:30:00'), y: new Date('2024-08-07T02:30:00'), severity: 'warn' },
324324
{ y0: new Date('2024-08-08T07:30:00'), y: new Date('2024-08-09T09:30:00'), severity: 'warn' },
325-
{ y0: new Date('2024-08-09T05:30:00'), y: new Date('2024-08-10T20:00:00'), severity: 'warn' },
325+
{ y0: new Date('2024-08-09T11:30:00'), y: new Date('2024-08-10T20:00:00'), severity: 'warn' },
326326
{ y0: new Date('2024-08-12T10:00:00'), y: new Date('2024-08-13T10:30:00'), severity: 'warn' }
327327
],
328328
[
@@ -394,7 +394,13 @@ class Timeline extends React.Component {
394394
containerComponent={
395395
<ChartVoronoiContainer
396396
labelComponent={
397-
<ChartTooltip constrainToVisibleArea labelComponent={<ChartLabel dx={-65} textAnchor="start" />} />
397+
<ChartTooltip
398+
constrainToVisibleArea
399+
dx={({ x, x0 }) => -(x - x0) / 2} // Position tooltip so pointer appears centered
400+
dy={-5} // Position tooltip so pointer appears above bar
401+
labelComponent={<ChartLabel dx={-68} textAnchor="start" />}
402+
orientation="top" // Mimic bullet chart tooltip orientation
403+
/>
398404
}
399405
labels={({ datum }) =>
400406
`Severity: ${datum.severity}\nStart: ${formatDate(new Date(datum.y0), true)}\nEnd: ${formatDate(new Date(datum.y), true)}`

0 commit comments

Comments
 (0)