-
Notifications
You must be signed in to change notification settings - Fork 50
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
[FEATURE] Initial ScatterChart Panel Plugin #1672
Conversation
-- Add Panel Plugin for Scatter Chart -- Add Tempo Query Editor for UI Editing Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Merge from main. Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
startTime: Date; | ||
} | ||
|
||
export function getUnixTimeRange(timeRange: AbsoluteTimeRange) { |
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.
Can't remember exactly, but we might have a similar util in @perses-dev/core
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.
I’ve removed this in the latest commit. This was a helper function used by greaterThanSevenDays().
// 1. Map x,y coordinates | ||
// 2. Datapoint size corresponds to the number of spans in a trace | ||
// 3. Color datapoint red if the trace contains an error | ||
const seriesTemplate: SeriesOption = { |
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 dataset lines above are in a useMemo so that's good, but these other lines could benefit from being memozied too. It would break the rules of hooks though so having a separate component like ScatterChartPanelLoaded.tsx would be the way to go (other panel types would benefit from that too)
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.
TBH, I’m a novice with hooks and don’t see how it would break the rules. Could you elaborate on the rules that are being broken and the implementation you’d like to see for the separate component ScatterChartPanelLoaded
? In the latest push, I attempted to use the useMemo() hook directly in scatterChartPanel to memoize the series formatting, and it didn’t throw any errors…
I am not sure how the rules are being broken because the memoized function is not inside a condition, loop, or event handler, and there are no other hooks within the function. And I moved the error checks that would return the function early, after the hooks.
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.
Oh great! I thought it was after the loading if conditions but I might have misread too, if no errors were thrown or anything then you should be good
return 'red'; | ||
} | ||
// Else return default color | ||
const defaultColor = '#56B4E9'; |
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.
chartsTheme is nice to leverage for these types of colors since it allows embed users to customize their palette, fonts, etc. (ex of defaultColor for thresholds)
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.
Absolutely, agree. Great catch; this is updated in the latest commit.
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.
Awesome and you can always add new colors too if what’s there isn’t enough
dataset: options.dataset, | ||
series: options.series, | ||
grid: { | ||
bottom: 40, |
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.
Similar comment about possibly leveraging chartsTheme if possible
Edit: NVM, ignore me, I see that grid is pretty custom here due to dataZoom
|
||
// Propagate changes to the query's value when the input is blurred to avoid constantly re-running queries in the | ||
// PanelPreview | ||
const handleQueryBlur = () => { |
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.
Side note: sometimes this onBlur logic annoys me in our Prometheus editor and I just want an explicit 'Run queries' button 😂
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.
I agree. This could be generated as a separate issue. Updating the panel to have an explicit 'Run queries' button might also be more intuitive for the user.
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.
🚀
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
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.
LGTM!
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.
Signed-off-by: Steven Cobb <sjcobb.dev@gmail.com>
* [BUGFIX] Tooltip positioning broken in Firefox Signed-off-by: Steven Cobb <sjcobb.dev@gmail.com> * fix lint from Scatterplot #1672, remove totalSeries Signed-off-by: Steven Cobb <sjcobb.dev@gmail.com> --------- Signed-off-by: Steven Cobb <sjcobb.dev@gmail.com>
Description
TLDR: Initial ScatterChart Panel Plugin
Note
ScatterChart Panel Plugin is based on the work done by Steve Cobb from [perses-embed-example](https://github.com/sjcobb/perses-embed-example).
Backend Changes
Add schemas for scatter plot panels in
schemas/panels/scatterplot
. In this initial iteration, nospec
options are added to this panel.Frontend Changes
1. Add scatter plot panel for data visualization
1B. Component TreeView
2. Changes to add a UI panel editing in a scatter plot with Tempo Data
Note: These changes were based on Time Series Query Editor. In the future, if additional data types are added, we should consider how to create more reusable components (i.e., if we can make a general query editor that is less tightly coupled to a specific query type).
switch(queryType) >> case ‘TraceQuery’ >> render <TraceQueryEditor>
<PluginKind queryType={TraceQuery}/>
drop-down will render TempoTraceQuery.<PluginSpecEditor queryType={TraceQuery}/>
will fetch the query plugin from the file TempoTraceQuery.tsx and get theOptionsEditorComponent: TempoTraceQueryEditor
3. Enable TimeRangeSelector on TraceQuery
{fooQuery}&start={unixStartTime}&end{unixEndTime}
. Pass this query toclient.getEnrichedTraceQuery(getQuery(), datasourceUrl)
to fetch trace data from API.Screenshots
Figure 1. Scatter Chart
![Perses_Scatterplot_PR_Screenshot_ScatterChart_Dec_20_2023](https://private-user-images.githubusercontent.com/59589720/292093825-ad87d52e-d4a0-4631-a0c0-814315812b43.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxNzczNzgsIm5iZiI6MTcyMDE3NzA3OCwicGF0aCI6Ii81OTU4OTcyMC8yOTIwOTM4MjUtYWQ4N2Q1MmUtZDRhMC00NjMxLWEwYzAtODE0MzE1ODEyYjQzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA1VDEwNTc1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEwNzVkYjQ0ZDM1OWQwZmMzNTIyNDVjNDY3YWE1YWVlNTI0ZDVlYWYzYzM2MTFlMzI1OTViNDMxOWFiZjI3NWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zT4WMd-CiEdqjsaJkSm9nU5Z7yex76qTwJg_6aQbyk4)
![Perses_Scatterplot_PR_Screenshot_TraceQueryEditor_Dec_20_2023](https://private-user-images.githubusercontent.com/59589720/292094660-6e9768f5-2fb1-438d-ba16-962aa9deb077.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxNzczNzgsIm5iZiI6MTcyMDE3NzA3OCwicGF0aCI6Ii81OTU4OTcyMC8yOTIwOTQ2NjAtNmU5NzY4ZjUtMmZiMS00MzhkLWJhMTYtOTYyYWE5ZGViMDc3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA1VDEwNTc1OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYyYTVlNTY2NzNjN2Y3YmZmZDg5ODBlODgxZTBjZmY5MDU3ZDkyMTNlZGI5ZDExZWE3MzBlYjBmMjM4N2VjMzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vW3gldUqL4cBFvnF3nr7vZwSZWXmEtq1IzJqvhBcN4Y)
Datapoint size corresponds to the number of spans within a trace.
Red datapoints indicate the trace contains and error.
Figure 2. Trace Query Editor
Checklist
[<catalog_entry>] <commit message>
naming convention using one of thefollowing
catalog_entry
values:FEATURE
,ENHANCEMENT
,BUGFIX
,BREAKINGCHANGE
,DOC
,IGNORE
.UI Changes
See [Storybook](https://github.com/perses/perses/tree/main/ui/storybook#visual-tests)
and [e2e](https://github.com/perses/perses/tree/main/ui/e2e#visual-tests) docs for more details. Common issues
include: