Skip to main content
100%

Using an 'if' statement in v4

✓ Published0🌍 Public
Dd3noob
Last edited Aug 15, 2016
Created on Aug 15, 2016

This example shows a line chart of stock closing prices over time, with points colored conditionally based on their value. The visualization combines a steelblue line path with circles that are red when the closing price is 400 or below and black otherwise. It uses d3.csv to load the data, d3.timeParse for date parsing, and d3.scaleTime and d3.scaleLinear for axes. The if statement inside the circle fill function demonstrates how to apply category-based styling within a d3.v4 data join.

AI-generated description

This is a simple graph demonstrating the addition of filtering using an if statement with a graph. This was written using d3.js v4 and is a follow on to the simple scatter plot example here.

This graph is part of the code samples for the update to the book D3 Tips and Tricks to version 4 of d3.js.

Similar vizzes