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

View File

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

View File

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