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 columnWidthRatio configuration to the style of the interval #6474

Merged
merged 5 commits into from
Sep 24, 2024

Conversation

interstellarmt
Copy link
Contributor

close #6386

Checklist
  • npm test passes
  • benchmarks are included
  • commit message follows commit guidelines
  • documents are updated
Description 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)
image

@coveralls
Copy link

coveralls commented Sep 24, 2024

Pull Request Test Coverage Report for Build 11015658210

Warning: 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

  • 24 of 24 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 86.704%

Totals Coverage Status
Change from base Build 10934119683: -0.001%
Covered Lines: 10587
Relevant Lines: 11832

💛 - Coveralls

src/runtime/render.ts Outdated Show resolved Hide resolved
src/runtime/option-preprocess/index.ts Outdated Show resolved Hide resolved
src/runtime/option-preprocess/index.ts Outdated Show resolved Hide resolved
src/runtime/render.ts Outdated Show resolved Hide resolved
@hustcc hustcc merged commit ff5bbc0 into v5 Sep 24, 2024
2 checks passed
@hustcc hustcc deleted the feat-interval-column-width-ratio branch September 24, 2024 15:38
Comment on lines +5 to +21
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 },
};
}
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,这个我下次做语法糖的时候看一下,看看需不需要迁移到transform里一起做

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.

G2 V4 的 columnWidthRatio 配置,在 G2 V5 如何实现相似效果
4 participants