@windborne/grapher 1.0.50 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -113,7 +113,7 @@ export default class Tooltip extends React.PureComponent {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
const preparedTooltips = this.props.tooltips.map((tooltip) => {
|
|
116
|
-
const { x, y, pixelY, pixelX, series, index, xLabel, yLabel, fullYPrecision } = tooltip;
|
|
116
|
+
const { x, y, pixelY, tooltipPixelY, pixelX, series, index, xLabel, yLabel, fullYPrecision } = tooltip;
|
|
117
117
|
|
|
118
118
|
if (typeof pixelX !== 'number') {
|
|
119
119
|
return null;
|
|
@@ -155,7 +155,8 @@ export default class Tooltip extends React.PureComponent {
|
|
|
155
155
|
return null;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
const
|
|
158
|
+
const markerTransform = `translate(${pixelX},${pixelY})`;
|
|
159
|
+
const tooltipTransform = `translate(${pixelX},${tooltipPixelY ?? pixelY})`;
|
|
159
160
|
|
|
160
161
|
const commonLabelProps = {
|
|
161
162
|
fullYPrecision: fullYPrecision || this.props.maxPrecision,
|
|
@@ -203,7 +204,8 @@ export default class Tooltip extends React.PureComponent {
|
|
|
203
204
|
fixedPosition,
|
|
204
205
|
multiplier,
|
|
205
206
|
textLeft,
|
|
206
|
-
|
|
207
|
+
markerTransform,
|
|
208
|
+
tooltipTransform,
|
|
207
209
|
commonLabelProps,
|
|
208
210
|
textTop,
|
|
209
211
|
height,
|
|
@@ -285,11 +287,11 @@ export default class Tooltip extends React.PureComponent {
|
|
|
285
287
|
<svg>
|
|
286
288
|
{
|
|
287
289
|
preparedTooltips.map((tooltip, i) => {
|
|
288
|
-
const { color, fixedPosition, width,
|
|
290
|
+
const { color, fixedPosition, width, markerTransform, tooltipTransform, baseLeft, commonLabelProps, yTranslation, multiplier, textLeft, textTop } = tooltip;
|
|
289
291
|
|
|
290
292
|
if (this.props.customTooltip || groupedTooltips) {
|
|
291
293
|
return (
|
|
292
|
-
<g key={i} transform={
|
|
294
|
+
<g key={i} transform={markerTransform} className="tooltip-item">
|
|
293
295
|
<circle r={4} fill={color}/>
|
|
294
296
|
</g>
|
|
295
297
|
);
|
|
@@ -299,7 +301,7 @@ export default class Tooltip extends React.PureComponent {
|
|
|
299
301
|
if (fixedPosition) {
|
|
300
302
|
return (
|
|
301
303
|
<g key={i} className="tooltip-item tooltip-item-fixed">
|
|
302
|
-
<circle r={4} fill={color} transform={
|
|
304
|
+
<circle r={4} fill={color} transform={markerTransform} />
|
|
303
305
|
|
|
304
306
|
<g transform={`translate(${baseLeft}, ${yTranslation})`}>
|
|
305
307
|
<path stroke={color} d={`M0,0 V-${halfHeight} h${width} V${halfHeight} h${-width} V0`} />
|
|
@@ -314,15 +316,17 @@ export default class Tooltip extends React.PureComponent {
|
|
|
314
316
|
}
|
|
315
317
|
|
|
316
318
|
return (
|
|
317
|
-
<g key={i}
|
|
318
|
-
<circle r={4} fill={color} />
|
|
319
|
+
<g key={i} className="tooltip-item">
|
|
320
|
+
<circle r={4} fill={color} transform={markerTransform} />
|
|
319
321
|
|
|
320
|
-
<
|
|
322
|
+
<g transform={tooltipTransform}>
|
|
323
|
+
<path stroke={color} d={`M${multiplier*caretPadding},0 L${multiplier*caretSize*2},-${caretSize} V-${halfHeight} h${multiplier*width} V${halfHeight} h${multiplier*-width} V${caretSize} L${multiplier*caretPadding},0`} />
|
|
321
324
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
325
|
+
<TooltipLabel
|
|
326
|
+
textLeft={textLeft} textTop={textTop}
|
|
327
|
+
{...commonLabelProps}
|
|
328
|
+
/>
|
|
329
|
+
</g>
|
|
326
330
|
</g>
|
|
327
331
|
);
|
|
328
332
|
})
|
|
@@ -177,12 +177,14 @@ export default function calculateTooltipState({mousePresent, mouseX, mouseY, siz
|
|
|
177
177
|
color = singleSeries.zeroLineColor;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
const
|
|
180
|
+
const followMouse = singleSeries.followingMouseTooltip && alwaysTooltipped.has(singleSeries);
|
|
181
|
+
const finalPixelY = isNaN(pixelY) ? sizing.elementHeight/2 : pixelY;
|
|
181
182
|
|
|
182
183
|
tooltips.push({
|
|
183
184
|
pixelWidth: sizing.elementWidth,
|
|
184
185
|
pixelX: pixelX,
|
|
185
|
-
pixelY:
|
|
186
|
+
pixelY: finalPixelY,
|
|
187
|
+
tooltipPixelY: followMouse ? mouseY : finalPixelY,
|
|
186
188
|
x,
|
|
187
189
|
y,
|
|
188
190
|
color,
|