Replies: 9 comments 8 replies
-
ref #4254 label.transform 本质是对 label 进行一些二次变化,从而让 label 看的更清晰,所以从属性上来区分,也可以作为统一命名的一个依据:
还有哪些? 规则:
举例:
{ type: 'overlap', strategy: 'hide' }
{ type: 'overlap', strategy: 'dodgeY' }
{ type: 'overflow', strategy: 'reduceFontSize', minFontSize: 8 }
{ type: 'contrast', strategy: 'reverseColor', contrastThreshold: 100 } |
Beta Was this translation helpful? Give feedback.
-
目前看 |
Beta Was this translation helpful? Give feedback.
-
关于颜色对比度,可以有设计规范:https://webaim.org/resources/contrastchecker/ 。之前我们的做法是直接颜色取反,可能不一定是更好的做法。 |
Beta Was this translation helpful? Give feedback.
-
我觉得现在命名不统一确实是问题,但不一定按照:目的 + 方式 来做,也许可以直接通过 type 透出就好了,只不过这个 type 需要整理。 |
Beta Was this translation helpful? Give feedback.
-
标签规则,第二版本规则:
举例:
{ type: 'overlapHide' }
{ type: 'overlapDodge' }
{ type: 'overflowShrink', minFontSize: 8 }
{ type: 'overflowHide' }
{ type: 'contrastEnlarge', threshold: 100 } { type: 'contrastHide', threshold: 100 } |
Beta Was this translation helpful? Give feedback.
-
标签规则,第三版本规则:
举例:
{ type: 'hideOverlap' }
{ type: 'dodgeOverlap' }
{ type: 'shrinkOverflow', minFontSize: 8 }
{ type: 'hideOverflow' }
{ type: 'enlargeContrast', threshold: 100 } { type: 'hideContrast', threshold: 100 } |
Beta Was this translation helpful? Give feedback.
-
具体实现 PR,在这里:#4453 |
Beta Was this translation helpful? Give feedback.
-
再增加一个将 label 限制在 canvas 或 plot 区域内的,溢出的话省略、偏移或隐藏。限制在 plot 内,是因为 plot 有 clip 配置属性,会对溢出的进行直接剪裁 @hustcc |
Beta Was this translation helpful? Give feedback.
-
label transform 为函数的情况如何使用呢 ? 文档上不详细, 能帮忙介绍一下吗( 最好有示例代码 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
label.transform
label 是以文本的形式来标注图形,让数据更加准确清晰。但是当 label 和图形进行组合显示在画布中的时候,可能需要额外做一些处理,让 label 文本显示的更好,这就是 label.transform 需要做的事情。
开始
label.transform 使用方式比较统一,举个例子。
选项
不同的 transform 有不同的功能和作用,当前 G2 内置了以下 label.transform。
dodgeY
- 对在 x 方向相交的标签在 y 方向上进行调整,防止标签重叠hideOverlap
- 当 label 发生碰撞的时候进行隐藏,默认保留前一个,隐藏后一个spider
- 调整标签沿坐标轴边沿两端对齐,适用于 polar 坐标系surround
- 调整标签沿坐标轴边沿两端对齐,适用于 polar 坐标系limitInShape
- 当标签和在背景 shape 容纳不下的时候隐藏,常用在 interval、rect、area 等大面积图形上xxcolor
- 调整颜色,保证 label 在有背景 shape 清晰可见,常用在 interval、rect、area 等大面积图形上Beta Was this translation helpful? Give feedback.
All reactions