From 93c9a7485268406cee7dc9c279fd4a4f1f225e22 Mon Sep 17 00:00:00 2001 From: eaglux Date: Thu, 6 Sep 2018 21:42:12 +0300 Subject: [PATCH] MouseCoordinateXV2: text for current x coordinate should be obtained with displayXAccessor instead of xAccessor, as MouseCoordinateX does (for discontinuousTimeScale, xAccessor will give index, not date) --- src/lib/coordinates/MouseCoordinateXV2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/coordinates/MouseCoordinateXV2.js b/src/lib/coordinates/MouseCoordinateXV2.js index bea7a6838..13d2d15a0 100644 --- a/src/lib/coordinates/MouseCoordinateXV2.js +++ b/src/lib/coordinates/MouseCoordinateXV2.js @@ -97,15 +97,22 @@ function xPosition(props, moreProps) { const { currentItem, xAccessor } = moreProps; return xAccessor(currentItem); } + +function displayXValue(moreProps) { + const { currentItem, displayXAccessor } = moreProps; + return displayXAccessor(currentItem); +} + function getXCoordinateInfo(ctx, props, moreProps) { const { xPosition } = props; const xValue = xPosition(props, moreProps); + const xValueDisplay = displayXValue(moreProps); const { at, displayFormat } = props; const { text } = props; const { xScale, chartConfig: { height } } = moreProps; ctx.font = `${text.fontStyle} ${text.fontWeight} ${text.fontSize}px ${text.fontFamily}`; - const t = displayFormat(xValue); + const t = displayFormat(xValueDisplay); const textWidth = ctx.measureText(t).width; const y = at === "bottom" ? height : 0;