如何删除“ 0%”在图中间?

发布于 2025-01-17 18:17:30 字数 772 浏览 3 评论 0原文

我尝试在plotOptions中使用“堆叠”和“样式”来删除图表中间的0%。请参阅我的“codepen”示例来了解我的问题并帮助我解决。

我的图形代码

 plotOptions: {
                            bar: {
                              stackings: 'normal',
                              dataLabels: {
                                enabled: true,
                                format: '{y} %',
                              },
                              marker: {
                                enabled: false,
                              },
                            },
                            series: {
                              grouping: false,
                            },
                          },

I tried "stacking" and "styles" in plotOptions to remove 0% in the middle of my graph. please see my "codepen" example to understand my problem and help me out.

my graph code

 plotOptions: {
                            bar: {
                              stackings: 'normal',
                              dataLabels: {
                                enabled: true,
                                format: '{y} %',
                              },
                              marker: {
                                enabled: false,
                              },
                            },
                            series: {
                              grouping: false,
                            },
                          },

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趴在窗边数星星i 2025-01-24 18:17:30

使用 formatter 函数并仅显示值不为 0 的数据标签:

  plotOptions: {
    bar: {
      ...,
      dataLabels: {
        enabled: true,
        formatter: function() {
          if (this.y !== 0) {
            return this.y + ' %';
          }
        }
      }
    }
  }

现场演示: http://jsfiddle.net/BlackLabel/t98hzdbx/

API 参考: https://api.highcharts.com/highcharts/series.column.dataLabels.formatter< /a>

Use formatter function and show data-labels only with different value than 0:

  plotOptions: {
    bar: {
      ...,
      dataLabels: {
        enabled: true,
        formatter: function() {
          if (this.y !== 0) {
            return this.y + ' %';
          }
        }
      }
    }
  }

Live demo: http://jsfiddle.net/BlackLabel/t98hzdbx/

API Reference: https://api.highcharts.com/highcharts/series.column.dataLabels.formatter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文