Guest User

Untitled

a guest
Dec 12th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. function redrawChart() {
  2. const enabledRegionsIds = regionsIds.filter(regionId => regions[regionId].enabled);
  3.  
  4. const paths = svg
  5. .selectAll('.line')
  6. .data(enabledRegionsIds);
  7.  
  8. paths.exit().remove();
  9.  
  10. paths
  11. .enter()
  12. .append('path')
  13. .merge(paths)
  14. .attr('class', 'line')
  15. .attr('id', regionId => `region-${ regionId }`)
  16. .attr('d', regionId => lineGenerator(regions[regionId].data)
  17. )
  18. .style('stroke', regionId => colorScale(regionId));
  19.  
  20. legends.each(function(regionId) {
  21. const opacityValue = enabledRegionsIds.indexOf(regionId) >= 0 ? ENABLED_OPACITY : DISABLED_OPACITY;
  22.  
  23. d3.select(this).attr('opacity', opacityValue);
  24. });
  25. }
Add Comment
Please, Sign In to add comment