Skip to content
Snippets Groups Projects
Legend.vue 9.03 KiB
Newer Older
<template>
    
    <div style="height:100%;overflow:auto">
        <p class="text-xs ma-1 ">
Peter Morstein's avatar
Peter Morstein committed
            Legende
        </p>
         <v-card  class="mx-1">

            <v-card-text>
Peter Morstein's avatar
Peter Morstein committed
                <v-checkbox
Peter Morstein's avatar
Peter Morstein committed
                    v-model="stationLayerActive"
Peter Morstein's avatar
Peter Morstein committed
                    hide-details
Peter Morstein's avatar
Peter Morstein committed
                    @change="$emit('layerVisibility',$event,'stationLayer')"
Peter Morstein's avatar
Peter Morstein committed
                    dense
                >
                    <template v-slot:label>
Peter Morstein's avatar
Peter Morstein committed
                        <svg xmlns="http://www.w3.org/2000/svg" height="24px" width="24px" viewBox="0 0 24 24" fill="%23333333"><path d="M0 0h24v24H0z" fill="none"/><path d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" stroke="black"/></svg>   
                        Wetterstationen
                    </template>
                </v-checkbox>
Peter Morstein's avatar
Peter Morstein committed
                <div style="margin-top:1em;">
                    <div style="float:left;margin-top:5px;">   
Peter Morstein's avatar
Peter Morstein committed
                        {{parseInt(this.mapProperties.getTemperatureBound().min)}} °C

                    </div>
                    <div 
                        class="gradient mx-1"
                        :style="{ backgroundImage: createStationColorramp(mapProperties.getTemperatureColorMap()) }"
                    ></div>
                    <div style="float:left;margin-top:5px;">   
Peter Morstein's avatar
Peter Morstein committed
                        {{parseInt(this.mapProperties.getTemperatureBound().max)}} °C
Peter Morstein's avatar
Peter Morstein committed
                <v-slider
Peter Morstein's avatar
Peter Morstein committed
                    v-model="mapProperties.stationDate"
Peter Morstein's avatar
Peter Morstein committed
                    width="50px"
                    step="1"
Peter Morstein's avatar
Peter Morstein committed
                    :min="mapProperties.completeDaterange[0]"
                    :max="mapProperties.completeDaterange[1]"
                    thumb-label="always"
                    thumb-size="29px"
Peter Morstein's avatar
Peter Morstein committed
                    style="margin-top:5em;margin-bottom:-25px;"
Peter Morstein's avatar
Peter Morstein committed
                    dense
                    @change="$emit('stationUpdate', $event)"
Peter Morstein's avatar
Peter Morstein committed
                >
                </v-slider>
Peter Morstein's avatar
Peter Morstein committed
            </v-card-text>
        </v-card>
        <v-card  class="ma-1">
            <v-card-text>
                <v-checkbox
Peter Morstein's avatar
Peter Morstein committed
                    v-model="layer1Active"
Peter Morstein's avatar
Peter Morstein committed
                    hide-details
                    dense
Peter Morstein's avatar
Peter Morstein committed
                    @change="$emit('layerVisibility',$event,'avgLayer1')"
                >
                    <template v-slot:label>
                        <div>
                            <v-icon>
                                 mdi-checkerboard
                            </v-icon> 
                            Durchschnittstemperatur Layer 1
                        </div>
                    </template>
                </v-checkbox>
                <div style="margin-top:1em;">
                    <div style="float:left;margin-top:5px;">   
                        {{parseInt(this.mapProperties.getTemperatureBound().min)}} °C
                    </div>
                    <div 
                        class="gradient mx-1"
Peter Morstein's avatar
Peter Morstein committed
                        :style="{ backgroundImage: createStationColorramp(mapProperties.getMeanColorMap('hex')) }"
                    ></div>
                    <div style="float:left;margin-top:5px;">   
                        {{parseInt(this.mapProperties.getTemperatureBound().max)}} °C
                    </div>
                </div>
Peter Morstein's avatar
Peter Morstein committed
                <div ref="legendTemperature1" id="legendTemperature1"></div>
                <v-range-slider
Peter Morstein's avatar
Peter Morstein committed
                    v-model="mapProperties.anomalieRange1"
Peter Morstein's avatar
Peter Morstein committed
                    step="1"
Peter Morstein's avatar
Peter Morstein committed
                    :min="mapProperties.completeDaterange[0]"
                    :max="mapProperties.completeDaterange[1]"
Peter Morstein's avatar
Peter Morstein committed
                    thumb-label="always"
                    thumb-size="29px"
Peter Morstein's avatar
Peter Morstein committed
                    style="margin-top:1em;width:330px;margin-left:12px;margin-bottom:-25px;"
Peter Morstein's avatar
Peter Morstein committed
                    dense
                >
                </v-range-slider>
            </v-card-text>
        </v-card>
        
Peter Morstein's avatar
Peter Morstein committed
        <v-card class="ma-1">
            <v-card-text>
                <v-checkbox
Peter Morstein's avatar
Peter Morstein committed
                    v-model="layer2Active"
Peter Morstein's avatar
Peter Morstein committed
                    hide-details
Peter Morstein's avatar
Peter Morstein committed
                    @change="$emit('layerVisibility',$event,'avgLayer2')"
Peter Morstein's avatar
Peter Morstein committed
                    dense
                >
                    <template v-slot:label>
                        <div>
                            <v-icon>
                                 mdi-checkerboard
                            </v-icon> 
                            Durchschnittstemperatur Layer 2
                        </div>
                    </template>
                </v-checkbox>
                <div style="margin-top:1em;">
                    <div style="float:left;margin-top:5px;">   
                        {{parseInt(this.mapProperties.getTemperatureBound().min)}} °C
                    </div>
                    <div 
                        class="gradient mx-1"
