Files
grafana/public/app/plugins/panel/graph2/GraphPanel.tsx

60 lines
1.6 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { PanelProps, GraphWithLegend /*, GraphSeriesXY*/ } from '@grafana/ui';
2018-12-17 13:55:25 +01:00
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) {
2018-12-17 13:55:25 +01:00
return (
<div className="panel-empty">
<p>No data found in response</p>
</div>
2018-12-17 13:55:25 +01:00
);
}
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>
);
};