-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 根据字段标记背景颜色,设置字体颜色 * feat: 添加 intelligentReverseTextColor 字段到 background condition * test: 添加背景智能反色相关单测 * docs: 添加开启文字智能反色文档
- Loading branch information
Showing
9 changed files
with
209 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
export const VALUE_RANGES_KEY = 'valueRanges'; | ||
export const DEFAULT_VALUE_RANGES = {}; | ||
/** | ||
* 亮度范围 0~255 | ||
* @see https://github.com/bgrins/TinyColor#getbrightness | ||
*/ | ||
export const FONT_COLOR_BRIGHTNESS_THRESHOLD = 220; | ||
export const DEFAULT_FONT_COLOR = '#000000'; | ||
export const REVERSE_FONT_COLOR = '#FFFFFF'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
s2-site/examples/analysis/conditions/demo/intelligent-background.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { PivotSheet } from '@antv/s2'; | ||
|
||
fetch( | ||
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json', | ||
) | ||
.then((res) => res.json()) | ||
.then((dataCfg) => { | ||
const container = document.getElementById('container'); | ||
|
||
const s2Options = { | ||
width: 600, | ||
height: 480, | ||
interaction: { | ||
hoverHighlight: false, | ||
}, | ||
conditions: { | ||
background: [ | ||
{ | ||
field: 'number', | ||
mapping() { | ||
return { | ||
// fill 是背景字段下唯一必须的字段,用于指定文本颜色 | ||
fill: '#000', | ||
intelligentReverseTextColor: true, | ||
}; | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
const s2 = new PivotSheet(container, dataCfg, s2Options); | ||
|
||
s2.render(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80cbf20
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.
Successfully deployed to the following URLs:
antvis-s2 – ./
antvis-s2-antv-s2.vercel.app
antvis-s2.vercel.app
antvis-s2-git-master-antv-s2.vercel.app
wanyingxing.vip