-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sankey): changeData API for sankey (#2367)
* feat(sankey): add change data API * test: add test case for change data * chore: update code * chore: merge master * fix: ci
- Loading branch information
Showing
11 changed files
with
206 additions
and
86 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,26 @@ | ||
import { Sankey } from '../../../../src'; | ||
import { createDiv } from '../../../utils/dom'; | ||
import { delay } from '../../../utils/delay'; | ||
import { ALIPAY_DATA } from '../../../data/sankey-energy'; | ||
|
||
describe('sankey', () => { | ||
it('changeData', async () => { | ||
const data = ALIPAY_DATA.slice(0, ALIPAY_DATA.length - 5); | ||
const sankey = new Sankey(createDiv(), { | ||
height: 500, | ||
data, | ||
sourceField: 'source', | ||
targetField: 'target', | ||
weightField: 'value', | ||
}); | ||
|
||
sankey.render(); | ||
await delay(50); | ||
sankey.changeData(ALIPAY_DATA); | ||
|
||
expect(sankey.options.data).toEqual(ALIPAY_DATA); | ||
expect(sankey.chart.views[0].getOptions().data.length).toBe(ALIPAY_DATA.length); | ||
|
||
sankey.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
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,3 +1,5 @@ | ||
export const X_FIELD = 'x'; | ||
export const Y_FIELD = 'y'; | ||
export const COLOR_FIELD = 'name'; | ||
export const NODES_VIEW_ID = 'nodes'; | ||
export const EDGES_VIEW_ID = 'views'; |
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
Oops, something went wrong.