javascript - 如何标记一个月中的几天?

标签 javascript highcharts

在 HighCharts JS 中,如何在每个条形下标记该月的天数(即标记蓝色条形),如下图所示(在下面的 JSFiddle 中显示)。目前,HighCharts 有时会跳过标签。我的客户希望将它们标记为连续/连续的数字。

HighCharts 的 JS Fiddle 在这里:http://jsfiddle.net/vecbtw7m/

HighCharts 的 JavaScript 代码:

$('#graphContainer2').highcharts({
    chart: { type: 'column' },
    title: { text: 'Monthly Page Views' },
    xAxis: {
        type: 'datetime',
        title: { text: 'Date' },
        min: new Date('2015/10/15').getTime(),
        max: new Date('2015/10/30').getTime(),
    },
    yAxis: {
        min: 0,
        title: { text: 'Page Views' }
    },
    series: [{
        name: 'Page Views',
        data: [
           [Date.UTC(2015,9,15), 27], [Date.UTC(2015,9,17), 54],
           [Date.UTC(2015,9,20), 42], [Date.UTC(2015,9,24), 13]
        ]
     }]
});

期望的结果(黄色) enter image description here

最佳答案

您可以在xAxis中添加标签格式化程序功能:

xAxis: {
       type: 'datetime',
        title: { text: 'Date' },
        min: new Date('2015/10/15').getTime(),
        max: new Date('2015/10/30').getTime(),
        tickInterval: 24 * 3600 * 1000,
        labels:{
        formatter: function () {
                        return Highcharts.dateFormat('%d', this.value);
                }
}

}

更新jsFiddle

关于javascript - 如何标记一个月中的几天?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32615399/

相关文章:

javascript - 构建要发送到 View 中的 HighCharts 的数据

javascript - 如何在我的 javascript 中保存添加或删除类 cookie?

javascript - backbone 路由,backbone.history 启动后的多个路由器

javascript - JQuery 无法解析此 HTML

javascript - Highcharts : How to fix labels to the top when xAxis rotation is 90°?

jquery - 使用外部按钮切换饼图数据

javascript - 在对象数组中查找特定属性

javascript - 基本的 cron 作业问题

javascript - 验证表单而不提交

javascript - Highchart的错误: Uncaught SyntaxError: Unexpected token for