Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/webapp/history-counters.js
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | export async function drawHistoryCounterGraph(container, historyData) { | ||||
// create line generator | // create line generator | ||||
const line = d3.line() | const line = d3.line() | ||||
.x(d => xScale(d[0])) | .x(d => xScale(d[0])) | ||||
.y(d => yScale(d[1])); | .y(d => yScale(d[1])); | ||||
// utility functions | // utility functions | ||||
const dateFormatter = d3.timeFormat('%d %b %Y'); | const dateFormatter = d3.timeFormat('%d %b %Y'); | ||||
const valueFormatter = d3.format('.3s'); | const valueFormatter = (v) => { | ||||
return d3.format('.3s')(v).replace(/G/, 'B'); | |||||
}; | |||||
const bisectDate = d3.bisector(d => d[0]).left; | const bisectDate = d3.bisector(d => d[0]).left; | ||||
// add x axis | // add x axis | ||||
g.append('g') | g.append('g') | ||||
.attr('class', 'axis') | .attr('class', 'axis') | ||||
.attr('transform', `translate(0, ${height})`) | .attr('transform', `translate(0, ${height})`) | ||||
.call( | .call( | ||||
d3.axisBottom(xScale) | d3.axisBottom(xScale) | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |