Highcharts类别不添加 [英] Highcharts Categories don't add

查看:202
本文介绍了Highcharts类别不添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示数字'6'类别,但是系列数据是稳定的。然而,发生了什么事,只有1 - 5在类别中显示。我将如何做到这一点?请参阅下面的代码:

I want to show number '6' category but data in series are steady like that. Yet what happened is that only 1 - 5 are showed in category. How will I do this? Please see code below:

function getchart()
{

$('#container').highcharts({
    chart: {
        type: 'column',
                renderTo: 'container'
    },
title: {
            text: 'Daily Events',
            style: {
                'color': '#06F',
                'font-family': 'Roboto',
                'font-size': '16px',
                'font-weight': 'bold'

            },
            useHTML: true
        },
    xAxis: {

       categories: [
                '1',
                '2',
                '3',
                '4',
                '5',
                '6'
            ]
    },

    yAxis: {
        min: 0,
        title: {
            text: 'No. of Events'
        },

        stackLabels: {
            enabled: true,
            style: {
                fontWeight: 'bold',
                color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
            }
        }
    },
  legend: {
            itemStyle: {

                'color': '#666',
                'font-family': 'Roboto',
                'font-weight': 'normal',
                'font-size': '11px'

            },

            useHTML: true
        },
     tooltip: {
        formatter: function() {
                return '<b>'+ this.series.name +'</b><br/>'+
                this.x +': '+ this.y;
        }
    },
    plotOptions: {
        column: {
        pointWidth: 30,
            stacking: 'normal',
            dataLabels: {
                enabled: true,
                color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
                style: {
                    textShadow: '0 0 3px black'
                }

            }
        }
    },

    series: [{
         name: 'Incoming',
        data: [
         {y: 10.4, color: '#FAA961'},  //incoming
          {y: 15.4, color: '#FAA961'}, 
          {y: 20.4, color: '#FAA961'}, 
          {y: 12.4, color: '#FAA961'}, 
          {y: 30.4, color: '#FAA961'}, 
        ],
        color: '#FAA961'
    }, {
        name: 'Ongoing',
        data: [
         {y: 10.4, color: '#438EF7'},  //incoming
          {y: 15.4, color: '#438EF7'}, 
          {y: 20.4, color: '#438EF7'}, 
          {y: 12.4, color: '#438EF7'}, 
          {y: 30.4, color: '#438EF7'}, 
        ],
        color: '#438EF7'
    }, {
        name: 'Finished',
        data: [
         {y: 34.4, color: '#43F752'},  //incoming
          {y: 35.4, color: '#43F752'}, 
          {y: 40.4, color: '#43F752'}, 
          {y: 42.4, color: '#43F752'}, 
          {y: 20.4, color: '#43F752'}, 
        ],
        color: '#43F752'
    }]
});

}


推荐答案

使用x轴的min和max值指定要在图表上显示的类别数组的最小和最大索引值。

You can use 'min' and 'max' values for x-axis to specify the minimum and maximum index value from category array to be displayed on chart.

/ p>

In your case,

min: 0,
max: 5

以下是更新的小提琴

这篇关于Highcharts类别不添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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