-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
62 additions
and
5 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
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
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'); |
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
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(); | ||
}); | ||
}); |