Skip to content

Trackball and crosshair is not visible in Sfcartision from latest version 27.x.52 #2125

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

Open
upendra-bajpai opened this issue Oct 12, 2024 · 11 comments
Labels
charts Charts component open Open

Comments

@upendra-bajpai
Copy link

upendra-bajpai commented Oct 12, 2024

Bug description

I had implemented trackball with version 24.x.x but recently I updated to latest version.
Now I can't see trackball or crosshair although I can see label on x axis hilighted while traversing.
Restoring to previous version I can see them again.
Is there anything which I need to update or it's a bug?

Ps.Thank you for this library

Steps to reproduce

Just update to 27.x.x for charts and impliment trackball in Sfcartision charts. Both Android and iOS can't show the trackball.

    _trackballBehavior = TrackballBehavior(
      enable: true,
      activationMode: ActivationMode.singleTap,
      lineType: TrackballLineType.vertical,
      lineColor: Colors.blue,
      markerSettings: TrackballMarkerSettings(
          color: Colors.white,
          borderColor: Colors.blue,
          borderWidth: 9,
          width: 5,
          height: 5,
          shape: DataMarkerType.circle,
          markerVisibility: TrackballVisibilityMode.visible),
      lineDashArray: [5, 5],
      builder: (BuildContext context, TrackballDetails trackballDetails) {
        final ChartData point = widget.data[trackballDetails.pointIndex!];
        // widget.onDataPointSelected.call(point);
        return Container(
          decoration: BoxDecoration(
            color: Colors.black.withOpacity(0.4),
            borderRadius: BorderRadius.circular(4),
          ),
          child: SectionSum(
              sum: (point.y! * 100).toInt(),
              textStyle: TextStyle(
                color: Colors.white,
                backgroundColor: Colors.black.withOpacity(0.4),
                fontFamily: GoogleFonts.poppins().fontFamily,
                fontSize: 12,
                fontWeight: FontWeight.w700,
              )),
        );
      },
    );

Screenshots or Video

Screenshots / Video demonstration

I can update if needed

Stack Traces

Stack Traces
No crashes available 

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

Doctor output
@VijayakumarMariappan VijayakumarMariappan added charts Charts component open Open labels Oct 14, 2024
@baconbyte
Copy link

I am seeing similar after just updating, I have a customised trackball, when I assign a custom builder the line no longer appears in 27.x.x but it did for 24.x.x

@baconbyte
Copy link

I had a quick look at the code in the debugger and it looks when I assign a custom builder the chartPointInfo collection is cleared before the line is drawn, it is not cleared when there isn't a custom builder assigned. I'm not sure where/when this is collection is cleared

void _drawTrackballLine(PaintingContext context, Offset offset, SfChartThemeData chartThemeData, ThemeData themeData) { if (chartPointInfo.isNotEmpty && lineType != TrackballLineType.none) { final Paint paint = Paint()

@upendra-bajpai
Copy link
Author

Without custom builder is it working? I am trying but no luck. I am expecting someone from syncfustion team to take a look at it.

@baconbyte
Copy link

Yes, it works when there isn't a custom builder for me, but I need the builder.

@stephengibson83
Copy link

Commenting to bump this issue a bit. I am also encountering the same issue and hoping for a fix ASAP.

@Baranibharathip
Copy link

Hi @upendra-bajpai,

We have checked the mentioned issue 'trackball and crosshair is not visible in Charts' and tried to replicate it in SfCartesianChart with version 27.1.52 by,

  1. Ensured on Windows, Android, and web platforms.
  2. Ensured with trackball and crosshair behavior.
  3. Ensured with trackball builder.

However, we were unable to reproduce it on our end. Please check the attached sample, and if you are still experiencing the issue, we request that you replicate it in the attached sample and provide us with more details regarding the specific scenario in which you are encountering this issue. This will help us to assist you more effectively.

Sample : GH_2125.zip

Regards,
Baranibharathi P.

@LavanyaGowtham2021 LavanyaGowtham2021 added waiting for customer response Cannot make further progress until the customer responds. and removed open Open labels Oct 28, 2024
@baconbyte
Copy link

I can get the example to work, in my code I have a setState in the builder - this seems to be causing the issue, when I comment it out the trackball is working but the setState notification is obviously no longer working

@baconbyte
Copy link

I've updated my code to use a ValueNotifier which it probably should have been using anyway instead of setState and it's working for me now.

Note though setState was working before I upgraded.

@LavanyaGowtham2021 LavanyaGowtham2021 added open Open and removed waiting for customer response Cannot make further progress until the customer responds. labels Nov 6, 2024
@Baranibharathip
Copy link

Hi Baconbyte,

We have reviewed your query and would like to inform you that TrackballBehavior.builder is implemented for customizing tooltip content based on the use case. Calling setState inside the builder can lead to issues, as it only executes when the trackball is displayed. Since trackballs are dynamically created and destroyed, this can disrupt the widget lifecycle, resulting in tooltips that may not render or update as expected. Therefore, we have restricted the usage of setState from the latest version and this is the default behavior of the trackball in SfCartesianChart.

Regards,
Baranibharathi P.

@upendra-bajpai
Copy link
Author

Thank you, I removed figured something like this and setstate , it's working fine now.
Many thanks to the team for this library

@LavanyaGowtham2021 LavanyaGowtham2021 added waiting for customer response Cannot make further progress until the customer responds. solved Solved the query using existing solutions and removed open Open waiting for customer response Cannot make further progress until the customer responds. labels Dec 14, 2024
@chotixity
Copy link

_trackballBehavior = TrackballBehavior(
enable: true,
activationMode: ActivationMode.singleTap,
lineType: TrackballLineType.vertical,
lineColor: Colors.black, // Use your app's color or any visible color
lineWidth: 2, // Make line width more visible
tooltipDisplayMode: TrackballDisplayMode.floatAllPoints,
shouldAlwaysShow: true,
builder: (BuildContext context, TrackballDetails trackballDetails) {

    return Container(
      decoration: BoxDecoration(
        color: Colors.black.withValues(alpha: .4),
        borderRadius: BorderRadius.circular(5),
      ),
      padding: const EdgeInsets.all(10),
      child: Text(
        '${trackballDetails.point?.x}\n${trackballDetails.point?.y}%',
        style: const TextStyle(color: Colors.white),
      ),
    );
  },
);

I'm on v 28.2.5 and the trackball line is not showing. The crosshairs work perfectly though

@VijayakumarMariappan VijayakumarMariappan added open Open and removed solved Solved the query using existing solutions labels May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
charts Charts component open Open
Projects
None yet
Development

No branches or pull requests

7 participants