【问题标题】:Remove data labels when ploting and exporting graphs绘制和导出图形时删除数据标签
【发布时间】:2015-01-20 17:56:58
【问题描述】:

所以,我有堆积条形图,当数据标签不适合该区域时,我想隐藏它们。例如类别 8,根本没有数据标签“4”。 这是一个类似的问题: Highcharts stacked bar chart hide data labels not to overlap 但我的问题是我还需要在导出时隐藏标签

我在生成图表以隐藏标签后完成了这段代码

  $.each(this.chartObject.series,function(i,data_series){
           if (data_series.visible){
              $.each(data_series.data,function(j,data){
                if(data.yBottom != null && data.plotY != null){
                  if(data.yBottom - data.plotY < 15){
                    if (typeof data.dataLabel != 'undefined'){
                       data.dataLabel.hide();
                     }
                  }
               }
             });
            }
         });

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    您需要将循环从回调移动到图表/事件/加载。

    chart: {
            events: {
                load: function () {
                    var chart = this;
    
                    $.each(chart.series, function (i, serie) {
                        $.each(serie.data, function (j, data) {
    
                                if (data.yBottom - data.plotY < 15) data.dataLabel.hide();
                        });
                    });
                }
            },
            renderTo: 'chart',
            defaultSeriesType: 'bar'
        },
    

    示例:http://jsfiddle.net/HA5xE/20

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-30
      • 1970-01-01
      • 2015-05-26
      • 2017-03-02
      • 2011-04-03
      相关资源
      最近更新 更多