import React from 'react'; import AutoSizer from 'react-virtualized-auto-sizer'; import { AbsoluteTimeRange, FieldConfigSource, toUtc } from '@grafana/data'; import { PanelRenderer } from '@grafana/runtime'; import { Field, PanelChrome, Input } from '@grafana/ui'; import { SceneObjectBase } from '../core/SceneObjectBase'; import { SceneComponentProps, SceneLayoutChildState } from '../core/types'; export interface VizPanelState extends SceneLayoutChildState { title?: string; pluginId: string; options?: object; fieldConfig?: FieldConfigSource; } export class VizPanel extends SceneObjectBase { static Component = ScenePanelRenderer; static Editor = VizPanelEditor; onSetTimeRange = (timeRange: AbsoluteTimeRange) => { const sceneTimeRange = this.getTimeRange(); sceneTimeRange.setState({ raw: { from: toUtc(timeRange.from), to: toUtc(timeRange.to), }, from: toUtc(timeRange.from), to: toUtc(timeRange.to), }); }; } function ScenePanelRenderer({ model }: SceneComponentProps) { const { title, pluginId, options, fieldConfig } = model.useState(); const { data } = model.getData().useState(); return ( {({ width, height }) => { if (width < 3 || height < 3) { return null; } return ( {(innerWidth, innerHeight) => ( <> {}} onChangeTimeRange={model.onSetTimeRange} /> )} ); }} ); } ScenePanelRenderer.displayName = 'ScenePanelRenderer'; function VizPanelEditor({ model }: SceneComponentProps) { const { title } = model.useState(); return ( model.setState({ title: evt.currentTarget.value })} /> ); }