gpt4 book ai didi

javascript - 如何执行日期范围以查看选定日期 Highcharts 中的数据

转载 作者:行者123 更新时间:2023-11-29 10:34:00 24 4
gpt4 key购买 nike

HTML、JS 和 Controller

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\TrackerController@graph')}}" 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号的数据。

最佳答案

要获取 2 个日期之间的数据,您可以使用 whereBetween 函数。这里是文档: https://laravel.com/docs/5.5/queries

示例:

Model::whereBetween('field', array($date_start, $date_end))

所以在你的代码中类似:

DiraStatistics::whereBetween('date_access',array($request->date, $request->date_end))->get();

关于javascript - 如何执行日期范围以查看选定日期 Highcharts 中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46845899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com