4

Does anybody know how I might change the circles in this graph http://bost.ocks.org/mike/nations/ to be triangles and still dynamically grow and shrink?

enter image description here

VividD
  • 10,456
  • 6
  • 64
  • 111
Apollo
  • 8,874
  • 32
  • 104
  • 192

2 Answers2

7

There are a variety of ways to create triangles; one way to do this without doing any geometry yourself is to use d3.svg.symbol with the type "triangle-up". Like so:

mbostock
  • 51,423
  • 13
  • 175
  • 129
0

I think that the code is almost the same, but instead of drawing circles, you need to compute the vertices of a polygon with three edges. Is important that the area of your triangle to be proportional to the value that it represents. Take a look to the polygon documentation https://github.com/mbostock/d3/wiki/SVG-Shapes

Pablo Navarro
  • 8,244
  • 2
  • 43
  • 52