Giter VIP home page Giter VIP logo

d3-demo's Introduction

An Introduction to D3

This repo contains boilerplate code for an introduction to the D3.js library. D3 is a javascript library that uses HTML, CSS, and SVG to bind data to DOM elements making possible an unlimited variety of data visualizations.

The code in this repo can be used to create line charts showing 5-day weather forecasts for any given US zip code. A deployed example of this app can be found at http://d3-weather-chart.surge.sh/.

The branch master contains boilerplate code that we can add D3 methods to. The Final branch contains the final result. The D3 methods to create the line charts can be found at https://gist.github.com/jsheridanwells/fc18e1bd39624f9c995f8ffcd48b3ad0.

In addition to D3, this library uses jQuery for AJAX requests and Bootstrap for styling. The data for this project comes from the OpenWeatherMap.org API.

Getting Started

In order to make AJAX requests, you will need a local development server. Http-server is a very easy option.

To install http-server, run:

$ npm install http-server -g

Follow these instructions to create a directory and to download the starter files:

  1. Clone this repository into a directory of your choice.
$ git clone https://github.com/jsheridanwells/D3-Demo.git
  1. Change to the D3-Demo directory
$ cd D3-Demo
  1. Start http-server. This will open your browser to the index at http://localhost:8080
$ http-server -o

Lastly, to get data from OpenWeatherMap, you will need to get a free API key and include that in the application files:

  1. Sign up for an API key.

  2. Create a file called api.js in the javascripts directory:

$ touch javascripts/api.js
  1. Open the api.js file in a text editor and paste the following code, replacing [YOUR API KEY] with the API key that you received from OpenWeatherMap.org:
'use strict';

// holds OpenWeatherMap.org api key
let api = '[YOUR API KEY]';

Once your API key is saved, if you refresh the browser, open your developer tools console, and enter a zip code in the input field, you should see a console log with data received from OpenWeatherMap.org.

d3-demo's People

Contributors

jsheridanwells avatar

Watchers

Seth avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.