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(partition): clip text in partition chart fill label #1033

Merged
merged 14 commits into from
Feb 22, 2021

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Feb 18, 2021

Summary

Optionally clip text for fill label in partition chart, and fix an alignment issue.

Before:

image

After:
image

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)
  • This was checked for cross-browser compatibility
  • Proper documentation or storybook story was added for features that require explanation or tutorials

@codecov-io
Copy link

codecov-io commented Feb 18, 2021

Codecov Report

Merging #1033 (47b525d) into master (b38d110) will increase coverage by 0.35%.
The diff coverage is 35.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1033      +/-   ##
==========================================
+ Coverage   72.84%   73.19%   +0.35%     
==========================================
  Files         363      379      +16     
  Lines       11229    11544     +315     
  Branches     2442     2492      +50     
==========================================
+ Hits         8180     8450     +270     
- Misses       3035     3072      +37     
- Partials       14       22       +8     
Flag Coverage Δ
unittests 72.79% <35.71%> (-0.06%) ⬇️

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

Impacted Files Coverage Δ
src/chart_types/partition_chart/layout/config.ts 54.54% <ø> (ø)
...types/partition_chart/layout/types/config_types.ts 100.00% <ø> (ø)
...es/partition_chart/layout/types/viewmodel_types.ts 83.33% <ø> (ø)
...artition_chart/renderer/canvas/canvas_renderers.ts 5.63% <0.00%> (-0.30%) ⬇️
...rtition_chart/layout/viewmodel/fill_text_layout.ts 98.04% <83.33%> (+<0.01%) ⬆️
.../partition_chart/layout/utils/circline_geometry.ts 98.31% <0.00%> (-0.85%) ⬇️
src/mocks/series/series_identifiers.ts 100.00% <0.00%> (ø)
src/mocks/theme.ts 86.66% <0.00%> (ø)
src/mocks/series/index.ts 100.00% <0.00%> (ø)
src/mocks/store/index.ts 100.00% <0.00%> (ø)
... and 12 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 b38d110...47b525d. Read the comment docs.

@dgieselaar dgieselaar mentioned this pull request Feb 18, 2021
4 tasks
@monfera monfera marked this pull request as ready for review February 19, 2021 09:49
Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

LGTM, I've left a few minor comments

@@ -111,7 +111,7 @@ function getVerticalAlignment(
case VerticalAlignments.bottom:
return -(container.y1 - linePitch * (totalRowCount - 1 - rowIndex) - paddingBottom - fontSize * overhang);
default:
return -((container.y0 + container.y1) / 2 + (linePitch * (rowIndex - totalRowCount)) / 2);
return -((container.y0 + container.y1) / 2 + (linePitch * (rowIndex + 1 - totalRowCount)) / 2);
Copy link
Member

Choose a reason for hiding this comment

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

:D

@@ -58,6 +66,7 @@ function renderTextRow(
ctx.font = cssFontShorthand(box, fontSize);
ctx.fillText(box.text, box.width / 2 + box.wordBeginning, 0);
});
ctx.closePath();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to call closePath here, and probably we don't even need the ctx.beginPath(); at line 60 as fillText doesn't need to instantiate a new path

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed! The follow-up PR significantly restructures the Canvas render code, will explain reasons (motive: reduce context save/restore count)

},
},
},
clip: {
Copy link
Member

Choose a reason for hiding this comment

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

we rename it clipText within the code as it clips the text, not the geometry. I know that is part of the fillLabel config, but we also have other attributes as textColor textContrast etc

Copy link
Contributor

Choose a reason for hiding this comment

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

@monfera monfera merged commit be9bea0 into elastic:master Feb 22, 2021
github-actions bot pushed a commit that referenced this pull request Mar 1, 2021
# [25.1.0](v25.0.1...v25.1.0) (2021-03-01)

### Bug Fixes

* rounding values on stacked w percentage charts ([#1039](#1039)) ([ee63a70](ee63a70))

### Features

* **axis:** log scale limit and base options ([#1032](#1032)) ([b38d110](b38d110))
* **partition:** clip text in partition chart fill label ([#1033](#1033)) ([be9bea0](be9bea0))
@markov00
Copy link
Member

markov00 commented Mar 1, 2021

🎉 This PR is included in version 25.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Mar 1, 2021
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [25.1.0](elastic/elastic-charts@v25.0.1...v25.1.0) (2021-03-01)

### Bug Fixes

* rounding values on stacked w percentage charts ([opensearch-project#1039](elastic/elastic-charts#1039)) ([021e836](elastic/elastic-charts@021e836))

### Features

* **axis:** log scale limit and base options ([#1032](elastic/elastic-charts#1032)) ([11f94c6](elastic/elastic-charts@11f94c6))
* **partition:** clip text in partition chart fill label ([opensearch-project#1033](elastic/elastic-charts#1033)) ([7626441](elastic/elastic-charts@7626441))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants