|
1 | 1 | import { BarGeometry } from '../rendering/rendering'; |
2 | 2 | import { computeXScale, computeYScales } from '../utils/scales'; |
3 | 3 | import { DataSeriesColorsValues } from '../utils/series'; |
4 | | -import { BarSeriesSpec, BasicSeriesSpec, RectAnnotationSpec } from '../utils/specs'; |
5 | | -import { getAnnotationId, getGroupId, getSpecId } from '../../../utils/ids'; |
| 4 | +import { BarSeriesSpec, BasicSeriesSpec, RectAnnotationSpec, Position } from '../utils/specs'; |
| 5 | +import { getAnnotationId, getGroupId, getSpecId, getAxisId } from '../../../utils/ids'; |
6 | 6 | import { TooltipType } from '../utils/interactions'; |
7 | 7 | import { ScaleContinuous } from '../../../utils/scales/scale_continuous'; |
8 | 8 | import { ScaleType } from '../../../utils/scales/scales'; |
@@ -392,4 +392,42 @@ function mouseOverTestSuite(scaleType: ScaleType) { |
392 | 392 | expect(store.tooltipPosition.transform).toBe(expectedTransform); |
393 | 393 | }); |
394 | 394 | }); |
| 395 | + describe('can format tooltip values on rotated chart', () => { |
| 396 | + beforeEach(() => { |
| 397 | + store.addAxisSpec({ |
| 398 | + hide: true, |
| 399 | + id: getAxisId('yaxis'), |
| 400 | + groupId: GROUP_ID, |
| 401 | + position: Position.Left, |
| 402 | + tickFormat: (value) => `left ${Number(value)}`, |
| 403 | + showOverlappingLabels: false, |
| 404 | + showOverlappingTicks: false, |
| 405 | + tickPadding: 0, |
| 406 | + tickSize: 0, |
| 407 | + }); |
| 408 | + store.addAxisSpec({ |
| 409 | + hide: true, |
| 410 | + id: getAxisId('xaxis'), |
| 411 | + groupId: GROUP_ID, |
| 412 | + position: Position.Bottom, |
| 413 | + tickFormat: (value) => `bottom ${Number(value)}`, |
| 414 | + showOverlappingLabels: false, |
| 415 | + showOverlappingTicks: false, |
| 416 | + tickPadding: 0, |
| 417 | + tickSize: 0, |
| 418 | + }); |
| 419 | + }); |
| 420 | + test('chart 0 rotation', () => { |
| 421 | + store.setCursorPosition(chartLeft + 0, chartTop + 99); |
| 422 | + expect(store.tooltipData[0].value).toBe('bottom 0'); |
| 423 | + expect(store.tooltipData[1].value).toBe('left 10'); |
| 424 | + }); |
| 425 | + |
| 426 | + test('chart 90 deg rotated', () => { |
| 427 | + store.chartRotation = 90; |
| 428 | + store.setCursorPosition(chartLeft + 0, chartTop + 99); |
| 429 | + expect(store.tooltipData[0].value).toBe('left 1'); |
| 430 | + expect(store.tooltipData[1].value).toBe('bottom 5'); |
| 431 | + }); |
| 432 | + }); |
395 | 433 | } |
0 commit comments