Basically I'm trying to put ticks on top of ranges on top of axis (all vertically aligned).
I have managed to achieved the same. However, the ticks (major and minor alike) are totally hidden behind the ranges.
This totally spoils the desired design. Since what I want is similar looking white bars (ticks) on top of ranges of multiple colours. So the output would look like coloured stripes.
Kindly let me know what my options are. Or is it not possible?
List<LinearShapePointer> _linearShapePointers;
final double _min = 0.0;
final double _max = 20.0;
@override
void initState() {
_linearShapePointers = [];
for (double i = _min; i <= _max;) {
_linearShapePointers.add(LinearShapePointer(
value: i,
color: Colors.blue,
width: 5,
height: 5,
enableAnimation: false,
shapeType: LinearShapePointerType.rectangle,
position: LinearElementPosition.cross,
));
i += 2;
}
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SfLinearGauge(
minimum: _min,
maximum: _max,
interval: 4.0,
showTicks: false,
markerPointers: _linearShapePointers,
ranges: <LinearGaugeRange>[
LinearGaugeRange(
startValue: _min,
endValue: _max,
position: LinearElementPosition.cross,
),
],
));
} |
Hi Praveen,
Thank you for the quick reply.
About the code, I was just able to find out the same on my own. Your code further clarifies the same.
Although I'm able to make a decent implementation of what was required, it's not exactly correct. So I'll ask how you would approach the following design:
A Linear Gauge consisting of only stripes (colour based on the range where its value belongs), and just one of these stripes to be longer and centred (to mark the current value)
To repeat where I currently am, I'm using multiple ranges for the different colours. And I'm placing white Widget Markers over the ranges at equal intervals so that the coloured ranges appear as striped. This much is done.
But I also want to make one of these "coloured stripes" longer, and vertically-centred to mark the current value.
Now, it doesn't seem possible to me, since it is the white Widget Markers that we are placing on top of the ranges to give an illusion of separate coloured stripes. And I want to modify a coloured stripe that is actually just one range. So this approach seems like a dead end if I want a perfect design.
But perhaps you could shed some light. Thanks.
But I also want to make one of these "colored stripes" longer, and vertically centered to mark the current value. |
I'm extremely sorry for replying this late. I had completely forgotten about it. Your image above was accurate, and I did not try to further optimize my logic.
But you guys have been amazing. I appreciate your commitment very much. You may close this forum as per your wish.