【问题标题】:dataLabels for bar chart in Highcharts not displaying for null values in 3.0.8Highcharts 中条形图的 dataLabels 在 3.0.8 中不显示空值
【发布时间】:2014-04-10 20:20:19
【问题描述】:

我一直在使用以下代码为 Highcharts 中的条形图设置 dataLabels...

plotOptions: {
    bar: {
        dataLabels: {
            enabled: true,
            formatter: function() {
                if (this.y==null) {
                    return '<i>(Suppressed)</i>';
                } else {
                    return '';
                }
            }
        }
    }
}

基本上,我希望能够在某个值因隐私原因被隐藏时向用户显示。

在以前版本的 Highcharts 中,标签会根据我的需要显示空值。在 3.0.8 版中,我没有得到任何空值的数据标签。

是否有解决方法或解决方法?

【问题讨论】:

    标签: javascript jquery highcharts


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      正如 Sebastian 指出的,这实际上是一个错误。但是,有一个简单的解决方法......在 highcharts.src.js 中,只需将调用用于获取 Series.prototype.alignDataLabel(第 16132 和 16133 行)中的 plotX 和 plotY 的 pick 函数更改为:

      plotX = pick(point.plotX, 0),
      plotY = pick(point.plotY, 0),
      

      而不是

      plotX = pick(point.plotX, -999),
      plotY = pick(point.plotY, -999),
      

      希望这最终对某人有所帮助......

      【讨论】:

        猜你喜欢
        • 2014-04-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-08
        • 2014-09-21
        • 1970-01-01
        相关资源
        最近更新 更多