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

This change allows the user to change the size of the label text. #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nverwer
Copy link
Contributor

@nverwer nverwer commented Nov 22, 2023

The constants for text size and stroke width have been made configurable, with the previous constant values as defaults.

@@ -23,6 +20,8 @@ export default Kapsule({
sort: { onChange(_, state) { state.needsReparse = true }},
label: { default: d => d.name },
labelOrientation: { default: 'auto' }, // angular, radial, auto
textSize: {default: 12},
Copy link
Owner

Choose a reason for hiding this comment

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

May be more fitting to call these two props labelFontSize and labelStrokeWidth.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will have a look later, and follow your suggestions. Thank you for having a look!

@@ -115,7 +114,7 @@ export default Kapsule({
state.svg = el.append('svg');
state.canvas = state.svg.append('g')
.style('font-family', 'sans-serif')
.style('font-size', `${TEXT_FONTSIZE}px`);
.style('font-size', `${state.textSize}px`);
Copy link
Owner

Choose a reason for hiding this comment

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

This needs to be moved to the update section so it can react to font size changes.

@@ -23,6 +20,8 @@ export default Kapsule({
sort: { onChange(_, state) { state.needsReparse = true }},
label: { default: d => d.name },
labelOrientation: { default: 'auto' }, // angular, radial, auto
textSize: {default: 12},
Copy link
Owner

Choose a reason for hiding this comment

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

Even though this is already an improvement, we could go a step further and turn these props into accessor functions, just like most of the other props. That way you could set different font sizes / stroke widths per individual element.

@@ -23,6 +20,8 @@ export default Kapsule({
sort: { onChange(_, state) { state.needsReparse = true }},
label: { default: d => d.name },
labelOrientation: { default: 'auto' }, // angular, radial, auto
textSize: {default: 12},
Copy link
Owner

Choose a reason for hiding this comment

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

Also, would you mind adding docs and types for these new attributes?

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.

2 participants