Repository navigation
Closed
Description
- flutter version any
- syncfusion_flutter_charts : ^18.3.40 or other version
The display error is as follows
Code
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: TargetCacheRateChart(),
);
}
}
class TargetCacheRateChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
List<TestEntity> list = [
TestEntity("10-01", 25.4),
TestEntity("10-02", 26.4),
TestEntity("10-03", 26.8),
// TestEntity("10-04", 25.6),
// TestEntity("10-05", 24.3),
// TestEntity("10-06", 25.6),
// TestEntity("10-07", 25.8),
TestEntity("10-08", 24.6),
TestEntity("10-09", 25.6),
TestEntity("10-10", 26.6),
TestEntity("10-11", 26.4),
TestEntity("10-12", 26.7),
TestEntity("10-13", 26.3),
TestEntity("10-14", 26.7),
];
List<TestEntity> list2 = [
TestEntity("10-01", 35.4),
TestEntity("10-02", 36.4),
TestEntity("10-03", 36.8),
TestEntity("10-04", 35.6),
TestEntity("10-05", 14.3),
TestEntity("10-06", 35.6),
TestEntity("10-07", 45.8),
TestEntity("10-08", 34.6),
TestEntity("10-09", 35.6),
TestEntity("10-10", 36.6),
// TestEntity("10-11", 26.4),
// TestEntity("10-12", 26.7),
// TestEntity("10-13", 26.3),
// TestEntity("10-14", 26.7),
];
List<LineSeries> buildCacheRate = [
LineSeries<TestEntity, String>(
name: "line1",
dataSource: list,
xValueMapper: (TestEntity entity, _) => entity.date,
yValueMapper: (TestEntity entity, _) => entity.y),
LineSeries<TestEntity, String>(
name: "line2",
dataSource: list2,
xValueMapper: (TestEntity entity, _) => entity.date,
yValueMapper: (TestEntity entity, _) => entity.y),
];
return Container(
child: SfCartesianChart(
plotAreaBorderWidth: 0,
primaryXAxis: CategoryAxis(
majorGridLines: MajorGridLines(width: 0),
axisLine: AxisLine(width: 0),
),
palette: [
new Color(0xFF5B8FF9),
new Color(0xFFE8684A),
],
primaryYAxis: NumericAxis(
axisLine: AxisLine(width: 0),
labelFormat: '{value} %',
majorTickLines: MajorTickLines(size: 0)),
legend: new Legend(isVisible: true),
series: buildCacheRate));
}
}
class TestEntity {
String date;
double y;
TestEntity(this.date, this.y);
}
Metadata
Metadata
Assignees
Labels
No labels

Activity
SriramKiranSenthilkumar commentedon Oct 16, 2020
HI @DingProg ,
Greetings from Syncfusion. We have analyzed your scenario and we would like to share some information regarding the rendering behaviour of the chart with category series values. If there are two series available in the chart with the different category data source values, then the
arrangeByindexproperty of theCategoryAxisshould be set to_true_which will group the series data points according to their index and if the two series have similar category data source values, then there is no need to set this property. As your two series data source in your chart has different category x-values, kindly set thearrangeByIndexproperty value as_true_so that the series gets rendered properly in the chart. We have also tested this with the provided code snippet.code snippet:
Screenshtot:

For further reference on
arrangeByIndexproperty, please check the user guide below.https://help.syncfusion.com/flutter/cartesian-charts/axis-types#indexed-category-axis
Please get in touch with us if you require further assistance.
Regards,
Sriram Kiran
DingProg commentedon Oct 19, 2020
Thank you very much
This is ok