Fl_chart: Is there a way to see the first and last spot values without the need for a touch interactivity?

Created on 7 May 2020  路  4Comments  路  Source: imaNNeoFighT/fl_chart

I try to achieve the following:
Screenshot 2020-05-07 at 7 45 16 PM

As you can see, the first and last spot need to show the values without the need for a touch interactivity.

Currently, all I have is this:
Screenshot_20200507-200657

Is this already possible?

Line Chart question

Most helpful comment

It is okay

All 4 comments

Yes, it is possible,
you should show tooltip items by default, and set the background color transparent,
check this sample:

Sample 5

Yes, it is possible,
you should show tooltip items by default, and set the background color transparent,
check this sample:

Sample 5

@imaNNeoFighT
Honestly great work, but I noticed that when I enable the LineTouchData, the tooltip text dissapears. And when I disable it, I can't focus on the spots and see the values from it. This is what I have:

 enabled: false,
        getTouchedSpotIndicator:
            (LineChartBarData barData, List<int> spotIndexes) {
          return spotIndexes.map((index) {
            return TouchedSpotIndicatorData(
              FlLine(color: Colors.transparent, strokeWidth: 0),
              FlDotData(
                show: true,
              ),
            );
          }).toList();
        },

Is there something that I overlooked? Please let me know how I can solve this.

@imaNNeoFighT

I have managed to fix the issue with the touchCallback:

bool hideSpotText = false;
...
touchCallback: (LineTouchResponse touchResponse) {
          if (touchResponse.touchInput is FlPanStart ||
              touchResponse.touchInput is FlPanMoveUpdate ||
              touchResponse.touchInput is FlLongPressStart ||
              touchResponse.touchInput is FlLongPressMoveUpdate) {
            hideSpotText = true;
          } else {
            hideSpotText = false;
          }

          setState(() {});
        },
        enabled: hideSpotText,

However, is it ok if I use setState every time when a touch interaction occurs? I mean, will it affect the performance of phones in a bad way or is it ok to leave it like this? Please let me know.

It is okay

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MobileMon picture MobileMon  路  4Comments

Mohdx picture Mohdx  路  4Comments

wukongssl picture wukongssl  路  3Comments

joaorpalma picture joaorpalma  路  3Comments

jamesblasco picture jamesblasco  路  4Comments