Skip to content

Conversation

@pedrolamas
Copy link
Member

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

@pedrolamas pedrolamas added this to the 1.35.1 milestone Nov 15, 2025
@pedrolamas pedrolamas requested a review from Copilot November 15, 2025 21:17
@pedrolamas pedrolamas added the GH - Bug Something isn't working label Nov 15, 2025
Copilot finished reviewing on behalf of pedrolamas November 15, 2025 21:19
Copy link

Copilot AI left a 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 dimensions prop 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]>
@pedrolamas pedrolamas requested a review from Copilot November 15, 2025 22:20
Copilot finished reviewing on behalf of pedrolamas November 15, 2025 22:23
Copy link

Copilot AI left a 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.

Comment on lines 46 to 52
if (this.chart && data && data.length) {
this.chart.setOption({
dataset: {
dimensions: this.dimensions,
source: data
}
})
Copy link

Copilot AI Nov 15, 2025

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
      }
    })
  }
}

Copilot uses AI. Check for mistakes.
Copy link
Member Author

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))
Copy link

Copilot AI Nov 15, 2025

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))
  ]
}
Suggested change
...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))

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Not required.

@pedrolamas pedrolamas merged commit 1487021 into fluidd-core:develop Nov 15, 2025
10 checks passed
@pedrolamas pedrolamas deleted the pedrolamas/fix-1737 branch November 15, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GH - Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't plot Cartographer frequency in diagnostics

1 participant