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

feat: add debug state for partition charts #1117

Merged

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Apr 13, 2021

Summary

Add the debug state for partition charts with the following type signature:

type PartitionDebugState = {
  panelTitle: string; // the title of the small multiple, empty if not small multiple
  partitions: Array<{
    name: string; // the name of the slice, before applying the formatter (the string is the same as it was in the data array)
    depth: number; // the layer of the slice when using multilayered pies/treemap
    color: string; // usually in rgba, better to use a color utility function in FTR to convert this into what you really need. The format can change in the future, so better be decoupled from that
    value: number; // the actual value of the slice
    coords: [Pixels,Pixels]; // a clickable central coordinate of the slice/sector
  }>;
};

fix #917

Checklist

Delete any items that are not applicable to this PR.

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • Proper documentation or storybook story was added for features that require explanation or tutorials
  • Unit tests were updated or added to match the most common scenarios

@markov00 markov00 requested a review from monfera April 13, 2021 08:52
@markov00 markov00 force-pushed the 2021_04_07-add_debug_state_partition branch from a9a5881 to 03df3b4 Compare April 13, 2021 11:43
@markov00 markov00 added :partition Partition/PieChart/Donut/Sunburst/Treemap chart related enhancement New feature or request labels Apr 13, 2021
@markov00 markov00 marked this pull request as ready for review April 13, 2021 11:48
@stratoula
Copy link

@markov00 I think we are fine, I get all the data I need for all my test cases 🎉

@markov00
Copy link
Member Author

jenkins test this please

Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

Nice work, seems appropriate to make a new partition property in the DebugState as there is not much crossover.


return {
rendered: state.chartRendered,
renderedCount: state.chartRenderedCount,
onRenderChange: settings.onRenderChange,
debugState: settings.debugState ? getDebugStateSelector(state) : null,
onRenderChange,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this method still bound correctly if needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I hope so, haven't checked

Copy link
Member Author

Choose a reason for hiding this comment

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

it works fine

}

function getCoordsForRectangle({ x0, x1, y1px, y0px }: QuadViewModel, diskCenter: PointObject): [Pixels, Pixels] {
const y = y0px + (y1px - y0px) / 2 + diskCenter.y;
Copy link
Contributor

Choose a reason for hiding this comment

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

Multilayer treemaps and mosaic have overlapping geoms for potential border/coloring around the larger group perimeter, so the mid Y activates a leaf node. It may be fine as the path still includes the non-leaf layers. If it's not desirable, an alternative would be, instead of computing the vertical center of the box, the y could be the top of the box plus a couple of pixels

Copy link
Contributor

@monfera monfera left a comment

Choose a reason for hiding this comment

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

Looks fantastic, thank you for having made this 🎉

Worked great with debugState, probably worth committing it i place of or in addition to debug.

Due to special cases, I tested coordinates with:

  • pie chart with big margins that push aside the chart
  • regular sunburst
  • sunburst with single 360 degree concentric disk / rings
  • no slices at all
  • sunburst small multiples
  • two-layer treemap
  • mosaic

function getCoordsForRectangle({ x0, x1, y1px, y0px }: QuadViewModel, diskCenter: PointObject): [Pixels, Pixels] {
const y = y0px + (y1px - y0px) / 2 + diskCenter.y;
const x = x0 + (x1 - x0) / 2 + diskCenter.x;
return [x, y];
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to put short coords in the data-ech-debug-state, it could be rounded here

Copy link
Member Author

Choose a reason for hiding this comment

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

done 211e439

@markov00 markov00 enabled auto-merge (squash) April 15, 2021 10:12
@markov00 markov00 disabled auto-merge April 15, 2021 10:14
@codecov-io
Copy link

Codecov Report

Merging #1117 (b29d541) into master (c1b59f2) will increase coverage by 0.63%.
The diff coverage is 96.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1117      +/-   ##
==========================================
+ Coverage   72.26%   72.90%   +0.63%     
==========================================
  Files         387      405      +18     
  Lines       12021    12384     +363     
  Branches     2629     2679      +50     
==========================================
+ Hits         8687     9028     +341     
- Misses       3309     3322      +13     
- Partials       25       34       +9     
Flag Coverage Δ
unittests 72.47% <96.96%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../chart_types/partition_chart/state/chart_state.tsx 70.68% <66.66%> (+0.51%) ⬆️
...partition_chart/state/selectors/get_debug_state.ts 100.00% <100.00%> (ø)
src/components/chart_status.tsx 91.66% <100.00%> (ø)
src/mocks/store/index.ts 100.00% <0.00%> (ø)
src/mocks/geometries.ts 92.85% <0.00%> (ø)
src/mocks/index.ts 100.00% <0.00%> (ø)
src/mocks/store/store.ts 92.59% <0.00%> (ø)
src/mocks/scale/scale.ts 77.77% <0.00%> (ø)
src/mocks/theme.ts 86.66% <0.00%> (ø)
src/mocks/series/data.ts 100.00% <0.00%> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1b59f2...b29d541. Read the comment docs.

@markov00 markov00 merged commit d7fc206 into elastic:master Apr 15, 2021
@markov00 markov00 deleted the 2021_04_07-add_debug_state_partition branch April 15, 2021 10:28
nickofthyme pushed a commit that referenced this pull request Apr 15, 2021
# [28.2.0](v28.1.0...v28.2.0) (2021-04-15)

### Bug Fixes

* **xy:** consider `useDefaultGroupDomain` on scale config ([#1119](#1119)) ([c1b59f2](c1b59f2)), closes [#1087](#1087)

### Features

* **a11y:** allow user to pass custom description for screen readers ([#1111](#1111)) ([2ee1b91](2ee1b91)), closes [#1097](#1097)
* **partition:** add debuggable state ([#1117](#1117)) ([d7fc206](d7fc206)), closes [#917](#917)
@nickofthyme
Copy link
Collaborator

🎉 This PR is included in version 28.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nickofthyme nickofthyme added the released Issue released publicly label Apr 15, 2021
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [28.2.0](elastic/elastic-charts@v28.1.0...v28.2.0) (2021-04-15)

### Bug Fixes

* **xy:** consider `useDefaultGroupDomain` on scale config ([opensearch-project#1119](elastic/elastic-charts#1119)) ([269ff1a](elastic/elastic-charts@269ff1a)), closes [opensearch-project#1087](elastic/elastic-charts#1087)

### Features

* **a11y:** allow user to pass custom description for screen readers ([opensearch-project#1111](elastic/elastic-charts#1111)) ([a0020ba](elastic/elastic-charts@a0020ba)), closes [#1097](elastic/elastic-charts#1097)
* **partition:** add debuggable state ([opensearch-project#1117](elastic/elastic-charts#1117)) ([08f8baf](elastic/elastic-charts@08f8baf)), closes [opensearch-project#917](elastic/elastic-charts#917)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request :partition Partition/PieChart/Donut/Sunburst/Treemap chart related released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pie chart vislib replacement functional tests
5 participants