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

Feature info chart fixes. #7156

Merged
merged 10 commits into from
May 28, 2024
Merged

Feature info chart fixes. #7156

merged 10 commits into from
May 28, 2024

Conversation

na9da
Copy link
Collaborator

@na9da na9da commented May 14, 2024

What this PR does

Alternate approach to #6960 for making y-column of feature info charts configurable.

This PR

  • allows y-columns to be used with <chart> component in feature info templates without changing the merge strategy of chart traits. It does it by passing the y-column as a prop to the FeatureInfoPanelChart.
  • TSifies FeatureInfoPanelChart and purges some scss it depends on.
  • Default label on x-axis will now say ${y-column-name}(${y-units}) x ${x-column-name}(${x-units})

Test me

  • Same behaviour as main when a y-column is specified.
  • Same behaviour as main when no y-column is specified
  • DEA coastlines chart
    • Check if the feature info panel chart is rendered correctly, can be expanded, downloaded and toggled from the workbench chart selector list
  • DEA water bodies chart
    • Check if the feature info panel chart is rendered correctly, can be expanded, downloaded and toggled from the workbench chart selector list

Checklist

  • There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
  • I've updated relevant documentation in doc/.
  • I've updated CHANGES.md with what I changed.
  • I've provided instructions in the PR description on how to test this PR.

@na9da na9da marked this pull request as ready for review May 20, 2024 06:45
@mwu2018
Copy link
Contributor

mwu2018 commented May 20, 2024

@na9da I've verified the above testing examples. Also have verified with my own datasets. They all work nicely.

@nf-s nf-s self-assigned this May 21, 2024
Comment on lines +388 to 390
if (yColumnId === undefined || yColumn === undefined) {
return undefined;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as before but just convinces TS that value is not undefined when using yColumnId below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use styled-components.

item: chartItem,
xAxisLabel: attrs.previewXLabel,
// Currently implementation supports showing only one column in the
// feature info panel chart
yColumn: attrs.yColumns?.[0],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pass y-column as prop to the FeatureInfoPanelChart

Copy link
Contributor

@nf-s nf-s left a comment

Choose a reason for hiding this comment

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

I feel like adding a y-column to FeatureInfoPanelChart kind of skips the TableStyle system. This behaviour is different from ChartView/ChartPanel - which uses ChartItem.showChartInPanel to determine which charts should be showing.

Ideally CsvChartCustomComponent y-columns attribute is used to set TableChartLineStyleTraits.isSelectedInWorkbench - and then FeatureInfoPanelChart shows the first applicable chart item.

What do you think?

@nf-s
Copy link
Contributor

nf-s commented May 22, 2024

I also wonder if it is worth reverting

if it is no longer needed here - as this was the only use of MergeStrategy.TopStratum. How strata is merged is hairy, and I'm not convinced that it was the best approach - it might be better to visit the problem more holistically later

Copy link
Contributor

@nf-s nf-s left a comment

Choose a reason for hiding this comment

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

After discussion: it is difficult to do what I suggested - so merge this in as short-term solution

@na9da
Copy link
Collaborator Author

na9da commented May 27, 2024

For more context, the reason why we are not able to implement the recommended fix to use isSelectedInWorkbench trait is that isSelectedInWorkbench is automatically set to true here for the first column:

createStratumInstance(TableChartLineStyleTraits, {
yAxisColumn: column.name,
isSelectedInWorkbench: i === 0 // activate only the first chart line by default
})

To override that programmatically, we'll need to know what columns exists, but that is not known until the chart catalog item is loaded here in FeatureInfoPanelChart. It is easier then, to just pass the chosen y-column as a prop.

@na9da na9da merged commit 23bcd07 into main May 28, 2024
9 checks passed
@na9da na9da deleted the chart-fixes branch May 28, 2024 05:29
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.

None yet

3 participants