Skip to main content
100%

Dynamic historical stock data with d3.js and YQL

✓ Published0🌍 Public
Dd3noob
Last edited Nov 30, 2019
Created on Mar 16, 2014

This interactive line chart displays daily stock prices for a user-selected ticker symbol over a specified date range. HTML input fields and an Update button control the query, which fetches historical data from Yahoo Finance’s YQL API. The visualization, built with d3.js (version 3.5.17), renders an SVG area with axes, a steelblue line for daily high prices, and a dynamically updated title. The code uses `d3.json` for the AJAX call, `d3.time.scale` and `d3.scale.linear` for plotting, and `d3.svg.line` for the path, with no input sanitization.

AI-generated description

This is a chart as used as an example to demonstrate the integration of a YQL query with d3.js and incorperating a degree of control over the query. It is described in the book D3 Tips and Tricks.

You can enter a stock in the form of a ticker symbol (YHOO = Yahoo!, MSFT = Microsoft, KO = Coca-Cola) along with a start and end date (in the format yyyy-mm-dd).

Fair Warning: There is no degree of sanitisation or validation on the inputs. The purpose is to demonstrate the YQL integration with d3.js.

Interesting note: The original version of this example used 'GOOG' as the ticker symbol, but for whatever reason it no longer appears to work.

mit Licensed

Similar vizzes