Geomap: implement basic tooltip support (#37318)

Co-authored-by: Bryan Uribe <buribe@hmc.edu>
This commit is contained in:
Ryan McKinley
2021-07-28 18:34:42 -07:00
committed by GitHub
parent 8b80d2256d
commit ced26bc624
7 changed files with 174 additions and 24 deletions

View File

@ -1,3 +1,4 @@
import React, { Component } from 'react';
import {
EventBus,
LegacyGraphHoverEvent,
@ -7,8 +8,9 @@ import {
DataHoverPayload,
BusEventWithPayload,
} from '@grafana/data';
import React, { Component } from 'react';
import { Subscription } from 'rxjs';
import { CustomScrollbar } from '@grafana/ui';
import { DataHoverView } from '../geomap/components/DataHoverView';
interface Props {
eventBus: EventBus;
@ -58,12 +60,16 @@ export class CursorView extends Component<Props, State> {
if (!event) {
return <div>no events yet</div>;
}
const { type, payload, origin } = event;
return (
<div>
<h2>Origin: {(event.origin as any)?.path}</h2>
<span>Type: {event.type}</span>
<pre>{JSON.stringify(event.payload.point, null, ' ')}</pre>
</div>
<CustomScrollbar autoHeightMin="100%" autoHeightMax="100%">
<h3>Origin: {(origin as any)?.path}</h3>
<span>Type: {type}</span>
<pre>{JSON.stringify(payload.point, null, ' ')}</pre>
{payload.data && (
<DataHoverView data={payload.data} rowIndex={payload.rowIndex} columnIndex={payload.columnIndex} />
)}
</CustomScrollbar>
);
}
}