Splinechart扑打
我试图制作一个可以从大列表中读取值的图表。我得到了@miftakhularzak的帮助。感谢他,列表的代表”。 无论如何,我试图实现建议的解决方案,但它对我没有完全有用,我认为这是因为我以某种方式弄乱了代码。
static List x =[26.0,13.10,1.3,1.5,1.9,1.8,1.9,2.9,3.0,1.9,1.8,1.4,9.0,2.0,3.4,4.7,1.8,1.9,2.9,3.0,1.9,1.8,1.4,1.0,2.0,3.4,4.7];
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
ChartData(4, x),
];
List<SplineSeries> generateSplineSeries(List<ChartData> chartData){
List<SplineSeries> splines = [];
for(int i=0; i<chartData.first.y!.length; i++){
splines.add( SplineSeries<ChartData, int>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y![i]
));
}
return splines;
}
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: generateSplineSeries(chartData),
)
)
)
);
}
}
class ChartData {
ChartData(this.x, this.y);
final int x;
final List? y;
}
如您所见,没有绘制线图。你能指出我在做什么错
I was trying to make a chart that can read values from a big List. I've got some help from @MiftakhulArzak " Line chart representation of List containing double values ", thanks to him.
Anyway I tried to implement the suggested solution but It didnt completely work for me which I think because I messed up the code somehow.
static List x =[26.0,13.10,1.3,1.5,1.9,1.8,1.9,2.9,3.0,1.9,1.8,1.4,9.0,2.0,3.4,4.7,1.8,1.9,2.9,3.0,1.9,1.8,1.4,1.0,2.0,3.4,4.7];
@override
Widget build(BuildContext context) {
final List<ChartData> chartData = [
ChartData(4, x),
];
List<SplineSeries> generateSplineSeries(List<ChartData> chartData){
List<SplineSeries> splines = [];
for(int i=0; i<chartData.first.y!.length; i++){
splines.add( SplineSeries<ChartData, int>(
dataSource: chartData,
xValueMapper: (ChartData data, _) => data.x,
yValueMapper: (ChartData data, _) => data.y![i]
));
}
return splines;
}
return Scaffold(
body: Center(
child: Container(
child: SfCartesianChart(
series: generateSplineSeries(chartData),
)
)
)
);
}
}
class ChartData {
ChartData(this.x, this.y);
final int x;
final List? y;
}
With this Code I get the outpus as this:
As you can see, No Line graph has been drawn. Can you point to me what am I doing wrong
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请使用此更新代码,
看起来,我不确定您是否想实现此目标。如果您想取得不同的成就,请在此处发表评论。
Please update code with this,
It will look like, I am not sure do you want to achieve this or else. If you want to achieve something different, please comment here.