From 29693a35fa9d6c3b987b646796ee197a95e2c3dc Mon Sep 17 00:00:00 2001 From: hellekin Date: Sun, 8 Nov 2020 17:00:56 +0100 Subject: Try fixing the SVG display bug again --- ps/gfx/sine.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ps/gfx') diff --git a/ps/gfx/sine.js b/ps/gfx/sine.js index 6958221..10bf7b6 100644 --- a/ps/gfx/sine.js +++ b/ps/gfx/sine.js @@ -12,7 +12,7 @@ const samples = Math.PI * 3 var data = generateSineData(samples) - + console.log(data) var xScale = d3.scaleLinear().domain([0, samples-1]).range([0, w]) @@ -29,8 +29,8 @@ .y1(function(d) { return yScale(d.y || d); }); const svg = view.append('svg') - .attr('width', width + margin.left + margin.right) - .attr('height', height + margin.top + margin.bottom) + .attr('width', bbox.width + margin.left + margin.right) + .attr('height', bbox.height + margin.top + margin.bottom) .append('g') .attr('transform',function(){ var x1 = bbox.x + bbox.width / 2 @@ -38,13 +38,13 @@ console.log(`rotate(90, ${x1}, ${y1}) translate(${margin.left}, ${margin.top})`) return `translate(${margin.left - x1}, ${margin.top -y1}) rotate(90, ${x1}, ${y1})` }) - -// svg.append("defs").append("clipPath").attr("id", "clip") -// .append("rect").attr("width", width).attr("height", height) -// .append("rect").attr("width", h).attr("height", w) + + svg.append("defs").append("clipPath").attr("id", "clip") + .append("rect").attr("width", width).attr("height", height) + .append("rect").attr("width", h).attr("height", w) const graphContainer = svg.append("g") -// .attr('transform', `translate(-${initialX}, -${initialY})`); + .attr('transform', `translate(-${initialX}, -${initialY})`); const state = { initialX, @@ -77,7 +77,7 @@ .attr('d', sine) }) } - + var drawGraph = function(state) { state.time += increase; drawSineWave(state); -- cgit v1.2.3