On Dec 18, 2017, at 14:27, rpjain@gmail.com wrote:
Thanks! The first approach worked. But I was hoping there would have been simpler way to just format the display of text...
On Thursday, December 14, 2017 at 1:14:05 PM UTC-5, Bryan Van de ven wrote:
Hi,
There are two approaches. Either way, you will want to put the data into a column in campCDS:
* preformat the values into strings (in Python), and put these values as column in campCDS. Then the LabelSet should be configured with
text="my_labels_colname"
Or:
* put the raw numeric data in campCDS and use a CustomJSTransform to format the numbers to strings (with $ in front or whatever) in the browser.
The first method is probably what I'd suggest, absent any other information.
Thanks,
Bryan
> On Dec 11, 2017, at 16:38, RJ <rpj...@gmail.com> wrote:
>
>
> I am trying to format the text for data labels to show contribution amounts in $. Not sure how to do this. Read the documentation but couldnt find much help. Attached is the sample of the contribution data. I am highlighted what I was trying to do but obviously it is throwing an error. Any suggestions?
>
> import pandas as pd
> from bokeh.models import ColumnDataSource, LinearColorMapper, LabelSet, PrintfTickFormatter
> from bokeh.plotting import figure, show, output_notebook
>
> camp = pd.read_excel('../data/sampleContributions.xlsx')
>
> campDF= camp.groupby('OFFICECD')['AMNT'].sum()
> campCDS = ColumnDataSource(data=dict(xvar=campDF.index, yval=campDF.values))
>
> p = figure(x_range=list(campDF.index), width=800, height=500)
> p.vbar('xvar', top='yval', width=.5, source=campCDS)
>
> barLabels = LabelSet(x='xvar', y='yval', text='{:.2f}'.format('yval'), source=campCDS )
> p.add_layout(barLabels)
>
>
> output_notebook()
> show(p)
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3fbf050c-b54c-455d-aa46-236bf29e6380%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
> <sampleContributions.xlsx>
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1bd15880-c5d1-47ee-bc03-61a8305dd930%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.