-
-
Notifications
You must be signed in to change notification settings - Fork 529
fix(Diagnostics): specify chart dimensions in use #1739
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
fix(Diagnostics): specify chart dimensions in use #1739
Conversation
Signed-off-by: Pedro Lamas <[email protected]>
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.
Pull Request Overview
This PR fixes a bug in the diagnostics chart rendering where echarts was inferring dimensions from the first dataset item, causing issues when dataset properties changed mid-dataset. The fix explicitly declares the chart dimensions to prevent inference errors.
- Adds explicit
dimensionsprop to AppChart component for echarts configuration - Computes chart dimensions dynamically based on diagnostics card configuration (date + metric collectors)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/components/widgets/diagnostics/DiagnosticsCard.vue | Adds computed property to generate chart dimensions array and passes it to AppChart component |
| src/components/ui/AppChart.vue | Adds optional dimensions prop and applies it to echarts dataset configuration |
Signed-off-by: Pedro Lamas <[email protected]>
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.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| if (this.chart && data && data.length) { | ||
| this.chart.setOption({ | ||
| dataset: { | ||
| dimensions: this.dimensions, | ||
| source: data | ||
| } | ||
| }) |
Copilot
AI
Nov 15, 2025
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.
Consider adding a watcher for the dimensions prop to handle cases where dimensions change after initial data load. If the dimensions are updated (e.g., when metrics are added/removed), the chart won't update without re-triggering the data watcher:
@Watch('dimensions')
onDimensionsChange (dimensions?: unknown[]) {
if (this.chart && dimensions) {
this.chart.setOption({
dataset: {
dimensions,
source: this.data
}
})
}
}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.
From tests, this doesn't seem to be required.
| get chartDimensions () { | ||
| return [ | ||
| 'date', | ||
| ...this.config.axes.flatMap(axis => axis.metrics.map(metric => metric.collector)) |
Copilot
AI
Nov 15, 2025
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 chartDimensions getter should filter out metrics from disabled axes to match the behavior of the series getter (line 221). Currently, dimensions include all metrics regardless of whether their axis is enabled, while series only includes metrics from enabled axes. This mismatch could cause issues with ECharts:
get chartDimensions () {
return [
'date',
...this.config.axes
.filter(axis => axis.enabled)
.flatMap(axis => axis.metrics.map(metric => metric.collector))
]
}| ...this.config.axes.flatMap(axis => axis.metrics.map(metric => metric.collector)) | |
| ...this.config.axes | |
| .filter(axis => axis.enabled) | |
| .flatMap(axis => axis.metrics.map(metric => metric.collector)) |
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.
Not required.
When one doesn't specify the input data dimensions, echarts will look at the first item on the dataset and infer from the available members, which can lead to problems if those change mid dataset - as it was the case here!
The fix is by declaring the dimensions we actually will use on the chart.
Fixes #1737