-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bar): bar plot not transformData before changedata (#2317)
* fix(bar): bar plot not transformData before changedata * test: destroy plot afterall * fix: prettier lint * fix: test fail Co-authored-by: kasmine <visiky>
- Loading branch information
Showing
5 changed files
with
54 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Bar } from '../../src'; | ||
import { createDiv } from '../utils/dom'; | ||
|
||
describe('bar changeData should keep order', () => { | ||
const data = [ | ||
{ | ||
type: '家具家电', | ||
sales: 38, | ||
}, | ||
{ | ||
type: '粮油副食', | ||
sales: 52, | ||
}, | ||
{ | ||
type: '生鲜水果', | ||
sales: 61, | ||
}, | ||
]; | ||
|
||
it('keep data order', () => { | ||
const barPlot = new Bar(createDiv(), { | ||
data, | ||
xField: 'sales', | ||
yField: 'type', | ||
seriesField: 'type', | ||
}); | ||
|
||
barPlot.render(); | ||
const chartData = barPlot.chart.getData(); | ||
barPlot.changeData(data); | ||
|
||
// 绘制从下至上 | ||
expect(barPlot.chart.geometries[0].elements[0].getData().sales).toBe(data[2].sales); | ||
expect(barPlot.chart.getData()).toEqual(chartData); | ||
|
||
barPlot.destroy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { BarOptions } from '.'; | ||
|
||
/** | ||
* 条形图数据需要进行反转 | ||
* @param data | ||
*/ | ||
export function transformBarData(data: BarOptions['data']): BarOptions['data'] { | ||
return data ? data.slice().reverse() : data; | ||
} |