Skip to content

Commit

Permalink
Add documentation and make small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldomke authored and imaNNeo committed Feb 11, 2022
1 parent 52b0faa commit 445c032
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* **BUGFIX** Allow to show title when axis diff is zero.
* **IMPROVEMENT** Improve iteration over axis values logic (it solves some minor problems on showing titles when min, max values are below than 1.0).
* **BREAKING** `LineTouchResponse` response now contains a list of `TouchLineBarSpot` instead of `LineBarSpot`. They are ordered based on their distance to the touch event and also contain that distance.
* **IMPROVEMENT** Added `distanceCalculator` to `LineTouchData` which is used to calculate the distance between spots and touch events

## 0.41.0
* **BUGFIX** Fix getNearestTouchedSpot. Previously it returned the first occurrence of a spot within the threshold, and not the nearest, #641, #645.
Expand Down
5 changes: 3 additions & 2 deletions lib/src/chart/line_chart/line_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ class LineTouchData extends FlTouchData<LineTouchResponse> with EquatableMixin {
getTouchedSpotIndicator =
getTouchedSpotIndicator ?? defaultTouchedIndicators,
touchSpotThreshold = touchSpotThreshold ?? 10,
distanceCalculator = distanceCalculator ?? xDistance,
distanceCalculator = distanceCalculator ?? _xDistance,
handleBuiltInTouches = handleBuiltInTouches ?? true,
getTouchLineStart = getTouchLineStart ?? defaultGetTouchLineStart,
getTouchLineEnd = getTouchLineEnd ?? defaultGetTouchLineEnd,
Expand Down Expand Up @@ -1472,6 +1472,7 @@ class LineTouchData extends FlTouchData<LineTouchResponse> with EquatableMixin {
getTouchedSpotIndicator:
getTouchedSpotIndicator ?? this.getTouchedSpotIndicator,
touchSpotThreshold: touchSpotThreshold ?? this.touchSpotThreshold,
distanceCalculator: distanceCalculator ?? this.distanceCalculator,
getTouchLineStart: getTouchLineStart ?? this.getTouchLineStart,
getTouchLineEnd: getTouchLineEnd ?? this.getTouchLineEnd,
handleBuiltInTouches: handleBuiltInTouches ?? this.handleBuiltInTouches,
Expand Down Expand Up @@ -1512,7 +1513,7 @@ typedef CalculateTouchDistance = double Function(
Offset touchPoint, Offset spotPixelCoordinates);

/// Default distanceCalculator only considers distance on x axis
double xDistance(Offset touchPoint, Offset spotPixelCoordinates) {
double _xDistance(Offset touchPoint, Offset spotPixelCoordinates) {
return ((touchPoint.dx - spotPixelCoordinates.dx)).abs();
}

Expand Down
12 changes: 11 additions & 1 deletion repo_files/documentations/line_chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ When you change the chart's state, it animates to the new state internally (usin
|touchTooltipData|a [LineTouchTooltipData](#LineTouchTooltipData), that determines how show the tooltip on top of touched spots (appearance of the showing tooltip bubble)|LineTouchTooltipData|
|getTouchedSpotIndicator| a callback that retrieves list of [TouchedSpotIndicatorData](#TouchedSpotIndicatorData) by the given list of [LineBarSpot](#LineBarSpot) for showing the indicators on touched spots|defaultTouchedIndicators|
|touchSpotThreshold|the threshold of the touch accuracy|10|
|distanceCalculator| a function to calculate the distance between a spot and a touch event| _xDistance|
|handleBuiltInTouches| set this true if you want the built in touch handling (show a tooltip bubble and an indicator on touched spots) | true|
|getTouchLineStart| controls where the line starts, default is bottom of the chart| defaultGetTouchLineStart|
|getTouchLineEnd| controls where the line ends, default is the touch point| defaultGetTouchLineEnd|
Expand Down Expand Up @@ -212,10 +213,19 @@ When you change the chart's state, it animates to the new state internally (usin
|spotIndex|index of the target [FlSpot](#FlSpot) inside [LineChartBarData](#LineChartBarData)|null|


### TouchLineBarSpot
|PropName|Description|default value|
|:-------|:----------|:------------|
|bar|the [LineChartBarData](#LineChartBarData) that contains a spot|null|
|barIndex|index of the target [LineChartBarData](#LineChartBarData) inside [LineChartData](#LineChartData)|null|
|spotIndex|index of the target [FlSpot](#FlSpot) inside [LineChartBarData](#LineChartBarData)|null|
|distance|distance to the touch event|null|


### LineTouchResponse
|PropName|Description|default value|
|:-------|:----------|:------------|
|lineBarSpots|a list of [LineBarSpot](#LineBarSpot)|null|
|lineBarSpots|a list of [TouchLineBarSpot](#TouchLineBarSpot)|null|

### ShowingTooltipIndicators
|PropName|Description|default value|
Expand Down

0 comments on commit 445c032

Please sign in to comment.