From 8bd715ad16405e3d3c49fbba61307b47791ca193 Mon Sep 17 00:00:00 2001 From: Goutte Date: Wed, 24 May 2017 12:05:51 +0200 Subject: [PATCH] Use a pixel art image for the sun. --- web/static/img/sun_128.png | Bin 0 -> 1719 bytes web/static/img/sun_256.png | Bin 0 -> 2217 bytes web/static/js/swapp.js | 7 +++---- web/static/js/swapp.ls | 9 +++++---- web/view/home.html.jinja2 | 3 +++ 5 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 web/static/img/sun_128.png create mode 100644 web/static/img/sun_256.png diff --git a/web/static/img/sun_128.png b/web/static/img/sun_128.png new file mode 100644 index 0000000..95d3d1f Binary files /dev/null and b/web/static/img/sun_128.png differ diff --git a/web/static/img/sun_256.png b/web/static/img/sun_256.png new file mode 100644 index 0000000..7d10bd0 Binary files /dev/null and b/web/static/img/sun_256.png differ diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index c2ee022..495ecd2 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -63,7 +63,7 @@ return active_sources.forEach(function(source){ return this$.loadData(source.slug, '2016-01-01T00:00:00', '2023-01-01T00:00:00').then(function(data){ this$.createTimeSeries(source, data); - return this$.orbits = new Orbits(configuration.sources, data['hci'], configuration.orbits_container); + return this$.orbits = new Orbits(this$.configuration.sources, data['hci'], this$.configuration.orbits_container, this$.configuration); }, function(data){ return console.error('Failed to load SW data.', data); }); @@ -359,9 +359,8 @@ this.yAxisTitle.append('tspan').attr('dy', '3px').text('HEE').attr('font-size', '8px'); this.yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)'); this.yAxisTitle.attr('transform', 'rotate(-90)'); - this.sun = this.plotWrapper.append("svg:circle"); + this.sun = this.plotWrapper.append("svg:image").attr('xlink:href', this.options.sun.img).attr('width', '32px').attr('height', '32px'); this.sun.append('svg:title').text("Sol"); - this.sun.attr("r", 17).style("fill", "yellow"); for (slug in ref$ = this.orbiters) { config = ref$[slug]; this.initOrbiter(slug, config); @@ -398,7 +397,7 @@ this.xScale.range([0, width]); this.yScale.range([height, 0]); this.svg.attr('width', width + this.margin.right + this.margin.left).attr('height', height + this.margin.top + this.margin.bottom); - this.sun.attr("cx", width / 2).attr("cy", height / 2); + this.sun.attr("x", width / 2 - 16).attr("y", height / 2 - 16); for (slug in ref$ = this.orbiters) { config = ref$[slug]; this.resizeOrbiter(slug, config); diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index 7ec05e4..92fefd2 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -48,7 +48,7 @@ export class SpaceWeather (data) ~> @createTimeSeries(source, data) # fixme: don't create a new Orbits instance every time - @orbits = new Orbits(configuration.sources, data['hci'], configuration.orbits_container) + @orbits = new Orbits(@configuration.sources, data['hci'], @configuration.orbits_container, @configuration) , (data) ~> console.error('Failed to load SW data.', data) ) @@ -376,9 +376,10 @@ export class Orbits @yAxisTitle.append('tspan').attr('dy', '-3px').text(' (AU)') @yAxisTitle.attr('transform', 'rotate(-90)') - @sun = @plotWrapper.append("svg:circle") + @sun = @plotWrapper.append("svg:image") + .attr('xlink:href', @options.sun.img) + .attr('width', '32px').attr('height', '32px') @sun.append('svg:title').text("Sol") - @sun.attr("r", 17).style("fill", "yellow") for slug, config of @orbiters @initOrbiter(slug, config) @@ -424,7 +425,7 @@ export class Orbits @svg.attr('width', width + @margin.right + @margin.left) .attr('height', height + @margin.top + @margin.bottom) - @sun.attr("cx", width / 2).attr("cy", height / 2) + @sun.attr("x", width / 2 - 16).attr("y", height / 2 - 16) for slug, config of @orbiters @resizeOrbiter(slug, config) diff --git a/web/view/home.html.jinja2 b/web/view/home.html.jinja2 index d93cc7f..41ac394 100755 --- a/web/view/home.html.jinja2 +++ b/web/view/home.html.jinja2 @@ -161,6 +161,9 @@ var configuration = { 'data_for_interval': "{{ request.url_root }}/data.csv" // ?started_at=&stopped_at= }, + sun: { + img: '{{ static('img/sun_128.png') }}' + }, sources : { jupiter: { slug: 'jupiter', -- libgit2 0.21.2