/
main.py
47 lines (35 loc) · 1.15 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, HeatmapChart, Text
# for convenient debug, has no effect in production
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()
# function to build example chart
def multiplication_chart():
data = []
for row in list(range(1, 11)):
temp = [round(row * number, 1) for number in list(range(1, 11))]
data.append(temp)
return data
# initialize widgets we will use in UI
chart = HeatmapChart(
title="Multiplication Table",
xaxis_title="xaxis_title",
color_range="table",
tooltip="Result multiplication of {x} * {series_name}",
)
data = multiplication_chart()
lines = [{"name": idx + 1, "x": list(range(1, 11)), "y": line} for idx, line in enumerate(data)]
chart.add_series_batch(lines)
text = Text(status="info")
card = Card(
title="Heatmap Chart",
content=Container([chart, text]),
)
layout = Container(widgets=[card])
app = sly.Application(layout=layout)
@chart.click
def show_cell_info(datapoint: HeatmapChart.ClickedDataPoint):
text.text = datapoint