98 lines
2.0 KiB
PHP
98 lines
2.0 KiB
PHP
@section('page-scripts')
|
|
<script src="https://code.highcharts.com/highcharts.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
subout = [];
|
|
subin = [];
|
|
@php
|
|
$x=0;
|
|
@endphp
|
|
@foreach ($chart->sortBy(function($item,$key) { $co = \App\Models\Category::findOrFail($item['category_id']); return sprintf('%s|%s|%s',$co->segment->unit->name,$co->segment->name,$co->name); }) as $data)
|
|
@php
|
|
$co = \App\Models\Category::findOrFail($data['category_id']);
|
|
$name = sprintf('%s|%s|%s',$co->segment->unit->name,$co->segment->name,$co->name);
|
|
$x++;
|
|
@endphp
|
|
@if ($data['subout'] > 0)
|
|
subout.push({ "x": {{ $x }}, "y": -{{ $data['subout'] }}, "name": '{{ $name }}' });
|
|
@else
|
|
subin.push({ "x": {{ $x }}, "y": {{ $data['subin'] }}, "name": '{{ $name }}' });
|
|
@endif
|
|
@endforeach
|
|
|
|
// Create the chart
|
|
Highcharts.chart('substitution', {
|
|
chart: {
|
|
type: 'scatter',
|
|
zoomtype: 'xy',
|
|
height: '30%',
|
|
},
|
|
title: {
|
|
text: ''
|
|
},
|
|
yAxis: {
|
|
title: {
|
|
text: 'Rev J$m'
|
|
}
|
|
},
|
|
xAxis: {
|
|
title: {
|
|
text: 'BU Categories'
|
|
},
|
|
visible: true,
|
|
labels: { enabled: false }
|
|
},
|
|
plotOptions: {
|
|
scatter: {
|
|
marker: {
|
|
radius: 5,
|
|
states: {
|
|
hover: {
|
|
enabled: true,
|
|
lineColor: 'rgb(100,100,100)'
|
|
}
|
|
}
|
|
},
|
|
states: {
|
|
hover: {
|
|
marker: {
|
|
enabled: true,
|
|
}
|
|
}
|
|
},
|
|
tooltip: {
|
|
headerFormat: '{series.name}<br>',
|
|
pointFormat: '<b>{point.name}</b>: {point.y}'
|
|
}
|
|
},
|
|
},
|
|
legend: {
|
|
layout: 'vertical',
|
|
align: 'right',
|
|
verticalAlign: 'top',
|
|
floating: true,
|
|
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
|
|
borderWidth: 1
|
|
},
|
|
exporting: {
|
|
enabled: false
|
|
},
|
|
credits: {
|
|
enabled: false
|
|
},
|
|
tooltip: {
|
|
valuePrefix: '$',
|
|
valueSuffix: 'm',
|
|
},
|
|
series: [{
|
|
name: 'Sub Out',
|
|
color: '#d9534f',
|
|
data: subout,
|
|
}, {
|
|
name: 'Sub In',
|
|
color: '#0099e6',
|
|
data: subin,
|
|
}],
|
|
});
|
|
</script>
|
|
@append |