-4

enter image description here

I am not able to put text like 15% or 16% in the graph. I s there any way to do it.

Invictus
  • 139
  • 3
  • 16
  • Downvoters please tell the reason to downvote. – Invictus Jul 19 '16 at 12:01
  • 1
    Have you tried this: http://stackoverflow.com/questions/20966817/how-to-add-text-inside-the-doughnut-chart-using-chart-js – TheGooseMan Jul 19 '16 at 12:03
  • 3
    @Invictus I downvoted you because you put no effort in creating this question. You might want to read [this](http://stackoverflow.com/help/how-to-ask) – Nick Jul 19 '16 at 12:06
  • ok @Nick . I am making a plunker of this to show my effort. I and yes I have read the question. I want to insert the value as shown in my image i.e. In bitween the circular stript where the color is filled. I don't mean to insert in inside the blank circular hole of donut. – Invictus Jul 19 '16 at 12:17

1 Answers1

3

Since the chart generation has changed a lot from Chart 1.X (docs) to 2.X (docs), it all depend on the version you are currently using for your project :

Version 1.X

Not available for Doughnut charts

If you are working with Pie charts, it is built in in the data you are passing to the chart.

See this jsFiddle for more information and a full result.


Version 2.X

Two methods :

  • You can create a new chart type using .extend() method.

    Then during the creation of the new type, you draw the percentage in the section.
    Check this jsFiddle to see the result (better than the first version, IMHO).

  • You can force the tooltip to always be enabled (as asked in this other question).

    You will just have to edit what is displayed in the tooltip to put the percentage instead of the value. And also move (edit X and Y positions) the tooltip to appear where it should be.

    The image displays a Pie chart, but you can make it work for a Doughnut.

    enter image description here

Community
  • 1
  • 1
tektiv
  • 14,010
  • 5
  • 61
  • 70
  • 2
    Thanks from this I was able to understand how to extent the doughnut to show values instead of the percentage. In case anyone is trying to figure that out I just modified slightly the V2 jsFindle verson http://jsfiddle.net/g6fajwg8/1/ – jcwrequests Aug 01 '16 at 14:26