Skip to content

Commit 8990bfb

Browse files
committed
Initial stab at using combine
1 parent becdf42 commit 8990bfb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/VisualizationLayer.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { geoPath, geoMercator } from 'd3-geo';
3-
import { toCircle, fromCircle } from 'flubber';
3+
import { toCircle, fromCircle, combine } from 'flubber';
44
import { interpolateHsl, interpolateNumber } from 'd3-interpolate';
55
import { scaleLinear } from 'd3-scale';
66
import TweenMax from 'gsap/TweenMax';
@@ -103,6 +103,12 @@ class VisualizationLayer extends React.Component {
103103
.filter(d => d.length > 0)
104104
.sort((a, b) => b.length - a.length)
105105
.join('M')}`;
106+
107+
d.geoPathMultiple = d.geoPath.split('M').filter((d, i) => i !== 0);
108+
d.geoPathMultiple = d.geoPathMultiple.map(gp => `M${gp}`);
109+
console.log('d.geoPathMultiple', d.geoPathMultiple);
110+
console.log('d.circlePath', d.circlePath);
111+
console.log('d.geoPath', d.geoPath);
106112
}
107113

108114
d.properties.neighbors &&
@@ -204,7 +210,9 @@ class VisualizationLayer extends React.Component {
204210
}
205211

206212
d.circlePath = generateCirclePath(d.x, d.y, d.r);
207-
d.toCartogram = toCircle(d.geoPath, d.x, d.y, d.r);
213+
d.toCartogram = d.geoPathMultiple
214+
? combine(d.geoPathMultiple, d.circlePath)
215+
: toCircle(d.geoPath, d.x, d.y, d.r);
208216
d.toMap = fromCircle(d.x, d.y, d.r, d.geoPath);
209217
d.toCartogramStyle = interpolateStyles(geoStyleD, circleStyleD);
210218
d.toMapStyle = interpolateStyles(circleStyleD, geoStyleD);

0 commit comments

Comments
 (0)