0
HTML,JS和控制器如何做一個日期範圍從選定的日期highcharts查看數據
public function graph(Request $request)
{
$statistics = DiraStatistics::where('date_access',$request->date)->get();
$question_asked_sum = $statistics->sum('question_asked');
$low_confidence_sum = $statistics->sum('low_confidence');
$no_answer_sum = $statistics->sum('no_answer');
$missing_intent_sum = $statistics->sum('missing_intent');
return view('AltHr.Chatbot.graph', compact('question_asked_sum', 'low_confidence_sum', 'no_answer_sum', 'missing_intent_sum'));
}
<form id="form-project" role="form" action="{{action('AltHr\Chatbot\[email protected]')}}" autocomplete="off" method="POST">
{{csrf_field()}}
<div class="form-group form-group-default required" >
<label>Date</label>
<input type="date" class="form-control" name="date" required>
</div>
<button class="btn alt-btn-black btn-xs alt-btn pull-right" type="submit">Select</button>
</form>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Build the chart
Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Pie Chart'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Percentage',
colorByPoint: true,
data: [{
name: 'Questions Asked',
y: {!! $question_asked_sum !!},
sliced: true,
selected: true
}, {
name: 'Low Confidence',
y: {!! $low_confidence_sum !!}
}, {
name: 'No Answer',
y: {!! $no_answer_sum !!}
}, {
name: 'Missing Intent',
y: {!! $missing_intent_sum !!}
}]
}]
});
});
</script>
傢伙嗨,所以目前我已經成功做了功能,我可以選擇從一個表格(僅一個日期)開始日期並查看數據(餅圖)。但我想知道如何使2日期輸入做一個「從」和「到」來做一個日期範圍來查看所選日期範圍的圖表中的數據,例如1/1/2017 - 5/1/2017年,所以我只能查看從1日至5日的數據。