Skip to content

Commit

Permalink
bugfix: 修复瀑布图
Browse files Browse the repository at this point in the history
  • Loading branch information
Leannechn committed Sep 30, 2021
1 parent 0b34c3b commit aa3b368
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bizcharts",
"version": "4.1.12-beta.1",
"version": "4.1.12",
"description": "bizcharts",
"keywords": [
"bizcharts",
Expand Down
4 changes: 2 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as SVGEngine from '@antv/g-svg/lib';
import { registerEngine } from '@antv/g2/lib/core';
// 导出自定义比例尺的能力
export { registerScale, getScale, registerTickMethod } from '@antv/scale';

export { setGlobal, GLOBAL } from '@antv/g2Plot/lib/core/global';
import './extend/scale/scale';

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

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



Expand Down
8 changes: 8 additions & 0 deletions src/createPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ import {
import { debounce, isArray, isFunction, isNil } from '@antv/util';
import warn from 'warning';

// 国际化处理
import { registerLocale } from '@antv/g2Plot/lib/core/locale';
import { EN_US_LOCALE } from '@antv/g2Plot/lib/locales/en_US';
import { ZH_CN_LOCALE } from '@antv/g2Plot/lib/locales/zh_CN';
/** default locale register */
registerLocale('en-US', EN_US_LOCALE);
registerLocale('zh-CN', ZH_CN_LOCALE);

const DEFAULT_PLACEHOLDER = (
<div
style={{ position: 'absolute', top: '48%', left: '50%', color: '#aaa', textAlign: 'center' }}
Expand Down
8 changes: 6 additions & 2 deletions src/plots/WaterfallChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import 'react';
import {Waterfall, WaterfallOptions } from '@antv/g2plot/lib/plots/waterfall';
import createPlot from '../createPlot';
import {Waterfall, WaterfallOptions as Options } from '@antv/g2plot/lib/plots/waterfall';
import createPlot, { BasePlotOptions } from '../createPlot';

interface WaterfallOptions extends Options, BasePlotOptions {

}

export default createPlot<WaterfallOptions>(Waterfall, 'WaterfallChart');
1 change: 1 addition & 0 deletions src/plots/core/dependents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type CategoryLegend = typeof Legend.Category;
type ContinuousLegend = typeof Legend.Continuous;
export { CategoryLegend, ContinuousLegend };
type HtmlTooltip = typeof Tooltip.Html;

export { HtmlTooltip };
export { Slider };
export { Scrollbar };
44 changes: 44 additions & 0 deletions unittest/plots/WaterfallChart-spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import WaterfallChart from '../../src/plots/WaterfallChart';
import { render, cleanup } from '@testing-library/react';

// 数据源
const data = [
{ type: '日用品', money: 120 },
{ type: '伙食费', money: 900 },
{ type: '交通费', money: 200 },
{ type: '水电费', money: 300 },
{ type: '房租', money: 1200 },
{ type: '商场消费', money: 1000 },
{ type: '应酬红包', money: -2000 },
];

describe('Plots-WaterfallChart', () => {
test('基础WaterfallChart', () => {
let chart = null;
render(<WaterfallChart
data={data}
title={{
visible: true,
text: '每月收支情况(瀑布图)',
}}
autoFit
padding="auto"
xField='type'
yField='money'
meta={{
type: {
alias: '类别',
},
money: {
alias: '金额',
},
}}

onGetG2Instance={(c) => {
chart = c;
}}
/>);
cleanup();
});
});

0 comments on commit aa3b368

Please sign in to comment.