Files
grafana/public/app/plugins/panel/graph2/GraphPanel.tsx
Hugo Häggmark 4b3440325e Explore: Replaces TimeSeries with GraphSeriesXY (#18475)
* Wip: Compiles and runs

* WIP: Logs Graph partially working

* Refactor: Adds GraphSeriesToggler

* Refactor: Adds tickDecimals to YAxis

* Refactor: Adds TimeZone and PlotSelection to Graph

* Refactor: Makes the graphResult work in Explore

* Refactor: Adds ExploreGraphPanel that is used by Logs and Explore

* Fix: Fixes strange behaviour with ExploreMode not beeing changed

* Fix: Adds onSelectionChanged to GraphWithLegend

* Refactor: Cleans up unused comments

* ExploreGraph: Disable colorpicker
2019-08-13 07:32:43 +02:00

60 lines
1.6 KiB
TypeScript

import React from 'react';
import { PanelProps, GraphWithLegend /*, GraphSeriesXY*/ } from '@grafana/ui';
import { Options } from './types';
import { GraphPanelController } from './GraphPanelController';
import { LegendDisplayMode } from '@grafana/ui/src/components/Legend/Legend';
interface GraphPanelProps extends PanelProps<Options> {}
export const GraphPanel: React.FunctionComponent<GraphPanelProps> = ({
data,
timeRange,
timeZone,
width,
height,
options,
onOptionsChange,
}) => {
if (!data) {
return (
<div className="panel-empty">
<p>No data found in response</p>
</div>
);
}
const {
graph: { showLines, showBars, showPoints },
legend: legendOptions,
} = options;
const graphProps = {
showBars,
showLines,
showPoints,
};
const { asTable, isVisible, ...legendProps } = legendOptions;
return (
<GraphPanelController data={data} options={options} onOptionsChange={onOptionsChange}>
{({ onSeriesToggle, ...controllerApi }) => {
return (
<GraphWithLegend
timeRange={timeRange}
timeZone={timeZone}
width={width}
height={height}
displayMode={asTable ? LegendDisplayMode.Table : LegendDisplayMode.List}
isLegendVisible={isVisible}
sortLegendBy={legendOptions.sortBy}
sortLegendDesc={legendOptions.sortDesc}
onSeriesToggle={onSeriesToggle}
{...graphProps}
{...legendProps}
{...controllerApi}
/>
);
}}
</GraphPanelController>
);
};