comparison client/src/components/fairway/AvailableFairwayDepth.vue @ 3327:7ab8a176db92

available_fairway_depth: adjust scale according to selected timerange
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 20 May 2019 12:41:57 +0200
parents 6996aa1d2df9
children 0e442b547f6d
comparison
equal deleted inserted replaced
3326:98ce6d101e01 3327:7ab8a176db92
73 import jsPDF from "jspdf"; 73 import jsPDF from "jspdf";
74 import canvg from "canvg"; 74 import canvg from "canvg";
75 import { pdfgen } from "@/lib/mixins"; 75 import { pdfgen } from "@/lib/mixins";
76 import { HTTP } from "@/lib/http"; 76 import { HTTP } from "@/lib/http";
77 import { displayError } from "@/lib/errors"; 77 import { displayError } from "@/lib/errors";
78 import { FREQUENCIES } from "@/store/fairwayavailability";
78 79
79 const hoursInDays = x => x / 24; 80 const hoursInDays = x => x / 24;
80 81
81 export default { 82 export default {
82 mixins: [diagram, pdfgen], 83 mixins: [diagram, pdfgen],
176 "to", 177 "to",
177 "frequency", 178 "frequency",
178 "legend" 179 "legend"
179 ]), 180 ]),
180 ...mapState("user", ["user"]), 181 ...mapState("user", ["user"]),
182 frequencyToRange() {
183 const frequencies = {
184 [FREQUENCIES.MONTHLY]: [-33, 33],
185 [FREQUENCIES.QUARTERLY]: [-93, 93],
186 [FREQUENCIES.YEARLY]: [-370, 370]
187 };
188 return frequencies[this.frequency];
189 },
181 fromDate() { 190 fromDate() {
182 return this.from; 191 return this.from;
183 }, 192 },
184 toDate() { 193 toDate() {
185 return this.to; 194 return this.to;
404 this.dimensions = this.getDimensions({ 413 this.dimensions = this.getDimensions({
405 main: { top: 20, right: 20, bottom: 110, left: 200 } 414 main: { top: 20, right: 20, bottom: 110, left: 200 }
406 }); 415 });
407 this.yScale = d3 416 this.yScale = d3
408 .scaleLinear() 417 .scaleLinear()
409 .domain([-33, 33]) 418 .domain(this.frequencyToRange)
410 .range([this.dimensions.mainHeight - 30, 0]); 419 .range([this.dimensions.mainHeight - 30, 0]);
411 d3.select(".diagram-container svg").remove(); 420 d3.select(".diagram-container svg").remove();
412 this.generateDiagramContainer(); 421 this.generateDiagramContainer();
413 this.drawBars(); 422 this.drawBars();
414 this.drawScaleLabel(); 423 this.drawScaleLabel();