title: adding percentage label to Bokeh Pie chart
body: <p>I want to add percentage as a label to my Bokeh donut chart. I have accomplished it! with a bit of mathematics! but I think that there must be a better built-in solution. I saw some solutions but they were from an older version of Bokeh and did not work for me. I am sharing my code and result:</p>
  
  <pre><code>from math import pi
  from bokeh.palettes import Category10
  from bokeh.models.sources import ColumnDataSource
  from bokeh.plotting import figure
  from bokeh.transform import cumsum 
  from bokeh.models import Legend, HoverTool, LabelSet
  from bokeh.io import output_notebook, show, push_notebook
  import numpy as np
  
  output_notebook()
  
  value = [10,20,30,40]*5
  
  data = {'name': ["A", "B","C","D"]*5,                               
          'value': value,                     
          'angle': [v/sum(value)*2*pi for v in value],
          'cumulative_angle':[(sum(value[0:i+1])- (item/2))/sum(value)*2*pi for i,item in enumerate(value)],
          'percentage': [d/sum(value)*100 for d in value],
          'color': Category10[5][1:]*5}      
  
  data['label'] = ["{:.0f}%".format(p) for p in data['percentage']]
  data['cos'] = np.cos(data['cumulative_angle'])*0.3
  data['sin'] = np.sin(data['cumulative_angle'])*0.3
  
  source = ColumnDataSource(data=data)
  
  
  TOOLTIPS = [ 
    ("Value", "@value"),
    ("Percentage", "@percentage{0.2f}%")
  ] 
  
  
  p = figure(plot_height=600,plot_width=600,x_range=(-1,1), y_range=(-1,1), tools='hover',
             tooltips=TOOLTIPS, title="My Donut Chart", toolbar_location=None)
  
  
  r = p.annular_wedge(x=0, y=0, inner_radius=0.2, outer_radius=0.4,
          start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
          line_color="white", fill_color='color', fill_alpha=1, source=source)
  
  
  legend = Legend(items=[LegendItem(label=dict(field="name"), renderers=[r])], location=(0, 80)) 
  p.add_layout(legend, 'right') 
  
  
  labels = LabelSet(x='cos', y='sin', text="label", y_offset=0,
            text_font_size="6pt", text_color="black",
            source=source, text_align='center')
  
  p.add_layout(labels)
  
  
  p.axis.axis_label=None
  p.axis.visible=False
  p.grid.grid_line_color = None
  p.outline_line_color = None
  
  
  show(p)
  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ILWnb.png" rel="nofollow noreferrer">the current Pie chart with percentages</a></p>
  
  <p>Although I think that this is mathematically right, it doesn't always work! It might be because of inner dimensions of Bokeh. For instance if you change the width and the height the percentages might scatter around, and you would need to set y_offset etc. to fix it. I don't want that! What is the correct way of implementing it?</p>
  
  <p>Thanks</p>