# HG changeset patch # User Thomas Junk # Date 1558432095 -7200 # Node ID cd745be63f71b0e51a11572ea86d8f712778dd24 # Parent 83210507aaca6e1a7b8125429a311bf47e1c64dd available_fairway_depth: draw lower levels refactored diff -r 83210507aaca -r cd745be63f71 client/src/components/fairway/AvailableFairwayDepth.vue --- a/client/src/components/fairway/AvailableFairwayDepth.vue Tue May 21 10:33:07 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepth.vue Tue May 21 11:48:15 2019 +0200 @@ -467,9 +467,11 @@ .data(d => d.lowerLevels) .enter() .append("rect") - .attr("y", this.yScale(0)) + .attr("y", d => { + return 2 * this.yScale(0) - this.yScale(hoursInDays(d.translateY)); + }) .attr("height", d => { - return this.yScale(0) - this.yScale(hoursInDays(d)); + return this.yScale(0) - this.yScale(hoursInDays(d.height)); }) .attr("width", this.barsWidth) .attr("fill", (d, i) => { diff -r 83210507aaca -r cd745be63f71 client/src/store/fairwayavailability.js --- a/client/src/store/fairwayavailability.js Tue May 21 10:33:07 2019 +0200 +++ b/client/src/store/fairwayavailability.js Tue May 21 11:48:15 2019 +0200 @@ -30,26 +30,26 @@ const MOCKDATA = { [FREQUENCIES.MONTHLY]: ` #label,# >= LDC [h],# < 200.00 [h],# >= 200.00 [h],# >= 230.00 [h],# >= 250.00 [h] -05-2018,670.000,450.000,70.000,50.000,100.000`, - // 06-2018,669.000,546.000,0.000,0.000,123.000 - // 07-2018,671.000,377.000,0.000,0.000,294.000 - // 08-2018,668.000,168.000,0.000,0.000,500.000 - // 09-2018,673.000,23.000,0.000,0.000,650.000 - // 10-2018,670.000,4.000,0.000,0.000,666.000 - // 11-2018,672.000,1.000,0.000,0.000,671.000 - // 12-2018,675.000,5.000,0.000,0.000,670.000 - // 01-2019,677.000,0.000,0.000,0.000,677.000 - // 02-2019,668.000,43.000,0.000,0.000,625.000 - // 03-2019,660.000,49.000,0.000,0.000,611.000 - // 04-2019,620.000,20.000,0.000,0.000,600.000 - // 05-2019,672.000,42.000,0.000,0.000,630.000`, +05-2018,670.000,450.000,70.000,50.000,100.000 +06-2018,669.000,546.000,0.000,0.000,123.000 +07-2018,671.000,377.000,0.000,0.000,294.000 +08-2018,668.000,168.000,0.000,0.000,500.000 +09-2018,673.000,23.000,0.000,0.000,650.000 +10-2018,670.000,4.000,0.000,0.000,666.000 +11-2018,672.000,1.000,0.000,0.000,671.000 +12-2018,675.000,5.000,0.000,0.000,670.000 +01-2019,677.000,0.000,0.000,0.000,677.000 +02-2019,668.000,43.000,0.000,0.000,625.000 +03-2019,660.000,49.000,0.000,0.000,611.000 +04-2019,620.000,20.000,0.000,0.000,600.000 +05-2019,672.000,42.000,0.000,0.000,630.000`, [FREQUENCIES.QUARTERLY]: ` #label,# >= LDC [h],# < 200.00 [h],# >= 200.00 [h],# >= 230.00 [h],# >= 250.00 [h] -Q2-2018,1989.000,0.000,0.000,0.000,1823.000 -Q3-2018,2108.000,0.000,0.000,0.000,1956.000 -Q3-2018,2145.000,0.000,0.000,0.000,2001.000 -Q1-2019,2155.000,0.000,0.000,0.000,2021.000 -Q2-2019,2160.000,0.000,0.000,0.000,1998.000`, +Q2-2018,989.000, 500.000,240.000,260.000,1823.000 +Q3-2018,1108.000,500.000,180.000,320.000,1956.000 +Q3-2018,1145.000,500.000,250.000,250.000,2001.000 +Q1-2019,1155.000,500.000,400.000,100.000,2021.000 +Q2-2019,1160.000,500.000,300.000,200.000,1998.000`, [FREQUENCIES.YEARLY]: ` #label,# >= LDC [h],# < 200.00 [h],# >= 200.00 [h],# >= 230.00 [h],# >= 250.00 [h] 2018,8360.000,0.000,0.000,0.000,7360.000 @@ -133,11 +133,21 @@ const label = result.shift(); const ldc = result.shift(); const highestLevel = result.pop(); + const sum = result.reduce((x, y) => Number(x) + Number(y)); + let last = 0; + const levelsWithSum = result.map(x => { + let result = { + height: Number(x), + translateY: sum - (last + Number(x)) + }; + last = last + Number(x); + return result; + }); return { label: label, ldc: ldc, highestLevel: highestLevel, - lowerLevels: result + lowerLevels: levelsWithSum }; }); commit("setFwData", transformed);