Skip to content

Commit ff8d933

Browse files
Matplotlib and Plotly Charts (#509)
* Line chart initial commit * More chart classes * LineChart Python model * Use custom flutter_svg library * aspect_ratio added to all controls * AspectRatio on Flutter side * Changed flutter_svg reference to flet-fixes branch * MatplotlibChart control * Added MatplotlibChart.isolated * Create plotly_chart.py * Update pubspec.lock * original_size
1 parent 1032f8d commit ff8d933

40 files changed

+377
-11
lines changed

client/pubspec.lock

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ packages:
196196
flutter_svg:
197197
dependency: transitive
198198
description:
199-
name: flutter_svg
200-
url: "https://pub.dartlang.org"
201-
source: hosted
199+
path: "."
200+
ref: flet-fixes
201+
resolved-ref: "71166dc07d39b686f117319a04479d26e44c2a24"
202+
url: "https://github.com/flet-dev/flutter_svg.git"
203+
source: git
202204
version: "1.1.5"
203205
flutter_test:
204206
dependency: "direct dev"

package/lib/src/controls/create_control.dart

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,20 @@ Widget constrainedControl(
326326
return _expandable(
327327
_positionedControl(
328328
context,
329-
_offsetControl(
330-
context,
331-
_scaledControl(
329+
_aspectRatio(
330+
_offsetControl(
332331
context,
333-
_rotatedControl(
332+
_scaledControl(
334333
context,
335-
_sizedControl(
336-
_tooltip(_opacity(context, widget, parent, control),
337-
parent, control),
334+
_rotatedControl(
335+
context,
336+
_sizedControl(
337+
_tooltip(
338+
_opacity(context, widget, parent, control),
339+
parent,
340+
control),
341+
parent,
342+
control),
338343
parent,
339344
control),
340345
parent,
@@ -391,6 +396,16 @@ Widget _tooltip(Widget widget, Control? parent, Control control) {
391396
: widget;
392397
}
393398

399+
Widget _aspectRatio(Widget widget, Control? parent, Control control) {
400+
var aspectRatio = control.attrDouble("aspectRatio");
401+
return aspectRatio != null
402+
? AspectRatio(
403+
aspectRatio: aspectRatio,
404+
child: widget,
405+
)
406+
: widget;
407+
}
408+
394409
Widget _rotatedControl(
395410
BuildContext context, Widget widget, Control? parent, Control control) {
396411
var rotationDetails = parseRotate(control, "rotate");

package/pubspec.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ dependencies:
2323
markdown: ^6.0.1
2424
file_picker: ^5.0.1
2525
shared_preferences: ^2.0.15
26-
flutter_svg: ^1.1.5
26+
flutter_svg:
27+
git:
28+
url: https://github.com/flet-dev/flutter_svg.git
29+
ref: flet-fixes
2730
window_to_front: ^0.0.3
2831
audioplayers: ^1.1.0
2932

sdk/python/flet/animated_switcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(
2525
rotate: RotateValue = None,
2626
scale: ScaleValue = None,
2727
offset: OffsetValue = None,
28+
aspect_ratio: OptionalNumber = None,
2829
animate_opacity: AnimationValue = None,
2930
animate_size: AnimationValue = None,
3031
animate_position: AnimationValue = None,
@@ -59,6 +60,7 @@ def __init__(
5960
rotate=rotate,
6061
scale=scale,
6162
offset=offset,
63+
aspect_ratio=aspect_ratio,
6264
animate_opacity=animate_opacity,
6365
animate_size=animate_size,
6466
animate_position=animate_position,

sdk/python/flet/card.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __init__(
2424
rotate: RotateValue = None,
2525
scale: ScaleValue = None,
2626
offset: OffsetValue = None,
27+
aspect_ratio: OptionalNumber = None,
2728
animate_opacity: AnimationValue = None,
2829
animate_size: AnimationValue = None,
2930
animate_position: AnimationValue = None,
@@ -55,6 +56,7 @@ def __init__(
5556
rotate=rotate,
5657
scale=scale,
5758
offset=offset,
59+
aspect_ratio=aspect_ratio,
5860
animate_opacity=animate_opacity,
5961
animate_size=animate_size,
6062
animate_position=animate_position,

sdk/python/flet/checkbox.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(
3333
rotate: RotateValue = None,
3434
scale: ScaleValue = None,
3535
offset: OffsetValue = None,
36+
aspect_ratio: OptionalNumber = None,
3637
animate_opacity: AnimationValue = None,
3738
animate_size: AnimationValue = None,
3839
animate_position: AnimationValue = None,
@@ -72,6 +73,7 @@ def __init__(
7273
rotate=rotate,
7374
scale=scale,
7475
offset=offset,
76+
aspect_ratio=aspect_ratio,
7577
animate_opacity=animate_opacity,
7678
animate_size=animate_size,
7779
animate_position=animate_position,

sdk/python/flet/circle_avatar.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __init__(
2424
rotate: RotateValue = None,
2525
scale: ScaleValue = None,
2626
offset: OffsetValue = None,
27+
aspect_ratio: OptionalNumber = None,
2728
animate_opacity: AnimationValue = None,
2829
animate_size: AnimationValue = None,
2930
animate_position: AnimationValue = None,
@@ -61,6 +62,7 @@ def __init__(
6162
rotate=rotate,
6263
scale=scale,
6364
offset=offset,
65+
aspect_ratio=aspect_ratio,
6466
animate_opacity=animate_opacity,
6567
animate_size=animate_size,
6668
animate_position=animate_position,

sdk/python/flet/column.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(
3030
rotate: RotateValue = None,
3131
scale: ScaleValue = None,
3232
offset: OffsetValue = None,
33+
aspect_ratio: OptionalNumber = None,
3334
animate_opacity: AnimationValue = None,
3435
animate_size: AnimationValue = None,
3536
animate_position: AnimationValue = None,
@@ -66,6 +67,7 @@ def __init__(
6667
rotate=rotate,
6768
scale=scale,
6869
offset=offset,
70+
aspect_ratio=aspect_ratio,
6971
animate_opacity=animate_opacity,
7072
animate_size=animate_size,
7173
animate_position=animate_position,

sdk/python/flet/constrained_control.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
rotate: RotateValue = None,
3030
scale: ScaleValue = None,
3131
offset: OffsetValue = None,
32+
aspect_ratio: OptionalNumber = None,
3233
animate_opacity: AnimationValue = None,
3334
animate_size: AnimationValue = None,
3435
animate_position: AnimationValue = None,
@@ -57,6 +58,7 @@ def __init__(
5758
self.scale = scale
5859
self.rotate = rotate
5960
self.offset = offset
61+
self.aspect_ratio = aspect_ratio
6062
self.animate_opacity = animate_opacity
6163
self.animate_size = animate_size
6264
self.animate_position = animate_position
@@ -169,6 +171,16 @@ def offset(self) -> OffsetValue:
169171
def offset(self, value: OffsetValue):
170172
self.__offset = value
171173

174+
# aspect_ratio
175+
@property
176+
def aspect_ratio(self) -> OptionalNumber:
177+
return self._get_attr("aspectRatio")
178+
179+
@aspect_ratio.setter
180+
@beartype
181+
def aspect_ratio(self, value: OptionalNumber):
182+
self._set_attr("aspectRatio", value)
183+
172184
# animate_opacity
173185
@property
174186
def animate_opacity(self) -> AnimationValue:

sdk/python/flet/container.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
rotate: RotateValue = None,
5656
scale: ScaleValue = None,
5757
offset: OffsetValue = None,
58+
aspect_ratio: OptionalNumber = None,
5859
animate_opacity: AnimationValue = None,
5960
animate_size: AnimationValue = None,
6061
animate_position: AnimationValue = None,
@@ -104,6 +105,7 @@ def __init__(
104105
rotate=rotate,
105106
scale=scale,
106107
offset=offset,
108+
aspect_ratio=aspect_ratio,
107109
animate_opacity=animate_opacity,
108110
animate_size=animate_size,
109111
animate_position=animate_position,

0 commit comments

Comments
 (0)