Install:

npm install --save d3 d3-geo topojson

Code:

import React, {Component} from 'react';
import * as d3 from 'd3';
import 'd3-geo';
import * as topojson from 'topojson';
const us = require('./us.json'); const width = 960;
const height = 600; class Map extends Component {
componentDidMount() {
const svg = d3.select(this.refs.mountSvg)
.append('svg')
.attr('height', height)
.attr('width', width); const path = d3.geoPath(); svg.append('path')
.datum(topojson.feature(us, us.objects.states))
.attr('class', 'land')
.attr('d', path); } render() {
const style = {
width,
height,
border: '1px solid black',
margin: '10px auto'
};
return (
<div style={style} ref="mountSvg"></div>
);
}
} export default Map;

Github: Link

[D3] Draw a basic US d3-geo map的更多相关文章

  1. [D3] 10. Creating Axes with D3

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  2. echarts (geo/map) 渐变效果

    这两天帮人搞了下中国范围内仓库量统计的需求,查了下echarts 里的文档找到类似的demo(链接:https://ecomfe.github.io/echarts-examples/public/e ...

  3. [D3] Create Chart Axes with D3 v4

    Most charts aren’t complete without axes to provide context and labeling for the graphical elements ...

  4. [D3 + AngularJS] 15. Create a D3 Chart as an Angular Directive

    Integrating D3 with Angular can be very simple. In this lesson, you will learn basic integration as ...

  5. d3可视化实战00:d3的使用心得和学习资料汇总

    最近以来,我使用d3进行我的可视化工具的开发已经3个月了,同时也兼用其他一些图表类库,自我感觉稍微有点心得.之前我也写过相关文章,我涉及的数据可视化的实现技术和工具,但是那篇文章对于项目开发而言太浅了 ...

  6. [D3] Create DOM Elements with D3 v4

    Change is good, but creating from scratch is even better. This lesson shows you how to create DOM el ...

  7. [D3] Modify DOM Elements with D3 v4

    Once you can get hold of DOM elements you’re ready to start changing them. Whether it’s changing col ...

  8. [D3] Select DOM Elements with D3 v4

    Before you can create dazzling data driven documents, you need to know how D3 accesses the DOM. This ...

  9. [D3] 12. Basic Transitions with D3

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

随机推荐

  1. 27.AngularJS 下载地址

    转自:https://www.cnblogs.com/best/tag/Angular/ 各个 angular.js 版本下载: https://github.com/angular/angular. ...

  2. org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner$1

    不能加载或找不到 org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner$1 经查证,是mybatis-spring-xxx.jar 这个版 ...

  3. c# 读取 excel文件内容,写入txt文档

    1 winform 读取excel文档 1)点击button按钮,弹出上传excel窗口 private void button_headcompany_Click(object sender, Ev ...

  4. C# double保留四位小数

    2.保留N位,四舍五入 . decimal d= decimal.Round(decimal.Parse("0.55555"),4); 3.保留N位四舍五入 Math.Round( ...

  5. UESTC 1584

    http://acm.uestc.edu.cn/#/problem/show/1584 Washi与Sonochi的约定 Time Limit: 3000/1000MS (Java/Others)   ...

  6. webpack4强势来袭

    # Webpack4## 安装> webpack 4默认不需要配置文件(它吸收了Parcel的思想,零配置)> - npm i -D webpack> - npm i -D webp ...

  7. Eclipse+PyDev解决中文输入和注释问题

    Eclipse的设置 window->preferences->general->editors->text editors->spelling->encoding ...

  8. 华为OJ平台试题 ——数组:整形数组合并

    代码: /* * 将两个整型数组依照升序合并,而且过滤掉反复数组元素 */ #include <stdio.h> #define N 256 #define M 512 /* * 合并数组 ...

  9. QQ互联账号登录

    本文说明的是依据某应用通过网页的qq信息来登录的过程.用途是利用QQ账号就能高速自己主动注冊并可以登录客户应用. 从webserver与腾讯server通信获取开房平台用户OpenID,再在应用ser ...

  10. jQuery源码06-jQuery = function(){};给JQ对象,添加一些方法和属性,extend : JQ的继承方法,jQuery.extend()

    /*! * Includes Sizzle.js 选择器,独立的库 * http://sizzlejs.com/ */ (function( window, undefined ) { //" ...