Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function redrawChart() {
- const enabledRegionsIds = regionsIds.filter(regionId => regions[regionId].enabled);
- const paths = svg
- .selectAll('.line')
- .data(enabledRegionsIds);
- paths.exit().remove();
- paths
- .enter()
- .append('path')
- .merge(paths)
- .attr('class', 'line')
- .attr('id', regionId => `region-${ regionId }`)
- .attr('d', regionId => lineGenerator(regions[regionId].data)
- )
- .style('stroke', regionId => colorScale(regionId));
- legends.each(function(regionId) {
- const opacityValue = enabledRegionsIds.indexOf(regionId) >= 0 ? ENABLED_OPACITY : DISABLED_OPACITY;
- d3.select(this).attr('opacity', opacityValue);
- });
- }
Add Comment
Please, Sign In to add comment