Skip to content

Commit 3130dc3

Browse files
lxfu1liufu.lf
and
liufu.lf
authored
fix: 修复 slider demos, 新增 scrollbar (#1594)
* fix: 修复 slider demos, 新增 scrollbar * fix: 文档注释 changeData, 修复词云图 data 为空的错误 Co-authored-by: liufu.lf <[email protected]>
1 parent b15334d commit 3130dc3

File tree

13 files changed

+37
-18
lines changed

13 files changed

+37
-18
lines changed

docs/common/chart-methods.en.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ plot.update({
2323
});
2424
```
2525

26+
<!--
2627
#### changeData()
2728
2829
<description>**可选** </description>
@@ -35,4 +36,4 @@ plot.update({
3536
3637
```ts
3738
plot.changeData(newData);
38-
```
39+
``` -->

docs/common/chart-methods.zh.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ plot.update({
2323
});
2424
```
2525

26-
#### changeData()
26+
<!-- #### changeData()
2727
2828
<description>**可选** </description>
2929
@@ -35,4 +35,4 @@ plot.update({
3535
3636
```ts
3737
plot.changeData(newData);
38-
```
38+
``` -->

docs/manual/upgrade.zh.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ G2Plot 2.0 兼容大部分的 1.x 版本图表功能和配置项,详情如下
4040
interactions: [
4141
{
4242
type: 'slider',
43-
min: 0.1,
44-
max: 0.8
43+
start: 0.1,
44+
end: 0.8
4545
},
4646
],
4747
// 变更后
4848
slider: {
49-
min: 0.1,
50-
max: 0.8
49+
start: 0.1,
50+
end: 0.8
5151
},
5252
```
5353

examples/area/basic/demo/basic-slider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ fetch('https://gw.alipayobjects.com/os/bmw-prod/1d565782-dde4-4bb6-8946-ea6a38cc
1212
tickCount: 5,
1313
},
1414
slider: {
15-
min: 0.1,
16-
max: 0.9,
15+
start: 0.1,
16+
end: 0.9,
1717
trendCfg: {
1818
isArea: true,
1919
},

examples/area/stacked/demo/basic-slider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ fetch('https://gw.alipayobjects.com/os/bmw-prod/b21e7336-0b3e-486c-9070-612ede49
99
yField: 'value',
1010
seriesField: 'country',
1111
slider: {
12-
min: 0.1,
13-
max: 0.9,
12+
start: 0.1,
13+
end: 0.9,
1414
},
1515
});
1616
area.render();

examples/line/basic/demo/line-slider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fetch('https://gw.alipayobjects.com/os/bmw-prod/1d565782-dde4-4bb6-8946-ea6a38cc
1313
tickCount: 5,
1414
},
1515
slider: {
16-
min: 0.1,
17-
max: 0.5,
16+
start: 0.1,
17+
end: 0.5,
1818
},
1919
});
2020

examples/tiny-line/basic/demo/line-style.ts

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const tinyLine = new TinyLine('container', {
99
lineStyle: {
1010
lineDash: [2, 2],
1111
},
12-
point: {},
1312
});
1413

1514
tinyLine.render();

src/adaptor/common.ts

+13
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ export function slider(params: Params<Options>): Params<Options> {
119119
return params;
120120
}
121121

122+
/**
123+
* 处理缩略轴的 adaptor
124+
* @param params
125+
*/
126+
export function scrollbar(params: Params<Options>): Params<Options> {
127+
const { chart, options } = params;
128+
const { scrollbar } = options;
129+
130+
chart.option('scrollbar', scrollbar);
131+
132+
return params;
133+
}
134+
122135
/**
123136
* scale 的 adaptor
124137
* @param axes

src/plots/column/adaptor.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { deepMix } from '@antv/util';
22
import { Params } from '../../core/adaptor';
33
import { findGeometry } from '../../utils';
4-
import { tooltip, slider, interaction, animation, theme, scale, annotation } from '../../adaptor/common';
4+
import { tooltip, slider, interaction, animation, theme, scale, annotation, scrollbar } from '../../adaptor/common';
55
import { interval } from '../../adaptor/geometries';
66
import { flow } from '../../utils';
77
import { ColumnOptions } from './types';
@@ -128,6 +128,7 @@ export function adaptor(params: Params<ColumnOptions>) {
128128
legend,
129129
tooltip,
130130
slider,
131+
scrollbar,
131132
theme,
132133
label,
133134
interaction,

src/plots/word-cloud/utils.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { WordCloudOptions } from './types';
1212
export function transform(params: Params<WordCloudOptions>) {
1313
const { chart, options } = params;
1414
const { data, imageMask, wordField, weightField, wordStyle, timeInterval, spiral } = options;
15+
if (!data || !data.length) {
16+
return [];
17+
}
1518
const { fontFamily, fontWeight, padding } = wordStyle;
1619
const dv = new DataSet.View().source(data);
1720
const range = dv.range(weightField);

src/types/common.ts

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Animation } from './animation';
88
import { Annotation } from './annotation';
99
import { State } from './state';
1010
import { Slider } from './slider';
11+
import { Scrollbar } from './scrollbar';
1112
import { ColorAttr } from './attr';
1213

1314
/** annotation position */
@@ -116,6 +117,8 @@ export type Options = {
116117
readonly legend?: Legend;
117118
/** 缩略轴 slider 的配置项 */
118119
readonly slider?: Slider;
120+
/** 缩略轴 scrollbar 的配置项 */
121+
readonly scrollbar?: Scrollbar;
119122
readonly animation?: Animation;
120123
readonly interactions?: Interaction[];
121124
readonly annotations?: Annotation[];

src/types/scrollbar.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ScrollbarOption as Scrollbar } from '@antv/g2/lib/interface';

src/types/slider.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
// 等 PR https://github.com/antvis/G2/pull/2766 合并,发包之后即可使用 G2 导出的
2-
// export { SliderOption as Slider } from '@antv/g2/lib/interface';
3-
export type Slider = any;
1+
export { SliderOption as Slider } from '@antv/g2/lib/interface';

0 commit comments

Comments
 (0)