Skip to content

Commit 60210b1

Browse files
authored
修复折线图类型错误 & 调整默认 autoHide 配置 (#2109)
* fix: 调整默认的 autoHide 配置 * fix: 修复折线图类型定义 * fix: fix histogram axis unit test * fix: fix histogram axis unit test
1 parent 13694ac commit 60210b1

File tree

5 files changed

+66
-7
lines changed

5 files changed

+66
-7
lines changed

__tests__/unit/core/index-spec.ts

+52-3
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,61 @@ describe('core', () => {
211211
xField: 'date',
212212
yField: 'value',
213213
});
214-
215-
line.render();
216-
217214
expect(container.dataset.chartSourceType).toBe('G2Plot');
218215
line.destroy();
219216

220217
expect(container.dataset.chartSourceType).toBe(undefined);
221218
});
219+
220+
it('default autoHide', () => {
221+
const line = new Line(createDiv(''), {
222+
data: partySupport.filter((o) => o.type === 'FF'),
223+
xField: 'date',
224+
yField: 'value',
225+
});
226+
227+
line.render();
228+
229+
expect(line.chart.getOptions().axes['date'].label.autoRotate).toBe(false);
230+
expect(line.chart.getOptions().axes['date'].label.autoHide).toEqual({
231+
type: 'equidistance',
232+
cfg: {
233+
minGap: 6,
234+
},
235+
});
236+
237+
line.update({
238+
xAxis: {
239+
label: {
240+
autoHide: {
241+
type: 'equidistance',
242+
cfg: {
243+
minGap: 12,
244+
},
245+
},
246+
},
247+
},
248+
});
249+
line.render();
250+
expect(line.chart.getOptions().axes['date'].label.autoRotate).toBe(false);
251+
expect(line.chart.getOptions().axes['date'].label.autoHide).toEqual({
252+
type: 'equidistance',
253+
cfg: {
254+
minGap: 12,
255+
},
256+
});
257+
258+
line.update({
259+
xAxis: {
260+
label: {
261+
autoHide: false,
262+
},
263+
},
264+
});
265+
line.render();
266+
expect(line.chart.getOptions().axes['date'].label.autoRotate).toBe(false);
267+
expect(line.chart.getOptions().axes['date'].label.autoHide).toBe(false);
268+
269+
line.destroy();
270+
});
222271
});

__tests__/unit/plots/histogram/axis-spec.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ describe('Histogram: axis', () => {
112112
expect(histogram.chart.options.axes.range).toEqual({
113113
nice: true,
114114
label: {
115-
autoHide: true,
115+
autoHide: {
116+
type: 'equidistance',
117+
cfg: {
118+
minGap: 6,
119+
},
120+
},
116121
autoRotate: false,
117122
},
118123
});

__tests__/unit/plots/histogram/index-spec.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ describe('histogram', () => {
3636
expect(histogram.chart.options.axes.range).toEqual({
3737
nice: true,
3838
label: {
39-
autoHide: true,
39+
autoHide: {
40+
type: 'equidistance',
41+
cfg: {
42+
minGap: 6,
43+
},
44+
},
4045
autoRotate: false,
4146
},
4247
});

src/core/plot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export abstract class Plot<O extends PickOptions> extends EE {
118118
nice: true,
119119
label: {
120120
autoRotate: false,
121-
autoHide: true,
121+
autoHide: { type: 'equidistance', cfg: { minGap: 6 } },
122122
},
123123
},
124124
yAxis: {

src/plots/line/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface LineOptions extends Options {
1919
/** 折线图形样式 */
2020
readonly lineStyle?: StyleAttr;
2121
/** 折线 shape 配置 */
22-
readonly lineShape?: LineGeometryOptions['line']['shape'];
22+
readonly lineShape?: Required<LineGeometryOptions>['line']['shape'];
2323
/** 折线数据点图形样式 */
2424
readonly point?: PointGeometryOptions['point'];
2525
}

0 commit comments

Comments
 (0)