Skip to content

Commit aa3b368

Browse files
committed
bugfix: 修复瀑布图
1 parent 0b34c3b commit aa3b368

File tree

6 files changed

+62
-5
lines changed

6 files changed

+62
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bizcharts",
3-
"version": "4.1.12-beta.1",
3+
"version": "4.1.12",
44
"description": "bizcharts",
55
"keywords": [
66
"bizcharts",

src/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as SVGEngine from '@antv/g-svg/lib';
44
import { registerEngine } from '@antv/g2/lib/core';
55
// 导出自定义比例尺的能力
66
export { registerScale, getScale, registerTickMethod } from '@antv/scale';
7-
7+
export { setGlobal, GLOBAL } from '@antv/g2Plot/lib/core/global';
88
import './extend/scale/scale';
99

1010
// 动画
@@ -17,7 +17,7 @@ registerEngine('svg', SVGEngine);
1717

1818
// @ts-ignore
1919
export * from '@antv/g2/lib/core';
20-
export const VERSION = '4.1.12-beta.1';
20+
export const VERSION = '4.1.12';
2121

2222

2323

src/createPlot.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ import {
2323
import { debounce, isArray, isFunction, isNil } from '@antv/util';
2424
import warn from 'warning';
2525

26+
// 国际化处理
27+
import { registerLocale } from '@antv/g2Plot/lib/core/locale';
28+
import { EN_US_LOCALE } from '@antv/g2Plot/lib/locales/en_US';
29+
import { ZH_CN_LOCALE } from '@antv/g2Plot/lib/locales/zh_CN';
30+
/** default locale register */
31+
registerLocale('en-US', EN_US_LOCALE);
32+
registerLocale('zh-CN', ZH_CN_LOCALE);
33+
2634
const DEFAULT_PLACEHOLDER = (
2735
<div
2836
style={{ position: 'absolute', top: '48%', left: '50%', color: '#aaa', textAlign: 'center' }}

src/plots/WaterfallChart.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import 'react';
2-
import {Waterfall, WaterfallOptions } from '@antv/g2plot/lib/plots/waterfall';
3-
import createPlot from '../createPlot';
2+
import {Waterfall, WaterfallOptions as Options } from '@antv/g2plot/lib/plots/waterfall';
3+
import createPlot, { BasePlotOptions } from '../createPlot';
4+
5+
interface WaterfallOptions extends Options, BasePlotOptions {
6+
7+
}
48

59
export default createPlot<WaterfallOptions>(Waterfall, 'WaterfallChart');

src/plots/core/dependents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type CategoryLegend = typeof Legend.Category;
2222
type ContinuousLegend = typeof Legend.Continuous;
2323
export { CategoryLegend, ContinuousLegend };
2424
type HtmlTooltip = typeof Tooltip.Html;
25+
2526
export { HtmlTooltip };
2627
export { Slider };
2728
export { Scrollbar };
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React from 'react';
2+
import WaterfallChart from '../../src/plots/WaterfallChart';
3+
import { render, cleanup } from '@testing-library/react';
4+
5+
// 数据源
6+
const data = [
7+
{ type: '日用品', money: 120 },
8+
{ type: '伙食费', money: 900 },
9+
{ type: '交通费', money: 200 },
10+
{ type: '水电费', money: 300 },
11+
{ type: '房租', money: 1200 },
12+
{ type: '商场消费', money: 1000 },
13+
{ type: '应酬红包', money: -2000 },
14+
];
15+
16+
describe('Plots-WaterfallChart', () => {
17+
test('基础WaterfallChart', () => {
18+
let chart = null;
19+
render(<WaterfallChart
20+
data={data}
21+
title={{
22+
visible: true,
23+
text: '每月收支情况(瀑布图)',
24+
}}
25+
autoFit
26+
padding="auto"
27+
xField='type'
28+
yField='money'
29+
meta={{
30+
type: {
31+
alias: '类别',
32+
},
33+
money: {
34+
alias: '金额',
35+
},
36+
}}
37+
38+
onGetG2Instance={(c) => {
39+
chart = c;
40+
}}
41+
/>);
42+
cleanup();
43+
});
44+
});

0 commit comments

Comments
 (0)