Peter Morstein's avatar
Peter Morstein committed
                        :style="{ backgroundImage: createStationColorramp(mapProperties.getMeanColorMap('hex')) }"
                    ></div>
                    <div style="float:left;margin-top:5px;">   
                        {{parseInt(this.mapProperties.getTemperatureBound().max)}} °C
                    </div>
                </div>
Peter Morstein's avatar
Peter Morstein committed
                <div ref="legendTemperature2" id="legendTemperature2"></div>
                <v-range-slider
Peter Morstein's avatar
Peter Morstein committed
                    v-model="mapProperties.anomalieRange2"
                    step="1"
Peter Morstein's avatar
Peter Morstein committed
                    :min="mapProperties.completeDaterange[0]"
                    :max="mapProperties.completeDaterange[1]"
                    thumb-label="always"
                    thumb-size="29px"
Peter Morstein's avatar
Peter Morstein committed
                    style="margin-top:1em;width:330px;margin-left:12px;margin-bottom:-25px;"
Peter Morstein's avatar
Peter Morstein committed
                    dense
Peter Morstein's avatar
Peter Morstein committed
                    
                >
                </v-range-slider>
Peter Morstein's avatar
Peter Morstein committed
                <v-progress-linear
                    indeterminate
                    color="blue darken-2"
                    :active="mapProperties._loadLayer2"
Peter Morstein's avatar
Peter Morstein committed
                ></v-progress-linear>
            </v-card-text>
        </v-card>
Peter Morstein's avatar
Peter Morstein committed
        <v-card class="ma-1">
            <v-card-text>
                <v-checkbox
Peter Morstein's avatar
Peter Morstein committed
                    v-model="anomalieLayerActive"
Peter Morstein's avatar
Peter Morstein committed
                    hide-details
Peter Morstein's avatar
Peter Morstein committed
                    @change="$emit('layerVisibility',$event,'anomalieLayer')"
Peter Morstein's avatar
Peter Morstein committed
                    dense
Peter Morstein's avatar
Peter Morstein committed
                >
                    <template v-slot:label>
                        <div>
                            <v-icon>
                                 mdi-checkerboard
                            </v-icon> 
                            Temperaturanomalie
                        </div>
                    </template>
                </v-checkbox>
                
                <div style="margin-top:1em;height:30px;">
                    <div style="float:left;margin-top:5px;">   
                        -1 °C
                    </div>
                    <div 
                        class="gradient mx-1"
Peter Morstein's avatar
Peter Morstein committed
                        :style="{ backgroundImage: createStationColorramp(mapProperties.getAnomalieColorMap('hex')) }"
                    ></div>
                    <div style="float:left;margin-top:5px;">   
                        3 °C
                    </div>
                </div>

Peter Morstein's avatar
Peter Morstein committed
            </v-card-text>
        </v-card>

        <v-btn
        class="ma-1"
        :loading="loading"
        :disabled="loading"
        color="blue"
Peter Morstein's avatar
Peter Morstein committed
        @click="$emit('calculateAnomalie')"
Peter Morstein's avatar
Peter Morstein committed
        >
            Berechne Anomalie
        </v-btn>
    </div>
    
</template>

<style scoped>
.gradient{
    width:75%;
    float:left;
    height:30px;
    background-color:black;
}

</style>

<script lang="ts">

import {Vue, Ref, Component, Emit, Prop } from 'vue-property-decorator';
import MapProperties from './MapProperties';
Peter Morstein's avatar
Peter Morstein committed
import TemperatureLegendChart from './TemperatureLegendChart';
Peter Morstein's avatar
Peter Morstein committed
import axios from 'axios'

@Component({})
export default class Legend extends Vue{
    @Prop({type: MapProperties, required: true}) mapProperties: MapProperties;
Peter Morstein's avatar
Peter Morstein committed
    private stationLayerActive: boolean = true;
    private layer1Active: boolean = true;
    private layer2Active: boolean = true;
    private anomalieLayerActive: boolean = true;
Peter Morstein's avatar
Peter Morstein committed
    private loading: boolean = false;
    
    mounted(){
        console.log("Legend mounted");
Peter Morstein's avatar
Peter Morstein committed

Peter Morstein's avatar
Peter Morstein committed
        axios.get("http://127.0.0.1:42000/annualMean", {
            headers: {'Access-Control-Allow-Origin': '*'}
        }).then(resp => {
Peter Morstein's avatar
Peter Morstein committed
            
Peter Morstein's avatar
Peter Morstein committed
            this.mapProperties.completeDaterange = [resp.data[0].date, resp.data[resp.data.length-1].date];
Peter Morstein's avatar
Peter Morstein committed

            let tChart1 = new TemperatureLegendChart();
            tChart1.render("legendTemperature1", resp.data);

            let tChart2 = new TemperatureLegendChart();
            tChart2.render("legendTemperature2", resp.data);

Peter Morstein's avatar
Peter Morstein committed
        });
Peter Morstein's avatar
Peter Morstein committed

    }

    private calculate(): void{
        
Peter Morstein's avatar
Peter Morstein committed
        setTimeout(() => (this.mapProperties._loadLayer2 = false), 3000)
        this.mapProperties._loadLayer2 = true;


Peter Morstein's avatar
Peter Morstein committed

    private createStationColorramp(colormap: string[]){
        let gradientStyle = 'linear-gradient(to right, ';
        gradientStyle += colormap.join(', ');
        gradientStyle += ')';

        return gradientStyle;

    }

}
</script>