I have been trying to create an horizontal TouchedSpotIndicator on my FlChart in flutter and I want it to stay permanently(not just to be visible when chart is touched)
Similar to the effect of the current price in trading apps like the in the MT4 app as seen below;
Below is my code but this only shows the default vertical line and it also disappears after touching the chart;
getTouchedSpotIndicator: (LineChartBarData barData, List<int> spotIndexes) {
return spotIndexes.map((spotIndex) {
final FlSpot spot = barData.spots[spotIndex];
if (spot.x == 0 || spot.x == 6) {
return null;
}
return TouchedSpotIndicatorData(
FlLine(color: Color(0xFFFFAB56), strokeWidth: 2.5, dashArray: [7]),
FlDotData(
show: true,
getDotPainter: (aa, bb, cc, dd) {
return FlDotCirclePainter(
color: Color(0xFFFFAB56),
radius: 7.5,
strokeWidth: 3.5,
strokeColor: Colors.white.withOpacity(0.5)
);
}
),
);
}).toList();
},
I have searched the FLChart API and couldn’t get any solution to make the indicator;
(1) permanently visible
(2) to make the indicator an horizontal one.
Please suggest any help as it would be appreciated. Thank you for your time
2
Answers
adding this following to
LineChartData
as a parameter ofLineChart
itself fixed the problem;Have you tried
https://app.flchart.dev/#/line
?Check the indicator properties on the horizontal middle line