Apexcharts.js: How to add custom tooltip to donut chart

Created on 25 Aug 2018  路  11Comments  路  Source: apexcharts/apexcharts.js

I want to add a array of tooltip to my donut chart. This is my chart
image

Most helpful comment

but how to add dynamic data to tooltip? data can be there in dataset/json array.

All 11 comments

Sorry, I don't get your question correctly.
Can you please elaborate what are you trying to accomplish?

I want to display some text instead of the default that is series. For each value in donut chart I have a text that i want to present as a tooltip

Something like this
image

You can use label formatters to modify the text instead of displaying the default one.
See the example

You will need to set

tooltip: {
  y: {
    formatter: function(value) {
      return value + "your text";
    }
  }
}

ok that would work. Is it possible to remove the series name?

Yes, but with CSS :)
Check the same example I just updated

Ok thanks

I forgot that you can also do it without CSS display:none using tooltip.y.title.formatter function :)

tooltip: {
    y: {
      formatter: function(val) {
        return val + ".00" + " Rs"
      },
      title: {
        formatter: function (seriesName) {
          return ''
        }
      }
    }
  },

Thanks @junedchhipa for above.

but how to add dynamic data to tooltip? data can be there in dataset/json array.

tooltip: {
      custom: function({ series, seriesIndex, dataPointIndex, w }) {
        return "<div>" + series + "</div>";
      }
 },

I forgot that you can also do it without CSS display:none using tooltip.y.title.formatter function :)

tooltip: {
    y: {
      formatter: function(val) {
        return val + ".00" + " Rs"
      },
      title: {
        formatter: function (seriesName) {
          return ''
        }
      }
    }
  },

It works to items of tooltip. I would like to change the tooltip title. I managed to do it, following the pattern of your code. Thank you very much

x: { formatter: function(x){ x + "changed" } }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlil picture jlil  路  3Comments

artfulrobot picture artfulrobot  路  3Comments

frlinw picture frlinw  路  3Comments

rcoundon picture rcoundon  路  3Comments

maasha picture maasha  路  3Comments