Published
Edited
Aug 13, 2021
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
multiples = {

const svg = d3.create('svg')
.attr('viewBox', [0, 0, 900, 1650])
.attr('font-family', 'sans-serif')
const chartContainer = svg
.selectAll('path')
.data(scaledData)
.join('g')
.attr('transform', (d, i) => `translate(${(i % 4) * 200}, ${Math.floor(i / 4) * 200})`)
const text_g = chartContainer.append('g')
svg.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`)
// svg.append('g')
// .call(xAxis)

chartContainer.append('g')
.call(yAxis)
chartContainer.append('path')
.join('path')
.attr('fill', 'none')
.attr('stroke', 'steelblue')
.attr('stroke-width', 2)
.attr('d', lineGenerator)
chartContainer.append('text')
.attr('font-size', 9)
.attr('y', 55)
.text('Cases')
.style('font-weight', 'bold')
.attr('transform', 'translate(20, -20)')
text_g.append('text')
.data(getChartData)
.text(d => d.team)
.attr('transform', `translate(${visWidth / 2}, ${visHeight / 3})`)
.style('text-anchor', 'middle')
.style('font-size', '14px')
.style('font-weight', 'bold')

return svg.node()
}
Insert cell
xAxis = g => g
.attr('transform', `translate(0,${600 - margin.bottom})`)
.call(d3.axisBottom(xScale).ticks(width / 80).tickSizeOuter(0))
Insert cell
yAxis = g => g
.attr('transform', `translate(${margin.left},0)`)
.call(d3.axisLeft(yScale))
.call(g => g.select('.domain').remove())
.call(g => g.select('.tick:first-of-type text').remove())
Insert cell
xScale = d3.scalePoint()
.domain(Object.keys(counts.total))
.range([margin.left, height - margin.right])
Insert cell
yScale = d3.scaleLinear()
.domain([0, getYScale])
.range([height - margin.bottom, margin.top])
Insert cell
lineGenerator = d3.line()
.x(d => xScale(d[0]))
.y(d => yScale(d[1]))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more