【问题标题】:How to show point.y in TrackballBehavior(builder)?How to show point.y in TrackballBehavior(builder)?
【发布时间】:2022-12-01 23:00:16
【问题描述】:

I have SfCartesianChart and I am showing TrackballBehavior. I want to customize it, but I don't have an idea how to get Y value in builder

this is my trackballBehavior:

_trackballBehavior = TrackballBehavior(
      enable: true,
      shouldAlwaysShow: true,
      lineColor: Color(0xFF454545),
      activationMode: ActivationMode.singleTap,
      tooltipDisplayMode: TrackballDisplayMode.nearestPoint,
      builder: (context, TrackballDetails trackballDetails) {
        log(trackballDetails.point.toString()); // Instance of 'CartesianChartPoint<dynamic>'
        return Container(
          child: Text(
            "point.y",
            style: TextStyle(
              color: Colors.white
            )
        ));
      },

I tried trackballDetails.series and others but it returns me an instance or null or index

But I want to get a value of Y axis

If I use point.y in format then everything works but I can't customize it. How to fix trackballDetails.series or trackballDetails.point

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    So I find the solution:

    trackballDetails.point?.yValue != null ?trackballDetails.point!.yValue.toString() : trackballDetails.point!.high.toString(),
    

    //This checking null helps to solve the problem if you meet null in your value

    【讨论】:

      猜你喜欢
      • 2022-11-20
      • 1970-01-01
      • 2022-12-28
      • 2022-12-02
      • 2022-12-26
      • 2022-12-26
      • 2022-11-20
      • 2022-12-02
      • 2022-11-09
      相关资源
      最近更新 更多