Using an 'if' statement in v6
✓ Published0🌍 Public
Dd3noob
Last edited Sep 14, 2020
Created on Sep 14, 2020
This example combines a line chart and scatterplot to show stock closing prices over time, with circles colored red when the price is 400 or below and black otherwise. It uses d3.line to generate the line path, d3.scaleTime and d3.scaleLinear for the axes, and d3.axisBottom and d3.axisLeft to render them. Data is loaded from a CSV file via d3.csv and parsed with d3.timeParse. The coloring logic relies on an if statement inside the fill function.
AI-generated descriptionThis is a simple graph demonstrating the addition of filtering using an if statement with a graph.
This graph is part of the code samples for the update to the book D3 Tips and Tricks to version 6 of d3.js.
mit Licensed