Skip to content

Commit 30a9d55

Browse files
authored
Always show hover line on charts (#2830)
* Turn on always * changeset * More complete default config
1 parent ef51737 commit 30a9d55

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

.changeset/cold-planes-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@lg-charts/core': patch
3+
---
4+
5+
Renders a vertical line on hover regardless of whether a ChartTooltip is rendered

charts/core/src/Chart/config/getDefaultChartOptions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,14 @@ export const getDefaultChartOptions = (
9595
},
9696
},
9797
},
98+
99+
// Adds vertical dashed line on hover, even when no tooltip is shown
100+
tooltip: {
101+
axisPointer: {
102+
z: 0, // Prevents dashed emphasis line from being rendered on top of mark lines and labels
103+
},
104+
show: true,
105+
trigger: 'axis',
106+
formatter: () => '',
107+
},
98108
});

charts/core/src/ChartTooltip/ChartTooltip.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ export function ChartTooltip({
3232
{
3333
tooltip: {
3434
id,
35-
axisPointer: {
36-
z: 0, // Prevents dashed emphasis line from being rendered on top of mark lines and labels
37-
},
38-
show: true,
39-
trigger: 'axis',
4035
// Still adding background color to prevent peak of color at corners
4136
backgroundColor:
4237
color[theme].background[Variant.InversePrimary][
@@ -79,7 +74,12 @@ export function ChartTooltip({
7974
{
8075
tooltip: {
8176
id,
82-
show: false,
77+
axisPointer: {
78+
z: 0, // Prevents dashed emphasis line from being rendered on top of mark lines and labels
79+
},
80+
show: true,
81+
trigger: 'axis',
82+
formatter: () => '',
8383
},
8484
},
8585
['tooltip'],

0 commit comments

Comments
 (0)