flet-charts 0.2.0.dev35__py3-none-any.whl → 0.70.0.dev6555__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of flet-charts might be problematic. Click here for more details.
- flet_charts/__init__.py +59 -17
- flet_charts/bar_chart.py +87 -30
- flet_charts/bar_chart_group.py +1 -2
- flet_charts/bar_chart_rod.py +36 -5
- flet_charts/candlestick_chart.py +269 -0
- flet_charts/candlestick_chart_spot.py +98 -0
- flet_charts/chart_axis.py +29 -9
- flet_charts/line_chart.py +76 -14
- flet_charts/line_chart_data.py +30 -5
- flet_charts/line_chart_data_point.py +33 -4
- flet_charts/matplotlib_backends/backend_flet_agg.py +16 -0
- flet_charts/matplotlib_chart.py +396 -36
- flet_charts/matplotlib_chart_with_toolbar.py +125 -0
- flet_charts/pie_chart.py +3 -6
- flet_charts/pie_chart_section.py +29 -18
- flet_charts/plotly_chart.py +17 -6
- flet_charts/radar_chart.py +214 -0
- flet_charts/radar_data_set.py +66 -0
- flet_charts/scatter_chart.py +75 -29
- flet_charts/scatter_chart_spot.py +44 -6
- flet_charts/types.py +159 -16
- flet_charts-0.70.0.dev6555.dist-info/METADATA +67 -0
- flet_charts-0.70.0.dev6555.dist-info/RECORD +47 -0
- flutter/flet_charts/CHANGELOG.md +1 -1
- flutter/flet_charts/LICENSE +1 -1
- flutter/flet_charts/analysis_options.yaml +1 -1
- flutter/flet_charts/lib/src/bar_chart.dart +2 -0
- flutter/flet_charts/lib/src/candlestick_chart.dart +129 -0
- flutter/flet_charts/lib/src/extension.dart +6 -0
- flutter/flet_charts/lib/src/radar_chart.dart +104 -0
- flutter/flet_charts/lib/src/scatter_chart.dart +22 -21
- flutter/flet_charts/lib/src/utils/bar_chart.dart +137 -73
- flutter/flet_charts/lib/src/utils/candlestick_chart.dart +118 -0
- flutter/flet_charts/lib/src/utils/charts.dart +12 -0
- flutter/flet_charts/lib/src/utils/line_chart.dart +15 -3
- flutter/flet_charts/lib/src/utils/pie_chart.dart +2 -1
- flutter/flet_charts/lib/src/utils/radar_chart.dart +90 -0
- flutter/flet_charts/lib/src/utils/scatter_chart.dart +22 -21
- flutter/flet_charts/pubspec.lock +85 -71
- flutter/flet_charts/pubspec.yaml +10 -9
- flet_charts-0.2.0.dev35.dist-info/METADATA +0 -69
- flet_charts-0.2.0.dev35.dist-info/RECORD +0 -38
- flutter/flet_charts/README.md +0 -3
- {flet_charts-0.2.0.dev35.dist-info → flet_charts-0.70.0.dev6555.dist-info}/WHEEL +0 -0
- {flet_charts-0.2.0.dev35.dist-info → flet_charts-0.70.0.dev6555.dist-info}/licenses/LICENSE +0 -0
- {flet_charts-0.2.0.dev35.dist-info → flet_charts-0.70.0.dev6555.dist-info}/top_level.txt +0 -0
flet_charts/__init__.py
CHANGED
|
@@ -1,37 +1,65 @@
|
|
|
1
|
-
from .bar_chart import (
|
|
1
|
+
from flet_charts.bar_chart import (
|
|
2
2
|
BarChart,
|
|
3
3
|
BarChartEvent,
|
|
4
4
|
BarChartTooltip,
|
|
5
5
|
BarChartTooltipDirection,
|
|
6
6
|
)
|
|
7
|
-
from .bar_chart_group import BarChartGroup
|
|
8
|
-
from .bar_chart_rod import BarChartRod, BarChartRodTooltip
|
|
9
|
-
from .bar_chart_rod_stack_item import BarChartRodStackItem
|
|
10
|
-
from .
|
|
11
|
-
|
|
7
|
+
from flet_charts.bar_chart_group import BarChartGroup
|
|
8
|
+
from flet_charts.bar_chart_rod import BarChartRod, BarChartRodTooltip
|
|
9
|
+
from flet_charts.bar_chart_rod_stack_item import BarChartRodStackItem
|
|
10
|
+
from flet_charts.candlestick_chart import (
|
|
11
|
+
CandlestickChart,
|
|
12
|
+
CandlestickChartEvent,
|
|
13
|
+
CandlestickChartTooltip,
|
|
14
|
+
)
|
|
15
|
+
from flet_charts.candlestick_chart_spot import (
|
|
16
|
+
CandlestickChartSpot,
|
|
17
|
+
CandlestickChartSpotTooltip,
|
|
18
|
+
)
|
|
19
|
+
from flet_charts.chart_axis import ChartAxis, ChartAxisLabel
|
|
20
|
+
from flet_charts.line_chart import (
|
|
12
21
|
LineChart,
|
|
13
22
|
LineChartEvent,
|
|
14
23
|
LineChartEventSpot,
|
|
15
24
|
LineChartTooltip,
|
|
16
25
|
)
|
|
17
|
-
from .line_chart_data import LineChartData
|
|
18
|
-
from .line_chart_data_point import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
from .
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
from flet_charts.line_chart_data import LineChartData
|
|
27
|
+
from flet_charts.line_chart_data_point import (
|
|
28
|
+
LineChartDataPoint,
|
|
29
|
+
LineChartDataPointTooltip,
|
|
30
|
+
)
|
|
31
|
+
from flet_charts.matplotlib_chart import (
|
|
32
|
+
MatplotlibChart,
|
|
33
|
+
MatplotlibChartMessageEvent,
|
|
34
|
+
MatplotlibChartToolbarButtonsUpdateEvent,
|
|
35
|
+
)
|
|
36
|
+
from flet_charts.matplotlib_chart_with_toolbar import MatplotlibChartWithToolbar
|
|
37
|
+
from flet_charts.pie_chart import PieChart, PieChartEvent
|
|
38
|
+
from flet_charts.pie_chart_section import PieChartSection
|
|
39
|
+
from flet_charts.plotly_chart import PlotlyChart
|
|
40
|
+
from flet_charts.radar_chart import (
|
|
41
|
+
RadarChart,
|
|
42
|
+
RadarChartEvent,
|
|
43
|
+
RadarChartTitle,
|
|
44
|
+
RadarShape,
|
|
45
|
+
)
|
|
46
|
+
from flet_charts.radar_data_set import RadarDataSet, RadarDataSetEntry
|
|
47
|
+
from flet_charts.scatter_chart import (
|
|
48
|
+
ScatterChart,
|
|
49
|
+
ScatterChartEvent,
|
|
50
|
+
ScatterChartTooltip,
|
|
51
|
+
)
|
|
52
|
+
from flet_charts.scatter_chart_spot import ScatterChartSpot, ScatterChartSpotTooltip
|
|
53
|
+
from flet_charts.types import (
|
|
26
54
|
ChartCirclePoint,
|
|
27
55
|
ChartCrossPoint,
|
|
28
56
|
ChartDataPointTooltip,
|
|
29
57
|
ChartEventType,
|
|
30
58
|
ChartGridLines,
|
|
31
|
-
ChartHorizontalAlignment,
|
|
32
59
|
ChartPointLine,
|
|
33
60
|
ChartPointShape,
|
|
34
61
|
ChartSquarePoint,
|
|
62
|
+
HorizontalAlignment,
|
|
35
63
|
)
|
|
36
64
|
|
|
37
65
|
__all__ = [
|
|
@@ -43,6 +71,11 @@ __all__ = [
|
|
|
43
71
|
"BarChartRodTooltip",
|
|
44
72
|
"BarChartTooltip",
|
|
45
73
|
"BarChartTooltipDirection",
|
|
74
|
+
"CandlestickChart",
|
|
75
|
+
"CandlestickChartEvent",
|
|
76
|
+
"CandlestickChartSpot",
|
|
77
|
+
"CandlestickChartSpotTooltip",
|
|
78
|
+
"CandlestickChartTooltip",
|
|
46
79
|
"ChartAxis",
|
|
47
80
|
"ChartAxisLabel",
|
|
48
81
|
"ChartCirclePoint",
|
|
@@ -50,10 +83,10 @@ __all__ = [
|
|
|
50
83
|
"ChartDataPointTooltip",
|
|
51
84
|
"ChartEventType",
|
|
52
85
|
"ChartGridLines",
|
|
53
|
-
"ChartHorizontalAlignment",
|
|
54
86
|
"ChartPointLine",
|
|
55
87
|
"ChartPointShape",
|
|
56
88
|
"ChartSquarePoint",
|
|
89
|
+
"HorizontalAlignment",
|
|
57
90
|
"LineChart",
|
|
58
91
|
"LineChartData",
|
|
59
92
|
"LineChartDataPoint",
|
|
@@ -62,10 +95,19 @@ __all__ = [
|
|
|
62
95
|
"LineChartEventSpot",
|
|
63
96
|
"LineChartTooltip",
|
|
64
97
|
"MatplotlibChart",
|
|
98
|
+
"MatplotlibChartMessageEvent",
|
|
99
|
+
"MatplotlibChartToolbarButtonsUpdateEvent",
|
|
100
|
+
"MatplotlibChartWithToolbar",
|
|
65
101
|
"PieChart",
|
|
66
102
|
"PieChartEvent",
|
|
67
103
|
"PieChartSection",
|
|
68
104
|
"PlotlyChart",
|
|
105
|
+
"RadarChart",
|
|
106
|
+
"RadarChartEvent",
|
|
107
|
+
"RadarChartTitle",
|
|
108
|
+
"RadarDataSet",
|
|
109
|
+
"RadarDataSetEntry",
|
|
110
|
+
"RadarShape",
|
|
69
111
|
"ScatterChart",
|
|
70
112
|
"ScatterChartEvent",
|
|
71
113
|
"ScatterChartSpot",
|
flet_charts/bar_chart.py
CHANGED
|
@@ -3,10 +3,9 @@ from enum import Enum
|
|
|
3
3
|
from typing import Any, Optional
|
|
4
4
|
|
|
5
5
|
import flet as ft
|
|
6
|
-
|
|
7
|
-
from .
|
|
8
|
-
from .
|
|
9
|
-
from .types import ChartEventType, ChartGridLines
|
|
6
|
+
from flet_charts.bar_chart_group import BarChartGroup
|
|
7
|
+
from flet_charts.chart_axis import ChartAxis
|
|
8
|
+
from flet_charts.types import ChartEventType, ChartGridLines, HorizontalAlignment
|
|
10
9
|
|
|
11
10
|
__all__ = [
|
|
12
11
|
"BarChart",
|
|
@@ -43,12 +42,14 @@ class BarChartTooltip:
|
|
|
43
42
|
The border radius of the tooltip.
|
|
44
43
|
"""
|
|
45
44
|
|
|
46
|
-
margin:
|
|
45
|
+
margin: ft.Number = 16
|
|
47
46
|
"""
|
|
48
47
|
Applies a bottom margin for showing tooltip on top of rods.
|
|
49
48
|
"""
|
|
50
49
|
|
|
51
|
-
padding:
|
|
50
|
+
padding: ft.PaddingValue = field(
|
|
51
|
+
default_factory=lambda: ft.Padding.symmetric(vertical=8, horizontal=16)
|
|
52
|
+
)
|
|
52
53
|
"""
|
|
53
54
|
Applies a padding for showing contents inside the tooltip.
|
|
54
55
|
"""
|
|
@@ -58,14 +59,14 @@ class BarChartTooltip:
|
|
|
58
59
|
Restricts the tooltip's width.
|
|
59
60
|
"""
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
rotation: ft.Number = 0.0
|
|
62
63
|
"""
|
|
63
64
|
The rotation angle of the tooltip.
|
|
64
65
|
"""
|
|
65
66
|
|
|
66
|
-
horizontal_offset:
|
|
67
|
+
horizontal_offset: ft.Number = 0.0
|
|
67
68
|
"""
|
|
68
|
-
|
|
69
|
+
The horizontal offset of this tooltip.
|
|
69
70
|
"""
|
|
70
71
|
|
|
71
72
|
border_side: Optional[ft.BorderSide] = None
|
|
@@ -73,20 +74,69 @@ class BarChartTooltip:
|
|
|
73
74
|
The tooltip border side.
|
|
74
75
|
"""
|
|
75
76
|
|
|
76
|
-
fit_inside_horizontally:
|
|
77
|
+
fit_inside_horizontally: bool = False
|
|
77
78
|
"""
|
|
78
79
|
Forces the tooltip to shift horizontally inside the chart, if overflow happens.
|
|
79
80
|
"""
|
|
80
81
|
|
|
81
|
-
fit_inside_vertically:
|
|
82
|
+
fit_inside_vertically: bool = False
|
|
82
83
|
"""
|
|
83
84
|
Forces the tooltip to shift vertically inside the chart, if overflow happens.
|
|
84
85
|
"""
|
|
85
86
|
|
|
86
|
-
direction:
|
|
87
|
-
"""
|
|
88
|
-
|
|
89
|
-
"""
|
|
87
|
+
direction: BarChartTooltipDirection = BarChartTooltipDirection.AUTO
|
|
88
|
+
"""
|
|
89
|
+
Defines the direction of this tooltip.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
horizontal_alignment: HorizontalAlignment = HorizontalAlignment.CENTER
|
|
93
|
+
"""
|
|
94
|
+
Defines the horizontal alignment of this tooltip.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
def copy(
|
|
98
|
+
self,
|
|
99
|
+
*,
|
|
100
|
+
bgcolor: Optional[ft.ColorValue] = None,
|
|
101
|
+
border_radius: Optional[ft.BorderRadiusValue] = None,
|
|
102
|
+
margin: Optional[ft.Number] = None,
|
|
103
|
+
padding: Optional[ft.PaddingValue] = None,
|
|
104
|
+
max_width: Optional[ft.Number] = None,
|
|
105
|
+
rotation: Optional[ft.Number] = None,
|
|
106
|
+
horizontal_offset: Optional[ft.Number] = None,
|
|
107
|
+
border_side: Optional[ft.BorderSide] = None,
|
|
108
|
+
fit_inside_horizontally: Optional[bool] = None,
|
|
109
|
+
fit_inside_vertically: Optional[bool] = None,
|
|
110
|
+
direction: Optional[BarChartTooltipDirection] = None,
|
|
111
|
+
horizontal_alignment: Optional[HorizontalAlignment] = None,
|
|
112
|
+
) -> "BarChartTooltip":
|
|
113
|
+
"""
|
|
114
|
+
Returns a copy of this object with the specified properties overridden.
|
|
115
|
+
"""
|
|
116
|
+
return BarChartTooltip(
|
|
117
|
+
bgcolor=bgcolor if bgcolor is not None else self.bgcolor,
|
|
118
|
+
border_radius=border_radius
|
|
119
|
+
if border_radius is not None
|
|
120
|
+
else self.border_radius,
|
|
121
|
+
margin=margin if margin is not None else self.margin,
|
|
122
|
+
padding=padding if padding is not None else self.padding,
|
|
123
|
+
max_width=max_width if max_width is not None else self.max_width,
|
|
124
|
+
rotation=rotation if rotation is not None else self.rotation,
|
|
125
|
+
horizontal_offset=horizontal_offset
|
|
126
|
+
if horizontal_offset is not None
|
|
127
|
+
else self.horizontal_offset,
|
|
128
|
+
border_side=border_side if border_side is not None else self.border_side,
|
|
129
|
+
fit_inside_horizontally=fit_inside_horizontally
|
|
130
|
+
if fit_inside_horizontally is not None
|
|
131
|
+
else self.fit_inside_horizontally,
|
|
132
|
+
fit_inside_vertically=fit_inside_vertically
|
|
133
|
+
if fit_inside_vertically is not None
|
|
134
|
+
else self.fit_inside_vertically,
|
|
135
|
+
direction=direction if direction is not None else self.direction,
|
|
136
|
+
horizontal_alignment=horizontal_alignment
|
|
137
|
+
if horizontal_alignment is not None
|
|
138
|
+
else self.horizontal_alignment,
|
|
139
|
+
)
|
|
90
140
|
|
|
91
141
|
|
|
92
142
|
@dataclass
|
|
@@ -113,11 +163,9 @@ class BarChartEvent(ft.Event["BarChart"]):
|
|
|
113
163
|
|
|
114
164
|
|
|
115
165
|
@ft.control("BarChart")
|
|
116
|
-
class BarChart(ft.
|
|
166
|
+
class BarChart(ft.LayoutControl):
|
|
117
167
|
"""
|
|
118
168
|
Draws a bar chart.
|
|
119
|
-
|
|
120
|
-

|
|
121
169
|
"""
|
|
122
170
|
|
|
123
171
|
groups: list[BarChartGroup] = field(default_factory=list)
|
|
@@ -125,9 +173,17 @@ class BarChart(ft.ConstrainedControl):
|
|
|
125
173
|
The list of [`BarChartGroup`][(p).]s to draw.
|
|
126
174
|
"""
|
|
127
175
|
|
|
128
|
-
|
|
176
|
+
group_spacing: ft.Number = 16.0
|
|
129
177
|
"""
|
|
130
|
-
|
|
178
|
+
An amount of space between bar [`groups`][(c).].
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
group_alignment: ft.MainAxisAlignment = ft.MainAxisAlignment.SPACE_EVENLY
|
|
182
|
+
"""
|
|
183
|
+
The alignment of the bar [`groups`][(c).] within this chart.
|
|
184
|
+
|
|
185
|
+
If set to [`MainAxisAlignment.CENTER`][flet.MainAxisAlignment.CENTER],
|
|
186
|
+
the space between the `groups` can be specified using [`group_spacing`][(c).].
|
|
131
187
|
"""
|
|
132
188
|
|
|
133
189
|
animation: ft.AnimationValue = field(
|
|
@@ -137,9 +193,6 @@ class BarChart(ft.ConstrainedControl):
|
|
|
137
193
|
)
|
|
138
194
|
"""
|
|
139
195
|
Controls chart implicit animation.
|
|
140
|
-
|
|
141
|
-
Value is of [`AnimationValue`](https://flet.dev/docs/reference/types/animationvalue)
|
|
142
|
-
type.
|
|
143
196
|
"""
|
|
144
197
|
|
|
145
198
|
interactive: bool = True
|
|
@@ -167,22 +220,22 @@ class BarChart(ft.ConstrainedControl):
|
|
|
167
220
|
Controls drawing of chart's vertical lines.
|
|
168
221
|
"""
|
|
169
222
|
|
|
170
|
-
left_axis: ChartAxis =
|
|
223
|
+
left_axis: Optional[ChartAxis] = None
|
|
171
224
|
"""
|
|
172
225
|
The appearance of the left axis, its title and labels.
|
|
173
226
|
"""
|
|
174
227
|
|
|
175
|
-
top_axis: ChartAxis =
|
|
228
|
+
top_axis: Optional[ChartAxis] = None
|
|
176
229
|
"""
|
|
177
230
|
The appearance of the top axis, its title and labels.
|
|
178
231
|
"""
|
|
179
232
|
|
|
180
|
-
right_axis: ChartAxis =
|
|
233
|
+
right_axis: Optional[ChartAxis] = None
|
|
181
234
|
"""
|
|
182
235
|
The appearance of the right axis, its title and labels.
|
|
183
236
|
"""
|
|
184
237
|
|
|
185
|
-
bottom_axis: ChartAxis =
|
|
238
|
+
bottom_axis: Optional[ChartAxis] = None
|
|
186
239
|
"""
|
|
187
240
|
The appearance of the bottom axis, its title and labels.
|
|
188
241
|
"""
|
|
@@ -202,14 +255,18 @@ class BarChart(ft.ConstrainedControl):
|
|
|
202
255
|
The maximum displayed value for Y axis.
|
|
203
256
|
"""
|
|
204
257
|
|
|
205
|
-
tooltip: Optional[BarChartTooltip] =
|
|
258
|
+
tooltip: Optional[BarChartTooltip] = field(
|
|
259
|
+
default_factory=lambda: BarChartTooltip()
|
|
260
|
+
)
|
|
206
261
|
"""
|
|
207
|
-
The tooltip configuration for
|
|
262
|
+
The tooltip configuration for this chart.
|
|
263
|
+
|
|
264
|
+
If set to `None`, tooltips will not shown throughout this chart.
|
|
208
265
|
"""
|
|
209
266
|
|
|
210
267
|
on_event: Optional[ft.EventHandler[BarChartEvent]] = None
|
|
211
268
|
"""
|
|
212
|
-
|
|
269
|
+
Called when an event occurs on this chart, such as a click or hover.
|
|
213
270
|
"""
|
|
214
271
|
|
|
215
272
|
def __post_init__(self, ref: Optional[ft.Ref[Any]]):
|
flet_charts/bar_chart_group.py
CHANGED
flet_charts/bar_chart_rod.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
from dataclasses import dataclass, field
|
|
2
|
-
from typing import Optional
|
|
2
|
+
from typing import Optional, Union
|
|
3
3
|
|
|
4
4
|
import flet as ft
|
|
5
|
-
|
|
6
|
-
from .
|
|
7
|
-
from .types import ChartDataPointTooltip
|
|
5
|
+
from flet_charts.bar_chart_rod_stack_item import BarChartRodStackItem
|
|
6
|
+
from flet_charts.types import ChartDataPointTooltip
|
|
8
7
|
|
|
9
8
|
__all__ = ["BarChartRod", "BarChartRodTooltip"]
|
|
10
9
|
|
|
@@ -22,6 +21,28 @@ class BarChartRodTooltip(ChartDataPointTooltip):
|
|
|
22
21
|
When `None`, defaults to [`BarChartRod.to_y`][(p).].
|
|
23
22
|
"""
|
|
24
23
|
|
|
24
|
+
def copy(
|
|
25
|
+
self,
|
|
26
|
+
*,
|
|
27
|
+
text: Optional[str] = None,
|
|
28
|
+
text_style: Optional[ft.TextStyle] = None,
|
|
29
|
+
text_align: Optional[ft.TextAlign] = None,
|
|
30
|
+
text_spans: Optional[list[ft.TextSpan]] = None,
|
|
31
|
+
rtl: Optional[bool] = None,
|
|
32
|
+
) -> "BarChartRodTooltip":
|
|
33
|
+
"""
|
|
34
|
+
Returns a copy of this object with the specified properties overridden.
|
|
35
|
+
"""
|
|
36
|
+
return BarChartRodTooltip(
|
|
37
|
+
text=text if text is not None else self.text,
|
|
38
|
+
text_style=text_style if text_style is not None else self.text_style,
|
|
39
|
+
text_align=text_align if text_align is not None else self.text_align,
|
|
40
|
+
text_spans=text_spans.copy()
|
|
41
|
+
if text_spans is not None
|
|
42
|
+
else (self.text_spans.copy() if self.text_spans is not None else None),
|
|
43
|
+
rtl=rtl if rtl is not None else self.rtl,
|
|
44
|
+
)
|
|
45
|
+
|
|
25
46
|
|
|
26
47
|
@ft.control("BarChartRod")
|
|
27
48
|
class BarChartRod(ft.BaseControl):
|
|
@@ -94,7 +115,9 @@ class BarChartRod(ft.BaseControl):
|
|
|
94
115
|
[`BarChart.interactive`][(p).] is set to `False`.
|
|
95
116
|
"""
|
|
96
117
|
|
|
97
|
-
tooltip: BarChartRodTooltip = field(
|
|
118
|
+
tooltip: Union[BarChartRodTooltip, str] = field(
|
|
119
|
+
default_factory=lambda: BarChartRodTooltip()
|
|
120
|
+
)
|
|
98
121
|
"""
|
|
99
122
|
The rod's tooltip configuration for this rod.
|
|
100
123
|
"""
|
|
@@ -103,3 +126,11 @@ class BarChartRod(ft.BaseControl):
|
|
|
103
126
|
"""
|
|
104
127
|
Whether a tooltip should be shown on top of hovered bar.
|
|
105
128
|
"""
|
|
129
|
+
|
|
130
|
+
def before_update(self):
|
|
131
|
+
super().before_update()
|
|
132
|
+
self._internals["tooltip"] = (
|
|
133
|
+
BarChartRodTooltip(text=self.tooltip)
|
|
134
|
+
if isinstance(self.tooltip, str)
|
|
135
|
+
else self.tooltip
|
|
136
|
+
)
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import Any, Optional
|
|
3
|
+
|
|
4
|
+
import flet as ft
|
|
5
|
+
from flet_charts.candlestick_chart_spot import CandlestickChartSpot
|
|
6
|
+
from flet_charts.chart_axis import ChartAxis
|
|
7
|
+
from flet_charts.types import ChartEventType, ChartGridLines, HorizontalAlignment
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"CandlestickChart",
|
|
11
|
+
"CandlestickChartEvent",
|
|
12
|
+
"CandlestickChartTooltip",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class CandlestickChartTooltip:
|
|
18
|
+
"""Configuration of the tooltip for [`CandlestickChart`][(p).]s."""
|
|
19
|
+
|
|
20
|
+
bgcolor: ft.ColorValue = "#FFFFECEF"
|
|
21
|
+
"""
|
|
22
|
+
Background color applied to the tooltip bubble.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
border_radius: ft.BorderRadiusValue = field(
|
|
26
|
+
default_factory=lambda: ft.BorderRadius.all(4)
|
|
27
|
+
)
|
|
28
|
+
"""
|
|
29
|
+
Corner radius of the tooltip bubble.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
padding: ft.PaddingValue = field(
|
|
33
|
+
default_factory=lambda: ft.Padding.symmetric(vertical=8, horizontal=16)
|
|
34
|
+
)
|
|
35
|
+
"""
|
|
36
|
+
Padding inside the tooltip bubble.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
max_width: ft.Number = 120
|
|
40
|
+
"""
|
|
41
|
+
Maximum width of the tooltip bubble.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
rotation: ft.Number = 0.0
|
|
45
|
+
"""
|
|
46
|
+
Rotation angle (in degrees) applied to the tooltip bubble.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
horizontal_offset: ft.Number = 0
|
|
50
|
+
"""
|
|
51
|
+
Horizontal offset applied to the tooltip bubble.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
horizontal_alignment: HorizontalAlignment = HorizontalAlignment.CENTER
|
|
55
|
+
"""
|
|
56
|
+
Horizontal alignment of the tooltip relative to the tapped candlestick.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
border_side: ft.BorderSide = field(default_factory=lambda: ft.BorderSide.none())
|
|
60
|
+
"""
|
|
61
|
+
The tooltip bubble border.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
fit_inside_horizontally: bool = False
|
|
65
|
+
"""
|
|
66
|
+
Forces the tooltip bubble to remain inside the chart horizontally.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
fit_inside_vertically: bool = False
|
|
70
|
+
"""
|
|
71
|
+
Forces the tooltip bubble to remain inside the chart vertically.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
show_on_top_of_chart_box_area: bool = False
|
|
75
|
+
"""
|
|
76
|
+
When set to `True`, the tooltip is drawn at the top of the chart box.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
def copy(
|
|
80
|
+
self,
|
|
81
|
+
*,
|
|
82
|
+
bgcolor: Optional[ft.ColorValue] = None,
|
|
83
|
+
border_radius: Optional[ft.BorderRadiusValue] = None,
|
|
84
|
+
padding: Optional[ft.PaddingValue] = None,
|
|
85
|
+
max_width: Optional[ft.Number] = None,
|
|
86
|
+
rotation: Optional[ft.Number] = None,
|
|
87
|
+
horizontal_offset: Optional[ft.Number] = None,
|
|
88
|
+
horizontal_alignment: Optional[HorizontalAlignment] = None,
|
|
89
|
+
border_side: Optional[ft.BorderSide] = None,
|
|
90
|
+
fit_inside_horizontally: Optional[bool] = None,
|
|
91
|
+
fit_inside_vertically: Optional[bool] = None,
|
|
92
|
+
show_on_top_of_chart_box_area: Optional[bool] = None,
|
|
93
|
+
) -> "CandlestickChartTooltip":
|
|
94
|
+
"""
|
|
95
|
+
Returns a copy of this object with the specified properties overridden.
|
|
96
|
+
"""
|
|
97
|
+
return CandlestickChartTooltip(
|
|
98
|
+
bgcolor=bgcolor if bgcolor is not None else self.bgcolor,
|
|
99
|
+
border_radius=border_radius
|
|
100
|
+
if border_radius is not None
|
|
101
|
+
else self.border_radius,
|
|
102
|
+
padding=padding if padding is not None else self.padding,
|
|
103
|
+
max_width=max_width if max_width is not None else self.max_width,
|
|
104
|
+
rotation=rotation if rotation is not None else self.rotation,
|
|
105
|
+
horizontal_offset=horizontal_offset
|
|
106
|
+
if horizontal_offset is not None
|
|
107
|
+
else self.horizontal_offset,
|
|
108
|
+
horizontal_alignment=horizontal_alignment
|
|
109
|
+
if horizontal_alignment is not None
|
|
110
|
+
else self.horizontal_alignment,
|
|
111
|
+
border_side=border_side if border_side is not None else self.border_side,
|
|
112
|
+
fit_inside_horizontally=fit_inside_horizontally
|
|
113
|
+
if fit_inside_horizontally is not None
|
|
114
|
+
else self.fit_inside_horizontally,
|
|
115
|
+
fit_inside_vertically=fit_inside_vertically
|
|
116
|
+
if fit_inside_vertically is not None
|
|
117
|
+
else self.fit_inside_vertically,
|
|
118
|
+
show_on_top_of_chart_box_area=show_on_top_of_chart_box_area
|
|
119
|
+
if show_on_top_of_chart_box_area is not None
|
|
120
|
+
else self.show_on_top_of_chart_box_area,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@dataclass
|
|
125
|
+
class CandlestickChartEvent(ft.Event["CandlestickChart"]):
|
|
126
|
+
"""Event raised for interactions with a [`CandlestickChart`][(p).]."""
|
|
127
|
+
|
|
128
|
+
type: ChartEventType
|
|
129
|
+
"""
|
|
130
|
+
Type of pointer gesture that triggered the event.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
spot_index: Optional[int] = None
|
|
134
|
+
"""
|
|
135
|
+
Index of the candlestick that was interacted with; `None` if none.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@ft.control("CandlestickChart")
|
|
140
|
+
class CandlestickChart(ft.LayoutControl):
|
|
141
|
+
"""
|
|
142
|
+
Draws a candlestick chart representing OHLC values.
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
spots: list[CandlestickChartSpot] = field(default_factory=list)
|
|
146
|
+
"""
|
|
147
|
+
Candlesticks to display on the chart.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
animation: ft.AnimationValue = field(
|
|
151
|
+
default_factory=lambda: ft.Animation(
|
|
152
|
+
duration=ft.Duration(milliseconds=150), curve=ft.AnimationCurve.LINEAR
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
"""
|
|
156
|
+
Controls chart implicit animations.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
interactive: bool = True
|
|
160
|
+
"""
|
|
161
|
+
Enables automatic tooltips and highlighting when hovering the chart.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
show_tooltips_for_selected_spots_only: bool = False
|
|
165
|
+
"""
|
|
166
|
+
Whether to permanently and only show the tooltips of spots with their
|
|
167
|
+
[`selected`][(p).CandlestickChartSpot.selected] property set to `True`.
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
long_press_duration: Optional[ft.DurationValue] = None
|
|
171
|
+
"""
|
|
172
|
+
The duration of a long press on the chart.
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
touch_spot_threshold: ft.Number = 4
|
|
176
|
+
"""
|
|
177
|
+
The distance threshold to consider a touch near a candlestick.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
bgcolor: Optional[ft.ColorValue] = None
|
|
181
|
+
"""
|
|
182
|
+
Background color of the chart.
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
border: Optional[ft.Border] = None
|
|
186
|
+
"""
|
|
187
|
+
Border drawn around the chart.
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
horizontal_grid_lines: Optional[ChartGridLines] = None
|
|
191
|
+
"""
|
|
192
|
+
Horizontal grid lines configuration.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
vertical_grid_lines: Optional[ChartGridLines] = None
|
|
196
|
+
"""
|
|
197
|
+
Vertical grid lines configuration.
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
left_axis: Optional[ChartAxis] = None
|
|
201
|
+
"""
|
|
202
|
+
Appearance of the left axis, its title and labels.
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
top_axis: Optional[ChartAxis] = None
|
|
206
|
+
"""
|
|
207
|
+
Appearance of the top axis, its title and labels.
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
right_axis: Optional[ChartAxis] = None
|
|
211
|
+
"""
|
|
212
|
+
Appearance of the right axis, its title and labels.
|
|
213
|
+
"""
|
|
214
|
+
|
|
215
|
+
bottom_axis: Optional[ChartAxis] = None
|
|
216
|
+
"""
|
|
217
|
+
Appearance of the bottom axis, its title and labels.
|
|
218
|
+
"""
|
|
219
|
+
|
|
220
|
+
baseline_x: Optional[ft.Number] = None
|
|
221
|
+
"""
|
|
222
|
+
Baseline value on the X axis.
|
|
223
|
+
"""
|
|
224
|
+
|
|
225
|
+
min_x: Optional[ft.Number] = None
|
|
226
|
+
"""
|
|
227
|
+
Minimum value displayed on the X axis.
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
max_x: Optional[ft.Number] = None
|
|
231
|
+
"""
|
|
232
|
+
Maximum value displayed on the X axis.
|
|
233
|
+
"""
|
|
234
|
+
|
|
235
|
+
baseline_y: Optional[ft.Number] = None
|
|
236
|
+
"""
|
|
237
|
+
Baseline value on the Y axis.
|
|
238
|
+
"""
|
|
239
|
+
|
|
240
|
+
min_y: Optional[ft.Number] = None
|
|
241
|
+
"""
|
|
242
|
+
Minimum value displayed on the Y axis.
|
|
243
|
+
"""
|
|
244
|
+
|
|
245
|
+
max_y: Optional[ft.Number] = None
|
|
246
|
+
"""
|
|
247
|
+
Maximum value displayed on the Y axis.
|
|
248
|
+
"""
|
|
249
|
+
|
|
250
|
+
rotation_quarter_turns: ft.Number = 0
|
|
251
|
+
"""
|
|
252
|
+
Number of quarter turns (90-degree increments) to rotate the chart.
|
|
253
|
+
"""
|
|
254
|
+
|
|
255
|
+
tooltip: Optional[CandlestickChartTooltip] = field(
|
|
256
|
+
default_factory=lambda: CandlestickChartTooltip()
|
|
257
|
+
)
|
|
258
|
+
"""
|
|
259
|
+
Tooltip configuration for the chart.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
on_event: Optional[ft.EventHandler[CandlestickChartEvent]] = None
|
|
263
|
+
"""
|
|
264
|
+
Called when an event occurs on this chart.
|
|
265
|
+
"""
|
|
266
|
+
|
|
267
|
+
def __post_init__(self, ref: Optional[ft.Ref[Any]]):
|
|
268
|
+
super().__post_init__(ref)
|
|
269
|
+
self._internals["skip_properties"] = ["tooltip"]
|