chart.js v2 - 使用时间刻度时如何“填充”图表 [英] chart.js v2 - how to 'fill' the graph when using time scale

查看:226
本文介绍了chart.js v2 - 使用时间刻度时如何“填充”图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用



如何使其合适:



Codepen:
http://codepen.io/WilbertE/pen/wzRmWr

解决方案

你想要使用 min & max 时间属性属性:

 选项:{
scale:{
xAxes:[{
type:time,
time:{
min:/ *在这里设置你的分钟.. * /,
max:/ * ..和你的最大值* /
}
}]
}
}


Im creating a chart with chart.js v2 and I have a good working graph which uses a time scaled axis. Now I want to show whole hours in the axis so I set the option like this:

xAxes: [{
    type: 'time',
    time: {
        unit: 'hour',
        unitStepSize: 1,
        displayFormats: { 'hour': 'H:mm' }
    }
}]

This works good but I have gaps at the beginning and end of the graph.

How can I make it fit like this:

Codepen: http://codepen.io/WilbertE/pen/wzRmWr

解决方案

You want to use the min & max attributes of the time property :

options: {
    scales: {
        xAxes: [{
            type: "time",
            time: {
                min: /* Set your min here .. */,
                max: /* .. and your max here*/
            }
        }]
    }
}

这篇关于chart.js v2 - 使用时间刻度时如何“填充”图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