diff --git a/CHANGELOG.md b/CHANGELOG.md index 996f1986f..0f437425c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ * [IMPROVEMENT] Added [Radar Chart Documentations](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/radar_chart.md) * [IMPROVEMENT] Added `textAlign` property in the [BarTooltipItem](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/bar_chart.md#bartooltipitem), [LineTooltipItem](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#linetooltipitem), and [ScatterTooltipItem](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/scatter_chart.md#scattertooltipitem), default is `TextAlign.center`. * [IMPROVEMENT] Added `direction` property in the [BarTouchTooltipData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/bar_chart.md#bartouchtooltipdata), and [LineTouchTooltipData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#linetouchtooltipdata) to specify the position of the tooltip (can be `auto`, `top`, `bottom`), default is `auto`. +* [IMPROVEMENT] Updated touch flow, we now use [hitTest](https://api.flutter.dev/flutter/rendering/RenderProxyBoxWithHitTestBehavior/hitTest.html) for handling touch and interactions. +* [IMPROVEMENT] Added 'clickHappened' property in all of our TouchResponses (such as [LineTouchResponse](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#LineTouchResponse), [BarTouchResponse](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/bar_chart.md#bartouchresponse), ...) +* [BREAKING] Some properties in [ScatterTouchResponse](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/scatter_chart.md#scattertouchresponse), and [PieTouchResponse](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/pie_chart.md#pietouchresponse) moved to a wrapper class, you need to access them through that wrapper class. * [BREAKING] Renamed `tooltipBottomMargin` to `tooltipMargin` property in the [BarTouchTooltipData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/bar_chart.md#bartouchtooltipdata), and [LineTouchTooltipData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/line_chart.md#linetouchtooltipdata) * [Bugfix] Fixed `double.infinity` in [PieChartData](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/pie_chart.md#piechartdata) .centerSpaceRadius, #584. diff --git a/lib/src/chart/bar_chart/bar_chart_data.dart b/lib/src/chart/bar_chart/bar_chart_data.dart index 4e7b21811..a80530c68 100644 --- a/lib/src/chart/bar_chart/bar_chart_data.dart +++ b/lib/src/chart/bar_chart/bar_chart_data.dart @@ -525,8 +525,8 @@ class BackgroundBarChartRodData with EquatableMixin { /// Holds data to handle touch events, and touch responses in the [BarChart]. /// /// There is a touch flow, explained [here](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/handle_touches.md) -/// in a simple way, each chart captures the touch events, and passes a concrete -/// instance of [FlTouchInput] to the painter, and gets a generated [BarTouchResponse]. +/// in a simple way, each chart's renderer captures the touch events, and passes the pointerEvent +/// to the painter, and gets touched spot, and wraps it into a concrete [BarTouchResponse]. class BarTouchData extends FlTouchData with EquatableMixin { /// Configs of how touch tooltip popup. final BarTouchTooltipData touchTooltipData; diff --git a/lib/src/chart/base/base_chart/base_chart_data.dart b/lib/src/chart/base/base_chart/base_chart_data.dart index 16ca83f0b..c9a324e72 100644 --- a/lib/src/chart/base/base_chart/base_chart_data.dart +++ b/lib/src/chart/base/base_chart/base_chart_data.dart @@ -70,8 +70,8 @@ class FlBorderData with EquatableMixin { /// Holds data to handle touch events, and touch responses in abstract way. /// /// There is a touch flow, explained [here](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/handle_touches.md) -/// in a simple way, each chart captures the touch events, and passes a concrete -/// instance of [FlTouchInput] to the painter, and gets a generated [BaseTouchResponse]. +/// in a simple way, each chart's renderer captures the touch events, and passes the pointerEvent +/// to the painter, and gets touched spot, and wraps it into a concrete [BaseTouchResponse]. class FlTouchData with EquatableMixin { /// You can disable or enable the touch system using [enabled] flag, final bool enabled; diff --git a/lib/src/chart/line_chart/line_chart_data.dart b/lib/src/chart/line_chart/line_chart_data.dart index 6f1fea2ab..b569c0d57 100644 --- a/lib/src/chart/line_chart/line_chart_data.dart +++ b/lib/src/chart/line_chart/line_chart_data.dart @@ -1287,8 +1287,8 @@ class ExtraLinesData with EquatableMixin { /// Holds data to handle touch events, and touch responses in the [LineChart]. /// /// There is a touch flow, explained [here](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/handle_touches.md) -/// in a simple way, each chart captures the touch events, and passes a concrete -/// instance of [FlTouchInput] to the painter, and gets a generated [LineTouchResponse]. +/// in a simple way, each chart's renderer captures the touch events, and passes the pointerEvent +/// to the painter, and gets touched spot, and wraps it into a concrete [LineTouchResponse]. class LineTouchData extends FlTouchData with EquatableMixin { /// Configs of how touch tooltip popup. final LineTouchTooltipData touchTooltipData; diff --git a/lib/src/chart/pie_chart/pie_chart_data.dart b/lib/src/chart/pie_chart/pie_chart_data.dart index 8690d308d..b018a5d14 100644 --- a/lib/src/chart/pie_chart/pie_chart_data.dart +++ b/lib/src/chart/pie_chart/pie_chart_data.dart @@ -252,8 +252,8 @@ typedef PieTouchCallback = void Function(PieTouchResponse); /// Holds data to handle touch events, and touch responses in the [PieChart]. /// /// There is a touch flow, explained [here](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/handle_touches.md) -/// in a simple way, each chart captures the touch events, and passes a concrete -/// instance of [FlTouchInput] to the painter, and gets a generated [PieTouchResponse]. +/// in a simple way, each chart's renderer captures the touch events, and passes the pointerEvent +/// to the painter, and gets touched spot, and wraps it into a concrete [PieTouchResponse]. class PieTouchData extends FlTouchData with EquatableMixin { /// you can implement it to receive touches callback final Function(PieTouchResponse)? touchCallback; diff --git a/lib/src/chart/radar_chart/radar_chart_data.dart b/lib/src/chart/radar_chart/radar_chart_data.dart index 95ec29385..15505ccf9 100644 --- a/lib/src/chart/radar_chart/radar_chart_data.dart +++ b/lib/src/chart/radar_chart/radar_chart_data.dart @@ -329,8 +329,8 @@ class RadarEntry with EquatableMixin { /// Holds data to handle touch events, and touch responses in the [RadarChart]. /// /// There is a touch flow, explained [here](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/handle_touches.md) -/// in a simple way, each chart captures the touch events, and passes a concrete -/// instance of [FlTouchInput] to the painter, and gets a generated [RadarTouchData]. +/// in a simple way, each chart's renderer captures the touch events, and passes the pointerEvent +/// to the painter, and gets touched spot, and wraps it into a concrete [RadarTouchResponse]. class RadarTouchData extends FlTouchData with EquatableMixin { /// you can implement it to receive touches callback final Function(RadarTouchResponse)? touchCallback; diff --git a/lib/src/chart/scatter_chart/scatter_chart_data.dart b/lib/src/chart/scatter_chart/scatter_chart_data.dart index c64a21318..dc26ee670 100644 --- a/lib/src/chart/scatter_chart/scatter_chart_data.dart +++ b/lib/src/chart/scatter_chart/scatter_chart_data.dart @@ -216,8 +216,8 @@ class ScatterSpot extends FlSpot with EquatableMixin { /// Holds data to handle touch events, and touch responses in the [ScatterChart]. /// /// There is a touch flow, explained [here](https://github.com/imaNNeoFighT/fl_chart/blob/master/repo_files/documentations/handle_touches.md) -/// in a simple way, each chart captures the touch events, and passes a concrete -/// instance of [FlTouchInput] to the painter, and gets a generated [ScatterTouchResponse]. +/// in a simple way, each chart's renderer captures the touch events, and passes the pointerEvent +/// to the painter, and gets touched spot, and wraps it into a concrete [ScatterTouchResponse]. class ScatterTouchData extends FlTouchData with EquatableMixin { /// show a tooltip on touched spots final ScatterTouchTooltipData touchTooltipData; diff --git a/repo_files/documentations/bar_chart.md b/repo_files/documentations/bar_chart.md index faaedf267..54180a60d 100644 --- a/repo_files/documentations/bar_chart.md +++ b/repo_files/documentations/bar_chart.md @@ -107,8 +107,8 @@ enum values {`start`, `end`, `center`, `spaceEvenly`, `spaceAround`, `spaceBetwe |PropName|Description|default value| |:-------|:----------|:------------| |spot|a [BarTouchedSpot](#BarTouchedSpot) class to hold data about touched spot| null | -|touchInput|a [FlTouchInput](base_chart.md#FlTouchInput) that is the touch behaviour|null| - +|touchInput|a [PointerEvent](https://api.flutter.dev/flutter/gestures/PointerEvent-class.html) that is the touch behaviour|null| +|clickHappened|If we detect a click event, this property is tru|false| ### BarTouchedSpot |PropName|Description|default value| diff --git a/repo_files/documentations/line_chart.md b/repo_files/documentations/line_chart.md index 843ba4a4e..57cd64d39 100644 --- a/repo_files/documentations/line_chart.md +++ b/repo_files/documentations/line_chart.md @@ -208,7 +208,8 @@ LineChart( |PropName|Description|default value| |:-------|:----------|:------------| |lineBarSpots|a list of [LineBarSpot](#LineBarSpot)|null| -|touchInput|a [FlTouchInput](base_chart.md#FlTouchInput) that is the touch behaviour|null| +|touchInput|a [PointerEvent](https://api.flutter.dev/flutter/gestures/PointerEvent-class.html) that is the touch behaviour|null| +|clickHappened|If we detect a click event, this property is true|false| ### ShowingTooltipIndicators |PropName|Description|default value| diff --git a/repo_files/documentations/pie_chart.md b/repo_files/documentations/pie_chart.md index 631df38b6..a21ea036b 100644 --- a/repo_files/documentations/pie_chart.md +++ b/repo_files/documentations/pie_chart.md @@ -48,12 +48,17 @@ PieChart( ### PieTouchResponse |PropName|Description|default value| |:-------|:----------|:------------| -|sectionData|the [PieChartSectionData](#PieChartSectionData) that user touched| null | +|touchedSection|Instance of [PieTouchedSection](#PieTouchedSection) which holds data about the touched section|null| +|touchInput|a [PointerEvent](https://api.flutter.dev/flutter/gestures/PointerEvent-class.html) that is the touch behaviour|null| +|clickHappened|If we detect a click event, this property is tru|false| + +### PieTouchedSection +|PropName|Description|default value| +|:-------|:----------|:------------| +|touchedSection|the [PieChartSectionData](#PieChartSectionData) that user touched| null | |touchedSectionIndex| index of the touched section | null| |touchAngle|the angle of the touch|null| |touchRadius| the radius of the touch|null| -|touchInput|a [FlTouchInput](base_chart.md#FlTouchInput) that is the touch behaviour|null| - ### some samples ---- diff --git a/repo_files/documentations/radar_chart.md b/repo_files/documentations/radar_chart.md index 5ae001f6f..1d9b9c77b 100644 --- a/repo_files/documentations/radar_chart.md +++ b/repo_files/documentations/radar_chart.md @@ -51,6 +51,8 @@ RadarChart( |PropName|Description|default value| |:-------|:----------|:------------| |touchedSpot|the [RadarTouchedSpot](#RadarTouchedSpot) that user touched| null | +|touchInput|a [PointerEvent](https://api.flutter.dev/flutter/gestures/PointerEvent-class.html) that is the touch behaviour|null| +|clickHappened|If we detect a click event, this property is true|false| ### RadarTouchedSpot |PropName|Description|default value| diff --git a/repo_files/documentations/scatter_chart.md b/repo_files/documentations/scatter_chart.md index bb82653f6..a99af52d1 100644 --- a/repo_files/documentations/scatter_chart.md +++ b/repo_files/documentations/scatter_chart.md @@ -63,10 +63,15 @@ ScatterChart( ###### you can listen to touch behaviors callback and retrieve this object when any touch action happened. |PropName|Description|default value| |:-------|:----------|:------------| -|touchedSpot|touched [ScatterSpot](#ScatterSpot)|null| -|touchedSpotIndex|index of touched [ScatterSpot](#ScatterSpot)|null| -|touchInput|a [FlTouchInput](base_chart.md#FlTouchInput) that is the touch behaviour|null| +|touchedSpot|Instance of [ScatterTouchedSpot](#ScatterTouchedSpot) which holds data about the touched section|null| +|touchInput|a [PointerEvent](https://api.flutter.dev/flutter/gestures/PointerEvent-class.html) that is the touch behaviour|null| +|clickHappened|If we detect a click event, this property is true|false| +### ScatterTouchedSpot +|PropName|Description|default value| +|:-------|:----------|:------------| +|spot|touched [ScatterSpot](#ScatterSpot)|null| +|spotIndex|index of touched [ScatterSpot](#ScatterSpot)|null| ### some samples ---- diff --git a/test/chart/data_pool.dart b/test/chart/data_pool.dart index 3ec789f59..1af1d4ec7 100644 --- a/test/chart/data_pool.dart +++ b/test/chart/data_pool.dart @@ -369,14 +369,8 @@ final FlGridData flGridData5 = FlGridData( getDrawingVerticalLine: null, ); -final BaseTouchResponse baseTouchResponse1 = BaseTouchResponse( - new PointerDownEvent(), - false -); -final BaseTouchResponse baseTouchResponse2 = BaseTouchResponse( - new PointerUpEvent(), - true -); +final BaseTouchResponse baseTouchResponse1 = BaseTouchResponse(new PointerDownEvent(), false); +final BaseTouchResponse baseTouchResponse2 = BaseTouchResponse(new PointerUpEvent(), true); final FlTouchData touchData1 = FlTouchData( false,