-
Notifications
You must be signed in to change notification settings - Fork 607
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
fix: Make bars with one axis thicker #8894
Conversation
@@ -110,6 +111,9 @@ function defaultSizeRef( | |||
return {value: scaleRange.step - 2}; | |||
} | |||
} | |||
if (!hasFieldDef) { | |||
return {signal: `0.8 * ${sizeChannel}`}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if we extract {signal:
0.8 * ${sizeChannel}}
as the constant. But I could not find a good place to place if we extract...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good question. For consistency with existing similar style, we can respect config.scale.bandPaddingInner/ barBandPaddingInner/rectBandPaddingInner
.
Basically, we can think of axis without a field as categorical axis with one unique value.
So we can do:
const padding = getFirstDefined(bandPaddingInner, mark === 'bar' ? barBandPaddingInner : rectBandPaddingInner); // this part is like paddingInner in scale.ts
return {signal: `${1 - padding} * ${sizeChannel}`};
examples/compiled/facet_bullet.svg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this example, we may want to set config.scale.barBandPaddingInner = 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last few nits before merging. :)
return {signal: `(1 - (${padding.expr})) * ${sizeChannel}`}; | ||
} | ||
/* istanbul ignore next: Condition should not happen -- only for warning in development. */ | ||
throw new Error('It should never reach here'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally avoid blatant error in Vega-Lite.
Better fall through to use existing logic and optionally gracefully warn (with log.warn
+ add the message "invalid to messages.ts) if you think it's really worth warning.
I think it's ok to just fall through though.
if (isSignalRef(padding)) { | ||
return {signal: `(1 - (${padding.signal})) * ${sizeChannel}`}; | ||
} else if (isNumber(padding)) { | ||
return {signal: `(1 - (${padding})) * ${sizeChannel}`}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- signal: `(1 - (${padding})) * ${sizeChannel}`
+ signal: `${1 - padding} * ${sizeChannel}`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need these parentheses and 1 - xxx math for this number case. We can just put in the number.
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com> Co-authored-by: Kanit Wongsuphasawat <kanitw@gmail.com>
Added the logic making the bar's size thicker if there is no secondary channel.