Skip to main content
100%

D3: Setting paragraphs' style conditionally, based on data

✓ Published0🌍 Public
KKaitlyn Trudeau
Last edited Oct 3, 2020
Created on Oct 3, 2020

This example demonstrates how D3.js can conditionally style paragraphs based on parsed CSV data. Using `d3.csv`, it loads California temperature records and binds each row to a paragraph whose text states “I can count up to [year].” The `.style()` method applies a color function that turns the text red when the temperature value exceeds 55, otherwise black. The visualization highlights threshold-based styling with D3’s data join, showing how data-driven decisions directly influence visual output. The code relies on D3 v6 and fetches data from a remote GitHub-hosted CSV file.

AI-generated description

A program that loads and parses some CSV data: CSS Named Colors.

MIT Licensed

Similar vizzes