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
Dataplane: Support timeSeriesLong without transform #62732
Dataplane: Support timeSeriesLong without transform #62732
Conversation
@@ -488,6 +489,27 @@ export class PanelStateWrapper extends PureComponent<Props, State> { | |||
// Yes this is called ever render for a function that is triggered on every mouse move | |||
this.eventFilter.onlyLocal = dashboard.graphTooltip === 0; | |||
|
|||
if (PanelComponent.name === 'TimeSeriesPanel' && data.series.every((df) => df.meta?.type === 'timeseries-long')) { |
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.
for sure not the right place for this.... if just TimeSeriesPanel.... maybe:
https://github.com/grafana/grafana/blob/main/public/app/plugins/panel/timeseries/utils.ts#L21
or perhaps in the prepareTimeSeries(...)
transformer?
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 prepareTimeSeries(...)
transformer works too! It was suggested by @leeoniya that I use partitionByValues(...)
but I am open to both suggestions. @ryantxu and @leeoniya how much different are these? Partition by Values creates a wide dataframe and Prepare Time Series allows you to choose wide or multi. According to the dataplane docs, converting TimeSeriesLong to wide modifies the data but converting to multi does not. I'm leaning towards Prepate Time Series now. @kylebrandt what do you think?
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.
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 think wide is best for this case. It is more performant with the time series panel as I understand it. Additionally because JavaScript provides undefined as a value for numbers (in addition to null), it doesn't have the same lossy data conversion properties that the backend does here.
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.
@ryantxu I tried implementing Prepare Time Series with toTimeSeriesMulti
and with the whole transformer. Both gave me the same results, grey lines and undefined y axis ticks.
Can you help me out with what I am missing?
if (data.series.every((df) => df.meta?.type === 'timeseries-long')) {
data.series = toTimeSeriesMulti(data.series)
// const options = { format: timeSeriesFormat.TimeSeriesMulti }
// const ctx = {
// interpolate: (value: string) => value,
// }
// data.series = prepareTimeSeriesTransformer.transformer(options, ctx)(data.series)
}
@leeoniya and @kylebrandt I made a change to handle when there are two frames in the series with different field names. Now, the transform handles each frame individually and then returns the transformed series. |
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.
Works for me, I'm not suited to review front end code, but things render as I would expect now, and the table view and query inspector show the frame still in long format (which is good).
Additionally, in the case where I had the transform in place, this still shows the same result, so doesn't seem to be breaking in that case.
Test with this debug snapshot |
* support timeSeriesLong without transform * move timeserieslong transform to the right spot * add review suggestions for using types and moving options inline * handle frames with different field names * remove extra options
Fixes #57543
This work is part of the Dataplane project and is a WIP.
What is this feature?
This work applies a transform automatically to data of type TimeSeriesLong when viewed in a Time Series panel. The transformation applied partitions rows based on fields of type string and uses these as labels for the numeric fields.
Who is this feature for?
This feature is for anyone who is using a tabular datasource like SQL and is applying a transform to visualize the data as time series.
Why do we need this feature?
If a series is of type TimeSeriesLong it requires a transformation. If it has fields of type string these fields could be represented as labels for fields of numeric data. We don't want users to have to apply a transformation themselves.
TimeSeriesLong not supported
TimeSeriesLong, supported, partitioned with labels
Use this debug snapshot to test
debug-Panel Title-2023-02-24 17_37_52.json.txt