-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull Back Issue while getting the live data from websocket #2318
Comments
Thank you for sharing the details and the video demonstrating the issue you're experiencing. Based on our analysis, we observed that the chart appears to "stretch" or "pull" data when new chunks arrive. This is likely due to the default animation applied during chart updates with new data points. To resolve this, we recommend disabling animation by setting animationDuration to 0 in series. This will ensure smooth and immediate updates without distortion, providing a consistent real-time scrolling experience without visual glitches. If you prefer to keep animation, we suggest using FastLineSeries, which is optimized for rendering large volumes of data efficiently. We have shared a code snippet and demo using both FastLineSeries and LineSeries, with and without animation, for your reference. Code snippet using FastLineSeries with animation disabled:
UG Links: Additionally, to boost the performance of the chart when there is a need to plot high volume data. We suggest following the key points below that can be used to boost the performance of the chart when there is a need to plot high volume data: • Load and store the required data points in the initState method itself and then set the data points to the chart series. If you still face the issue, we kindly request you to try to replicate the reported issue in the below attached test sample and revert us so that it will help us assist you in a better way. Please let us know if you need any further assistance. gh2318.zip Regards, |
I am fetching real-time data via WebSockets from ThingsBoard and have fixed time window (10s), the timewindow is not depended to data points due to live it scrolling from right to left continuously without any interruption , if any data comes it should show in time window if not it will not affect the time window and time window will runs as usual without data.
ISSUE I AM FACING
The background time window is working correctly but while having the data ( as I am geeting the 200 of data in 1 chunk and it is also the time between the 2 chunks is not fixed so may be in 10sec i am getting 2 chunks * 200 data = 400 data or sometime i am getting 1 chunk * 200 data = 200 data ), So while the first chunk of data is coming looks good but while next chunk is coming and the 1st chunk is moving towards Y -axis while touching the Y-axis it looks like the 1st chunk is throwing the lines of graph to the 2nd chunk of graph to feed it (Looks like 2nd chunk is Pulling back the graphs from the 1st chunk which is actually not in window, I don't know may be the issue is in UI or backend)
Below is the actual flutter code implementation where i am getting the values and the issue i have explained above i captured a video of that, Please see the video and my code and review it where is the actuall issue Please suggest me I am waiting for the reply from you guys.
screen-20250325-201100.mp4
CODE
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:smarty/features/login/thingsboard_service.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:intl/intl.dart';
import 'package:web_socket_channel/io.dart';
class StatsHomeScreen extends StatefulWidget {
@OverRide
_StatsHomeScreenState createState() => _StatsHomeScreenState();
}
class _StatsHomeScreenState extends State {
List dataPoints = [];
late Timer timer;
int visibleDuration = 10; // Keep last 10 seconds visible
DateTime startTime = DateTime.now(); // Base time to move timeline
final ThingsBoardAuthService authService = ThingsBoardAuthService();
late IOWebSocketChannel channel; // WebSocket connection
@OverRide
void initState() {
super.initState();
}
Future connectWebSocket() async {
print("🔌 Connecting to WebSocket...");
String? accesstoken = await authService.getValidToken();
channel = IOWebSocketChannel.connect(
"ws://localhost/api/ws/plugins/telemetry?token=$accesstoken",
);
}
@OverRide
void dispose() {
timer.cancel();
channel.sink.close(); // Close WebSocket connection
print("🔌 WebSocket Disconnected.");
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
DateTime minTime = startTime.subtract(Duration(seconds: visibleDuration));
DateTime maxTime = startTime;
}
}
// Data model for time-series points
class LiveData {
final DateTime time;
final double? value;
LiveData(this.time, this.value);
}
The text was updated successfully, but these errors were encountered: