PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, June 27, 2022

[FIXED] how to remove "0%" at middle of graph?

 June 27, 2022     graph, graph-visualization, highcharts, react-graph-vis     No comments   

Issue

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,
                            },
                          },

Solution

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



Answered By - ppotaczek
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing