Nachbaren in Popup

main
Giò Diani 2025-01-09 18:34:20 +01:00
parent 638d835d3b
commit 3b935a4d20
3 changed files with 78 additions and 9 deletions

View File

@ -78,6 +78,10 @@ class Api
return self::get("/property/{$id}/capacities/weekdays/{$date}");
}
public static function propertyNeighbours(int $id): mixed
{
return self::get("/property/{$id}/neighbours");
}

View File

@ -12,6 +12,12 @@
<dt>Zum letzten mal gefunden</dt>
<dd>{{ $base['last_found'] }}</dd>
</dl>
<h2>Kurzzeitmietobjekte in der Nähe</h2>
<ul>
@foreach($neighbours as $n)
<li><a href="/prop/{{ $n['id'] }}">{{ $n['lat'] }}, {{$n['lon']}}</a></li>
@endforeach
</ul>
</div>
@endsection
@ -55,7 +61,7 @@
Auslastung Tage für Monat
</h2>
</header>
<div id="chart-capacity-daily">
</article>
<script type="module">
const chartTimeline = document.getElementById('timeline');
@ -119,6 +125,46 @@ const cCapacityMonthlyOptions = {
cCapacityMonthly.setOption(cCapacityMonthlyOptions);
const chartCapacityDaily = document.getElementById('chart-capacity-daily');
const cCapacityDaily = echarts.init(chartCapacityDaily);
const cCapacityDailyOptions = {
timeline: {
show: false,
data: {!! $extractiondates !!},
axisType: 'time',
},
grid: {
top: 0,
bottom: 25,
left: 70,
right: 10
},
xAxis: {
type: 'value',
max: 100
},
yAxis: {
type: 'category',
},
options: [
@foreach ($capacitiesDaily as $cD)
{
yAxis: {
data: {!! json_encode($cD['weekdays']) !!}
},
series: [{
type: 'bar',
data: {!! json_encode($cM['capacities']) !!}
}]
},
@endforeach
]
};
cCapacityDaily.setOption(cCapacityDailyOptions);
const chartCapacity = document.getElementById('chart-capacity');
const cCapacity = echarts.init(chartCapacity);
@ -156,13 +202,18 @@ const cCapacityOptions = {
fontWeight: 'bold',
}
},
series: {
name: 'Alle',
series: [{
name: 'Auslastung',
type: 'line',
stack: 'Total',
symbolSize: 7,
data: {!! json_encode($capacities['capacities']) !!}
}
},
{
name: 'Auslastung Region',
type: 'line',
symbolSize: 7,
data: {!! json_encode($capacities['capacities']) !!}
}]
};
cCapacity.setOption(cCapacityOptions);

View File

@ -26,16 +26,18 @@ Route::get('/prop/{id}', function (int $id) {
$propertyBase = Api::propertyBase($id);
$extractions = Api::propertyExtractions($id);
$propertyCapacities = Api::propertyCapacities($id);
$propertyNeighbours = Api::propertyNeighbours($id);
//$regionCapacities = Api::regionCapacities(-1);
$regionCapacities = [];
$propertyCapacitiesMonthly = [];
$propertyCapacitiesDaily = [];
foreach ($extractions as $extraction) {
$propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $extraction['created_at']);
$propertyCapacitiesDaily[] = Api::propertyCapacitiesDaily($id, $extraction['created_at']);
}
//dump($propertyCapacitiesMonthly);
$data = [];
$dates = [];
@ -54,5 +56,17 @@ Route::get('/prop/{id}', function (int $id) {
}
return view('property', ['base' => $propertyBase[0], "extractiondates" => json_encode($dates), "calendar" => $data, 'capacities' => $propertyCapacities, 'capacitiesMonthly' => $propertyCapacitiesMonthly]);
return view('property', ['base' => $propertyBase[0], "extractiondates" => json_encode($dates), "calendar" => $data, 'capacities' => $propertyCapacities, 'capacitiesMonthly' => $propertyCapacitiesMonthly, 'capacitiesDaily' => $propertyCapacitiesDaily, 'regionCapacities' => $regionCapacities, 'neighbours' => $propertyNeighbours]);
});
Route::get('/region/{id}', function (int $id) {
$regionCapacities = Api::regionCapacities($id);
dump($regionCapacities);
return view('region', ['capacities' => $regionCapacities]);
});