diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ed5e3fe0..56c482f71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,5 @@ ## newVersion * **FEATURE** (by @julien4215) Add direction property to the [HorizontalLineLabel](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/base_chart.md#horizontallinelabel) and [VerticalLineLabel](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/base_chart.md#verticallinelabel), #1574 - -## 0.67.0 * **FEATURE** (by @apekshamehta) Added new method called getTooltipColor for axis charts (bar,line,scatter) to change backgroud color of tooltip dynamically.[issue](https://github.com/imaNNeo/fl_chart/issues/1279). * **BREAKING** (by @apekshamehta) Removed tooltipBgColor property from Bar, Line and Scatter Charts. diff --git a/example/lib/presentation/samples/bar/bar_chart_sample1.dart b/example/lib/presentation/samples/bar/bar_chart_sample1.dart index 36d9b15c4..30ffa61f2 100644 --- a/example/lib/presentation/samples/bar/bar_chart_sample1.dart +++ b/example/lib/presentation/samples/bar/bar_chart_sample1.dart @@ -162,19 +162,7 @@ class BarChartSample1State extends State { return BarChartData( barTouchData: BarTouchData( touchTooltipData: BarTouchTooltipData( - getTooltipColor: (group) { - Color bgColor = switch (group.x) { - 0 => AppColors.contentColorPurple.withAlpha(100), - 1 => AppColors.contentColorYellow.withAlpha(100), - 2 => AppColors.contentColorBlue.withAlpha(100), - 3 => AppColors.contentColorOrange.withAlpha(100), - 4 => AppColors.contentColorPink.withAlpha(100), - 5 => AppColors.contentColorRed.withAlpha(100), - 6 => AppColors.contentColorPurple.withAlpha(150), - _ => throw Error(), - }; - return bgColor; - }, + getTooltipColor: (_) => Colors.blueGrey, tooltipHorizontalAlignment: FLHorizontalAlignment.right, tooltipMargin: -10, getTooltipItem: (group, groupIndex, rod, rodIndex) { diff --git a/example/lib/presentation/samples/line/line_chart_sample3.dart b/example/lib/presentation/samples/line/line_chart_sample3.dart index e5d4cc83a..1dd048687 100644 --- a/example/lib/presentation/samples/line/line_chart_sample3.dart +++ b/example/lib/presentation/samples/line/line_chart_sample3.dart @@ -206,22 +206,7 @@ class _LineChartSample3State extends State { }).toList(); }, touchTooltipData: LineTouchTooltipData( - getTooltipColor: (touchedSpot) { - Color bgColor = switch (( - touchedSpot.x.toInt(), - touchedSpot.y.toDouble() - )) { - (0, 1.3) => AppColors.contentColorPurple.withAlpha(100), - (1, 1) => AppColors.contentColorYellow.withAlpha(100), - (2, 1.8) => AppColors.contentColorBlue.withAlpha(100), - (3, 1.5) => AppColors.contentColorOrange.withAlpha(100), - (4, 2.2) => AppColors.contentColorPink.withAlpha(100), - (5, 1.8) => AppColors.contentColorRed.withAlpha(100), - (6, 3) => AppColors.contentColorPurple.withAlpha(150), - _ => throw Error(), - }; - return bgColor; - }, + getTooltipColor: (touchedSpot) => widget.tooltipBgColor, getTooltipItems: (List touchedBarSpots) { return touchedBarSpots.map((barSpot) { final flSpot = barSpot; diff --git a/example/lib/presentation/samples/scatter/scatter_chart_sample2.dart b/example/lib/presentation/samples/scatter/scatter_chart_sample2.dart index 27664cfb7..8ce83961e 100644 --- a/example/lib/presentation/samples/scatter/scatter_chart_sample2.dart +++ b/example/lib/presentation/samples/scatter/scatter_chart_sample2.dart @@ -127,21 +127,7 @@ class _ScatterChartSample2State extends State { }, touchTooltipData: ScatterTouchTooltipData( getTooltipColor: (ScatterSpot touchedBarSpot) { - Color bgColor = switch (( - touchedBarSpot.x.toInt(), - touchedBarSpot.y.toInt() - )) { - (4, 4) => AppColors.contentColorPurple.withAlpha(100), - (2, 5) => AppColors.contentColorYellow.withAlpha(100), - (4, 5) => AppColors.contentColorBlue.withAlpha(100), - (8, 6) => AppColors.contentColorOrange.withAlpha(100), - (5, 7) => AppColors.contentColorPink.withAlpha(100), - (7, 2) => AppColors.contentColorRed.withAlpha(100), - (3, 2) => AppColors.contentColorPurple.withAlpha(150), - (2, 8) => AppColors.contentColorYellow.withAlpha(100), - _ => throw Error(), - }; - return bgColor; + return touchedBarSpot.dotPainter.mainColor; }, getTooltipItems: (ScatterSpot touchedBarSpot) { return ScatterTooltipItem( diff --git a/pubspec.yaml b/pubspec.yaml index cab8f6a0d..ec542a720 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.67.0 +version: 0.66.2 homepage: https://flchart.dev/ repository: https://github.com/imaNNeo/fl_chart issue_tracker: https://github.com/imaNNeo/fl_chart/issues