Welcome to the Flutter feedback portal. We’re happy you’re here! If you have feedback on how to improve the Flutter, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
I found a series visibility problem.
Step to reproduce:
1) click the add button 2 times so that there are 6 series.
2) click the legend of "Series 1" to make Series 1 visible.
Bug:
The Series 4 and 5 are also visible but they should not.
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
void main() {
runApp(MaterialApp(
home: TestPage(),
));
}
class TestPage extends StatefulWidget {
@override
_TestPageState createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
List<List<Datum>> seriesData;
Future future;
@override
void initState() {
super.initState();
seriesData = [];
_addData();
_addData();
_addData();
_addData();
future = Future.delayed(Duration(seconds: 1));
}
void _addData() {
final random = Random();
seriesData.insert(0, [
Datum(DateTime(2020, 7, 1), random.nextInt(10)),
Datum(DateTime(2020, 7, 2), random.nextInt(10)),
Datum(DateTime(2020, 7, 3), random.nextInt(10)),
Datum(DateTime(2020, 7, 4), random.nextInt(10)),
Datum(DateTime(2020, 7, 5), random.nextInt(10)),
Datum(DateTime(2020, 7, 6), random.nextInt(10)),
Datum(DateTime(2020, 7, 7), random.nextInt(10)),
Datum(DateTime(2020, 7, 8), random.nextInt(10)),
Datum(DateTime(2020, 7, 9), random.nextInt(10)),
]);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
children: [
RaisedButton(
child: Text('Add'),
onPressed: () => setState(_addData),
),
Expanded(
child: SfCartesianChart(
series: seriesData.map((data) {
return LineSeries<Datum, DateTime>(
dataSource: data,
xValueMapper: (Datum datum, _) => datum.x,
yValueMapper: (Datum datum, _) => datum.y,
markerSettings: MarkerSettings(
isVisible: true,
),
isVisible: data == seriesData.first,
);
}).toList(growable: false),
primaryXAxis: DateTimeAxis(
dateFormat: DateFormat.Md().add_Hm(),
zoomPosition: 1,
zoomFactor: 0.2,
),
primaryYAxis: NumericAxis(
anchorRangeToVisiblePoints: false,
),
legend: Legend(
isVisible: true,
position: LegendPosition.right,
),
),
)
],
),
);
}
}
class Datum {
DateTime x;
num y;
Datum(this.x, this.y);
}