CartesianGrid = (canvas, size=[500, 500], xDomain=[1, -1], yDomain=[-1, 1], padding=10 ) => {
const grid = canvas.append('g').attr("class", "grid grid--cartesian");
const height = size[1];
const width = size[0];
const xScale = d3.scaleLinear().domain(xDomain).range([width - padding, padding]);
const yScale = d3.scaleLinear().domain(yDomain).range([height - padding, padding]);
const yAxis = d3.axisLeft(yScale);
const xAxis = d3.axisBottom(xScale)
const xAxisPlot = grid.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + (height / 2) +")")
.call(xAxis.tickSize(-height, 0, 0));
const yAxisPlot = grid.append("g")
.attr("class", "axis axis--y")
.attr("transform", "translate("+ (width/2) +",0)")
.call(yAxis.tickSize(-width, 0, 0));
xAxisPlot.selectAll(".tick line")
.attr("stroke", "silver")
.attr("y1", (width - (2*padding))/2 * -1)
.attr("y2", (width - (2*padding))/2 * 1);
yAxisPlot.selectAll(".tick line")
.attr("stroke", "silver")
.attr("x1", (width - (2*padding))/2 * -1)
.attr("x2", (width - (2*padding))/2 * 1);
}