我有这个基本的散点图,我正在尝试修改一些点的半径和颜色。
我使用了charts_flutter
包,并根据其docs\examples设置了colorFn
对象的radiusPxFn
和charts.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/