

|
SfCartesianChart(
// Modifed the get labels method in the tooltip builder.
tooltipBehavior: TooltipBehavior(
color: Colors.black,
enable: true,
format: 'point.y',
header: '',
canShowMarker: false,
builder: (data, point, series, pointIndex, seriesIndex) {
// Stored the point value in the CartesianChartPoint variable
final CartesianChartPoint chartDate = point;
final String seriesName = series.name;
// Stored the point’s y- value
final double pointValue = chartDate.y;
String getLabel() {
if (isMainSeries) {
// In order to check whether the point is null or not, you can check the isEmpty property
// of the CartesianChartPoint instead of checking the y-value of that point.
if (chartDate.isEmpty == true) {
return "Blank";
} else if (pointValue == 0) {
return "Missed";
} else {
return "${pointValue.toInt()} points";
}
} else {
double _pointValue = pointValue ?? 0;
return "$seriesName: ${_pointValue.toInt()}";
}
}
return Container(
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(5),
),
child: Padding(
padding: const EdgeInsets.all(5.5),
child: Text(
getLabel(),
style: TextStyle(color: Colors.white),
),
),
);
},
)
// Your configuration
) |
Hello!
I am facing the same issue, but in order to build the tooltip correctly i need to use `data` from the tooltipBuilder.. is there any ways to have to right data in the builder even though i have an initial min and max value on my cartesian chart ?
Thank you!
Hi Celia,
We have checked the tooltip builder callback and ensured the data values are getting properly without any issues when having an initial minimum and maximum. So, we kindly request you provide more information on your requirement in detail along with screenshots or screen recordings so that it will help us assist you in a better way.
Regards,
Yuvaraj.