flet-charts 0.2.0.dev35__tar.gz → 0.2.0.dev84__tar.gz

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.
Files changed (45) hide show
  1. {flet_charts-0.2.0.dev35/src/flet_charts.egg-info → flet_charts-0.2.0.dev84}/PKG-INFO +8 -9
  2. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/README.md +7 -1
  3. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/pyproject.toml +6 -6
  4. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/__init__.py +24 -17
  5. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/bar_chart.py +83 -23
  6. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/bar_chart_group.py +1 -1
  7. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/bar_chart_rod.py +36 -4
  8. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/chart_axis.py +29 -9
  9. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/line_chart.py +72 -7
  10. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/line_chart_data.py +30 -4
  11. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/line_chart_data_point.py +32 -2
  12. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/matplotlib_chart.py +2 -1
  13. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/pie_chart.py +3 -3
  14. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/pie_chart_section.py +5 -0
  15. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/scatter_chart.py +70 -23
  16. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/scatter_chart_spot.py +43 -4
  17. flet_charts-0.2.0.dev84/src/flet_charts/types.py +427 -0
  18. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84/src/flet_charts.egg-info}/PKG-INFO +8 -9
  19. flet_charts-0.2.0.dev84/src/flet_charts.egg-info/requires.txt +1 -0
  20. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/bar_chart.dart +2 -0
  21. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/scatter_chart.dart +22 -21
  22. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/utils/bar_chart.dart +26 -9
  23. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/utils/charts.dart +12 -0
  24. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/utils/line_chart.dart +15 -3
  25. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/utils/pie_chart.dart +1 -0
  26. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/utils/scatter_chart.dart +22 -21
  27. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/pubspec.lock +48 -32
  28. flet_charts-0.2.0.dev35/src/flet_charts/types.py +0 -284
  29. flet_charts-0.2.0.dev35/src/flet_charts.egg-info/requires.txt +0 -11
  30. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/LICENSE +0 -0
  31. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/setup.cfg +0 -0
  32. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/bar_chart_rod_stack_item.py +0 -0
  33. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts/plotly_chart.py +0 -0
  34. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts.egg-info/SOURCES.txt +0 -0
  35. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts.egg-info/dependency_links.txt +0 -0
  36. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flet_charts.egg-info/top_level.txt +0 -0
  37. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/CHANGELOG.md +0 -0
  38. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/LICENSE +0 -0
  39. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/README.md +0 -0
  40. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/analysis_options.yaml +0 -0
  41. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/flet_charts.dart +0 -0
  42. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/extension.dart +0 -0
  43. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/line_chart.dart +0 -0
  44. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/lib/src/pie_chart.dart +0 -0
  45. {flet_charts-0.2.0.dev35 → flet_charts-0.2.0.dev84}/src/flutter/flet_charts/pubspec.yaml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flet-charts
3
- Version: 0.2.0.dev35
3
+ Version: 0.2.0.dev84
4
4
  Summary: A Flet extension for creating interactive charts and graphs.
5
5
  Author-email: Flet contributors <hello@flet.dev>
6
6
  License-Expression: Apache-2.0
@@ -12,13 +12,6 @@ Requires-Python: >=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: flet>=0.70.0.dev0
15
- Provides-Extra: all
16
- Requires-Dist: plotly>=6.0.1; extra == "all"
17
- Requires-Dist: matplotlib>=3.10.1; extra == "all"
18
- Provides-Extra: plotly
19
- Requires-Dist: plotly>=6.0.1; extra == "plotly"
20
- Provides-Extra: matplotlib
21
- Requires-Dist: matplotlib>=3.10.1; extra == "matplotlib"
22
15
  Dynamic: license-file
23
16
 
24
17
  # flet-charts
@@ -48,7 +41,9 @@ This package supports the following platforms:
48
41
  | Android | ✅ |
49
42
  | Web | ✅ |
50
43
 
51
- ## Installation
44
+ ## Usage
45
+
46
+ ### Installation
52
47
 
53
48
  To install the `flet-charts` package and add it to your project dependencies:
54
49
 
@@ -67,3 +62,7 @@ To install the `flet-charts` package and add it to your project dependencies:
67
62
  ```bash
68
63
  poetry add flet-charts
69
64
  ```
65
+
66
+ ### Examples
67
+
68
+ For examples, see [these](./examples).
@@ -25,7 +25,9 @@ This package supports the following platforms:
25
25
  | Android | ✅ |
