Geomap: support hide from tooltip (#43127)

This commit is contained in:
Ryan McKinley 2021-12-14 15:32:17 -08:00 committed by GitHub
parent 198f947d0b
commit c2392598ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View File

@ -43,7 +43,9 @@ export class DataHoverView extends PureComponent<Props> {
return (
<table className={this.style.infoWrap}>
<tbody>
{data.fields.map((f, i) => (
{data.fields
.filter((f) => !Boolean(f.config.custom?.hideFrom?.tooltip))
.map((f, i) => (
<tr key={`${i}/${rowIndex}`} className={i === columnIndex ? this.style.highlight : ''}>
<th>{getFieldDisplayName(f, data)}:</th>
<td>{fmt(f, rowIndex)}</td>

View File

@ -7,12 +7,17 @@ import { mapPanelChangedHandler, mapMigrationHandler } from './migrations';
import { getLayerEditor } from './editor/layerEditor';
import { LayersEditor } from './editor/LayersEditor';
import { config } from '@grafana/runtime';
import { commonOptionsBuilder } from '@grafana/ui';
export const plugin = new PanelPlugin<GeomapPanelOptions>(GeomapPanel)
.setNoPadding()
.setPanelChangeHandler(mapPanelChangedHandler)
.setMigrationHandler(mapMigrationHandler)
.useFieldConfig()
.useFieldConfig({
useCustomConfig: (builder) => {
commonOptionsBuilder.addHideFrom(builder);
},
})
.setPanelOptions((builder, context) => {
let category = ['Map view'];
builder.addCustomEditor({

View File

@ -1,4 +1,5 @@
import { MapLayerHandler, MapLayerOptions, SelectableValue } from '@grafana/data';
import { HideableFieldConfig } from '@grafana/schema';
import { LayerElement } from 'app/core/components/Layers/types';
import BaseLayer from 'ol/layer/Base';
import { Units } from 'ol/proj/Units';
@ -40,6 +41,11 @@ export const defaultView: MapViewConfig = {
zoom: 1,
};
/** Support hide from legend/tooltip */
export interface GeomapFieldConfig extends HideableFieldConfig {
// nothing custom yet
}
export interface GeomapPanelOptions {
view: MapViewConfig;
controls: ControlsOptions;