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

PieChart: Support row data in pie charts #34755

Merged
merged 5 commits into from May 28, 2021
Merged

Conversation

torkelo
Copy link
Member

@torkelo torkelo commented May 26, 2021

It's very frustrating that the pie chart currently cannot visualize:

Screenshot from 2021-05-26 17-29-51
Screenshot from 2021-05-26 17-29-57

A few weeks ago we removed the "all values" option that is part of stat/gauge/bargauge. Because it does not work with palette based color schemes, setting manual color does not work
either as we can only color fields, not values.

Screenshot from 2021-05-26 17-31-35

One way would be to add a transform that pivots the data (Rows to fields). But that is a bit painful from a user / ease of use perspective. In this PR I tested a way to update seriesIndex to get unique auto colors. We could never support custom color selection with this mode.

With this PR
Screenshot from 2021-05-26 17-38-08

The thing that would be nice to add with this an auto mode that selects Calculate or All values based on the data using some heuristic.

Question is given that color picker will never work with the data in this form, should we skip this solution and explore a way for a panel add a transform? but how to make that easy to use? Or panel edit to suggest a transform?

Updated so that color picker created overrides does work. They will say "not found" in panel edit but this feels ok

@torkelo torkelo requested a review from ryantxu May 26, 2021 15:38
@torkelo torkelo added this to In Review (max. internal 8, external 3) in Frontend Platform Backlog via automation May 27, 2021
@dprokop dprokop requested review from a team, peterholmberg, natellium, oscarkilhed and dprokop and removed request for a team, peterholmberg and natellium May 27, 2021 07:45
@torkelo torkelo marked this pull request as ready for review May 27, 2021 08:10
@torkelo torkelo requested a review from a team May 27, 2021 08:10
@torkelo
Copy link
Member Author

torkelo commented May 27, 2021

Ok, added logic that makes color overrides added by the color picker work

@@ -152,6 +152,13 @@ export const getFieldDisplayValues = (options: GetFieldDisplayValuesOptions): Fi
}
}

// Palette color modes use series index (field index) which does not work for when displaing rows
// So updating seriesIndex here makes the palette color modes work in "All values" mode
field.state = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: would it be worth to change this to something like field.state = setIndexForPaletteColor(field.state) and move the code + comment into a small help function.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@mckn mckn left a comment

Choose a reason for hiding this comment

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

Great work with this!

@torkelo torkelo added this to the 8.0.0-beta3 milestone May 28, 2021
@torkelo torkelo added old backport v8.0.x Mark PR for automatic backport to v8.0.x add to changelog labels May 28, 2021
@torkelo torkelo merged commit 658cc5d into main May 28, 2021
Frontend Platform Backlog automation moved this from In Review (max. internal 8, external 3) to Done May 28, 2021
@torkelo torkelo deleted the support-row-data-in-piechart branch May 28, 2021 05:29
grafanabot pushed a commit that referenced this pull request May 28, 2021
* PieChart: Support row data in pie chart

* Make color override work

* removed thing

* Minor refactoring

(cherry picked from commit 658cc5d)
torkelo added a commit that referenced this pull request May 28, 2021
* PieChart: Support row data in pie chart

* Make color override work

* removed thing

* Minor refactoring

(cherry picked from commit 658cc5d)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
@hugohaggmark hugohaggmark changed the title PieChart: Support row data in pie chart PieChart: Support row data in pie charts Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend old backport v8.0.x Mark PR for automatic backport to v8.0.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants