function renderGeography(map) {
    var g = map.el.map;
    var opts = map.options;
    var pad = 20;

    var geo = g.selectAll('path')
      .data(map.geodata);

    geo
      .enter()
      .insert('path');

    geo
      .attr('data-id', function(d) { return d.id; })
      .each(function(d) {
        var el = d3.select(this);
        var p = d.properties;

        el.attr('fill', p.fill_color || opts.fill_color);
        el.attr('stroke', p.stroke_color || opts.stroke_color);
        el.attr('stroke-width', p.stroke_size || opts.stroke_size);
        if (p.tooltip) el.attr('data-tooltip', p.tooltip);
      })
      .attr('d', map.path);

    geo
      .exit()
      .remove();

    // Scale and position map centered within map view:
    var bbox = g.node().getBBox();
    var maxWidth = opts.width - (pad * 2);
    var scale = maxWidth / bbox.width;
    var offsetX = pad - (bbox.x * scale);
    var offsetY = map._y - (bbox.y * scale);
    g.attr('transform', 'translate('+offsetX+','+offsetY+') scale('+scale+')');

    map._y += Math.round(bbox.height * scale) + pad;
  }
// Renders all map geography shapes with their colors:
Renders all map geography shapes with their colors.
Renders all map geography shapes with their colors .
function renderGeography(map) {
    var g = map.el.map;
    var opts = map.options;
    var pad = 20;
    var geo = g.selectAll('path')
      .data(map.geodata);
    geo
      .enter()
      .insert('path');
    geo
      .attr('data-id', function(d) { return d.id; })
      .each(function(d) {
        var el = d3.select(this);
        var p = d.properties;
        el.attr('fill', p.fill_color || opts.fill_color);
        el.attr('stroke', p.stroke_color || opts.stroke_color);
        el.attr('stroke-width', p.stroke_size || opts.stroke_size);
        if (p.tooltip) el.attr('data-tooltip', p.tooltip);
      })
      .attr('d', map.path);
    geo
      .exit()
      .remove();
    var bbox = g.node().getBBox();
    var maxWidth = opts.width - (pad * 2);
    var scale = maxWidth / bbox.width;
    var offsetX = pad - (bbox.x * scale);
    var offsetY = map._y - (bbox.y * scale);
    g.attr('transform', 'translate('+offsetX+','+offsetY+') scale('+scale+')');
    map._y += Math.round(bbox.height * scale) + pad;
  }
function renderGeography ( map ) { var g = map . el . map ; var opts = map . options ; var pad = 20 ; var geo = g . selectAll ( 'path' ) . data ( map . geodata ) ; geo . enter ( ) . insert ( 'path' ) ; geo . attr ( 'data-id' , function ( d ) { return d . id ; } ) . each ( function ( d ) { var el = d3 . select ( this ) ; var p = d . properties ; el . attr ( 'fill' , p . fill_color || opts . fill_color ) ; el . attr ( 'stroke' , p . stroke_color || opts . stroke_color ) ; el . attr ( 'stroke-width' , p . stroke_size || opts . stroke_size ) ; if ( p . tooltip ) el . attr ( 'data-tooltip' , p . tooltip ) ; } ) . attr ( 'd' , map . path ) ; geo . exit ( ) . remove ( ) ; var bbox = g . node ( ) . getBBox ( ) ; var maxWidth = opts . width - ( pad * 2 ) ; var scale = maxWidth / bbox . width ; var offsetX = pad - ( bbox . x * scale ) ; var offsetY = map . _y - ( bbox . y * scale ) ; g . attr ( 'transform' , 'translate(' + offsetX + ',' + offsetY + ') scale(' + scale + ')' ) ; map . _y += Math . round ( bbox . height * scale ) + pad ; }
Renders all map geography shapes with their colors:
Renders all map geography shapes with their colors :
// Scale and position map centered within map view: