Apexcharts.js: Add custom text on radialBar Chart

Created on 23 Oct 2018  路  5Comments  路  Source: apexcharts/apexcharts.js

Hi I do not speak English well but this radialBar has been used so beautifully
This radialBar is very good.
So, i used my project.
i need radialBar xaxis So, i tried
Where is xaxis on radialBar ?

plz, your answer
thank you

default

Most helpful comment

There is no direct option to draw labels as you described in the image.

But, you can use ApexChart's addText() method to draw custom text elements on the chart area.
Here is a codepen example which produces this result.
screen shot 2018-10-23 at 11 41 33 am

The code for generating these labels

var chartAreaBounds = chart.w.globals.dom.baseEl.querySelector('.apexcharts-inner').getBoundingClientRect();

chart.addText({
  x: chartAreaBounds.width / 2,
  y: 10,
  text: "0",
  fontSize: 16,
  textAnchor: "middle"
});

chart.addText({
  x: chartAreaBounds.width - 5,
  y: chartAreaBounds.height / 2 + 10,
  text: "90",
  fontSize: 16,
  textAnchor: "start"
});

chart.addText({
  x: chartAreaBounds.width / 2,
  y: chartAreaBounds.height + 30,
  text: "180",
  fontSize: 16,
  textAnchor: "middle"
});

chart.addText({
  x: 5,
  y: chartAreaBounds.height / 2 + 10,
  text: "270",
  fontSize: 16,
  textAnchor: "end"
});

All 5 comments

There is no direct option to draw labels as you described in the image.

But, you can use ApexChart's addText() method to draw custom text elements on the chart area.
Here is a codepen example which produces this result.
screen shot 2018-10-23 at 11 41 33 am

The code for generating these labels

var chartAreaBounds = chart.w.globals.dom.baseEl.querySelector('.apexcharts-inner').getBoundingClientRect();

chart.addText({
  x: chartAreaBounds.width / 2,
  y: 10,
  text: "0",
  fontSize: 16,
  textAnchor: "middle"
});

chart.addText({
  x: chartAreaBounds.width - 5,
  y: chartAreaBounds.height / 2 + 10,
  text: "90",
  fontSize: 16,
  textAnchor: "start"
});

chart.addText({
  x: chartAreaBounds.width / 2,
  y: chartAreaBounds.height + 30,
  text: "180",
  fontSize: 16,
  textAnchor: "middle"
});

chart.addText({
  x: 5,
  y: chartAreaBounds.height / 2 + 10,
  text: "270",
  fontSize: 16,
  textAnchor: "end"
});

I was impressed by your efforts !
your answer is give hope to me
thank you
have a nice day!

@junedchhipa

I have tried your answer. but I got an error: (in codepen example also)

chart.addText is not a function

Is there any solution to this?

Hi @junedchhipa,

I have the same problem with the latest release.

@junedchhipa

I have tried your answer. but I got an error: (in codepen example also)

chart.addText is not a function

Is there any solution to this?

I don't see anything either in the codepen example

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thellimist picture thellimist  路  3Comments

jeroenpol picture jeroenpol  路  3Comments

ismaildervisoglu picture ismaildervisoglu  路  3Comments

rcoundon picture rcoundon  路  3Comments

frlinw picture frlinw  路  3Comments