src/components/world.js
// This positions labels and also hides them conditionally
This positions labels and also hides them conditionally
This positions labels and also hides them conditionally
function position_labels() {
      svg
        .selectAll(".label")
        .attr("transform", function(d) {
          return (
            "translate(" + projection(d.features[3].geometry.coordinates) + ")"
          );
        })
        .attr("dx", function(d) {
          return d.labelOffset[0];
        })
        .attr("dy", function(d) {
          return d.labelOffset[1];
        })
        .attr("opacity", function(d) {
          var geoangle = geo.geoDistance(d.features[3].geometry.coordinates, [
            -projection.rotate()[0],
            projection.rotate()[1]
          ]);
          if (geoangle > 1.5707963267949) {
            return "0";
          } else {
            return "1.0";
          }
        });
    }
function position_labels ( ) { svg . selectAll ( ".label" ) . attr ( "transform" , function ( d ) { return ( "translate(" + projection ( d . features [ 3 ] . geometry . coordinates ) + ")" ) ; } ) . attr ( "dx" , function ( d ) { return d . labelOffset [ 0 ] ; } ) . attr ( "dy" , function ( d ) { return d . labelOffset [ 1 ] ; } ) . attr ( "opacity" , function ( d ) { var geoangle = geo . geoDistance ( d . features [ 3 ] . geometry . coordinates , [ - projection . rotate ( ) [ 0 ] , projection . rotate ( ) [ 1 ] ] ) ; if ( geoangle > 1.5707963267949 ) { return "0" ; } else { return "1.0" ; } } ) ; }
This positions labels and also hides them conditionally
This positions labels and also hides them conditionally