26
26
  | Web | ✅ |
27
27
 
28
- ## Installation
28
+ ## Usage
29
+
30
+ ### Installation
29
31
 
30
32
  To install the `flet-charts` package and add it to your project dependencies:
31
33
 
@@ -44,3 +46,7 @@ To install the `flet-charts` package and add it to your project dependencies:
44
46
  ```bash
45
47
  poetry add flet-charts
46
48
  ```
49
+
50
+ ### Examples
51
+
52
+ For examples, see [these](./examples).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "flet-charts"
3
- version = "0.2.0.dev35"
3
+ version = "0.2.0.dev84"
4
4
  description = "A Flet extension for creating interactive charts and graphs."
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Flet contributors", email = "hello@flet.dev" }]
@@ -19,11 +19,6 @@ Issues = "https://github.com/flet-dev/flet-charts/issues"
19
19
  [tool.setuptools.package-data]
20
20
  "flutter.flet_charts" = ["**/*"]
21
21
 
22
- [project.optional-dependencies]
23
- all = ["plotly>=6.0.1", "matplotlib>=3.10.1"]
24
- plotly = ["plotly>=6.0.1"]
25
- matplotlib = ["matplotlib>=3.10.1"]
26
-
27
22
  [dependency-groups]
28
23
  test = [
29
24
  "pytest >=7.2.0",
@@ -57,6 +52,7 @@ docs = [
57
52
  "markdown-exec[ansi] >=1.11.0",
58
53
  "pydocstyle >=6.3.0",
59
54
  "linkcheckmd >=1.4.0",
55
+ "mkdocs-external-images",
60
56
  { include-group = 'docs-coverage' },
61
57
  ]
62
58
  all = [
@@ -64,6 +60,10 @@ all = [
64
60
  { include-group = 'docs' },
65
61
  ]
66
62
 
63
+ [tool.uv.sources]
64
+ mkdocs-external-images = { git = "https://github.com/flet-dev/mkdocs-external-images", tag = "v0.2.0" }
65
+
66
+
67
67
  [tool.ruff]
68
68
  line-length = 88
69
69
  target-version = "py39"
@@ -1,37 +1,44 @@
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 .chart_axis import ChartAxis, ChartAxisLabel
11
- from .line_chart import (
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.chart_axis import ChartAxis, ChartAxisLabel
11
+ from flet_charts.line_chart import (
12
12
  LineChart,
13
13
  LineChartEvent,
14
14
  LineChartEventSpot,
15
15
  LineChartTooltip,
16
16
  )
17
- from .line_chart_data import LineChartData
18
- from .line_chart_data_point import LineChartDataPoint, LineChartDataPointTooltip
19
- from .matplotlib_chart import MatplotlibChart
20
- from .pie_chart import PieChart, PieChartEvent
21
- from .pie_chart_section import PieChartSection
22
- from .plotly_chart import PlotlyChart
23
- from .scatter_chart import ScatterChart, ScatterChartEvent, ScatterChartTooltip
24
- from .scatter_chart_spot import ScatterChartSpot, ScatterChartSpotTooltip
25
- from .types import (
17
+ from flet_charts.line_chart_data import LineChartData
18
+ from flet_charts.line_chart_data_point import (
19
+ LineChartDataPoint,
20
+ LineChartDataPointTooltip,
21
+ )
22
+ from flet_charts.matplotlib_chart import MatplotlibChart
23
+ from flet_charts.pie_chart import PieChart, PieChartEvent
24
+ from flet_charts.pie_chart_section import PieChartSection
25
+ from flet_charts.plotly_chart import PlotlyChart
26
+ from flet_charts.scatter_chart import (
27
+ ScatterChart,
28
+ ScatterChartEvent,
29
+ ScatterChartTooltip,
30
+ )
31
+ from flet_charts.scatter_chart_spot import ScatterChartSpot, ScatterChartSpotTooltip
32
+ from flet_charts.types import (
26
33
  ChartCirclePoint,
27
34
  ChartCrossPoint,
28
35
  ChartDataPointTooltip,
29
36
  ChartEventType,
30
37
  ChartGridLines,
31
- ChartHorizontalAlignment,
32
38
  ChartPointLine,
33
39
  ChartPointShape,
34
40
  ChartSquarePoint,
41
+ HorizontalAlignment,
35
42
  )
36
43
 
37
44
  __all__ = [
@@ -50,10 +57,10 @@ __all__ = [
50
57
  "ChartDataPointTooltip",
51
58
  "ChartEventType",
52
59
  "ChartGridLines",
53
- "ChartHorizontalAlignment",
54
60
  "ChartPointLine",
55
61
  "ChartPointShape",
56
62
  "ChartSquarePoint",
63
+ "HorizontalAlignment",
57
64
  "LineChart",
58
65
  "LineChartData",
59
66
  "LineChartDataPoint",
@@ -4,9 +4,9 @@ from typing import Any, Optional
4
4
 
5
5
  import flet as ft
6
6
 
7
- from .bar_chart_group import BarChartGroup
8
- from .chart_axis import ChartAxis
9
- from .types import ChartEventType, ChartGridLines
7
+ from flet_charts.bar_chart_group import BarChartGroup
8
+ from flet_charts.chart_axis import ChartAxis
9
+ from flet_charts.types import ChartEventType, ChartGridLines, HorizontalAlignment
10
10
 
11
11
  __all__ = [
12
12
  "BarChart",
@@ -43,12 +43,14 @@ class BarChartTooltip:
43
43
  The border radius of the tooltip.
44
44
  """
45
45
 
46
- margin: Optional[ft.Number] = None
46
+ margin: ft.Number = 16
47
47
  """
48
48
  Applies a bottom margin for showing tooltip on top of rods.
49
49
  """
50
50
 
51
- padding: Optional[ft.PaddingValue] = None
51
+ padding: ft.PaddingValue = field(
52
+ default_factory=lambda: ft.Padding.symmetric(vertical=8, horizontal=16)
53
+ )
52
54
  """
53
55
  Applies a padding for showing contents inside the tooltip.
54
56
  """
@@ -58,14 +60,14 @@ class BarChartTooltip:
58
60
  Restricts the tooltip's width.
59
61
  """
60
62
 
61
- rotate_angle: Optional[ft.Number] = None
63
+ rotation: ft.Number = 0.0
62
64
  """
63
65
  The rotation angle of the tooltip.
64
66
  """
65
67
 
66
- horizontal_offset: Optional[ft.Number] = None
68
+ horizontal_offset: ft.Number = 0.0
67
69
  """
68
- Applies horizontal offset for showing tooltip.
70
+ The horizontal offset of this tooltip.
69
71
  """
70
72
 
71
73
  border_side: Optional[ft.BorderSide] = None
@@ -73,20 +75,69 @@ class BarChartTooltip:
73
75
  The tooltip border side.
74
76
  """
75
77
 
76
- fit_inside_horizontally: Optional[bool] = None
78
+ fit_inside_horizontally: bool = False
77
79
  """
78
80
  Forces the tooltip to shift horizontally inside the chart, if overflow happens.
79
81
  """
80
82
 
81
- fit_inside_vertically: Optional[bool] = None
83
+ fit_inside_vertically: bool = False
82
84
  """
83
85
  Forces the tooltip to shift vertically inside the chart, if overflow happens.
84
86
  """
85
87
 
86
- direction: Optional[BarChartTooltipDirection] = None
87
- """
88
- Controls showing tooltip on top or bottom, default is auto.
89
- """
88
+ direction: BarChartTooltipDirection = BarChartTooltipDirection.AUTO
89
+ """
90
+ Defines the direction of this tooltip.
91
+ """
92
+
93
+ horizontal_alignment: HorizontalAlignment = HorizontalAlignment.CENTER
94
+ """
95
+ Defines the horizontal alignment of this tooltip.
96
+ """
97
+
98
+ def copy(
99
+ self,
100
+ *,
101
+ bgcolor: Optional[ft.ColorValue] = None,
102
+ border_radius: Optional[ft.BorderRadiusValue] = None,
103
+ margin: Optional[ft.Number] = None,
104
+ padding: Optional[ft.PaddingValue] = None,
105
+ max_width: Optional[ft.Number] = None,
106
+ rotation: Optional[ft.Number] = None,
107
+ horizontal_offset: Optional[ft.Number] = None,
108
+ border_side: Optional[ft.BorderSide] = None,
109
+ fit_inside_horizontally: Optional[bool] = None,
110
+ fit_inside_vertically: Optional[bool] = None,
111
+ direction: Optional[BarChartTooltipDirection] = None,
112
+ horizontal_alignment: Optional[HorizontalAlignment] = None,
113
+ ) -> "BarChartTooltip":
114
+ """
115
+ Returns a copy of this object with the specified properties overridden.
116
+ """
117
+ return BarChartTooltip(
118
+ bgcolor=bgcolor if bgcolor is not None else self.bgcolor,
119
+ border_radius=border_radius
120
+ if border_radius is not None
121
+ else self.border_radius,
122
+ margin=margin if margin is not None else self.margin,
123
+ padding=padding if padding is not None else self.padding,
124
+ max_width=max_width if max_width is not None else self.max_width,
125
+ rotation=rotation if rotation is not None else self.rotation,
126
+ horizontal_offset=horizontal_offset
127
+ if horizontal_offset is not None
128
+ else self.horizontal_offset,
129
+ border_side=border_side if border_side is not None else self.border_side,
130
+ fit_inside_horizontally=fit_inside_horizontally
131
+ if fit_inside_horizontally is not None
132
+ else self.fit_inside_horizontally,
133
+ fit_inside_vertically=fit_inside_vertically
134
+ if fit_inside_vertically is not None
135
+ else self.fit_inside_vertically,
136
+ direction=direction if direction is not None else self.direction,
137
+ horizontal_alignment=horizontal_alignment
138
+ if horizontal_alignment is not None
139
+ else self.horizontal_alignment,
140
+ )
90
141
 
91
142
 
92
143
  @dataclass
@@ -117,7 +168,7 @@ class BarChart(ft.ConstrainedControl):
117
168
  """
118
169
  Draws a bar chart.
119
170
 
120
- ![Overview](assets/bar-chart/diagram.svg)
171
+ ![Overview](assets/bar-chart-diagram.svg)
121
172
  """
122
173
 
123
174
  groups: list[BarChartGroup] = field(default_factory=list)
@@ -125,9 +176,17 @@ class BarChart(ft.ConstrainedControl):
125
176
  The list of [`BarChartGroup`][(p).]s to draw.
126
177
  """
127
178
 
128
- spacing: Optional[ft.Number] = None
179
+ group_spacing: ft.Number = 16.0
180
+ """
181
+ A amount of space between bar [`groups`][..].
129
182
  """
130
- A amount of space between bar groups.
183
+
184
+ group_alignment: ft.MainAxisAlignment = ft.MainAxisAlignment.SPACE_EVENLY
185
+ """
186
+ A alignment of the bar [`groups`][..] within this chart.
187
+
188
+ If set to [`MainAxisAlignment.CENTER`][flet.MainAxisAlignment.CENTER],
189
+ the space between the `groups` can be specified using [`group_spacing`][..].
131
190
  """
132
191
 
133
192
  animation: ft.AnimationValue = field(
@@ -137,9 +196,6 @@ class BarChart(ft.ConstrainedControl):
137
196
  )
138
197
  """
139
198
  Controls chart implicit animation.
140
-
141
- Value is of [`AnimationValue`](https://flet.dev/docs/reference/types/animationvalue)
142
- type.
143
199
  """
144
200
 
145
201
  interactive: bool = True
@@ -202,14 +258,18 @@ class BarChart(ft.ConstrainedControl):
202
258
  The maximum displayed value for Y axis.
203
259
  """
204
260
 
205
- tooltip: Optional[BarChartTooltip] = None
261
+ tooltip: Optional[BarChartTooltip] = field(
262
+ default_factory=lambda: BarChartTooltip()
263
+ )
206
264
  """
207
- The tooltip configuration for the chart.
265
+ The tooltip configuration for this chart.
266
+
267
+ If set to `None`, tooltips will not shown throughout this chart.
208
268
  """
209
269
 
210
270
  on_event: Optional[ft.EventHandler[BarChartEvent]] = None
211
271
  """
212
- Fires when a bar is hovered or clicked.
272
+ Called when an event occurs on this chart, such as a click or hover.
213
273
  """
214
274
 
215
275
  def __post_init__(self, ref: Optional[ft.Ref[Any]]):
@@ -3,7 +3,7 @@ from typing import Optional
3
3
 
4
4
  import flet as ft
5
5
 
6
- from .bar_chart_rod import BarChartRod
6
+ from flet_charts.bar_chart_rod import BarChartRod
7
7
 
8
8
  __all__ = ["BarChartGroup"]
9
9
 
@@ -1,10 +1,10 @@
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
5
 
6
- from .bar_chart_rod_stack_item import BarChartRodStackItem
7
- from .types import ChartDataPointTooltip
6
+ from flet_charts.bar_chart_rod_stack_item import BarChartRodStackItem
7
+ from flet_charts.types import ChartDataPointTooltip
8
8
 
9
9
  __all__ = ["BarChartRod", "BarChartRodTooltip"]
10
10
 
@@ -22,6 +22,28 @@ class BarChartRodTooltip(ChartDataPointTooltip):
22
22
  When `None`, defaults to [`BarChartRod.to_y`][(p).].
23
23
  """
24
24
 
25
+ def copy(
26
+ self,
27
+ *,
28
+ text: Optional[str] = None,
29
+ text_style: Optional[ft.TextStyle] = None,
30
+ text_align: Optional[ft.TextAlign] = None,
31
+ text_spans: Optional[list[ft.TextSpan]] = None,
32
+ rtl: Optional[bool] = None,
33
+ ) -> "BarChartRodTooltip":
34
+ """
35
+ Returns a copy of this object with the specified properties overridden.
36
+ """
37
+ return BarChartRodTooltip(
38
+ text=text if text is not None else self.text,
39
+ text_style=text_style if text_style is not None else self.text_style,
40
+ text_align=text_align if text_align is not None else self.text_align,
41
+ text_spans=text_spans.copy()
42
+ if text_spans is not None
43
+ else (self.text_spans.copy() if self.text_spans is not None else None),
44
+ rtl=rtl if rtl is not None else self.rtl,
45
+ )
46
+
25
47
 
26
48
  @ft.control("BarChartRod")
27
49
  class BarChartRod(ft.BaseControl):
@@ -94,7 +116,9 @@ class BarChartRod(ft.BaseControl):
94
116
  [`BarChart.interactive`][(p).] is set to `False`.
95
117
  """
96
118
 
97
- tooltip: BarChartRodTooltip = field(default_factory=lambda: BarChartRodTooltip())
119
+ tooltip: Union[BarChartRodTooltip, str] = field(
120
+ default_factory=lambda: BarChartRodTooltip()
121
+ )
98
122
  """
99
123
  The rod's tooltip configuration for this rod.
100
124
  """
@@ -103,3 +127,11 @@ class BarChartRod(ft.BaseControl):
103
127
  """
104
128
  Whether a tooltip should be shown on top of hovered bar.
105
129
  """
130
+
131
+ def before_update(self):
132
+ super().before_update()
133
+ self._internals["tooltip"] = (
134
+ BarChartRodTooltip(text=self.tooltip)
135
+ if isinstance(self.tooltip, str)
136
+ else self.tooltip
137
+ )
@@ -1,5 +1,5 @@
1
1
  from dataclasses import field
2
- from typing import Optional, Union
2
+ from typing import Optional
3
3
 
4
4
  import flet as ft
5
5
 
@@ -17,11 +17,9 @@ class ChartAxisLabel(ft.BaseControl):
17
17
  A value to draw label for.
18
18
  """
19
19
 
20
- label: Optional[Union[ft.Control, str]] = None
20
+ label: Optional[ft.StrOrControl] = None
21
21
  """
22
- The label to display for the specified `value`.
23
-
24
- Can be a string or a `Control`.
22
+ The label to display for the specified [`value`][..].
25
23
  """
26
24
 
27
25
 
@@ -38,12 +36,12 @@ class ChartAxis(ft.BaseControl):
38
36
 
39
37
  title_size: ft.Number = 16
40
38
  """
41
- Width or height of title area.
39
+ The size of title area.
42
40
  """
43
41
 
44
42
  show_labels: bool = True
45
43
  """
46
- Whether to display the `labels` along the axis.
44
+ Whether to display the [`labels`][..] along the axis.
47
45
  If `labels` is empty then automatic labels are displayed.
48
46
  """
49
47
 
@@ -55,10 +53,32 @@ class ChartAxis(ft.BaseControl):
55
53
 
56
54
  label_spacing: Optional[ft.Number] = None
57
55
  """
58
- The interval between automatic labels.
56
+ The spacing/interval between labels.
57
+
58
+ If a value is not set, a suitable value
59
+ will be automatically calculated and used.
59
60
  """
60
61
 
61
62
  label_size: ft.Number = 22
62
63
  """
63
- Width or height of labels area.
64
+ The maximum space for each label in [`labels`][..].
65
+
66
+ Each label will stretch to fit this space.
67
+ """
68
+
69
+ show_min: bool = True
70
+ """
71
+ Whether to display a label for the minimum value
72
+ independent of the sampling interval.
64
73
  """
74
+
75
+ show_max: bool = True
76
+ """
77
+ Whether to display a label for the maximum value
78
+ independent of the sampling interval.
79
+ """
80
+
81
+ def before_update(self):
82
+ super().before_update()
83
+ if self.label_spacing == 0:
84
+ raise ValueError("label_spacing cannot be 0")
@@ -3,9 +3,9 @@ from typing import Any, Optional
3
3
 
4
4
  import flet as ft
5
5
 
6
- from .chart_axis import ChartAxis
7
- from .line_chart_data import LineChartData
8
- from .types import ChartEventType, ChartGridLines
6
+ from flet_charts.chart_axis import ChartAxis
7
+ from flet_charts.line_chart_data import LineChartData
8
+ from flet_charts.types import ChartEventType, ChartGridLines, HorizontalAlignment
9
9
 
10
10
  __all__ = [
11
11
  "LineChart",
@@ -27,6 +27,20 @@ class LineChartEventSpot:
27
27
  The line's point index or `-1` if no point was hovered.
28
28
  """
29
29
 
30
+ def copy(
31
+ self,
32
+ *,
33
+ bar_index: Optional[int] = None,
34
+ spot_index: Optional[int] = None,
35
+ ) -> "LineChartEventSpot":
36
+ """
37
+ Returns a copy of this object with the specified properties overridden.
38
+ """
39
+ return LineChartEventSpot(
40
+ bar_index=bar_index if bar_index is not None else self.bar_index,
41
+ spot_index=spot_index if spot_index is not None else self.spot_index,
42
+ )
43
+
30
44
 
31
45
  @dataclass
32
46
  class LineChartEvent(ft.Event["LineChart"]):
@@ -72,7 +86,7 @@ class LineChartTooltip:
72
86
  Restricts the tooltip's width.
73
87
  """
74
88
 
75
- rotate_angle: ft.Number = 0.0
89
+ rotation: ft.Number = 0.0
76
90
  """
77
91
  The tooltip's rotation angle in degrees.
78
92
  """
@@ -84,7 +98,7 @@ class LineChartTooltip:
84
98
 
85
99
  border_side: ft.BorderSide = field(default_factory=lambda: ft.BorderSide.none())
86
100
  """
87
- The tooltip's border side.
101
+ Defines the borders of this tooltip.
88
102
  """
89
103
 
90
104
  fit_inside_horizontally: bool = False
@@ -102,13 +116,60 @@ class LineChartTooltip:
102
116
  Whether to force the tooltip container to top of the line.
103
117
  """
104
118
 
119
+ horizontal_alignment: HorizontalAlignment = HorizontalAlignment.CENTER
120
+ """
121
+ The horizontal alignment of this tooltip.
122
+ """
123
+
124
+ def copy(
125
+ self,
126
+ *,
127
+ bgcolor: Optional[ft.ColorValue] = None,
128
+ border_radius: Optional[ft.BorderRadiusValue] = None,
129
+ margin: Optional[ft.Number] = None,
130
+ padding: Optional[ft.PaddingValue] = None,
131
+ max_width: Optional[ft.Number] = None,
132
+ rotation: Optional[ft.Number] = None,
133
+ horizontal_offset: Optional[ft.Number] = None,
134
+ border_side: Optional[ft.BorderSide] = None,
135
+ fit_inside_horizontally: Optional[bool] = None,
136
+ fit_inside_vertically: Optional[bool] = None,
137
+ show_on_top_of_chart_box_area: Optional[bool] = None,
138
+ ) -> "LineChartTooltip":
139
+ """
140
+ Returns a copy of this object with the specified properties overridden.
141
+ """
142
+ return LineChartTooltip(
143
+ bgcolor=bgcolor if bgcolor is not None else self.bgcolor,
144
+ border_radius=border_radius
145
+ if border_radius is not None
146
+ else self.border_radius,
147
+ margin=margin if margin is not None else self.margin,
148
+ padding=padding if padding is not None else self.padding,
149
+ max_width=max_width if max_width is not None else self.max_width,
150
+ rotation=rotation if rotation is not None else self.rotation,
151
+ horizontal_offset=horizontal_offset
152
+ if horizontal_offset is not None
153
+ else self.horizontal_offset,
154
+ border_side=border_side if border_side is not None else self.border_side,
155
+ fit_inside_horizontally=fit_inside_horizontally
156
+ if fit_inside_horizontally is not None
157
+ else self.fit_inside_horizontally,
158
+ fit_inside_vertically=fit_inside_vertically
159
+ if fit_inside_vertically is not None
160
+ else self.fit_inside_vertically,
161
+ show_on_top_of_chart_box_area=show_on_top_of_chart_box_area
162
+ if show_on_top_of_chart_box_area is not None
163
+ else self.show_on_top_of_chart_box_area,
164
+ )
165
+
105
166
 
106
167
  @ft.control("LineChart")
107
168
  class LineChart(ft.ConstrainedControl):
108
169
  """
109
170
  Draws a line chart.
110
171
 
111
- ![Overview](assets/line-chart/diagram.svg)
172
+ ![Overview](assets/line-chart-diagram.svg)
112
173
  """
113
174
 
114
175
  data_series: list[LineChartData] = field(default_factory=list)
@@ -215,9 +276,13 @@ class LineChart(ft.ConstrainedControl):
215
276
  Defines the maximum displayed value for Y axis.
216
277
  """
217
278
 
218
- tooltip: LineChartTooltip = field(default_factory=lambda: LineChartTooltip())
279
+ tooltip: Optional[LineChartTooltip] = field(
280
+ default_factory=lambda: LineChartTooltip()
281
+ )
219
282
  """
220
283
  The tooltip configuration for this chart.
284
+
285
+ If set to `None`, no tooltips will be shown throughout this chart.
221
286
  """
222
287
 
223
288
  on_event: Optional[ft.EventHandler[LineChartEvent]] = None
@@ -3,8 +3,8 @@ from typing import Optional, Union
3
3
 
4
4
  import flet as ft
5
5
 
6
- from .line_chart_data_point import LineChartDataPoint
7
- from .types import ChartPointLine, ChartPointShape
6
+ from flet_charts.line_chart_data_point import LineChartDataPoint
7
+ from flet_charts.types import ChartPointLine, ChartPointShape
8
8
 
9
9
  __all__ = ["LineChartData"]
10
10
 
@@ -19,7 +19,7 @@ class LineChartData(ft.BaseControl):
19
19
 
20
20
  curved: bool = False
21
21
  """
22
- Set to `True` to draw chart line as a curve.
22
+ Whether to draw this chart line as a curve.
23
23
  """
24
24
 
25
25
  color: ft.ColorValue = ft.Colors.CYAN
@@ -49,7 +49,7 @@ class LineChartData(ft.BaseControl):
49
49
 
50
50
  prevent_curve_over_shooting_threshold: ft.Number = 10.0
51
51
  """
52
- Threshold to prevent overshooting algorithm.
52
+ Threshold for [`prevent_curve_over_shooting`][..] algorithm.
53
53
  """
54
54
 
55
55
  dash_pattern: Optional[list[int]] = None
@@ -128,3 +128,29 @@ class LineChartData(ft.BaseControl):
128
128
  """
129
129
  Defines the appearance and shape of a selected line point.
130
130
  """
131
+
132
+ curve_smoothness: ft.Number = 0.35
133
+ """
134
+ Defines the smoothness of a curve line,
135
+ when [`curved`][..] is set to `True`.
136
+ """
137
+
138
+ rounded_stroke_join: bool = False
139
+ """
140
+ Whether to draw rounded line joins.
141
+ """
142
+
143
+ step_direction: Optional[ft.Number] = None
144
+ """
145
+ Determines the direction of each step.
146
+
147
+ If not `None`, this chart will be drawn as a
148
+ [Step Line Chart](https://docs.anychart.com/Basic_Charts/Step_Line_Chart).
149
+
150
+ Below are some typical values:
151
+
152
+ - `0.0`: Go to the next spot directly, with the current point's y value.
153
+ - `0.5`: Go to the half with the current spot y, and with the next spot y
154
+ for the rest.
155
+ - `1.0`: Go to the next spot y and direct line to the next spot.
156
+ """