From d718684300e5a4c2a243744cd641b606c28b6c4f Mon Sep 17 00:00:00 2001 From: vargburz Date: Thu, 21 Jul 2022 19:12:12 +0300 Subject: [PATCH] Grafana Legend --- src/components/Panel.tsx | 32 ++++++++++++++++++++++---------- src/models/options/barOptions.ts | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/components/Panel.tsx b/src/components/Panel.tsx index 6bf5f7b..8508b51 100644 --- a/src/components/Panel.tsx +++ b/src/components/Panel.tsx @@ -11,6 +11,8 @@ import { ChartwerkGaugePod } from '@chartwerk/gauge-pod'; import { ChartwerkBarPod } from '@chartwerk/bar-pod'; import { PanelData, TimeRange, PanelProps } from '@grafana/data'; +import { VizLegend } from '@grafana/ui'; +import { LegendDisplayMode } from '@grafana/schema'; import React, { useRef } from 'react'; import { css } from 'emotion'; @@ -52,17 +54,27 @@ export function Panel({ options, data, width, height, timeRange, onChangeTimeRan } window.open(options.gauge.link, '_self'); }; - + const legendItems = [ + { label: 'metric1', yAxis: 100, color: 'red' }, + { label: 'metric2', yAxis: 200, color: 'green' }, + ]; return ( -
+
+
+ +
); } diff --git a/src/models/options/barOptions.ts b/src/models/options/barOptions.ts index b45e09f..4feb9fd 100644 --- a/src/models/options/barOptions.ts +++ b/src/models/options/barOptions.ts @@ -26,6 +26,7 @@ export class BarOptions { scroll: { zoom: { isActive: false }, pan: { isActive: false } }, mouse: { doubleClick: { isActive: false } }, }, + renderLegend: false, annotations: [ { key: 'm-1', color: 'red' }, { key: 'm-2', color: 'green' },