From 99ae88488e13ef54b5ae3afc8bbe2d3a1273fbdb Mon Sep 17 00:00:00 2001 From: Alex Cabrera Date: Thu, 23 Apr 2020 11:07:47 -0400 Subject: [PATCH] update empty graph --- src/Graph.svelte | 55 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Graph.svelte b/src/Graph.svelte index 5be4650bb..52836320c 100644 --- a/src/Graph.svelte +++ b/src/Graph.svelte @@ -298,33 +298,34 @@ .selectAll('*') .remove(); - // // size chart - // var margin = { top: 20, right: 20, bottom: 70, left: 40 }, - // width = w - margin.left - margin.right, - // height = 0.75 * w - margin.top - margin.bottom; - - // // parse the date time - // var parseDate = d3.timeParse('%Y%m%d'); - - // // set ranges - // this.x = d3.scaleBand().rangeRound([0, width]); - // this.y = d3.scaleLinear().range([height, 0]); - - // // attach graphic - // var svg = d3 - // .select(el) - // .append('svg') - // .attr('width', width + margin.left + margin.right) - // .attr('height', height + margin.top + margin.bottom) - // .append('g') - // .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - // // draw axes - // svg - // .append('g') - // .attr('transform', 'translate(0,' + height + ')') - // .call(d3.axisBottom(this.x).tickFormat('')); - // svg.append('g').call(d3.axisLeft(this.y).tickFormat('')); + if (w > 400) w = 400; + // size chart + var margin = { top: 20, right: 20, bottom: 70, left: 40 }, + width = w - margin.left - margin.right, + height = 0.75 * w - margin.top - margin.bottom; + + // parse the date time + var parseDate = d3.timeParse('%Y%m%d'); + + // set ranges + this.x = d3.scaleBand().rangeRound([0, width]); + this.y = d3.scaleLinear().range([height, 0]); + + // attach graphic + var svg = d3 + .select(el) + .append('svg') + .attr('width', width + margin.left + margin.right) + .attr('height', height + margin.top + margin.bottom) + .append('g') + .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + // draw axes + svg + .append('g') + .attr('transform', 'translate(0,' + height + ')') + .call(d3.axisBottom(this.x).tickFormat('')); + svg.append('g').call(d3.axisLeft(this.y).tickFormat('')); } updateChart() {}