我有这个基本的散点图,我正在尝试修改一些点的半径和颜色。
我使用了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/

10-12 20:06