Get started with d3-dsv CDN

BSD-3-Clause licensed

D3-DSV: library for parsing, optimizing data for D3.js visualization.

Tags:
  • d3
  • dsv
  • csv
  • tsv

Stable version

Copied!

How to start using d3-dsv CDN


// Import d3 and d3-dsv libraries
const d3 = require("d3");
const dsv = require("d3-dsv");

// Set up the SVG container
const svg = d3.select("body")
  .append("svg")
  .attr("width", 500)
  .attr("height", 500);

// Define the parse function for CSV data
const parseCSV = dsv.parseCSV(
  "data:text/csv;charset=utf-8," +
  "id,x,y\n" +
  "1,10,20\n" +
  "2,50,80\n" +
  "3,70,120"
);

// Parse the CSV data using d3-dsv
parseCSV.then(function(data) {
  // Bind data to circles
  const circles = svg.selectAll("circle")
    .data(data)
    .enter()
    .append("circle")
    .attr("cx", function(d) { return d.x; })
    .attr("cy", function(d) { return d.y; })
    .attr("r", 5)
    .attr("fill", "steelblue");
});

All versions