Skip to content

Commit

Permalink
Show an example of changing Sankey names dynamically (uber#923)
Browse files Browse the repository at this point in the history
* show an example of changing sankey names dynamically

* fix tests and litn
  • Loading branch information
James Sayer committed Aug 23, 2018
1 parent 2ebcb8d commit 0766787
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions showcase/sankey/voronoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ export default class VoronoiSankeyExample extends React.Component {
<div>
<div>{`${activeNode ? activeNode.name : 'None'} selected`}</div>
<Sankey
nodes={nodes.map(d => ({
...d,
opacity: activeNode && d.name === activeNode.name ? FOCUSED_NODE_OPACITY : BLURRED_NODE_OPACITY
}))}
nodes={nodes.map(d => {
const isActiveNode = activeNode && d.name ===
activeNode.name;
return {
...d,
opacity: isActiveNode ? FOCUSED_NODE_OPACITY : BLURRED_NODE_OPACITY,
name: isActiveNode ? `!${d.name}!` : d.name
};
})}
links={links.map(d => ({...d}))}
width={200}
height={200}
Expand Down
2 changes: 1 addition & 1 deletion tests/components/sankey-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test('Sankey: Showcase Example - VoronoiSankey', t => {

t.equal($.text(), 'None selectedabc', 'should find that no bar is hovered');
$.find('.rv-voronoi__cell').at(0).simulate('mouseOver');
t.equal($.text(), 'a selectedabc', 'should find that the first bar is hovered bar is hovered');
t.equal($.text(), 'a selected!a!bc', 'should find that the first bar is hovered bar is hovered');
$.find('.rv-voronoi__cell').at(0).simulate('mouseLeave');

t.end();
Expand Down

0 comments on commit 0766787

Please sign in to comment.