-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 columnWidthRatio configuration to the style of the interval #6474
Conversation
Pull Request Test Coverage Report for Build 11015658210Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
export function columnWidthRatio<T extends G2ViewTree = G2ViewTree>( | ||
options: T, | ||
): T { | ||
const { style, scale, type } = options; | ||
const scaleOption: G2View = {}; | ||
const columnWidthRatio = get(style, 'columnWidthRatio'); | ||
if (columnWidthRatio && type === 'interval') { | ||
scaleOption.x = { | ||
...scale?.x, | ||
padding: 1 - columnWidthRatio, | ||
}; | ||
} | ||
return { | ||
...options, | ||
scale: { ...scale, ...scaleOption }, | ||
}; | ||
} |
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.
这段逻辑更好是放在 transform 里面:这是 G2 提供的增加一些语法糖的内置机制,这样就不需要修改 runtime 的代码了。可以参考这个PR #5914
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.
好的,这个我下次做语法糖的时候看一下,看看需不需要迁移到transform里一起做
close #6386
Checklist
npm test
passesDescription of change
add columnWidthRatio configuration to the style of the interval.
You can refer to the example below for usage.
example:
style: { columnWidthRatio: 0.2 } or .style('columnWidthRatio', 0.2)