From 4a653c7d31e3f2b59a544740191765b2a3edaa7c Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 27 Sep 2022 11:33:04 -0400 Subject: [PATCH] XYChart further improvements (#55152) (#55846) * Tooltip shows all data facets. Renamed options * Add per series line style * Remove line style option from manual panel options * Refactored tooltip view * sets selected after switch to manual * remove facet prefixes * in manual mode pull series names from config options, not y facet * unused import * Point size * x & y axes labels * Fix manual series prep * betterer Co-authored-by: Ryan McKinley Co-authored-by: Leon Sorokin (cherry picked from commit 3361f2c62da2c6ea97425feff0ef330ce9b57d63) Co-authored-by: Victor Marin <36818606+mdvictor@users.noreply.github.com> --- .betterer.results | 3 + .../plugins/panel/xychart/ManualEditor.tsx | 35 +++-- .../app/plugins/panel/xychart/TooltipView.tsx | 139 +++++++++--------- .../plugins/panel/xychart/XYChartPanel2.tsx | 17 ++- public/app/plugins/panel/xychart/config.ts | 37 ++--- .../app/plugins/panel/xychart/models.gen.ts | 30 ++-- public/app/plugins/panel/xychart/module.tsx | 8 +- public/app/plugins/panel/xychart/scatter.ts | 100 +++++++------ public/app/plugins/panel/xychart/types.ts | 8 +- 9 files changed, 205 insertions(+), 172 deletions(-) diff --git a/.betterer.results b/.betterer.results index dde6c04bddb..4033d667fe5 100644 --- a/.betterer.results +++ b/.betterer.results @@ -8957,6 +8957,9 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"] ], + "public/app/plugins/panel/xychart/TooltipView.tsx:5381": [ + [0, 0, 0, "Do not use any type assertions.", "0"] + ], "public/app/plugins/panel/xychart/XYChartPanel2.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], diff --git a/public/app/plugins/panel/xychart/ManualEditor.tsx b/public/app/plugins/panel/xychart/ManualEditor.tsx index 99ae51ca050..a81a7cca5b3 100644 --- a/public/app/plugins/panel/xychart/ManualEditor.tsx +++ b/public/app/plugins/panel/xychart/ManualEditor.tsx @@ -1,5 +1,5 @@ import { css, cx } from '@emotion/css'; -import React, { FC, useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { GrafanaTheme, StandardEditorProps } from '@grafana/data'; import { Button, Field, IconButton, useStyles } from '@grafana/ui'; @@ -9,12 +9,12 @@ import { ColorDimensionEditor, ScaleDimensionEditor } from 'app/features/dimensi import { XYChartOptions, ScatterSeriesConfig, defaultScatterConfig } from './models.gen'; -export const ManualEditor: FC> = ({ +export const ManualEditor = ({ value, onChange, context, -}) => { - const [selected, setSelected] = useState(-1); +}: StandardEditorProps) => { + const [selected, setSelected] = useState(0); const style = useStyles(getStyles); const onFieldChange = (val: any | undefined, index: number, field: string) => { @@ -36,22 +36,27 @@ export const ManualEditor: FC { + if (!value?.length) { + createNewSeries(); // adds a new series + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + const onSeriesDelete = (index: number) => { onChange(value.filter((_, i) => i !== index)); }; - const { options } = context; + // const { options } = context; const getRowStyle = (index: number) => { return index === selected ? `${style.row} ${style.sel}` : style.row; }; - if (options === undefined || !options.series) { - return null; - } - return ( <>