Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: decouple tooltip from XY chart #553

Merged
merged 18 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .playground/playground.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Chart, ScaleType, Position, Axis, getAxisId, timeFormatter, getSpecId, AreaSeries } from '../src';
import { Chart, ScaleType, Position, Axis, getAxisId, timeFormatter, getSpecId, AreaSeries, Settings } from '../src';
import { KIBANA_METRICS } from '../src/utils/data_samples/test_dataset_kibana';
export class Playground extends React.Component {
chartRef: React.RefObject<Chart> = React.createRef();
Expand All @@ -13,6 +13,7 @@ export class Playground extends React.Component {
<>
<div className="chart">
<Chart className={'story-chart'}>
<Settings showLegend={true} />
<Axis
id={getAxisId('bottom')}
title={'timestamp per 1 minute'}
Expand All @@ -33,7 +34,10 @@ export class Playground extends React.Component {
yScaleType={ScaleType.Linear}
xAccessor={0}
yAccessors={[1]}
data={KIBANA_METRICS.metrics.kibana_os_load[0].data}
y0Accessors={[2]}
data={KIBANA_METRICS.metrics.kibana_os_load[0].data.map((d) => {
return [...d, d[1] - 10];
})}
/>
</Chart>
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/0-Intro/1-Overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Return types:
```ts
type BarStyleAccessor = (
datum: RawDataSeriesDatum,
seriesIdentifier: SeriesIdentifier,
seriesIdentifier: XYChartSeriesIdentifier,
) => RecursivePartial<BarSeriesStyle> | Color | null;
```

Expand All @@ -250,7 +250,7 @@ Return types:
```ts
type PointStyleAccessor = (
datum: RawDataSeriesDatum,
seriesIdentifier: SeriesIdentifier,
seriesIdentifier: XYChartSeriesIdentifier,
) => RecursivePartial<PointStyle> | Color | null;
```

Expand Down
9 changes: 9 additions & 0 deletions src/chart_types/partition_chart/state/chart_state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ export class PartitionState implements InternalChartState {
getPointerCursor() {
return 'default';
}
isTooltipVisible() {
return false;
}
getTooltipInfo() {
return undefined;
}
getTooltipAnchor() {
return null;
}
}
114 changes: 41 additions & 73 deletions src/chart_types/xy_chart/crosshair/crosshair_utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getFinalTooltipPosition } from './crosshair_utils';
import { getFinalTooltipPosition } from '../../../components/tooltip/utils';

describe('Tooltip position', () => {
const container = {
Expand All @@ -19,15 +19,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: true,
vPosition: {
bandHeight: 0,
bandTop: 0,
},
hPosition: {
bandWidth: 0,
bandLeft: 10,
},
isRotated: false,
y1: 0,
y0: 0,
x0: 10,
x1: 10,
},
5,
);
Expand All @@ -39,15 +35,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: true,
vPosition: {
bandHeight: 0,
bandTop: 90,
},
hPosition: {
bandWidth: 0,
bandLeft: 10,
},
isRotated: false,
y0: 90,
y1: 90,
x0: 10,
x1: 10,
},
5,
);
Expand All @@ -59,15 +51,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: true,
vPosition: {
bandHeight: 0,
bandTop: 0,
},
hPosition: {
bandWidth: 0,
bandLeft: 100,
},
isRotated: false,
y0: 0,
y1: 0,
x0: 100,
x1: 100,
},
5,
);
Expand All @@ -79,15 +67,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: true,
vPosition: {
bandHeight: 0,
bandTop: 90,
},
hPosition: {
bandWidth: 0,
bandLeft: 100,
},
isRotated: false,
y0: 90,
y1: 90,
x0: 100,
x1: 100,
},
5,
);
Expand All @@ -101,15 +85,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: false,
vPosition: {
bandHeight: 0,
bandTop: 0,
},
hPosition: {
bandWidth: 0,
bandLeft: 10,
},
isRotated: true,
y0: 0,
y1: 0,
x1: 10,
x0: 10,
},
5,
);
Expand All @@ -121,15 +101,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: false,
vPosition: {
bandHeight: 0,
bandTop: 90,
},
hPosition: {
bandWidth: 0,
bandLeft: 10,
},
isRotated: true,
y0: 90,
y1: 90,
x1: 10,
x0: 10,
},
5,
);
Expand All @@ -141,15 +117,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: false,
vPosition: {
bandHeight: 0,
bandTop: 0,
},
hPosition: {
bandWidth: 0,
bandLeft: 100,
},
isRotated: true,
y0: 0,
y1: 0,
x1: 100,
x0: 100,
},
5,
);
Expand All @@ -161,15 +133,11 @@ describe('Tooltip position', () => {
container,
tooltip,
{
isRotatedHorizontal: false,
vPosition: {
bandHeight: 0,
bandTop: 90,
},
hPosition: {
bandWidth: 0,
bandLeft: 100,
},
isRotated: true,
y0: 90,
y1: 90,
x1: 100,
x0: 100,
},
5,
);
Expand Down
Loading