Created
June 21, 2018 07:33
-
-
Save levvsha/65fa45eb9cc486a6710405ef5b94fc52 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const legendContainer = d3.select('.legend'); | |
| const legends = legendContainer | |
| .append('svg') | |
| .attr('width', 150) | |
| .attr('height', 353) | |
| .selectAll('g') | |
| .data(regionsIds) | |
| .enter() | |
| .append('g') | |
| .attr('class', 'legend-item') | |
| .attr('transform', (regionId, index) => `translate(0,${ index * 20 })`) | |
| .on('click', clickLegendHandler); | |
| legends.append('rect') | |
| .attr('x', 0) | |
| .attr('y', 0) | |
| .attr('width', 12) | |
| .attr('height', 12) | |
| .style('fill', regionId => colorScale(regionId)) | |
| .select(function() { return this.parentNode; }) | |
| .append('text') | |
| .attr('x', 20) | |
| .attr('y', 10) | |
| .text(regionId => regionsNamesById[regionId]) | |
| .attr('class', 'textselected') | |
| .style('text-anchor', 'start') | |
| .style('font-size', 12); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment