1

How can Bokeh 1.3 new widget DataCube to sum more than 1 field?

Bokeh 1.3 doc :https://blog.bokeh.org/posts/release-1-3-0

From the sample code of Bokeh doc, it will sum 1 field only, I have tried with a list of 2 fields but no luck.

Sample codes:

source = ColumnDataSource(data=dict(
    d0=['A', 'E', 'E', 'E', 'J', 'L', 'M'],
    d1=['B', 'D', 'D', 'H', 'K', 'L', 'N'],
    d2=['C', 'F', 'G', 'H', 'K', 'L', 'O'],
    px=[10,  20,  30,  40,  50,  60,  70 ],
))

target = ColumnDataSource(data=dict(row_indices=[], labels=[]))

formatter = StringFormatter(font_style='bold')

columns = [
    TableColumn(field='d2', title='Name', width=40, sortable=False, formatter=formatter),
    TableColumn(field='px', title='Price', width=40, sortable=False),
]

grouping = [
    GroupingInfo(getter='d0', aggregators=[SumAggregator(field_='px')]),
    GroupingInfo(getter='d1', aggregators=[SumAggregator(field_='px')])
]

cube = DataCube(source=source, columns=columns, grouping=grouping, target=target)

Any help is great, thanks.

Wing
  • 11
  • 1
  • It's not clear to me that it is currently possible. Rather than leave an unanswered question on SO, I'd suggest closing this and continuing to try and see if jburgy can provide a definitive answer in the PR – bigreddot Sep 11 '19 at 05:28

0 Answers0