【问题标题】:highcharts not showing the `column` barhighcharts 未显示“列”栏
【发布时间】:2020-07-29 05:00:35
【问题描述】:

我正在尝试显示图表,但它没有显示 column bar 。我的浏览器控制台没有看到任何错误,下面是我的脚本

$('#complete_chart').highcharts({
                chart: {
                    type: 'column',
                    margin: 75,
                    options3d: {
                        enabled: false,
                        alpha: 10,
                        beta: 25,
                        depth: 70
                    }
                },
                title: {
                    text: 'Performance',
                    style: {
                            fontSize: '18px',
                            fontFamily: 'Verdana, sans-serif'
                    }
                },
                subtitle: {
                  text: 'Complete',
                  style: {
                            fontSize: '15px',
                            fontFamily: 'Verdana, sans-serif'
                    }
                },
                plotOptions: {
                    column: {
                        depth: 25
                    }
                },
                credits: {
                    enabled: false
                },
              
                exporting: { 
                    enabled: false 
                },
                xAxis: {
                    categories: ["25","35","23","36","34"]           
                  },
                yAxis: {
                    title: {
                        text: ''
                    },
                },
                tooltip: {
                    formatter: function() {
                      var s = '<b>'+ this.point.project_name +'</b>';            
                      return s;     
                    }
                  },
                series: [{
                    name: 'Report Data',
                    data: [{"name":"Progress 1","val":100},{"name":"Progress 1","val":-165},{"name":"Progress 1","val":-1233},{"name":"Progress 1","val":-1114},{"name":"Progress 1","val":-175}],
                    shadow : true,
                    dataLabels: {
                        enabled: true,
                        color: '#045396',
                        align: 'center',
                        formatter: function() {
                        
                            return Highcharts.numberFormat(this.val, 0);
                        }, // one decimal
                        y: 0, // 10 pixels down from the top
                        style: {
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif'
                        }
                    }
                }]
            });

我错过了什么吗?

【问题讨论】:

    标签: javascript json highcharts


    【解决方案1】:

    series.data 中 y 轴数据的绘图是 y 而不是 val。例如:

    [{"name":"Progress 1","y":100}...]
    

    更改它必须为您提供柱形图中的列的可见性。 参考:https://www.highcharts.com/docs/chart-concepts/series#the-data-in-a-series

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多