Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@redsift/d3-rs-geo

Package Overview
Dependencies
Maintainers
6
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redsift/d3-rs-geo

Generates geo maps using D3v4.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
6
Weekly downloads
 
Created
Source

d3-rs-geo

Circle CI npm MIT

d3-rs-geo presents a TopoJSON map in an SVG container.

Example

View @redsift/d3-rs-geo on Codepen

Flat map

Sample bars with a bottom orientation

Map with country coloring and great arcs

Sample bars with a left orientation

Usage

Browser

<script src="//static.redsift.io/reusable/d3-rs-geo/latest/d3-rs-geo.umd-es2015.min.js"></script>
<script>
    var chart = d3_rs_geo.html();
    d3.select('body').datum('https://static.redsift.io/thirdparty/topojson/examples/world-50m.json').call(chart);
</script>

ES6

import { html as chart } from "@redsift/d3-rs-geo";
let eml = chart();
...

Require

var chart = require("@redsift/d3-rs-geo");
var eml = chart.html();
...

Datum

Datum can be one of:

  1. String representing the URL to load the TopoJSON file for the map from
  2. Object representing the TopoJSON itself
  3. Object with key url (URL to load the TopoJSON file) and optionally the keys points and links

Points

Represents points of interest on the map. [ [ longitude, latitude ] ... ]

Points - Custom presentation

Default presentation uses a symbol. You can supply a custom symbol i.e. object that implements a draw function as per https://github.com/d3/d3-shape#symbol_type or supply a totally custom reusable component via the pointsDisplay property.

// Display a text label instead of the default symbol.
var points = [ [ -76.852587, 38.991621, 'NY' ], [ -0.076132, 51.5074, 'London' ] ];

function displayText(selection) {
    selection.each(function(d, i) {
        let node = select(this).selectAll('text').data([ d ]);
        node = node.enter().append('text').merge(node);
        node.text(d[2]);
    });
}
var chart = d3_rs_geo.html().points(points).pointsDisplay(displayText);
d3.select('body')
    .datum('https://static.redsift.io/thirdparty/topojson/examples/world-50m.json')
    .call(chart);

Represents great arcs between two points. [ [ longitude-1, latitude-1, longitude-2, latitude-2 ] ... ]

Default presentation uses a dashed line.

// Display a solid red line
var links = [ [ -76.852587, 38.991621, -0.076132, 51.5074 ] ];

function redLine(selection) {
    selection.attr('stroke', 'red').attr('stroke-width', '2px');
}
var chart = d3_rs_geo.html().links(links).linksDisplay(redLine);
d3.select('body')
    .datum('https://static.redsift.io/thirdparty/topojson/examples/world-50m.json')
    .call(chart);

onClick(d,i,c)

Click handler for map interactions. d will be the object of the interaction from the TopoJSON data structure. E.g. if the click was on a country, d will be an object and d.id will be the ISO_3166-1 country code.

d will be null if the click was outside a country boundary.

Parameters

PropertyDescriptionTransitionPreview
classedString SVG custom classN
width, height, size, scaleInteger SVG container sizesY
background
theme
margin
graticule
projectionhttp://map-projections.net/patterson.php
projectionScale
interruptedEnabled clipping for interrupted projections
countryBoolean enable country polygons
fillLand filling
pointsDecimal expression of [ Longitude, Latitude ]
pointsDisplay
links
linksDisplay
zoom
zoomX, zoomY
onClick

Keywords

FAQs

Package last updated on 14 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc