I have this basic scatter plot and I am trying to modify some of the dots radiuses and color.
I use the charts_flutter
package, and according to their docs\examples there should be a colorFn
and a radiusPxFn
attributes to the charts.Series
object.
This is the relevant code I have written so far:
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,
);
}
When I type colorFn
inside charts.Series
I get an error of undefined name
(same goes for radiusPxFn
)
Is there another way to modify the size and color attributes? Am I doing something wrong here?
It seems that colorFn is placed outside Series constructor. It should be:
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
)
];