调整ChartJS中的X轴步骤
16lz
2021-01-22
I work on ChartJS. I have some values which are saving according to hour and date from database. I want to adjust X axis by hour. Now, all my hour and minute showing on X axis and I want to just showing hours. I write a script for that in my PHP file. But nothing happened. How can I change X axis step?
我在ChartJS上工作。我有一些值根据数据库中的小时和日期保存。我想按小时调整X轴。现在,我所有的小时和分钟都在X轴上显示,我想要显示几小时。我在PHP文件中编写了一个脚本。但什么都没发生。如何更改X轴步骤?
Here is my script code:
这是我的脚本代码:
<script>
$(document).ready(function(){
var data = <?php echo json_encode($data) ?>;
var gun= [];
var guc = [];
var saat = [];
var hour = [];
for(var i in data) {
gun.push(data[i].gun);
guc.push(data[i].Guc);
saat.push(data[i].saat);
hour.push(data[i].hour);
}
var chartdata = {
labels: saat,
datasets: [
{label: "Güç",
fill: true,
lineTension: 0.1,
backgroundColor: "rgba(211, 72, 54,0.5)",
borderColor: "rgba(211, 72, 54, 1)",
pointHoverBackgroundColor: "rgba(211, 72, 54, 1)",
pointHoverBorderColor: "rgba(211, 72, 54, 1)",
steppedLine: true,
data: guc
}
]
};
var ctx = $("#mycanvas7");
var LineGraph = new Chart(ctx, {
type: 'line',
data: chartdata,
options: {
min: 0,
max: 23,
stepSize: 24
}
});
});
</script>
1 个解决方案
#1
2
xAxes: [{
ticks: {
autoSkip: true,
maxTicksLimit: 24
}
}]
This will help you I guess
这对我有帮助
更多相关文章
- python解压zip脚本
- 使用python脚本配置zabbix发送报警邮件
- 见证历史!Python或将取代VBA,成为Excel官方脚本语言!
- 解决Linux下运行Python脚本显示“: 没有那个文件或目录”的问题
- 通过Excel / VBA运行Python脚本
- 利用Dnspod api批量更新添加DNS解析【python脚本】
- 是否可以在没有安装铁python的PC上运行编译的铁python脚本?
- python脚本下载并解码MNIST数据遇到的问题
- 从另一个Python脚本调用Python脚本的最佳方式是什么?