gpt4 book ai didi

flutter - 更改散点图抖动的半径和颜色

转载 作者:行者123 更新时间:2023-12-03 04:37:43 24 4
gpt4 key购买 nike

我有这个基本的散点图,我正在尝试修改一些点的半径和颜色。
我使用了charts_flutter包,并根据其docs\examples设置了colorFn对象的radiusPxFncharts.Series属性。
这是我到目前为止编写的相关代码:

class VennDiagramWidget extends StatefulWidget {
@override
_VennState createState() => _VennState();
}

class _VennState extends State<VennDiagramWidget> {
List<charts.Series<VennCircle, int>> circlesList;

static List<charts.Series<VennCircle, int>> _createRandomCircles() {
final circles = [
VennCircle(1, 5, 0.8, 'Venn1'),
VennCircle(2, 10, 0.5, 'Venn2'),
VennCircle(3, 20, 1, 'Venn3'),
];

return [
new charts.Series(
id: 'Circles',
data: circles,
domainFn: (VennCircle venn, _) => venn.circleSize,
measureFn: (VennCircle venn, _) => venn.opacity),
colorFn:
];
}

scatterPlot() {
return charts.ScatterPlotChart(
circlesList,
animate: true,
);
}
当我在 colorFn中键入 charts.Series时,出现 undefined name错误( radiusPxFn相同)
还有另一种修改大小和颜色属性的方法吗?我在这里做错什么了吗?

最佳答案

看来 colorFn 放置在系列构造函数的外部。它应该是:

return [
new charts.Series(
id: 'Circles',
data: circles,
domainFn: (VennCircle venn, _) => venn.circleSize,
measureFn: (VennCircle venn, _) => venn.opacity,
colorFn: (VennCircle venn, _) => charts.ColorUtil.fromDartColor(Colors.green),
radiusPxFn: (VennCircle venn, _) => venn.circleSize
)
];

关于flutter - 更改散点图抖动的半径和颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63843687/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com