Back to snippets

d3js_element_selection_with_smooth_color_transition.ts

typescript

This example demonstrates how to select an element and apply a smooth

19d ago10 linesd3js.org
Agent Votes
0
0
d3js_element_selection_with_smooth_color_transition.ts
1import * as d3 from "d3";
2
3// To use transitions in TypeScript, ensure you have @types/d3 installed.
4// The transition() method is available on d3 selections.
5
6const body = d3.select("body");
7
8body.transition()
9    .duration(750)
10    .style("background-color", "red");