hourly graph uses image with internal canvas for drawing
This commit is contained in:
parent
64fb06d7b4
commit
69d14236f1
|
@ -42,18 +42,20 @@ class HourlyGraph extends WeatherDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
drawCanvas() {
|
drawCanvas() {
|
||||||
if (!this.canvas) this.canvas = this.elem.querySelector('.chart canvas');
|
if (!this.image) this.image = this.elem.querySelector('.chart img');
|
||||||
|
|
||||||
// get available space
|
// get available space
|
||||||
const boundingRect = this.canvas.getBoundingClientRect();
|
const availableWidth = 532;
|
||||||
const availableWidth = boundingRect.width;
|
const availableHeight = 285;
|
||||||
const availableHeight = boundingRect.height;
|
|
||||||
|
|
||||||
this.canvas.width = availableWidth;
|
this.image.width = availableWidth;
|
||||||
this.canvas.height = availableHeight;
|
this.image.height = availableHeight;
|
||||||
|
|
||||||
// get context
|
// get context
|
||||||
const ctx = this.canvas.getContext('2d');
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = availableWidth;
|
||||||
|
canvas.height = availableHeight;
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.imageSmoothingEnabled = false;
|
ctx.imageSmoothingEnabled = false;
|
||||||
|
|
||||||
// calculate time scale
|
// calculate time scale
|
||||||
|
@ -97,6 +99,9 @@ class HourlyGraph extends WeatherDisplay {
|
||||||
this.elem.querySelector('.y-axis .l-2').innerHTML = midTemp;
|
this.elem.querySelector('.y-axis .l-2').innerHTML = midTemp;
|
||||||
this.elem.querySelector('.y-axis .l-3').innerHTML = minTemp;
|
this.elem.querySelector('.y-axis .l-3').innerHTML = minTemp;
|
||||||
|
|
||||||
|
// set the image source
|
||||||
|
this.image.src = canvas.toDataURL();
|
||||||
|
|
||||||
super.drawCanvas();
|
super.drawCanvas();
|
||||||
this.finishDraw();
|
this.finishDraw();
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,8 +367,6 @@ class Radar extends WeatherDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
RadarContext.putImageData(RadarImageData, 0, 0);
|
RadarContext.putImageData(RadarImageData, 0, 0);
|
||||||
|
|
||||||
// MapContext.drawImage(RadarContext.canvas, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static mergeDopplerRadarImage(mapContext, radarContext) {
|
static mergeDopplerRadarImage(mapContext, radarContext) {
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 50px;
|
left: 50px;
|
||||||
|
|
||||||
canvas {
|
img {
|
||||||
width: 532px;
|
width: 532px;
|
||||||
height: 285px;
|
height: 285px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<div class="label l-3">55</div>
|
<div class="label l-3">55</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="chart">
|
<div class="chart">
|
||||||
<canvas id="chart-area"></canvas>
|
<img id="chart-area"></img>
|
||||||
</div>
|
</div>
|
||||||
<div class="x-axis">
|
<div class="x-axis">
|
||||||
<div class="label l-1">12a</div>
|
<div class="label l-1">12a</div>
|
||||||
|
|
Loading…
Reference in a new issue