241 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			241 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
@extends('base')
 | 
						|
@section('main')
 | 
						|
<article class="header">
 | 
						|
    <header>
 | 
						|
        <h2>
 | 
						|
            Anzahl jemals gefundene Kurzzeitmietobjekte pro Region
 | 
						|
        </h2>
 | 
						|
    </header>
 | 
						|
    <div id="chart-props-per-region"></div>
 | 
						|
</article>
 | 
						|
<article class="header">
 | 
						|
    <header>
 | 
						|
        <h2>
 | 
						|
            Entwicklung der Anzahl jemals gefunden Kurzzeitmietobjekte
 | 
						|
        </h2>
 | 
						|
    </header>
 | 
						|
    <div id="extractions"></div>
 | 
						|
</article>
 | 
						|
<article>
 | 
						|
    <div id="leaflet"></div>
 | 
						|
</article>
 | 
						|
<article class="header">
 | 
						|
    <header>
 | 
						|
      <h2>
 | 
						|
        Gesamtauslastung
 | 
						|
      </h2>
 | 
						|
    </header>
 | 
						|
    <div id="chart-heatmap"></div>
 | 
						|
</article>
 | 
						|
<script type="module">
 | 
						|
 | 
						|
const sharedOptions = {
 | 
						|
  basic: {
 | 
						|
    color: ['#f1eef6','#bdc9e1','#74a9cf','#2b8cbe','#045a8d'],
 | 
						|
    grid: {
 | 
						|
      top: 20,
 | 
						|
      left: 60,
 | 
						|
      right: 0,
 | 
						|
      bottom: 50
 | 
						|
    },
 | 
						|
    name: (opt) => {
 | 
						|
      return {
 | 
						|
        name: opt.name,
 | 
						|
        nameLocation: opt.location,
 | 
						|
        nameGap: 24,
 | 
						|
        nameTextStyle: {
 | 
						|
          fontWeight: 'bold',
 | 
						|
        },
 | 
						|
      }
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
const extractionDates = {!! json_encode($growth['dates']) !!};
 | 
						|
 | 
						|
const chartHeatmap = document.getElementById('chart-heatmap');
 | 
						|
const cHeatmap = echarts.init(chartHeatmap);
 | 
						|
const cHeatmapOptions = {
 | 
						|
  tooltip: {
 | 
						|
    position: 'top'
 | 
						|
  },
 | 
						|
  grid: {
 | 
						|
    top: 25,
 | 
						|
    right: 0,
 | 
						|
    bottom: 0,
 | 
						|
    left: 0
 | 
						|
  },
 | 
						|
  xAxis: {
 | 
						|
    name: 'Kurzzeitmietobjekt',
 | 
						|
    type: 'category',
 | 
						|
    data: {!! json_encode($heat['property_ids']) !!},
 | 
						|
    splitArea: {
 | 
						|
      show: false
 | 
						|
    },
 | 
						|
    axisLabel: {
 | 
						|
      show: true,
 | 
						|
    }
 | 
						|
  },
 | 
						|
  yAxis: {
 | 
						|
    type: 'category',
 | 
						|
    data: extractionDates,
 | 
						|
    splitArea: {
 | 
						|
      show: true
 | 
						|
    }
 | 
						|
  },
 | 
						|
  visualMap: {
 | 
						|
    type: 'piecewise',
 | 
						|
    min: 0,
 | 
						|
    max: 100,
 | 
						|
    calculable: true,
 | 
						|
    orient: 'horizontal',
 | 
						|
    left: 'center',
 | 
						|
    top: 0,
 | 
						|
    inRange: {
 | 
						|
      color: ['#f1eef6','#bdc9e1','#74a9cf','#2b8cbe','#045a8d']
 | 
						|
    },
 | 
						|
  },
 | 
						|
  series: [
 | 
						|
    {
 | 
						|
      name: 'Auslastung',
 | 
						|
      type: 'heatmap',
 | 
						|
      data: {!! json_encode($heat['values']) !!},
 | 
						|
      label: {
 | 
						|
        show: false
 | 
						|
      },
 | 
						|
      tooltip: {
 | 
						|
        formatter: '{b0}: {c0}<br />{b1}: {c1}',
 | 
						|
      },
 | 
						|
      emphasis: {
 | 
						|
        itemStyle: {
 | 
						|
          borderColor: '#000',
 | 
						|
          borderWidth: 2
 | 
						|
        }
 | 
						|
      }
 | 
						|
    }
 | 
						|
  ]
 | 
						|
}
 | 
						|
 | 
						|
cHeatmap.setOption(cHeatmapOptions);
 | 
						|
 | 
						|
const chartPropsPerRegion = document.getElementById('chart-props-per-region');
 | 
						|
const cPropsPerRegion = echarts.init(chartPropsPerRegion);
 | 
						|
const cPropsPerRegionOptions = {
 | 
						|
  grid: sharedOptions.basic.grid,
 | 
						|
  xAxis: {
 | 
						|
    name: 'Region',
 | 
						|
    nameLocation: 'center',
 | 
						|
    nameGap: 24,
 | 
						|
    nameTextStyle: {
 | 
						|
      fontWeight: 'bold',
 | 
						|
    },
 | 
						|
    type: 'category',
 | 
						|
    data: {!! $propsPerRegion[0] !!}
 | 
						|
  },
 | 
						|
  yAxis: {
 | 
						|
    type: 'value',
 | 
						|
    name: 'Anzahl Kurzzeitmietobjekte',
 | 
						|
    nameLocation: 'middle',
 | 
						|
    nameGap: 38,
 | 
						|
    nameTextStyle: {
 | 
						|
      fontWeight: 'bold',
 | 
						|
    },
 | 
						|
  },
 | 
						|
  series: [
 | 
						|
    {
 | 
						|
      data: {!! $propsPerRegion[1] !!},
 | 
						|
      type: 'bar'
 | 
						|
    }
 | 
						|
  ]
 | 
						|
};
 | 
						|
 | 
						|
cPropsPerRegion.setOption(cPropsPerRegionOptions);
 | 
						|
 | 
						|
const chartExtractions = document.getElementById('extractions');
 | 
						|
const cExtractions = echarts.init(chartExtractions);
 | 
						|
 | 
						|
const filters = {
 | 
						|
  regions: ["Alle", "Davos", "Engadin", "Heidiland", "St. Moritz"]
 | 
						|
}
 | 
						|
 | 
						|
const cExtractionsOptions = {
 | 
						|
  tooltip: {
 | 
						|
    trigger: 'axis'
 | 
						|
  },
 | 
						|
  legend: {
 | 
						|
    data: filters.regions
 | 
						|
  },
 | 
						|
  color: sharedOptions.basic.color,
 | 
						|
  grid: sharedOptions.basic.grid,
 | 
						|
  xAxis: {
 | 
						|
    name: 'Zeitpunkt Scraping',
 | 
						|
    nameLocation: 'center',
 | 
						|
    nameGap: 24,
 | 
						|
    nameTextStyle: {
 | 
						|
      fontWeight: 'bold',
 | 
						|
    },
 | 
						|
    type: 'category',
 | 
						|
    boundaryGap: false,
 | 
						|
    data: extractionDates
 | 
						|
  },
 | 
						|
  yAxis: {
 | 
						|
    name: 'Anzahl Kurzzeitmietobjekte',
 | 
						|
    nameLocation: 'center',
 | 
						|
    nameGap: 38,
 | 
						|
    nameTextStyle: {
 | 
						|
      fontWeight: 'bold',
 | 
						|
    },
 | 
						|
    type: 'value'
 | 
						|
  },
 | 
						|
  series: [
 | 
						|
    {
 | 
						|
      name: 'Alle',
 | 
						|
      type: 'line',
 | 
						|
      stack: 'Total',
 | 
						|
      data: {!! json_encode($growth['total_all']) !!}
 | 
						|
    },
 | 
						|
    {
 | 
						|
      name: 'Heidiland',
 | 
						|
      type: 'line',
 | 
						|
      stack: 'Heidiland',
 | 
						|
      data: {!! json_encode($growth['total_heidiland']) !!}
 | 
						|
    },
 | 
						|
    {
 | 
						|
      name: 'Davos',
 | 
						|
      type: 'line',
 | 
						|
      stack: 'Davos',
 | 
						|
      data: {!! json_encode($growth['total_davos']) !!}
 | 
						|
    },
 | 
						|
    {
 | 
						|
      name: 'Engadin',
 | 
						|
      type: 'line',
 | 
						|
      stack: 'Engadin',
 | 
						|
      data: {!! json_encode($growth['total_engadin']) !!}
 | 
						|
    },
 | 
						|
    {
 | 
						|
      name: 'St. Moritz',
 | 
						|
      type: 'line',
 | 
						|
      stack: 'St. Moritz',
 | 
						|
      data: {!! json_encode($growth['total_stmoritz']) !!}
 | 
						|
    },
 | 
						|
  ]
 | 
						|
};
 | 
						|
 | 
						|
cExtractions.setOption(cExtractionsOptions);
 | 
						|
 | 
						|
const map = L.map('leaflet').setView([46.862962, 9.535296], 9);
 | 
						|
 | 
						|
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
 | 
						|
    maxZoom: 19,
 | 
						|
    attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
 | 
						|
}).addTo(map);
 | 
						|
 | 
						|
const properties = {!! json_encode($geo) !!}
 | 
						|
properties.forEach( prop => {
 | 
						|
    let coords = prop.coordinates.split(',');
 | 
						|
    L.marker(coords).addTo(map).bindPopup('<a href="/prop/'+prop.id+'">'+prop.coordinates+'</a>');
 | 
						|
})
 | 
						|
 | 
						|
 | 
						|
</script>
 | 
						|
@endsection
 |