| 123456789101112131415161718192021222324252627 |
- import * as d3 from 'd3';
- // d3js module: add grid
- export default (selection, scales, options) => {
- const addGridlinesX = () => d3.axisBottom(scales.xScale).ticks(5);
- const addGridlinesY = () => d3.axisLeft(scales.yScale).ticks(15);
- // add the X gridlines
- selection.append('g')
- .attr('class', 'grid grid--x')
- .attr('transform', `translate(0, ${options.heightWithoutMargin})`)
- .call(
- addGridlinesX()
- .tickSize(-options.heightWithoutMargin)
- .tickFormat('')
- );
- // add the Y gridlines
- selection.append('g')
- .attr('class', `grid grid--y mod${options.module}__grid--y`)
- .call(
- addGridlinesY()
- .tickSize(-options.widthWithoutMargin)
- .tickFormat('')
- );
- };
|