Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen to normal tap on Tooltip instead of longpress #37

Closed
sukhcha-in opened this issue Jul 8, 2019 · 26 comments
Closed

Listen to normal tap on Tooltip instead of longpress #37

sukhcha-in opened this issue Jul 8, 2019 · 26 comments
Labels
enhancement New feature or request

Comments

@sukhcha-in
Copy link

First of all, thank you for this amazing library <3

Please provide onTap option with some sort of MoveUpdate to show Tooltip on chart as an alternative to onLongPress

Looking forward for this library

@imaNNeo imaNNeo added the enhancement New feature or request label Jul 8, 2019
@imsurajsharma
Copy link

Yes, I also want the same thing. Please provide that functionality.

@odonc
Copy link

odonc commented Jul 15, 2019

Would be great, I don't know if users will realise they can long press to show tip. Normal press would be better.

@Mazas17
Copy link

Mazas17 commented Jul 24, 2019

Also please keep in mind that chart should maintain selected state on rebuild. For example, if some data point is selected and then rebuild occurs, that selection should be preserved.

@imaNNeo
Copy link
Owner

imaNNeo commented Jul 24, 2019

I think it should handle out of the chart,
I mean you can tell to the chart, which tooltip should be shown now,
then you can keep the state of selected tooltip on your side,
and it is more customizable.
@Mazas17

@Mazas17
Copy link

Mazas17 commented Jul 25, 2019

Also sounds good

@MostHated
Copy link

To take this one further, I am wanting to use this on desktop. Is there a way to make it so that if a mouse is hovering over it, it shows all the time and follows the mouse as if you are holding down a press?

@imaNNeo
Copy link
Owner

imaNNeo commented Jul 25, 2019

Yes, for sure we will add the Desktop compatibility,
I just need time :),
Also, all contributions are welcome,
give it a try!
@MostHated

@imaNNeo
Copy link
Owner

imaNNeo commented Jul 26, 2019

Hi,
Unfortunately, Github started banning Iranian users while ago,
If they didn't stop their action, I can't continue on this repo,
read more it here,
If you want to prevent this unfair action, give a start on this repository and say your support by creating an issue, and spread it.
Best regards,
Iman Khoshabi

@dipendra-sharma
Copy link

dipendra-sharma commented Jul 31, 2019

I've done this enhancement. Replace your fl_chart.dart with attached file (Remove .txt).
fl_chart.dart.txt

@odonc
Copy link

odonc commented Jul 31, 2019 via email

@sukhcha-in
Copy link
Author

@dipendra-sharma Thank you, works as expected ;)

@MostHated
Copy link

MostHated commented Aug 1, 2019

Yes, for sure we will add the Desktop compatibility,
I just need time :),
Also, all contributions are welcome,
give it a try!
@MostHated

I am having a go at this to see what I can come up with.

I tried adding/changing this below. It works, but the position available for Listeners vs Gesture is only d.position and d.localPosition, so it kind of acts weird and some of the points jump to another spot on the graph with 3 lines when you get close to them slowly, lol.

I want to try a few things first to see if there is a way to fix the position before I do a PR.

class FlChart extends StatefulWidget {
  final BaseChart chart;
  var enableTap;
  var enablePointer;

  FlChart({
    Key key,
    @required this.chart,
    this.enableTap = true,
    this.enablePointer = true,
  }) : super(key: key) {
    if (chart == null) {
      throw Exception('chart should not be null');
    }
  }
  @override
  Widget build(BuildContext context) {
    return widget.enablePointer ? _withPointerInput() : widget.enableTap ? _widgetWithTap() : _widgetWithLongPress();
  }
  Widget _withPointerInput() {
    return Listener(
      onPointerEnter: (d) {
        _touchInputNotifier.value = FlLongPressStart(
          _globalToLocal(context, d.localPosition),
        );
      },
      onPointerHover: (d) {
        _touchInputNotifier.value = FlLongPressMoveUpdate(
          _globalToLocal(context, d.localPosition),
        );
      },
      onPointerExit: (d) {
        _touchInputNotifier.value = FlLongPressEnd(
          _globalToLocal(context, d.localPosition),
        );
      },
      child: CustomPaint(
        painter: widget.chart.painter(
          touchInputNotifier: _touchInputNotifier,
          touchResponseSink: widget.chart.getData().touchData.touchResponseSink,
        ),
      ),
    );
  }

@imaNNeo
Copy link
Owner

imaNNeo commented Aug 2, 2019

No, I will not shut down this repo, I just need some free times to improve it
@odonc

@dipendra-sharma
Copy link

Hi, @imaNNeoFighT Please add me in contributors. I've already done it, will create a PR. Both the features will be there Long press & Tap.

@imaNNeo
Copy link
Owner

imaNNeo commented Aug 2, 2019

You can make a PR already,
clone the project,
make a new branch,
push your changes to each branch separately (or maybe both of them in one branch),
then make a PR from your Repo branch to This Repo master branch.
@dipendra-sharma

@dipendra-sharma
Copy link

Yes, for sure we will add the Desktop compatibility,
I just need time :),
Also, all contributions are welcome,
give it a try!
@MostHated

I am having a go at this to see what I can come up with.

I tried adding/changing this below. It works, but the position available for Listeners vs Gesture is only d.position and d.localPosition, so it kind of acts weird and some of the points jump to another spot on the graph with 3 lines when you get close to them slowly, lol.

I want to try a few things first to see if there is a way to fix the position before I do a PR.

class FlChart extends StatefulWidget {
  final BaseChart chart;
  var enableTap;
  var enablePointer;

  FlChart({
    Key key,
    @required this.chart,
    this.enableTap = true,
    this.enablePointer = true,
  }) : super(key: key) {
    if (chart == null) {
      throw Exception('chart should not be null');
    }
  }
  @override
  Widget build(BuildContext context) {
    return widget.enablePointer ? _withPointerInput() : widget.enableTap ? _widgetWithTap() : _widgetWithLongPress();
  }
  Widget _withPointerInput() {
    return Listener(
      onPointerEnter: (d) {
        _touchInputNotifier.value = FlLongPressStart(
          _globalToLocal(context, d.localPosition),
        );
      },
      onPointerHover: (d) {
        _touchInputNotifier.value = FlLongPressMoveUpdate(
          _globalToLocal(context, d.localPosition),
        );
      },
      onPointerExit: (d) {
        _touchInputNotifier.value = FlLongPressEnd(
          _globalToLocal(context, d.localPosition),
        );
      },
      child: CustomPaint(
        painter: widget.chart.painter(
          touchInputNotifier: _touchInputNotifier,
          touchResponseSink: widget.chart.getData().touchData.touchResponseSink,
        ),
      ),
    );
  }

@MostHated Have you tested it? it is not working on iPhone 7.

@dipendra-sharma
Copy link

@imaNNeoFighT

Remote: Permission to imaNNeoFighT/fl_chart.git denied to dipendra-sharma. unable to access 'https://github.com/imaNNeoFighT/fl_chart.git/': The requested URL returned error: 403

@imaNNeo
Copy link
Owner

imaNNeo commented Aug 2, 2019

Sorry you have to firstly fork it in your profile,
Then clone it and...

@MostHated
Copy link

MostHated commented Aug 2, 2019

@MostHated Have you tested it? it is not working on iPhone 7.

I would assume that is because iPhone does not have a pointer. It uses touch/gesture. Pointer is for desktop platforms. I don't think anything with "pointer" in the event callback will work with Android or iPhone unless you attach a mouse to it.

I tested and it works for me on both go-flutter and flutter-desktop-embedded.

https://i.imgur.com/ECBG3G9.gifv

@dipendra-sharma
Copy link

@MostHated Pointer was not working on the iPhone device.

@MostHated
Copy link

MostHated commented Aug 5, 2019

Yes, did you read my explanation above? Pointer only works I believe if you are running on a platform which is using the debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; override, which would typically only be desktop platforms. If you are running Android or iPhone, you would not be using pointer.

@imaNNeo
Copy link
Owner

imaNNeo commented Aug 15, 2019

Hi, thanks all for your patience,
It is added in 0.1.6, If you had any feedback, feel free to let me know.
and also there are a lot of features to implement and pull requests are welcome.
Best regards!

@jlubeck
Copy link
Contributor

jlubeck commented Mar 30, 2020

@imaNNeoFighT was the MouseOver on desktop that was mentioned by @MostHated ever implemented?
I can't seem to find it in the code or documentation...

thanks!

@imaNNeo
Copy link
Owner

imaNNeo commented Mar 31, 2020

Hi @jlubeck
At the moment our main focus is on the Quality and Stability in the android and iOS,
even though, we will focus on web and desktop, when they are stabled in the Flutter.
Thanks for reaching me out.

@imaNNeo
Copy link
Owner

imaNNeo commented Mar 31, 2020

Also, feel free to make an issue about it,
we can follow it up there.

@jlubeck
Copy link
Contributor

jlubeck commented Mar 31, 2020

Ok, I was asking mainly because @MostHated seemed to had it working... I'll create the new ticket. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants