Comments (2)
Hi @bilalep,
We have analyzed your query and found that the reported issue occurs only when we use the bloc to convert a stream, replacing the first data points with the new data. This issue is scheduled to be fixed in our upcoming weekly release which is scheduled on June 25, 2024. We will update you here once the release is rolled out and we appreciate your patience until then.
Additionally, if your requirement is to add new data to the end of the pervious data using bloc to convert a stream, we suggest the below code snippets and sample to achieve your requirement.
Code Snippet:
`
late CandleBloc _bloc;
List _chartData = [];
void initState() {
super.initState();
_bloc = CandleBloc();
_bloc.candleStream.listen((data) {
setState(() {
_chartData.addAll(data);
});
});
}
void dispose() {
_bloc.dispose();
super.dispose();
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Candle Chart Demo'),
),
body: Center(
child: _chartData.isNotEmpty
? Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
height: 300,
child: SfCartesianChart(
primaryXAxis: DateTimeAxis(),
primaryYAxis: NumericAxis(),
series: _getCandleSeries(_chartData),
),
),
)
: CircularProgressIndicator(),
),
);
}
List<CandleSeries<CandleChartData, DateTime>> _getCandleSeries(
List<CandleChartData> data) {
return <CandleSeries<CandleChartData, DateTime>>[
CandleSeries<CandleChartData, DateTime>(
dataSource: data,
xValueMapper: (CandleChartData sales, _) => sales.timestamp,
lowValueMapper: (CandleChartData sales, _) => sales.low,
highValueMapper: (CandleChartData sales, _) => sales.high,
openValueMapper: (CandleChartData sales, _) => sales.open,
closeValueMapper: (CandleChartData sales, _) => sales.close,
),
];
}
}
class CandleBloc {
final _candleController = StreamController<List>.broadcast();
Stream<List> get candleStream => _candleController.stream;
CandleBloc() {
_startGeneratingData();
}
void _startGeneratingData() {
Timer.periodic(Duration(seconds: 1), (timer) {
final candle = CandleChartData(
open: 20 + Random().nextInt(10).toDouble(),
close: 20 + Random().nextInt(10).toDouble(),
high: 20 + Random().nextInt(10).toDouble(),
low: 20 + Random().nextInt(10).toDouble(),
timestamp: DateTime.now(),
);
_addCandle(candle);
});
}
void _addCandle(CandleChartData candle) {
_candleController.sink.add([candle]);
}
void dispose() {
_candleController.close();
}
}
`
Please let us know if you need any further assistance.
Regards,
Preethika Selvam.
gh1916.zip
from flutter-widgets.
Hi @bilalep,
We have fixed the range exception that occurs when using the bloc to convert a stream for replacing the first data points with the new data points. This fix has been included in the latest version below. Therefore, we kindly request that you upgrade the syncfusion_flutter_charts package to the latest version below to avoid this issue.
Version: https://pub.dev/packages/syncfusion_flutter_charts/versions/26.1.39
Root cause: Missed to consider the candle line rendering when the candle series, open and close values are the same.
Regards,
Preethika Selvam.
from flutter-widgets.
Related Issues (20)
- Unable to change month's cell default hover decoration. HOT 1
- [syncfusion_flutter_charts] Unable to Control Two Charts with a Single Range Slider HOT 1
- SfCalendar change color month HOT 3
- [datagrid] Incomplete async feature HOT 1
- [syncfusion_flutter_charts] ColumnSeries with negative values HOT 2
- syncfusion_flutter_calendar increase height of appointment in month view HOT 2
- [syncfusion_flutter_xlsio] Read Files
- sfCalendar schedule view customization HOT 2
- SfPdfViewer.memory not open protected PDF HOT 3
- Remove references to deprecated v1 Android embedding HOT 2
- implement Verify pdf signatures like ninja-labs-tech/verify-pdf HOT 4
- extremely slow to read sign fields and certificate from a simple one page PDF HOT 3
- SfPdfViewer.asset not showing pdf file in release but works locally. HOT 4
- How to fix duplicate value in filteringUI
- RangeError (length): Invalid value: Not in inclusive range 0..3: 4. Error thrown #1685 HOT 3
- Request for Slider Component with Video Timestamp Integration HOT 1
- Any way to add a custom image Marker on PDF files using pdfviewer like annotation HOT 1
- Trackball does not disappear after moving the chart HOT 1
- Empty gray page when PDF used inside a SizedBox with adjustable width HOT 2
- Support WebAssembly for Flutter Web HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-widgets.