官术网_书友最值得收藏!

  • Learning D3.js Mapping
  • Thomas Newton Oscar Villarreal
  • 361字
  • 2021-08-06 19:42:42

Step-by-step bootstrap

The next section covers detailed instructions to set up your development environment to rapidly create visualizations in later chapters. By the end of the chapter, you will have a working environment for the rest of the book (an example of a map running and an initial look at tools used to create visualizations).

A lightweight web server

Technically, most of the content we will craft can render directly in the browser without the use of a web server. However, we highly recommend you not to go ahead with this approach. Running a web server in your local development environment is extremely easy and provides several benefits:

  • Geographic information, statistical data, and visualization code can be clearly separated into isolated files
  • API calls can be stubbed and simulated, allowing easy integration into a full-stack application in the future
  • It will prevent common mistakes when making AJAX calls to fetch geographic and statistical data (for example, the same-origin policy)

For our choice of the web server and other tools in our toolbox, we will rely on a Node.js package named http-server. Node.js is a platform built on Chrome's JavaScript runtime, which is used to build fast, scalable network applications. The platform includes Node Package Manager (npm), which was created by other members of the vibrant Node.js community and allows the developer to quickly install packages of prebuilt software.

To install Node.js, simply perform the following steps:

  1. Go to the website http://nodejs.org.
  2. Click on the INSTALL button.
  3. Open the downloaded package and follow the defaults.

To test the installation, type in the following in the command line:

node –v
v0.10.26 # or something similar should return

Now that Node.js and npm are installed, we can proceed to install the web server. When the web server is installed globally with the –g command, it becomes easily accessible throughout the system.

Once on the command line, enter the following:

npm install -g http-server

You can quickly verify the package was installed by typing the following:

http-server

Then open your web browser to http://localhost:8080. The browser should display a list of all the files in the directory from where you initiated the command.

主站蜘蛛池模板: 巍山| 民勤县| 繁昌县| 小金县| 奎屯市| 曲沃县| 龙门县| 章丘市| 米易县| 绥化市| 绥芬河市| 辽源市| 霍林郭勒市| 宁安市| 鄂温| 拜城县| 平南县| 卫辉市| 明溪县| 阿尔山市| 西青区| 克山县| 山东省| 贡觉县| 连平县| 佳木斯市| 资中县| 秦皇岛市| 拜城县| 武陟县| 隆昌县| 明星| 乐昌市| 台南市| 霍邱县| 共和县| 襄垣县| 贵定县| 娄烦县| 富平县| 沙田区|