Treemap chart

Hi bokehers’

is there a rapid way to do a Treemap chart like
Treemaps ?
Or shall I need to code it :cold_face:
thanks
olivier

Hi @odadoun ,

There is not right now, no. If you decide to code it up, we’d love to see it. :slight_smile:

1 Like

@odadoun,

Depending on your requirements, you might be able to leverage Holoviz panel to accomplish this with bokeh content as well.

In principle, you can combine bokeh models and figures, plotly, and other functionality in panel. And since the panel server is the bokeh server under the hood, you have all of that functionality too.

bokeh is my go-to visualization framework, but I often find that complementing it with some extras from panel works quite well.

Here’s a very simple example using one of the plotly examples in the link you provided, combined with a bokeh button that just acknowledges that it was pressed, i.e. no link between the button and the treemap.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""
import plotly.express as px
import numpy as np

from bokeh.models import Button
import panel as pn

pn.extension('plotly')


def press_cb():
    print("button press")

b = Button(button_type='primary', width=300, label='Press')
b.on_click(press_cb)


df = px.data.gapminder().query("year == 2007")
df["world"] = "world" # in order to have a single root node
fig = px.treemap(df, path=['world', 'continent', 'country'], values='pop',
                  color='lifeExp', hover_data=['iso_alpha'],
                  color_continuous_scale='RdBu',
                  color_continuous_midpoint=np.average(df['lifeExp'], weights=df['pop']))

ui = pn.Column(b, fig)
ui.servable()
2 Likes

@carolyn thanks but I think I will postponed this task :shushing_face:
@_jm thanks your solution seems to be very good :crazy_face:

1 Like

I believe that it is possible to do it using quads and some geometry equations functions.
I really enjoy bokeh and I am looking for a job as data viz, lets say I managed to get it done, any chance of job in the team? :slight_smile:

1 Like

@Reinhold83 When Bokeh 3.0 is released, there will be a new block glyph available that is easier to use for treemaps. It accepts x and y corner coordinates, and width and height, which agrees with some common external treemap libraries.

I don’t really understand your question about a job. Are you asking about paid employment? Bokeh is a volunteer open source project, not a company with employees.

1 Like

Bokeh 3.0
Can’t wait :muscle:
Bokeh is a volunteer open source project, not a company with employees
:love_you_gesture: :ok_hand:

1 Like

Just a silly comment dude.

@Reinhold83 there have definitely been people who have mistaken Bokeh for a business or company over the years, so there was no way for me to know otherwise here. I can’t really do anything but take things at face value. :person_shrugging:

Taking the opportunity that you are online an active @bigredot could you tell me if it is possible the discussion I opened, please?