-
+
JSX.Element;
- onSeriesColorChange?: SeriesColorChangeHandler;
onLabelClick?: (item: VizLegendItem, event: React.MouseEvent ) => void;
onLabelMouseEnter?: (item: VizLegendItem, event: React.MouseEvent) => void;
onLabelMouseOut?: (item: VizLegendItem, event: React.MouseEvent) => void;
@@ -33,6 +32,3 @@ export interface VizLegendItem {
getDisplayValues?: () => DisplayValue[];
fieldIndex?: DataFrameFieldIndex;
}
-
-export type SeriesOptionChangeHandler = (label: string, option: TOption) => void;
-export type SeriesColorChangeHandler = SeriesOptionChangeHandler;
diff --git a/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx b/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx
index e1d9bbd110a..dcf575bf342 100644
--- a/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx
+++ b/packages/grafana-ui/src/components/uPlot/PlotLegend.tsx
@@ -14,14 +14,12 @@ const defaultFormatter = (v: any) => (v == null ? '-' : v.toFixed(1));
interface PlotLegendProps extends VizLegendOptions, Omit {
data: DataFrame[];
config: UPlotConfigBuilder;
- onSeriesColorChange?: (label: string, color: string) => void;
onLegendClick?: (event: GraphNGLegendEvent) => void;
}
export const PlotLegend: React.FC = ({
data,
config,
- onSeriesColorChange,
onLegendClick,
placement,
calcs,
@@ -99,7 +97,6 @@ export const PlotLegend: React.FC = ({
placement={placement}
items={legendItems}
displayMode={displayMode}
- onSeriesColorChange={onSeriesColorChange}
/>
);
diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx
index 984216ca447..881c3e76d14 100644
--- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx
+++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx
@@ -29,6 +29,7 @@ import {
import { selectors } from '@grafana/e2e-selectors';
import { loadSnapshotData } from '../utils/loadSnapshotData';
import { RefreshEvent, RenderEvent } from 'app/types/events';
+import { changeSeriesColorConfigFactory } from 'app/plugins/panel/timeseries/overrides/colorSeriesConfigFactory';
const DEFAULT_PLUGIN_ERROR = 'Error in plugin';
@@ -75,11 +76,16 @@ export class PanelChrome extends Component {
refreshWhenInView: false,
context: {
eventBus,
+ onSeriesColorChange: this.onSeriesColorChange,
},
data: this.getInitialPanelDataState(),
};
}
+ onSeriesColorChange = (label: string, color: string) => {
+ this.onFieldConfigChange(changeSeriesColorConfigFactory(label, color, this.props.panel.fieldConfig));
+ };
+
getInitialPanelDataState(): PanelData {
return {
state: LoadingState.NotStarted,
diff --git a/public/app/plugins/panel/barchart/BarChartPanel.tsx b/public/app/plugins/panel/barchart/BarChartPanel.tsx
index f8b2073ca8b..78f6d9e9f73 100755
--- a/public/app/plugins/panel/barchart/BarChartPanel.tsx
+++ b/public/app/plugins/panel/barchart/BarChartPanel.tsx
@@ -1,7 +1,6 @@
import React, { useCallback, useMemo } from 'react';
import { FieldType, PanelProps, VizOrientation } from '@grafana/data';
import { BarChart, BarChartOptions, GraphNGLegendEvent } from '@grafana/ui';
-import { changeSeriesColorConfigFactory } from '../timeseries/overrides/colorSeriesConfigFactory';
import { hideSeriesConfigFactory } from '../timeseries/overrides/hideSeriesConfigFactory';
interface Props extends PanelProps {}
@@ -32,13 +31,6 @@ export const BarChartPanel: React.FunctionComponent = ({
[fieldConfig, onFieldConfigChange, data.series]
);
- const onSeriesColorChange = useCallback(
- (label: string, color: string) => {
- onFieldConfigChange(changeSeriesColorConfigFactory(label, color, fieldConfig));
- },
- [fieldConfig, onFieldConfigChange]
- );
-
if (!data || !data.series?.length) {
return (
@@ -70,7 +62,6 @@ export const BarChartPanel: React.FunctionComponent = ({
width={width}
height={height}
onLegendClick={onLegendClick}
- onSeriesColorChange={onSeriesColorChange}
{...options}
orientation={orientation}
/>
diff --git a/public/app/plugins/panel/piechart/PieChartPanel.tsx b/public/app/plugins/panel/piechart/PieChartPanel.tsx
index cfad454589c..167182b332c 100644
--- a/public/app/plugins/panel/piechart/PieChartPanel.tsx
+++ b/public/app/plugins/panel/piechart/PieChartPanel.tsx
@@ -1,8 +1,7 @@
-import React, { useCallback } from 'react';
+import React from 'react';
import { PieChart } from '@grafana/ui';
import { PieChartOptions } from './types';
import { PanelProps } from '@grafana/data';
-import { changeSeriesColorConfigFactory } from '../timeseries/overrides/colorSeriesConfigFactory';
interface Props extends PanelProps {}
@@ -16,13 +15,6 @@ export const PieChartPanel: React.FC = ({
fieldConfig,
timeZone,
}) => {
- const onSeriesColorChange = useCallback(
- (label: string, color: string) => {
- onFieldConfigChange(changeSeriesColorConfigFactory(label, color, fieldConfig));
- },
- [fieldConfig, onFieldConfigChange]
- );
-
return (
= ({
reduceOptions={options.reduceOptions}
replaceVariables={replaceVariables}
data={data.series}
- onSeriesColorChange={onSeriesColorChange}
pieType={options.pieType}
displayLabels={options.displayLabels}
legendOptions={options.legend}
diff --git a/public/app/plugins/panel/timeline/TimelinePanel.tsx b/public/app/plugins/panel/timeline/TimelinePanel.tsx
index c1d31ea1299..629ba7d32a0 100755
--- a/public/app/plugins/panel/timeline/TimelinePanel.tsx
+++ b/public/app/plugins/panel/timeline/TimelinePanel.tsx
@@ -1,7 +1,6 @@
import React, { useCallback } from 'react';
import { PanelProps } from '@grafana/data';
import { GraphNGLegendEvent, TimelineChart, TimelineOptions } from '@grafana/ui';
-import { changeSeriesColorConfigFactory } from '../timeseries/overrides/colorSeriesConfigFactory';
import { hideSeriesConfigFactory } from '../timeseries/overrides/hideSeriesConfigFactory';
interface TimelinePanelProps extends PanelProps {}
@@ -26,13 +25,6 @@ export const TimelinePanel: React.FC = ({
[fieldConfig, onFieldConfigChange, data.series]
);
- const onSeriesColorChange = useCallback(
- (label: string, color: string) => {
- onFieldConfigChange(changeSeriesColorConfigFactory(label, color, fieldConfig));
- },
- [fieldConfig, onFieldConfigChange]
- );
-
if (!data || !data.series?.length) {
return (
@@ -50,7 +42,6 @@ export const TimelinePanel: React.FC = ({
width={width}
height={height}
onLegendClick={onLegendClick}
- onSeriesColorChange={onSeriesColorChange}
{...options}
/>
);
diff --git a/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx b/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx
index fc64d4bec62..873047033ad 100644
--- a/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx
+++ b/public/app/plugins/panel/timeseries/TimeSeriesPanel.tsx
@@ -2,7 +2,6 @@ import { Field, PanelProps } from '@grafana/data';
import { GraphNG, GraphNGLegendEvent, TooltipPlugin, ZoomPlugin } from '@grafana/ui';
import { getFieldLinksForExplore } from 'app/features/explore/utils/links';
import React, { useCallback } from 'react';
-import { changeSeriesColorConfigFactory } from './overrides/colorSeriesConfigFactory';
import { hideSeriesConfigFactory } from './overrides/hideSeriesConfigFactory';
import { AnnotationsPlugin } from './plugins/AnnotationsPlugin';
import { ContextMenuPlugin } from './plugins/ContextMenuPlugin';
@@ -34,13 +33,6 @@ export const TimeSeriesPanel: React.FC = ({
return getFieldLinksForExplore({ field, rowIndex, range: timeRange });
};
- const onSeriesColorChange = useCallback(
- (label: string, color: string) => {
- onFieldConfigChange(changeSeriesColorConfigFactory(label, color, fieldConfig));
- },
- [fieldConfig, onFieldConfigChange]
- );
-
if (!data || !data.series?.length) {
return (
@@ -59,7 +51,6 @@ export const TimeSeriesPanel: React.FC = ({
height={height}
legend={options.legend}
onLegendClick={onLegendClick}
- onSeriesColorChange={onSeriesColorChange}
>
{(config, alignedDataFrame) => {
return (
diff --git a/public/app/plugins/panel/xychart/XYChartPanel.tsx b/public/app/plugins/panel/xychart/XYChartPanel.tsx
index 3a9aa848f10..5a02c2d3baf 100644
--- a/public/app/plugins/panel/xychart/XYChartPanel.tsx
+++ b/public/app/plugins/panel/xychart/XYChartPanel.tsx
@@ -4,7 +4,6 @@ import { PanelProps } from '@grafana/data';
import { Options } from './types';
import { hideSeriesConfigFactory } from '../timeseries/overrides/hideSeriesConfigFactory';
import { getXYDimensions } from './dims';
-import { changeSeriesColorConfigFactory } from '../timeseries/overrides/colorSeriesConfigFactory';
interface XYChartPanelProps extends PanelProps {}
@@ -29,13 +28,6 @@ export const XYChartPanel: React.FC = ({
[fieldConfig, onFieldConfigChange, frames]
);
- const onSeriesColorChange = useCallback(
- (label: string, color: string) => {
- onFieldConfigChange(changeSeriesColorConfigFactory(label, color, fieldConfig));
- },
- [fieldConfig, onFieldConfigChange]
- );
-
if (dims.error) {
return (
@@ -61,7 +53,6 @@ export const XYChartPanel: React.FC = ({
height={height}
legend={options.legend}
onLegendClick={onLegendClick}
- onSeriesColorChange={onSeriesColorChange}
>
{(config, alignedDataFrame) => {
return (
|