TreemapChart widget in Supervisely is a widget used for displaying a treemap chart. It allows users to visualize data for comparison distribution of different objects. The TreemapChart widget allows easily visualize data to determine the distribution of objects in comparison to each other.
Determines colors for cells in series in TreemapChart
tooltip
str
Determines tooltip for cells in series in TreemapChart
title
Determines TreemapChart title.
type:str
colors
Determines colors for cells in series in TreemapChart. The colors should be in hex format (e.g. #ff0000).
type:List[str]
default value:None
tooltip
Determines the tooltip for cells in series in TreemapChart. The tooltip should be in str format and may contain {x} and {y} placeholders. The name of the cell will be shown instead of {x} and the value of the cell will be shown instead of {y}. If not specified, the default tooltip will be used (e.g. name: value)
tooltip = "This is the name: {x}, this is the value: {y}"
chart = TreemapChart(
title="Treemap Chart",
tooltip=tooltip,
)
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, TreemapChart, Container, Text
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()
# Colors are optional. If not specified, the default colors will be used.
colors = [
"#008FFB",
"#00E396",
"#FEB019",]
# Tooltip is optional. If not specified, the default tooltip will be used.
tooltip = "This is the name: {x}, this is the value: {y}"
tc = TreemapChart(title="Treemap Chart", colors=colors, tooltip=tooltip)
clicked_datapoint = Text(status="info")
@tc.click
def clicked(datapoint):
# Datapoint is a namedtuple with fields: series_index, data_index, data
# data is a dict with fields: name, value
clicked_datapoint.text = datapoint
# Creating Card widget, which will contain the Transfer widget and the Text widget.
card = Card(title="TreemapChart", content=Container(widgets=[dc, clicked_datapoint]))
# Creating the application layout.
layout = Container(widgets=[card])
# Initializing the application.
app = sly.Application(layout=layout)