From d49a163c5816edfad03ba94e4369ca00407c40ca Mon Sep 17 00:00:00 2001 From: Goutte Date: Mon, 26 Jun 2017 08:52:10 +0200 Subject: [PATCH] Fix the resize and try to tweak the ticks some more. --- web/static/js/swapp.js | 15 +++++++++------ web/static/js/swapp.ls | 11 +++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index 7f4393c..90b54b7 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -63,7 +63,12 @@ }; SpaceWeather.prototype.resize = function(){ var ref$; - return (ref$ = this.orbits) != null ? ref$.resize() : void 8; + if ((ref$ = this.orbits) != null) { + ref$.resize(); + } + return timeSeries.forEach(function(ts){ + return ts.resize(); + }); }; SpaceWeather.prototype.init = function(){ var active_sources, res$, k, this$ = this; @@ -165,7 +170,6 @@ if (!(parameter_slug in this.parameters)) { console.error("Unknown parameter " + parameter_slug + "."); } - console.info("Enabling parameter " + parameter_slug + "...", $("#time_series ." + parameter_slug)); this.parameters[parameter_slug].active = true; timeSeries.forEach(function(ts){ if (ts.parameter === parameter_slug && this$.sources[ts.source.slug].active) { @@ -178,7 +182,6 @@ if (!(parameter_slug in this.parameters)) { console.error("Unknown parameter " + parameter_slug + "."); } - console.info("Disabling parameter " + parameter_slug + "..."); this.parameters[parameter_slug].active = false; timeSeries.forEach(function(ts){ if (ts.parameter === parameter_slug) { @@ -238,7 +241,7 @@ this.yScale = d3.scaleLinear().domain(d3.extent(this.data, function(d){ return d.y; })); - this.xAxis = d3.axisBottom().ticks(7, ",f").tickFormat(d3.timeFormat("%Y-%m-%d")); + this.xAxis = d3.axisBottom().tickFormat(d3.timeFormat("%Y-%m-%d")).ticks(7); this.yAxis = d3.axisLeft().ticks(10); this.line = d3.line().x(function(d){ return this$.xScale(d.x); @@ -278,8 +281,8 @@ this.path.attr('d', this.line); this.xAxis.scale(this.xScale); this.yAxis.scale(this.yScale); - this.xAxis.ticks(Math.floor(width / 60)); - this.yAxis.ticks(Math.floor(height / 18)); + this.xAxis.ticks(Math.floor(width / 90.0)); + this.yAxis.ticks(Math.floor(height / 18.0)); this.svg.select('.x.axis').attr('transform', 'translate(0,' + height + ')').call(this.xAxis); this.svg.select('.y.axis').call(this.yAxis); this.yAxisText.attr("y", 20 - this.margin.left).attr("x", 0 - height / 2); diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index 0dcd993..77f2a07 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -58,6 +58,7 @@ export class SpaceWeather resize: -> @orbits?.resize(); + timeSeries.forEach((ts) -> ts.resize()) init: -> active_sources = [ @sources[k] for k of @sources when @sources[k].config.active ] @@ -118,15 +119,12 @@ export class SpaceWeather enableParameter: (parameter_slug) -> if parameter_slug not of @parameters then console.error("Unknown parameter #{parameter_slug}.") - console.info("Enabling parameter #{parameter_slug}...", $("\#time_series .#parameter_slug")) @parameters[parameter_slug].active = true timeSeries.forEach((ts) ~> $(ts.svg.node()).show() if ts.parameter == parameter_slug && @sources[ts.source.slug].active) -# console.log("Assertion", @sources[ts.source.slug].active == ts.source.active) this disableParameter: (parameter_slug) -> if parameter_slug not of @parameters then console.error("Unknown parameter #{parameter_slug}.") - console.info("Disabling parameter #{parameter_slug}...") @parameters[parameter_slug].active = false timeSeries.forEach((ts) -> $(ts.svg.node()).hide() if ts.parameter == parameter_slug) this @@ -171,8 +169,9 @@ export class TimeSeries #console.info("Y domain #{@title}", d3.extent(@data, (d) -> d.y)) @xAxis = d3.axisBottom() - .ticks(7, ",f") .tickFormat(d3.timeFormat("%Y-%m-%d")) + .ticks(7) +# .ticks(7, ",f") @yAxis = d3.axisLeft() .ticks(10) @@ -263,8 +262,8 @@ export class TimeSeries @yAxis.scale(@yScale) #if width < 600 then @xAxis.ticks(3) else @xAxis.ticks(7, ",f") - @xAxis.ticks(Math.floor(width / 60)) - @yAxis.ticks(Math.floor(height / 18)) + @xAxis.ticks(Math.floor(width / 90.0)) # not working as expected + @yAxis.ticks(Math.floor(height / 18.0)) @svg.select('.x.axis') .attr('transform', 'translate(0,' + height + ')') -- libgit2 0.21.2