Mercurial > gemma
changeset 4144:737e1199800f
draw now line with fixed delta
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 02 Aug 2019 11:07:29 +0200 |
parents | afc564e0db40 |
children | 6095e95db454 |
files | client/src/components/gauge/Waterlevel.vue |
diffstat | 1 files changed, 5 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/gauge/Waterlevel.vue Fri Aug 02 11:01:30 2019 +0200 +++ b/client/src/components/gauge/Waterlevel.vue Fri Aug 02 11:07:29 2019 +0200 @@ -698,6 +698,8 @@ .call(lineChunked); }, drawNowLines({ scale, extent, diagram, navigation }) { + const [lo, hi] = extent.waterlevel; + const dy = Math.ceil(0.15 * (hi - lo)); const nowLine = d3 .line() .x(d => scale.x(d.x)) @@ -706,19 +708,14 @@ const nowLabel = selection => { selection.attr( "transform", - `translate(${scale.x(new Date())}, ${scale.y( - Math.ceil(extent.waterlevel[1] * 1.07) - )})` + `translate(${scale.x(new Date())}, ${scale.y(hi + dy)})` ); }; // draw in main diagram .append("path") - .datum([ - { x: new Date(), y: Math.floor(extent.waterlevel[0] * 0.9) }, - { x: new Date(), y: Math.ceil(extent.waterlevel[1] * 1.07) } - ]) + .datum([{ x: new Date(), y: lo - dy }, { x: new Date(), y: hi + dy }]) .attr("class", "now-line") .attr("d", nowLine); diagram // label @@ -731,10 +728,7 @@ // draw in nav navigation .append("path") - .datum([ - { x: new Date(), y: extent.waterlevel[0] }, - { x: new Date(), y: extent.waterlevel[1] - 20 } - ]) + .datum([{ x: new Date(), y: hi + dy }, { x: new Date(), y: lo - dy }]) .attr("class", "now-line") .attr( "d",