Commit 7928242b authored by Dominik Hebeler's avatar Dominik Hebeler

fixed scaling of the y achsis

parent aaa2016a
...@@ -166,6 +166,7 @@ class AdminInterface extends Controller ...@@ -166,6 +166,7 @@ class AdminInterface extends Controller
$oldLogs = []; $oldLogs = [];
$rekordTag = 0; $rekordTag = 0;
$minCount = 0;
$rekordTagDate = ""; $rekordTagDate = "";
$size = 0; $size = 0;
$count = 0; $count = 0;
...@@ -195,6 +196,9 @@ class AdminInterface extends Controller ...@@ -195,6 +196,9 @@ class AdminInterface extends Controller
$rekordTagSameTime = $sameTime; $rekordTagSameTime = $sameTime;
$rekordTagDate = Carbon::now()->subDays($key)->format('d.m.Y'); $rekordTagDate = Carbon::now()->subDays($key)->format('d.m.Y');
} }
if ($minCount === 0 || $insgesamt < $minCount) {
$minCount = $insgesamt;
}
$oldLogs[$key]['sameTime'] = number_format(floatval($sameTime), 0, ",", "."); $oldLogs[$key]['sameTime'] = number_format(floatval($sameTime), 0, ",", ".");
$oldLogs[$key]['insgesamt'] = number_format(floatval($insgesamt), 0, ",", "."); $oldLogs[$key]['insgesamt'] = number_format(floatval($insgesamt), 0, ",", ".");
# Nun noch den median: # Nun noch den median:
...@@ -212,6 +216,7 @@ class AdminInterface extends Controller ...@@ -212,6 +216,7 @@ class AdminInterface extends Controller
->with('title', 'Suchanfragen - MetaGer') ->with('title', 'Suchanfragen - MetaGer')
->with('today', number_format(floatval($logToday), 0, ",", ".")) ->with('today', number_format(floatval($logToday), 0, ",", "."))
->with('oldLogs', $oldLogs) ->with('oldLogs', $oldLogs)
->with('minCount', $minCount)
->with('rekordCount', number_format(floatval($rekordTag), 0, ",", ".")) ->with('rekordCount', number_format(floatval($rekordTag), 0, ",", "."))
->with('rekordTagSameTime', number_format(floatval($rekordTagSameTime), 0, ",", ".")) ->with('rekordTagSameTime', number_format(floatval($rekordTagSameTime), 0, ",", "."))
->with('rekordDate', $rekordTagDate) ->with('rekordDate', $rekordTagDate)
......
...@@ -10,11 +10,26 @@ ...@@ -10,11 +10,26 @@
@php ($startX = 20) @php ($startX = 20)
@php ($startY = $height-20) @php ($startY = $height-20)
@php ($maxCount = intval(str_replace(".", "", $rekordCount))) @php ($maxCount = intval(str_replace(".", "", $rekordCount)))
@php ($yPerSearch = ($startY - $padding - $paddingArrow) / floatval($maxCount)) @php ($minCount = $minCount)
@php ($scaleFromTo = $maxCount - $minCount)
@php ($yPerSearch = ($startY - $padding - $paddingArrow) / floatval($scaleFromTo))
@php ($entryCount = min(sizeof($oldLogs), 30)) @php ($entryCount = min(sizeof($oldLogs), 30))
@php ($daysPerEntry = sizeof($oldLogs) / floatval($entryCount)) @php ($daysPerEntry = sizeof($oldLogs) / floatval($entryCount))
<div id="graph"> <div id="graph">
<svg width="100%" height="auto" viewbox="0 0 {{$width}} {{$height}}"> <svg width="100%" height="auto" viewbox="0 0 {{$width}} {{$height}}">
<!-- Data -->
@php($vStep = ($width - $padding - $paddingArrow - $startX) / floatval(sizeof($oldLogs)-1))
<polyline
points="
@foreach($oldLogs as $key => $value)
{{$width - $padding - $paddingArrow - (($key-1)*$vStep)}},{{$startY - ((intval(str_replace(".", "", $value['insgesamt'])) - $minCount) * $yPerSearch)}}
@endforeach
{{$startX}},{{$startY}}
{{$width-$padding-$paddingArrow}},{{$startY}}
"
fill="rgba(255,127,0,.2)" stroke="rgb(255,127,0)" stroke-width=".5"
/>
<!-- Y-Achse --> <!-- Y-Achse -->
<path d="m{{$startX}} {{$startY}} L{{$startX}} {{$padding}} L{{$startX-1}} {{$padding}} L{{$startX}} {{$padding-1}} L{{$startX+1}} {{$padding}} L{{$startX}} {{$padding}}z" fill="#333" stroke="#333" stroke-width=".7" /> <path d="m{{$startX}} {{$startY}} L{{$startX}} {{$padding}} L{{$startX-1}} {{$padding}} L{{$startX}} {{$padding-1}} L{{$startX+1}} {{$padding}} L{{$startX}} {{$padding}}z" fill="#333" stroke="#333" stroke-width=".7" />
<!-- Skalierung Y-Achse --> <!-- Skalierung Y-Achse -->
...@@ -22,7 +37,7 @@ ...@@ -22,7 +37,7 @@
<line x1="{{$startX-1}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$startX+1}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#333" stroke="#333" stroke-width=".7" /> <line x1="{{$startX-1}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$startX+1}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#333" stroke="#333" stroke-width=".7" />
<line x1="{{$startX}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$width-$padding-$paddingArrow}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#777" stroke="#777" stroke-width=".2" /> <line x1="{{$startX}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$width-$padding-$paddingArrow}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#777" stroke="#777" stroke-width=".2" />
<text x="{{$startX - 15}}" y="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) + 2 }}" style="font-size: .3em;"> <text x="{{$startX - 15}}" y="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) + 2 }}" style="font-size: .3em;">
{{ round(($maxCount - ($maxCount * ($i/10.0))) / 1000.0)}}k {{ round(($maxCount - ($scaleFromTo * ($i/10.0))) / 1000.0)}}k
</text> </text>
@endfor @endfor
<!-- X-Achse --> <!-- X-Achse -->
...@@ -33,19 +48,6 @@ ...@@ -33,19 +48,6 @@
{{ Carbon::now()->subDays(floor(($entryCount-$i) * $daysPerEntry))->format('d.m')}} {{ Carbon::now()->subDays(floor(($entryCount-$i) * $daysPerEntry))->format('d.m')}}
</text> </text>
@endfor @endfor
<!-- Data -->
@php($vStep = ($width - $padding - $paddingArrow - $startX) / floatval(sizeof($oldLogs)-1))
<polyline
points="
@foreach($oldLogs as $key => $value)
{{$width - $padding - $paddingArrow - (($key-1)*$vStep)}},{{$startY - (intval(str_replace(".", "", $value['insgesamt'])) * $yPerSearch)}}
@endforeach
{{$startX}},{{$startY}}
{{$width-$padding-$paddingArrow}},{{$startY}}
"
fill="rgba(255,127,0,.2)" stroke="rgb(255,127,0)" stroke-width=".5"
/>
</svg> </svg>
</div> </div>
<p>{{ exec("uptime") }}</p> <p>{{ exec("uptime") }}</p>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment