Skip to content
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

demo: alternative time range selection on timeseries panel #744

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

darrenjaneczek
Copy link
Contributor

This demo uses a custom implementation of SceneTimeRangeLike to overrides the default time range selection behavior to capture the selection, store it in a different time range, and display it on the panel as an annotation.

override-scenes-timerange-behavior-to-set-annotation-for-alt-timerange.webm

@@ -152,7 +152,7 @@ export function SceneRefreshPickerRenderer({ model }: SceneComponentProps<SceneR
const { refresh, intervals, autoEnabled, autoValue, isOnCanvas, primary, withText } = model.useState();
const isRunning = useQueryControllerState(model);

let text = refresh === RefreshPicker.autoOption.value ? autoValue : withText ? 'Refresh' : undefined;
let text = refresh === RefreshPicker.autoOption?.value ? autoValue : withText ? 'Refresh' : undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that autoOption was undefined, causing a few demos to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leeoniya
Copy link
Contributor

leeoniya commented May 23, 2024

perhaps loosely related: grafana/grafana#88107

considering adding onSelectRange() callback to panelContext. maybe also onClickDataPoint() callback in near future.

feels like we maybe should introduce some kind of point annotations (besides exemplars), and x+y rectangular annotations? 🤔

@darrenjaneczek
Copy link
Contributor Author

perhaps loosely related: grafana/grafana#88107

considering adding onSelectRange() callback to panelContext. maybe also onClickDataPoint() callback in near future.

feels like we maybe should introduce some kind of point annotations (besides exemplars), and x+y rectangular annotations? 🤔

Yes, quite related.
This one is more tied to time range selection. The other can be two-dimensional.

If panels could all generally have alternative behaviors for range selection, I think that could simplify this greatly.

For this specific implementation, it would also be really interesting to be able to modify the range of the annotation by dragging the left or right edges. Can that be achieved simply by manipulating the panel context?

@leeoniya
Copy link
Contributor

leeoniya commented May 23, 2024

Can that be achieved simply by manipulating the panel context?

that would be super expensive to do on mousemove, since requires redraw. but maybe via eventBus/signals or smth. but in general allowing selections to be resized should be built into the panels. if you need to custom set it once via props/fieldConfig, then that should be fast enough, too.

cc @dprokop

[
(vizPanel: VizPanel) => {
patchPanelContext(vizPanel);
const altTimeRangeScene = sceneGraph.findObject(vizPanel, (scene) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be nice to have a sceneGraph.findKey(s: string) function

Copy link
Contributor Author

@darrenjaneczek darrenjaneczek May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darrenjaneczek darrenjaneczek self-assigned this May 24, 2024
@darrenjaneczek darrenjaneczek force-pushed the demo/alt-timerange-selector branch from c49f8e9 to fed4429 Compare June 3, 2024 13:27
@darrenjaneczek darrenjaneczek force-pushed the demo/alt-timerange-selector branch from fed4429 to 9a19743 Compare August 1, 2024 20:17
@leeoniya
Copy link
Contributor

leeoniya commented Aug 1, 2024

@darrenjaneczek grafana/grafana#88107 was merged, it uses onSelectRange and a different type of xymark annotation that doesnt have the bottom hoverable region. maybe take a look.

@darrenjaneczek darrenjaneczek force-pushed the demo/alt-timerange-selector branch from 9a19743 to cfb9307 Compare September 11, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants