-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Sankey renderer to React (#4255)
- Loading branch information
1 parent
79b37e8
commit 0aca649
Showing
6 changed files
with
291 additions
and
267 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { useState, useEffect, useMemo } from 'react'; | ||
import resizeObserver from '@/services/resizeObserver'; | ||
import { RendererPropTypes } from '@/visualizations'; | ||
|
||
import initSankey from './initSankey'; | ||
|
||
export default function Renderer({ data }) { | ||
const [container, setContainer] = useState(null); | ||
|
||
const render = useMemo(() => initSankey(data), [data]); | ||
|
||
useEffect(() => { | ||
if (container) { | ||
render(container); | ||
const unwatch = resizeObserver(container, () => { | ||
render(container); | ||
}); | ||
return unwatch; | ||
} | ||
}, [container, render]); | ||
|
||
return (<div className="sankey-visualization-container" ref={setContainer} />); | ||
} | ||
|
||
Renderer.propTypes = RendererPropTypes; |
File renamed without changes.
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.