BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi,
The app I built for SfCartesianChart can't show waves after boot up, have to click 'hot reload' button in the debugger (running on my computer) to show.
Any ideas on solving this?
Hi Zhu,
We have checked your query at our end and, as we are not able to understand what you are proposing as your requirement, we kindly request that you share more information on your requirement in detail, along with screenshots or screen recordings, so that it will help us to assist you in a better way.
Regards,
Yuvaraj.
Hi, Yuvaraj,
I'm using flutter and vscode to build my app which use SfCartesianChart, it's in debug state by now.
After I click F5 (which means start debugging) , flutter would build the app and install it to my Android phone and start debugging, it should display the charts on screen, but there are only the the title, axises and legends, no charts, I have to click the 'hot reload' button in vscode's debug tool bar, then the charts can also be displayed.
Looks like the charts are actually ready, they just need a redraw (by hot reload or change the phone's direction) to be displayed.
By the way, I run my async load data fuction wraped in Future.delayed in initState() of the stateful widget that have SfCartesianChart inside it, it does not matter, right?
Regards,
Zhu
Hi Zhu,
We tried to replicate the reported issue by calling the loadData method within the Future.delayed method with a 2-second time duration and it is working fine, the chart renders properly. Unfortunately, we were not able to reproduce the reported issue as we are not exactly sure in what scenario the issue is occurring. So, we kindly request you to try to reproduce the reported issue using the test sample attached below and revert back to us. This will help us assist you in a better way.
Regards,
Yuvaraj.
Hi, Yuvaraj,
Thank you for providing the test sample, I tried it and it works well here.
Here's my app's initState code:
void initState() {
Future.delayed(Duration.zero, () async {
await readFile();
loadData();
});
super.initState();
}
I tried to put super.initState() in front of the Future.delayed part, still can't display charts by itself.
Regards,
Zhu
Hi Zhu,
We have checked your code snippet and the reported issue is not reproduced at our end. Due to minimal information, we can't able to provide you a solution earlier. So, we kindly request you to provide more information about your chart code with the data source and screenshot or screen record. Also, try to reproduce the issue in a shared sample and get back to us it will be more helpful to us to assist you in a better way.
Regards,
Yuvaraj
Hi, Yuvaraj,
Thanks for the help, I'll try to reproduce the issue in a shared sample and get back to you.
Regards,
Zhu
Hi, Yuvaraj,
Attached is the app files(except the build folders), please take a check.
Another issue:
Using FastLineSeries ( changing series: getData to series: getData1) would bring below error:
════════ Exception caught by rendering library ═════════════════════════════════
The data points should be available to render fast line series.
'package:syncfusion_flutter_charts/src/chart/series_painter/fastline_painter.dart':
package:syncfusion_flutter_charts/…/series_painter/fastline_painter.dart:1
Failed assertion: line 184 pos 14: 'seriesPoints.isNotEmpty'
The relevant error-causing widget was SfCartesianChart
lib\main.dart:48
════════════════════════════════════════════════════════════════════════════════
Regards,
Zhu
Hi, Yuvaraj,
Sorry, forgot to attach the data file, here it is.
Extract it to Android phone path of '/data/user/0/com.example.tests/files', then the app can work.
Regards,
Zhu
Hi Zhu,
We have checked your sample and it is not in a runnable state, then we checked your code snippet and found that you have called the read() in the Future.delaved, and returned the chart inside the build method, so the chart gets rendered before the read and loadData method get called. Here, the read() method will get called after some time due to being wrapped inside the Future.delaved. To resolve this issue, we suggest returning the chart widget inside the FutureBuilder build method when the snapshot argument has data and assigning the read() function to the future property in the FutureBuilder. This way, the chart will be rendered at the initial startup. We have shared the FutureBuilder sample link and simple sample below for your reference.
https://api.flutter.dev/flutter/widgets/FutureBuilder-class.html#widgets.FutureBuilder.1
Regards,
Yuvaraj.
Hi, Yuvaraj,
Problem solved, thank you so much for the kind help.
Best Regards,
Zhu
Hi Zhu,
Most Welcome. Kindly get back to us if you have further queries. We are always happy to assist you.
Regards,
Yuvaraj.