flet-charts 0.2.0.dev13__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 +35 -0
- flet_charts/bar_chart.py +237 -0
- flet_charts/bar_chart_group.py +33 -0
- flet_charts/bar_chart_rod.py +111 -0
- flet_charts/bar_chart_rod_stack_item.py +31 -0
- flet_charts/chart_axis.py +64 -0
- flet_charts/line_chart.py +251 -0
- flet_charts/line_chart_data.py +140 -0
- flet_charts/line_chart_data_point.py +85 -0
- flet_charts/matplotlib_chart.py +64 -0
- flet_charts/pie_chart.py +89 -0
- flet_charts/pie_chart_section.py +89 -0
- flet_charts/plotly_chart.py +56 -0
- flet_charts/scatter_chart.py +218 -0
- flet_charts/scatter_chart_spot.py +102 -0
- flet_charts/types.py +288 -0
- flet_charts-0.2.0.dev13.dist-info/METADATA +69 -0
- flet_charts-0.2.0.dev13.dist-info/RECORD +38 -0
- flet_charts-0.2.0.dev13.dist-info/WHEEL +5 -0
- flet_charts-0.2.0.dev13.dist-info/licenses/LICENSE +201 -0
- flet_charts-0.2.0.dev13.dist-info/top_level.txt +2 -0
- flutter/flet_charts/CHANGELOG.md +3 -0
- flutter/flet_charts/LICENSE +201 -0
- flutter/flet_charts/README.md +3 -0
- flutter/flet_charts/analysis_options.yaml +5 -0
- flutter/flet_charts/lib/flet_charts.dart +3 -0
- flutter/flet_charts/lib/src/bar_chart.dart +95 -0
- flutter/flet_charts/lib/src/extension.dart +25 -0
- flutter/flet_charts/lib/src/line_chart.dart +236 -0
- flutter/flet_charts/lib/src/pie_chart.dart +71 -0
- flutter/flet_charts/lib/src/scatter_chart.dart +140 -0
- flutter/flet_charts/lib/src/utils/bar_chart.dart +177 -0
- flutter/flet_charts/lib/src/utils/charts.dart +173 -0
- flutter/flet_charts/lib/src/utils/line_chart.dart +208 -0
- flutter/flet_charts/lib/src/utils/pie_chart.dart +56 -0
- flutter/flet_charts/lib/src/utils/scatter_chart.dart +85 -0
- flutter/flet_charts/pubspec.lock +776 -0
- flutter/flet_charts/pubspec.yaml +24 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import 'package:equatable/equatable.dart';
|
|
2
|
+
import 'package:fl_chart/fl_chart.dart';
|
|
3
|
+
import 'package:flet/flet.dart';
|
|
4
|
+
import 'package:flutter/material.dart';
|
|
5
|
+
|
|
6
|
+
import 'charts.dart';
|
|
7
|
+
|
|
8
|
+
class PieChartEventData extends Equatable {
|
|
9
|
+
final String eventType;
|
|
10
|
+
final int? sectionIndex;
|
|
11
|
+
final Offset? localPosition;
|
|
12
|
+
|
|
13
|
+
const PieChartEventData(
|
|
14
|
+
{required this.eventType,
|
|
15
|
+
required this.sectionIndex,
|
|
16
|
+
this.localPosition});
|
|
17
|
+
|
|
18
|
+
factory PieChartEventData.fromDetails(
|
|
19
|
+
FlTouchEvent event, PieTouchResponse? response) {
|
|
20
|
+
return PieChartEventData(
|
|
21
|
+
eventType: eventMap[event.runtimeType.toString()] ?? "undefined",
|
|
22
|
+
sectionIndex: response?.touchedSection?.touchedSectionIndex,
|
|
23
|
+
localPosition: event.localPosition,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Map<String, dynamic> toMap() => <String, dynamic>{
|
|
28
|
+
'type': eventType,
|
|
29
|
+
'section_index': sectionIndex,
|
|
30
|
+
"local_x": localPosition?.dx,
|
|
31
|
+
"local_y": localPosition?.dy
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
@override
|
|
35
|
+
List<Object?> get props => [eventType, sectionIndex];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
PieChartSectionData parsePieChartSectionData(
|
|
39
|
+
Control section, BuildContext context) {
|
|
40
|
+
section.notifyParent = true;
|
|
41
|
+
var theme = Theme.of(context);
|
|
42
|
+
var title = section.getString("title");
|
|
43
|
+
return PieChartSectionData(
|
|
44
|
+
value: section.getDouble("value"),
|
|
45
|
+
color: section.getColor("color", context),
|
|
46
|
+
radius: section.getDouble("radius"),
|
|
47
|
+
showTitle: title != null,
|
|
48
|
+
title: title,
|
|
49
|
+
titleStyle: section.getTextStyle("title_style", theme),
|
|
50
|
+
borderSide: section.getBorderSide("border_side", theme,
|
|
51
|
+
defaultValue: BorderSide.none)!,
|
|
52
|
+
titlePositionPercentageOffset: section.getDouble("title_position"),
|
|
53
|
+
badgeWidget: section.buildWidget("badge_content"),
|
|
54
|
+
badgePositionPercentageOffset: section.getDouble("badge_position"),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import 'package:collection/collection.dart';
|
|
2
|
+
import 'package:equatable/equatable.dart';
|
|
3
|
+
import 'package:fl_chart/fl_chart.dart';
|
|
4
|
+
import 'package:flet/flet.dart';
|
|
5
|
+
import 'package:flutter/material.dart';
|
|
6
|
+
|
|
7
|
+
import 'charts.dart';
|
|
8
|
+
|
|
9
|
+
class ScatterChartEventData extends Equatable {
|
|
10
|
+
final String eventType;
|
|
11
|
+
final int? spotIndex;
|
|
12
|
+
|
|
13
|
+
const ScatterChartEventData({required this.eventType, this.spotIndex});
|
|
14
|
+
|
|
15
|
+
factory ScatterChartEventData.fromDetails(
|
|
16
|
+
FlTouchEvent event, ScatterTouchResponse? response) {
|
|
17
|
+
return ScatterChartEventData(
|
|
18
|
+
eventType: eventMap[event.runtimeType.toString()] ?? "undefined",
|
|
19
|
+
spotIndex: response?.touchedSpot?.spotIndex);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Map<String, dynamic> toMap() => {'type': eventType, 'spot_index': spotIndex};
|
|
23
|
+
|
|
24
|
+
@override
|
|
25
|
+
List<Object?> get props => [eventType, spotIndex];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ScatterTouchTooltipData? parseScatterTouchTooltipData(
|
|
29
|
+
BuildContext context, Control control, List<ScatterSpot> spots,
|
|
30
|
+
[ScatterTouchTooltipData? defaultValue]) {
|
|
31
|
+
var tooltip = control.get("tooltip");
|
|
32
|
+
if (tooltip == null) return defaultValue;
|
|
33
|
+
|
|
34
|
+
final theme = Theme.of(context);
|
|
35
|
+
|
|
36
|
+
return ScatterTouchTooltipData(
|
|
37
|
+
tooltipBorder: parseBorderSide(tooltip["border_side"], theme,
|
|
38
|
+
defaultValue: BorderSide.none)!,
|
|
39
|
+
rotateAngle: parseDouble(tooltip["rotate_angle"]),
|
|
40
|
+
maxContentWidth: parseDouble(tooltip["max_width"]),
|
|
41
|
+
tooltipPadding: parsePadding(tooltip["padding"]),
|
|
42
|
+
tooltipHorizontalAlignment: FLHorizontalAlignment.values
|
|
43
|
+
.firstWhereOrNull((v) => v.name == tooltip["horizontal_alignment"]),
|
|
44
|
+
tooltipHorizontalOffset: parseDouble(tooltip["horizontal_offset"]),
|
|
45
|
+
tooltipBorderRadius: parseBorderRadius(tooltip["border_radius"]),
|
|
46
|
+
fitInsideHorizontally: parseBool(tooltip["fit_inside_horizontally"]),
|
|
47
|
+
fitInsideVertically: parseBool(tooltip["fit_inside_vertically"]),
|
|
48
|
+
getTooltipColor: (ScatterSpot spot) {
|
|
49
|
+
// var spotIndex =
|
|
50
|
+
// spots.indexWhere((spot) => spot.x == spot.x && spot.y == spot.y);
|
|
51
|
+
// var dp = control.children("spots")[spotIndex];
|
|
52
|
+
return parseColor(
|
|
53
|
+
tooltip["bgcolor"], theme, const Color.fromRGBO(96, 125, 139, 1))!;
|
|
54
|
+
},
|
|
55
|
+
getTooltipItems: (touchedSpot) {
|
|
56
|
+
var spotIndex = spots.indexWhere(
|
|
57
|
+
(spot) => spot.x == touchedSpot.x && spot.y == touchedSpot.y);
|
|
58
|
+
return parseScatterTooltipItem(
|
|
59
|
+
control.children("spots")[spotIndex], touchedSpot, context);
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ScatterTooltipItem? parseScatterTooltipItem(
|
|
65
|
+
Control dataPoint, ScatterSpot spot, BuildContext context) {
|
|
66
|
+
if (!dataPoint.getBool("show_tooltip", true)!) return null;
|
|
67
|
+
|
|
68
|
+
final theme = Theme.of(context);
|
|
69
|
+
|
|
70
|
+
var tooltip = dataPoint.get("tooltip");
|
|
71
|
+
var style = parseTextStyle(tooltip["text_style"], theme, const TextStyle())!;
|
|
72
|
+
if (style.color == null) {
|
|
73
|
+
style = style.copyWith(color: spot.dotPainter.mainColor);
|
|
74
|
+
}
|
|
75
|
+
return ScatterTooltipItem(
|
|
76
|
+
tooltip["text"] ?? dataPoint.getDouble("y").toString(),
|
|
77
|
+
textStyle: style,
|
|
78
|
+
textAlign: parseTextAlign(tooltip["text_align"], TextAlign.center)!,
|
|
79
|
+
children: tooltip["text_spans"] != null
|
|
80
|
+
? parseTextSpans(tooltip["text_spans"], theme, (s, eventName,
|
|
81
|
+
[eventData]) {
|
|
82
|
+
s.triggerEvent(eventName, eventData);
|
|
83
|
+
})
|
|
84
|
+
: null);
|
|
85
|
+
}
|