2025-01-05 13:26:51 +01:00

262 lines
5.5 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@extends('base')
@section('body-class', 'overview')
@section('main')
<article class="header" style="grid-area: chart1;">
<header>
<h2>
Anzahl jemals gefundene Kurzzeitmietobjekte pro Region
</h2>
<button popovertarget="pop1">
<span>Erklärungen zum Diagramm</span>
</button>
<div popover id="pop1">
<p>Das Diagram zeigt...</p>
</div>
<div>
</header>
<div id="chart-props-per-region"></div>
</article>
<article class="header" style="grid-area: chart2;">
<header>
<h2>
Entwicklung der Anzahl jemals gefunden Kurzzeitmietobjekte
</h2>
</header>
<div id="extractions"></div>
</article>
<article style="grid-area: chart4;">
<div id="leaflet"></div>
</article>
<article class="header" style="grid-area: chart3;">
<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: 30,
right: 0,
bottom: 0,
left: 0
},
dataZoom: [{
type: 'inside'
}
],
xAxis: {
show: false,
name: 'Kurzzeitmietobjekt',
type: 'category',
data: {!! json_encode($heat['property_ids']) !!},
splitArea: {
show: false
},
axisLabel: {
show: true,
}
},
yAxis: {
show: false,
type: 'category',
data: extractionDates,
splitArea: {
show: true
}
},
visualMap: {
type: 'piecewise',
min: 0,
max: 100,
calculable: true,
orient: 'horizontal',
left: 'center',
top: 0,
formatter: (v1, v2) => {
return `${v1}${v2}%`;
},
inRange: {
color: sharedOptions.basic.color,
},
},
series: [
{
name: 'Auslastung',
type: 'heatmap',
blurSize: 0,
data: {!! json_encode($heat['values']) !!},
label: {
show: false
},
tooltip: {
formatter: (data) => {
let v = data.value
return `Kurzzeitmietobjekte-ID: ${data.name}<br />Datum Scraping: ${extractionDates[v[1]]}<br/>Auslastung: ${v[2]} %`
},
},
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: '&copy; <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