-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: interval geometry 支持配置图形背景,支持图表: 柱、条形图,玉珏图 (#2190)
* feat(interval): interval 支持几何图形 background 设置,作用于 column、bar、radial-bar 1、column 新增配置项 columnBackground 2、bar 新增配置项 barBackground 3、radial-bar 新增配置项 barBackground、minBarWidth、maxBarWidth * docs(radial-bar): 默认关闭玉珏图动画,优化玉珏图 demo * docs: 增加柱、条形图的文档 api - [x] 抽取 bar-style、column-style 文档(含 minwidth、maxwidth、background 配置) - [x] 柱形图、条形图、玉珏图 关于图形样式 文档更新,支持 minwidth、maxwidth、background * fix: 修复 lint 问题 * test: 添加 interval geometry 背景设置的单测 * fix: 注明柱子背景在玉珏图为 line 类型时,不生效
- Loading branch information
Showing
26 changed files
with
576 additions
and
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { interval, P, Params } from '../../../../src'; | ||
import { IntervalGeometryOptions } from '../../../../src/adaptor/geometries'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
describe('adaptor - interval', () => { | ||
function adaptor(params: Params<IntervalGeometryOptions>): Params<IntervalGeometryOptions> { | ||
const { chart, options } = params; | ||
const { data } = options; | ||
|
||
chart.data(data); | ||
|
||
// 直接使用 geometry 进行测试 | ||
interval({ | ||
chart, | ||
options: { | ||
...options, | ||
interval: {}, | ||
args: { columnBackground: options.columnBackground }, | ||
}, | ||
}); | ||
return params; | ||
} | ||
|
||
function getPlot() { | ||
const plot = new P( | ||
createDiv(), | ||
{ | ||
width: 400, | ||
height: 300, | ||
data: [ | ||
{ type: '1', value: 10 }, | ||
{ type: '2', value: 12 }, | ||
], | ||
appendPadding: 10, | ||
xField: 'type', | ||
yField: 'value', | ||
mapping: {}, | ||
}, | ||
adaptor | ||
); | ||
|
||
plot.render(); | ||
return plot; | ||
} | ||
|
||
it('columnBackground', () => { | ||
const plot = getPlot(); | ||
expect(plot.chart.geometries[0].elements[0].shape.isGroup()).toBe(false); | ||
|
||
plot.update({ | ||
columnBackground: { style: { fill: 'red' } }, | ||
}); | ||
expect(plot.options.columnBackground).toBeDefined(); | ||
// @ts-ignore | ||
const shapes = plot.chart.geometries[0].elements[0].shape.getChildren(); | ||
expect(shapes.length).toBe(2); | ||
expect(shapes[0].attr('fill')).toBe('red'); | ||
|
||
plot.update({ columnBackground: null }); | ||
expect(plot.chart.geometries[0].elements[0].shape.isGroup()).toBe(false); | ||
}); | ||
}); |
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
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
Oops, something went wrong.