fl_chart icon indicating copy to clipboard operation
fl_chart copied to clipboard

Since v0.40.0, touch event `MoveUpdate` cannot be called continuously after tap

Open htsuruo opened this issue 3 years ago • 6 comments

Hi, thanks to your awesome chart package.

Since v0.40.0, touch event MoveUpdate cannot be called continuously after tap(= required longPress). Difference in behavior is here.

v0.36.4 v0.40.0~
need_not_to_longpress required_longpress

Is the behavior expected?

I think, it's change is not good for users. Some users cannot aware that the chart enable for them to trace line and show tooltip because of need to wait for certain amount of time. Therefore, I would like to revert to v0.36.0 behavior.

To Reproduce

Just use line_chart_sample_1.dart https://github.com/imaNNeoFighT/fl_chart/blob/master/example/lib/line_chart/samples/line_chart_sample1.dart

Thanks.

htsuruo avatar Aug 23 '22 08:08 htsuruo

I suggest we have a flag for this, to set the long press to be true or false. user are not mostly aware that they need to longPress

Divinoart avatar Aug 23 '22 22:08 Divinoart

Found a fix for it, Not the best practice but you'll need to edit the package.

Goto lib/src/chart/base/base_chart/render_base_chart.dart

then update line 72 to this:

Screenshot 2022-08-23 at 9 44 21 PM

_longPressGestureRecognizer = LongPressGestureRecognizer(duration: const Duration(milliseconds: 0));

The trick is, it sets the LongPressGestureRecognizer.duration to be 0 milliseconds instead of 500 from kLongPressTimeout.

Suggestion to the dev team is to make this a feature flag so people can enable or disable LongPress feature

Divinoart avatar Aug 24 '22 03:08 Divinoart

@Divinoart

Hi, thanks for your response.

I suggest we have a flag for this, to set the long press to be true or false.

Your approach is better, so I agree with you.

htsuruo avatar Aug 24 '22 05:08 htsuruo

@Divinoart

_longPressGestureRecognizer = LongPressGestureRecognizer(duration: const Duration(milliseconds: 0)); The trick is, it sets the LongPressGestureRecognizer.duration to be 0 milliseconds instead of 500 from kLongPressTimeout.

Good Job👍 Your solution works expected behavior.

_longPressGestureRecognizer = LongPressGestureRecognizer(duration: Duration.zero);
Duration.zero(v0.55.1)
duration zero

htsuruo avatar Aug 24 '22 05:08 htsuruo

Great!

Divinoart avatar Aug 24 '22 05:08 Divinoart

Added longPressDuration optional property. https://github.com/HTsuruo/fl_chart/tree/feature/tsuruo/enable-customize-longpress-duration

I hesitated that whether optional property should take a boolean true/false or duration, but finally decided that Duration property because it's better for flexibility.

LineTouchData(
  handleBuiltInTouches: true,
  touchTooltipData: LineTouchTooltipData(
    tooltipBgColor: Colors.blueGrey.withOpacity(0.8),
  ),
  
  // Here is additional property.
  // You can customize how long it takes for tooltips to appear.
  longPressDuration: Duration.zero,
);

htsuruo avatar Aug 24 '22 06:08 htsuruo

Resolved by #1128

htsuruo avatar Jan 19 '23 00:01 htsuruo

Resolved by #1128

Thank you for contributing. It will be available in the next version soon.

imaNNeo avatar Jan 19 '23 07:01 imaNNeo

0.60.0 is just released. Check it out!

imaNNeo avatar Jan 26 '23 21:01 imaNNeo