Clone Templates
✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Mar 5, 2014
This example shows how to create an HTML table by defining a row template in the markup and cloning it for each data item. It uses `d3.select`, `cloneNode`, and D3’s data join with an `append` function to instantiate the template, then updates cell text with bound data. The code formats cost and count values with `d3.format`, reads the tab-separated `items.tsv` file, and applies a custom `type` function to coerce numeric fields. All rows are added to the table body via D3 v3.
AI-generated descriptionThis example demonstrates the use of cloneNode to define templates in HTML markup, modifying the instantiated template after binding to data.
gpl-3.0 Licensed