From 902a4bd6a33371ed10f33f2bca833bf9a5cdeafa Mon Sep 17 00:00:00 2001 From: alr2413 Date: Tue, 14 May 2024 14:27:19 +0200 Subject: [PATCH] added custom properties attribute to line chart bar data --- lib/src/chart/line_chart/line_chart_data.dart | 10 ++++++++++ pubspec.yaml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/chart/line_chart/line_chart_data.dart b/lib/src/chart/line_chart/line_chart_data.dart index 02ffb9eb7..5fe8ea757 100644 --- a/lib/src/chart/line_chart/line_chart_data.dart +++ b/lib/src/chart/line_chart/line_chart_data.dart @@ -244,6 +244,7 @@ class LineChartBarData with EquatableMixin { this.shadow = const Shadow(color: Colors.transparent), this.isStepLineChart = false, this.lineChartStepData = const LineChartStepData(), + this.properties = const {}, }) : color = color ?? ((color == null && gradient == null) ? Colors.cyan : null), belowBarData = belowBarData ?? BarAreaData(), @@ -366,6 +367,9 @@ class LineChartBarData with EquatableMixin { /// Holds data for representing a Step Line Chart, and works only if [isStepChart] is true. final LineChartStepData lineChartStepData; + /// Holds custom properties for this [LineChartBarData], like curve title, subtitle that can be used in the tooltip, etc. + final Map properties; + /// Lerps a [LineChartBarData] based on [t] value, check [Tween.lerp]. static LineChartBarData lerp( LineChartBarData a, @@ -397,6 +401,9 @@ class LineChartBarData with EquatableMixin { isStepLineChart: b.isStepLineChart, lineChartStepData: LineChartStepData.lerp(a.lineChartStepData, b.lineChartStepData, t), + properties: {} + ..addAll(a.properties) + ..addAll(b.properties), ); } @@ -422,6 +429,7 @@ class LineChartBarData with EquatableMixin { Shadow? shadow, bool? isStepLineChart, LineChartStepData? lineChartStepData, + Map? properties, }) { return LineChartBarData( spots: spots ?? this.spots, @@ -445,6 +453,7 @@ class LineChartBarData with EquatableMixin { shadow: shadow ?? this.shadow, isStepLineChart: isStepLineChart ?? this.isStepLineChart, lineChartStepData: lineChartStepData ?? this.lineChartStepData, + properties: properties ?? this.properties, ); } @@ -470,6 +479,7 @@ class LineChartBarData with EquatableMixin { shadow, isStepLineChart, lineChartStepData, + properties, ]; } diff --git a/pubspec.yaml b/pubspec.yaml index e668c0773..4598cc86c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: fl_chart description: A highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart. -version: 0.68.0 +version: 0.69.0 homepage: https://flchart.dev/ repository: https://github.com/imaNNeo/fl_chart issue_tracker: https://github.com/imaNNeo/fl_chart/issues