diff --git a/public/app/plugins/panel/graph2/getGraphSeriesModel.ts b/public/app/features/explore/flotgraph/getGraphSeriesModel.ts similarity index 100% rename from public/app/plugins/panel/graph2/getGraphSeriesModel.ts rename to public/app/features/explore/flotgraph/getGraphSeriesModel.ts diff --git a/public/app/plugins/panel/graph2/types.ts b/public/app/features/explore/flotgraph/types.ts similarity index 100% rename from public/app/plugins/panel/graph2/types.ts rename to public/app/features/explore/flotgraph/types.ts diff --git a/public/app/features/explore/utils/decorators.ts b/public/app/features/explore/utils/decorators.ts index f7d8770def9..7195b88766a 100644 --- a/public/app/features/explore/utils/decorators.ts +++ b/public/app/features/explore/utils/decorators.ts @@ -13,7 +13,7 @@ import { config } from '@grafana/runtime'; import { groupBy } from 'lodash'; import { ExplorePanelData } from '../../../types'; -import { getGraphSeriesModel } from '../../../plugins/panel/graph2/getGraphSeriesModel'; +import { getGraphSeriesModel } from '../flotgraph/getGraphSeriesModel'; import { dataFrameToLogsModel } from '../../../core/logs_model'; import { refreshIntervalToSortOrder } from '../../../core/utils/explore'; import { LegendDisplayMode } from '@grafana/ui'; diff --git a/public/app/features/plugins/built_in_plugins.ts b/public/app/features/plugins/built_in_plugins.ts index e7fc01e4365..cf7c19894fc 100644 --- a/public/app/features/plugins/built_in_plugins.ts +++ b/public/app/features/plugins/built_in_plugins.ts @@ -39,7 +39,6 @@ const tempoPlugin = async () => await import(/* webpackChunkName: "tempoPlugin" */ 'app/plugins/datasource/tempo/module'); import * as textPanel from 'app/plugins/panel/text/module'; -import * as graph2Panel from 'app/plugins/panel/graph2/module'; import * as graph3Panel from 'app/plugins/panel/graph3/module'; import * as graphPanel from 'app/plugins/panel/graph/module'; import * as dashListPanel from 'app/plugins/panel/dashlist/module'; @@ -82,7 +81,6 @@ const builtInPlugins: any = { 'app/plugins/datasource/tempo/module': tempoPlugin, 'app/plugins/panel/text/module': textPanel, - 'app/plugins/panel/graph2/module': graph2Panel, 'app/plugins/panel/graph3/module': graph3Panel, 'app/plugins/panel/graph/module': graphPanel, 'app/plugins/panel/dashlist/module': dashListPanel, diff --git a/public/app/plugins/panel/graph2/GraphPanel.tsx b/public/app/plugins/panel/graph2/GraphPanel.tsx deleted file mode 100644 index 5f25ed020eb..00000000000 --- a/public/app/plugins/panel/graph2/GraphPanel.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -import { GraphWithLegend, Chart } from '@grafana/ui'; -import { PanelProps } from '@grafana/data'; -import { Options } from './types'; -import { GraphPanelController } from './GraphPanelController'; - -interface GraphPanelProps extends PanelProps {} - -export const GraphPanel: React.FunctionComponent = ({ - data, - timeRange, - timeZone, - width, - height, - options, - fieldConfig, - onOptionsChange, - onChangeTimeRange, -}) => { - if (!data) { - return ( -
-

No data found in response

-
- ); - } - - const { - graph: { showLines, showBars, showPoints }, - legend: legendOptions, - tooltipOptions, - } = options; - - const graphProps = { - showBars, - showLines, - showPoints, - tooltipOptions, - }; - return ( - - {({ onSeriesToggle, onHorizontalRegionSelected, ...controllerApi }) => { - return ( - - - - ); - }} - - ); -}; diff --git a/public/app/plugins/panel/graph2/GraphPanelController.tsx b/public/app/plugins/panel/graph2/GraphPanelController.tsx deleted file mode 100644 index 72c70029450..00000000000 --- a/public/app/plugins/panel/graph2/GraphPanelController.tsx +++ /dev/null @@ -1,149 +0,0 @@ -import React from 'react'; -import { GraphSeriesToggler } from '@grafana/ui'; -import { PanelData, GraphSeriesXY, AbsoluteTimeRange, TimeZone, FieldConfigSource } from '@grafana/data'; - -import { getGraphSeriesModel } from './getGraphSeriesModel'; -import { Options, SeriesOptions } from './types'; -import { SeriesColorChangeHandler, SeriesAxisToggleHandler } from '@grafana/ui/src/components/Graph/GraphWithLegend'; - -interface GraphPanelControllerAPI { - series: GraphSeriesXY[]; - onSeriesAxisToggle: SeriesAxisToggleHandler; - onSeriesColorChange: SeriesColorChangeHandler; - onSeriesToggle: (label: string, event: React.MouseEvent) => void; - onToggleSort: (sortBy: string) => void; - onHorizontalRegionSelected: (from: number, to: number) => void; -} - -interface GraphPanelControllerProps { - children: (api: GraphPanelControllerAPI) => JSX.Element; - options: Options; - fieldConfig: FieldConfigSource; - data: PanelData; - timeZone: TimeZone; - onOptionsChange: (options: Options) => void; - onChangeTimeRange: (timeRange: AbsoluteTimeRange) => void; -} - -interface GraphPanelControllerState { - graphSeriesModel: GraphSeriesXY[]; -} - -export class GraphPanelController extends React.Component { - constructor(props: GraphPanelControllerProps) { - super(props); - - this.onSeriesColorChange = this.onSeriesColorChange.bind(this); - this.onSeriesAxisToggle = this.onSeriesAxisToggle.bind(this); - this.onToggleSort = this.onToggleSort.bind(this); - this.onHorizontalRegionSelected = this.onHorizontalRegionSelected.bind(this); - - this.state = { - graphSeriesModel: getGraphSeriesModel( - props.data.series, - props.timeZone, - props.options.series || {}, - props.options.graph, - props.options.legend, - props.fieldConfig - ), - }; - } - - static getDerivedStateFromProps(props: GraphPanelControllerProps, state: GraphPanelControllerState) { - return { - ...state, - graphSeriesModel: getGraphSeriesModel( - props.data.series, - props.timeZone, - props.options.series || {}, - props.options.graph, - props.options.legend, - props.fieldConfig - ), - }; - } - - onSeriesOptionsUpdate(label: string, optionsUpdate: SeriesOptions) { - const { onOptionsChange, options } = this.props; - const updatedSeriesOptions: { [label: string]: SeriesOptions } = { ...options.series }; - updatedSeriesOptions[label] = optionsUpdate; - onOptionsChange({ - ...options, - series: updatedSeriesOptions, - }); - } - - onSeriesAxisToggle(label: string, yAxis: number) { - const { - options: { series }, - } = this.props; - const seriesOptionsUpdate: SeriesOptions = series[label] - ? { - ...series[label], - yAxis: { - ...series[label].yAxis, - index: yAxis, - }, - } - : { - yAxis: { - index: yAxis, - }, - }; - this.onSeriesOptionsUpdate(label, seriesOptionsUpdate); - } - - onSeriesColorChange(label: string, color: string) { - const { - options: { series }, - } = this.props; - const seriesOptionsUpdate: SeriesOptions = series[label] - ? { - ...series[label], - color, - } - : { - color, - }; - - this.onSeriesOptionsUpdate(label, seriesOptionsUpdate); - } - - onToggleSort(sortBy: string) { - const { onOptionsChange, options } = this.props; - onOptionsChange({ - ...options, - legend: { - ...options.legend, - sortBy, - sortDesc: sortBy === options.legend.sortBy ? !options.legend.sortDesc : false, - }, - }); - } - - onHorizontalRegionSelected(from: number, to: number) { - const { onChangeTimeRange } = this.props; - onChangeTimeRange({ from, to }); - } - - render() { - const { children } = this.props; - const { graphSeriesModel } = this.state; - - return ( - - {({ onSeriesToggle, toggledSeries }) => { - return children({ - series: toggledSeries, - onSeriesColorChange: this.onSeriesColorChange, - onSeriesAxisToggle: this.onSeriesAxisToggle, - onToggleSort: this.onToggleSort, - onSeriesToggle: onSeriesToggle, - onHorizontalRegionSelected: this.onHorizontalRegionSelected, - }); - }} - - ); - } -} diff --git a/public/app/plugins/panel/graph2/README.md b/public/app/plugins/panel/graph2/README.md deleted file mode 100644 index 667ab51784a..00000000000 --- a/public/app/plugins/panel/graph2/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Text Panel - Native Plugin - -The Text Panel is **included** with Grafana. - -The Text Panel is a very simple panel that displays text. The source text is written in the Markdown syntax meaning you can format the text. Read [GitHub's Mastering Markdown](https://guides.github.com/features/mastering-markdown/) to learn more. diff --git a/public/app/plugins/panel/graph2/img/icn-graph-panel.svg b/public/app/plugins/panel/graph2/img/icn-graph-panel.svg deleted file mode 100644 index eefedfb679a..00000000000 --- a/public/app/plugins/panel/graph2/img/icn-graph-panel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/app/plugins/panel/graph2/module.tsx b/public/app/plugins/panel/graph2/module.tsx deleted file mode 100644 index 1eb3400183d..00000000000 --- a/public/app/plugins/panel/graph2/module.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { PanelPlugin } from '@grafana/data'; -import { GraphPanel } from './GraphPanel'; -import { Options } from './types'; - -export const plugin = new PanelPlugin(GraphPanel).useFieldConfig().setPanelOptions(builder => { - builder - .addBooleanSwitch({ - path: 'graph.showBars', - name: 'Show bars', - description: '', - defaultValue: false, - }) - .addBooleanSwitch({ - path: 'graph.showLines', - name: 'Show lines', - description: '', - defaultValue: true, - }) - .addBooleanSwitch({ - path: 'graph.showPoints', - name: 'Show poins', - description: '', - defaultValue: false, - }) - .addBooleanSwitch({ - path: 'legend.isVisible', - name: 'Show legend', - description: '', - defaultValue: true, - }) - .addBooleanSwitch({ - path: 'legend.asTable', - name: 'Display legend as table', - description: '', - defaultValue: false, - }) - .addRadio({ - path: 'legend.placement', - name: 'Legend placement', - description: '', - defaultValue: 'under', - settings: { - options: [ - { value: 'under', label: 'Below graph' }, - { value: 'right', label: 'Right to the graph' }, - ], - }, - }) - .addRadio({ - path: 'tooltipOptions.mode', - name: 'Tooltip mode', - description: '', - defaultValue: 'single', - settings: { - options: [ - { value: 'single', label: 'Single series' }, - { value: 'multi', label: 'All series' }, - ], - }, - }); -}); diff --git a/public/app/plugins/panel/graph2/plugin.json b/public/app/plugins/panel/graph2/plugin.json deleted file mode 100644 index e39a28ff047..00000000000 --- a/public/app/plugins/panel/graph2/plugin.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "type": "panel", - "name": "React graph", - "id": "graph2", - "state": "alpha", - - "info": { - "author": { - "name": "Grafana Labs", - "url": "https://grafana.com" - }, - "logos": { - "small": "img/icn-graph-panel.svg", - "large": "img/icn-graph-panel.svg" - } - } -}