Skip to content

Instantly share code, notes, and snippets.

@basith374
Created July 18, 2020 11:34
Show Gist options
  • Save basith374/0e3f84e6d83bd84f33b40fde5309c633 to your computer and use it in GitHub Desktop.
Save basith374/0e3f84e6d83bd84f33b40fde5309c633 to your computer and use it in GitHub Desktop.
d3 v4 line chart
import { scaleLinear, scaleLog, axisLeft, axisBottom, select, line, format } from 'd3';
const yScale = scaleLog().domain([0, 100]).range([300, 0])
const xScale = scaleLinear().domain([1, 100]).range([0, 500]);
const pathline = line().x(d => xScale(d.x)).y(d => yScale(d.y));
axisLeft(yScale).tickValues([maxViews, minViews]).tickFormat(format('.2s'))(select('.leftAxis'));
axisBottom(xScale).tickValues([1, songs.length])(select('.bottomAxis'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment