Skip to main content
100%

Changing the colour of an axis in v4

✓ Published0🌍 Public
Dd3noob
Last edited Jul 20, 2016
Created on Jul 16, 2016

This example shows a simple line graph with time-based x-axis and linear y-axis, where the y-axis is rendered in red through a custom CSS class. The code uses d3.csv to load date and stock price data from a local CSV file, d3.timeParse to convert date strings, and d3.axisBottom and d3.axisLeft to generate the axes. The y-axis group receives the class `axisRed`, whose CSS rules set the stroke of its lines and paths, and the fill of its text, to red. The approach demonstrates a straightforward way to style individual axis components in d3 v4.

AI-generated description

This is a simple line graph written to illustrate a method of changing the colour of an axis in v4 of d3.js.

I suspect that it is not the best or most efficient method, so I am standing this up as an example to seek advice on a better solution. The question asked on Stack Overflow is here

forked from the block: <a href='http://bl.ocks.org/d3noob/402dd382a51a4f6eea487f9a35566de0'>Simple line graph with v4</a>

gpl-3.0 Licensed

Similar vizzes