You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Impossible to apply ClipData just for LineChartBarData instead of all elements in LineChartData
Also clipData: const FlClipData(top: true, bottom: false, left: true, right: true), never works correctly, it works like FlClipData.all()
The FlClipData(top: true, bottom: false, left: true, right: true) works like FlClipData.all(). So, It clips the LineChartBarData but also the VerticalLine.
Expected: I'd like Clip just the LineChartBarData.
Simple example code:
voidmain() {
runApp(constMyApp());
}
classMyAppextendsStatelessWidget {
constMyApp({super.key});
@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
debugShowCheckedModeBanner:false,
home:Scaffold(
appBar:AppBar(title:constText('fl_chart VerticalLine with Picture')),
body:Padding(
padding:constEdgeInsets.all(16.0),
child:LineChartWidget(),
),
),
);
}
}
classLineChartWidgetextendsStatefulWidget {
@override_LineChartWidgetStatecreateState() =>_LineChartWidgetState();
}
class_LineChartWidgetStateextendsState<LineChartWidget> {
ui.Picture? _customPicture;
@overridevoidinitState() {
super.initState();
_generateCustomPicture();
}
Future<void> _generateCustomPicture() async {
final picture =createCustomPicture();
setState(() {
_customPicture = picture;
});
}
@overrideWidgetbuild(BuildContext context) {
return _customPicture ==null?constCenter(child:CircularProgressIndicator())
:LineChart(
LineChartData(
minX:2,
lineBarsData: [
LineChartBarData(
spots:const [FlSpot(1, 2), FlSpot(3, 4), FlSpot(5, 3), FlSpot(7, 5)],
color:Colors.blue,
barWidth:3,
),
],
lineTouchData:constLineTouchData(enabled:false),
// FlClipData(top: true, bottom: false, left: true, right: true)// doesn't work correctly. It works like FlClipData.all() It clips the LineChartBarData// but also the VerticalLine. I'd like Clip just the LineChartBarData// clipData: const FlClipData(top: true, bottom: false, left: true, right: true),
extraLinesData:ExtraLinesData(
verticalLines: [
VerticalLine(
x:5,
color:Colors.red,
strokeWidth:2,
sizedPicture:SizedPicture(_customPicture!, 40, 20),
),
],
),
),
);
}
}
ui.PicturecreateCustomPicture() {
final recorder = ui.PictureRecorder();
final canvas =Canvas(recorder);
final paint =Paint()
..color =Colors.red
..style =PaintingStyle.fill;
canvas.drawCircle(constOffset(20, 20), 20, paint);
return recorder.endRecording();
}
The text was updated successfully, but these errors were encountered:
NemuelLealPereira
changed the title
impossible apply ClipData just for LineChartBarData instead all elements into LineChartData
Impossible to apply ClipData just for LineChartBarData instead of all elements in LineChartData
Mar 10, 2025
Hi guys,
Impossible to apply ClipData just for LineChartBarData instead of all elements in LineChartData
Also
clipData: const FlClipData(top: true, bottom: false, left: true, right: true),
never works correctly, it works likeFlClipData.all()
The FlClipData(top: true, bottom: false, left: true, right: true) works like FlClipData.all(). So, It clips the LineChartBarData but also the VerticalLine.
Expected: I'd like Clip just the LineChartBarData.
Simple example code:
The text was updated successfully, but these errors were encountered: