@@ -122,19 +122,22 @@ export function getTooltipPosition(
122122 chartRotation : Rotation ,
123123 cursorBandPosition : Dimensions ,
124124 cursorPosition : { x : number ; y : number } ,
125+ isSingleValueXScale : boolean ,
125126) : string {
126127 const isHorizontalRotated = isHorizontalRotation ( chartRotation ) ;
127128 const hPosition = getHorizontalTooltipPosition (
128129 cursorPosition . x ,
129130 cursorBandPosition ,
130131 chartDimensions ,
131132 isHorizontalRotated ,
133+ isSingleValueXScale ,
132134 ) ;
133135 const vPosition = getVerticalTooltipPosition (
134136 cursorPosition . y ,
135137 cursorBandPosition ,
136138 chartDimensions ,
137139 isHorizontalRotated ,
140+ isSingleValueXScale ,
138141 ) ;
139142 const xTranslation = `translateX(${ hPosition . position } px) translateX(-${ hPosition . offset } %)` ;
140143 const yTranslation = `translateY(${ vPosition . position } px) translateY(-${ vPosition . offset } %)` ;
@@ -146,9 +149,17 @@ export function getHorizontalTooltipPosition(
146149 cursorBandPosition : Dimensions ,
147150 chartDimensions : Dimensions ,
148151 isHorizontalRotated : boolean ,
152+ isSingleValueXScale : boolean ,
149153 padding : number = 20 ,
150154) : { offset : number ; position : number } {
151155 if ( isHorizontalRotated ) {
156+ if ( isSingleValueXScale ) {
157+ return {
158+ offset : 0 ,
159+ position : cursorBandPosition . left ,
160+ } ;
161+ }
162+
152163 if ( cursorXPosition <= chartDimensions . width / 2 ) {
153164 return {
154165 offset : 0 ,
@@ -180,6 +191,7 @@ export function getVerticalTooltipPosition(
180191 cursorBandPosition : Dimensions ,
181192 chartDimensions : Dimensions ,
182193 isHorizontalRotated : boolean ,
194+ isSingleValueXScale : boolean ,
183195 padding : number = 20 ,
184196) : {
185197 offset : number ;
@@ -198,6 +210,12 @@ export function getVerticalTooltipPosition(
198210 } ;
199211 }
200212 } else {
213+ if ( isSingleValueXScale ) {
214+ return {
215+ offset : 0 ,
216+ position : cursorBandPosition . top ,
217+ } ;
218+ }
201219 if ( cursorYPosition <= chartDimensions . height / 2 ) {
202220 return {
203221 offset : 0 ,
0 commit comments