-
Notifications
You must be signed in to change notification settings - Fork 5
DRAFT | SystemLink Data Frames Data Source | Enable high resolution zoom for numerical data in Plotly panel #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
be9b02b
c71cd25
b46168e
4dedd75
578f744
855bd7e
c99881e
323ca43
21bac2b
bc1fe33
dc9d310
cfa0dc3
2c28fe5
6fd5173
ed883e5
38b7ecd
67e638f
819522b
c64d41f
a10d448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import { | |
| } from '@grafana/data'; | ||
| import { AxisLabels, PanelOptions } from './types'; | ||
| import { useTheme2, ContextMenu, MenuItemsGroup, linkModelToContextMenuItems } from '@grafana/ui'; | ||
| import { getTemplateSrv, PanelDataErrorView } from '@grafana/runtime'; | ||
| import { getTemplateSrv, PanelDataErrorView, locationService } from '@grafana/runtime'; | ||
| import { getFieldsByName, notEmpty, Plot, renderMenuItems, useTraceColors } from './utils'; | ||
| import { AxisType, Legend, PlotData, PlotType, toImage, Icons, PlotlyHTMLElement } from 'plotly.js-basic-dist-min'; | ||
| import { saveAs } from 'file-saver'; | ||
|
|
@@ -28,7 +28,7 @@ interface MenuState { | |
| interface Props extends PanelProps<PanelOptions> {} | ||
|
|
||
| export const PlotlyPanel: React.FC<Props> = (props) => { | ||
| const { data, width, height, options } = props; | ||
| const { data, width, height, options, id, timeRange } = props; | ||
| const [menu, setMenu] = useState<MenuState>({ x: 0, y: 0, show: false, items: [] }); | ||
| const theme = useTheme2(); | ||
|
|
||
|
|
@@ -153,7 +153,25 @@ export const PlotlyPanel: React.FC<Props> = (props) => { | |
| props.onOptionsChange({...options, xAxis: { ...options.xAxis, min: from.valueOf(), max: to.valueOf() } }); | ||
| } | ||
| } else { | ||
| props.onOptionsChange({...options, xAxis: { ...options.xAxis, min: xAxisMin, max: xAxisMax } }); | ||
| const queryParams = locationService.getSearchObject(); | ||
| const fetchHighResolutionDataOnZoom = queryParams['fetchHighResolutionData']; | ||
|
|
||
| if ( | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When We need to refresh the dashboard as a whole because there aren't any out-of-the-box APIs available to handle this in any other optimised way. |
||
| fetchHighResolutionDataOnZoom !== undefined | ||
| && typeof fetchHighResolutionDataOnZoom === 'string' | ||
| && fetchHighResolutionDataOnZoom !== '' | ||
| && fetchHighResolutionDataOnZoom.split(',').includes(id.toString()) | ||
| ) { | ||
| locationService.partial({ | ||
| [`${options.xAxis.field}-min`]: Math.floor(xAxisMin), | ||
| [`${options.xAxis.field}-max`]: Math.ceil(xAxisMax) | ||
| }, true); | ||
| // (document.querySelector('[aria-label="Refresh dashboard"]') as HTMLButtonElement).click(); | ||
| props.onChangeTimeRange({ from: timeRange.from.valueOf() + 1, to: timeRange.to.valueOf() + 1 }); | ||
| props.onChangeTimeRange({ from: timeRange.from.valueOf(), to: timeRange.to.valueOf() }); | ||
| } else { | ||
| props.onOptionsChange({...options, xAxis: { ...options.xAxis, min: xAxisMin, max: xAxisMax } }); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "Plotly" panel is updated to handle zoom based on the query params state.
Hence, when the dashboard is loaded for the first time, the query params need to be updated.
I've added this here because this was the only place in the data source where both query and request values are available.