Apexcharts.js: Extend custom tooltip example with more values

Created on 2 Jan 2020  路  4Comments  路  Source: apexcharts/apexcharts.js

Apex Charts tooltips are very powerful and I like that we can customize them with the Apex.tooltip.custom method. A regular Apex Charts tooltip contains lots of information in it, however in the custom tooltip example you have (https://codepen.io/apexcharts/pen/NBdyvV) you only show how to get the current value which is the easiest to find. I tried to find the category names but the w object is so huge it's very hard to find the info you need there. It would be great if you could extent the custom tooltip example with all the info you have in the regular tooltip.

tooltip

Most helpful comment

i had the same issue
use categoryLabels instead of labels

All 4 comments

Sure, I will update the example.

Updated the codepen.
X-values or categories are accessible in w.globals.labels

tooltip: {
  custom: function({ series, seriesIndex, dataPointIndex, w }) {
    return (
      '<div class="arrow_box">' +
      '<span>' +
      w.globals.labels[dataPointIndex] +
      ': ' +
      series[seriesIndex][dataPointIndex] +
      '</span>' +
      '</div>'
    )
  }
}

Thanks for that. Problem with this approach is that when you switch to line charts, category names will be presented as numbers: https://codepen.io/Deka87/pen/YzPExYx?editors=0010. Any workaround for this?

i had the same issue
use categoryLabels instead of labels

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pribilinskiy picture pribilinskiy  路  3Comments

felixalguzman picture felixalguzman  路  3Comments

jeroenpol picture jeroenpol  路  3Comments

georgehardy picture georgehardy  路  3Comments

rudeayelo picture rudeayelo  路  3Comments