value property

num Function(T, int, List<T>) value
getter/setter pair

When a pie is generated (see Pie.call), the value accessor will be invoked for each element in the input data list, being passed the element d, the index i, and the list data as three arguments.

final pie = Pie(…)..value = (d, i, data) => d["value"];

pie.value; // (d, i, data) => d["value"]

The value accessor defaults to:

value(d, i, data) {
  return d;
}

If your data are not numbers, then you should specify an accessor that returns the corresponding numeric value for a given datum. For example, given a CSV file with number and name fields:

number,name
4,Locke
8,Reyes
15,Ford
16,Jarrah
23,Shephard
42,Kwon

You might say:

final data = await csv("lost.csv", autoType);
final pie = Pie(…)..value = (d, i, data) => d["number"];
final arcs = pie(data);

This is similar to mapping your data to values before invoking the pie generator:

finak arcs = Pie(…)(data.map((d) => d["number"]));

The benefit of an accessor is that the input data remains associated with the returned objects, thereby making it easier to access other fields of the data, for example to set the color or to add text labels.

Implementation

num Function(T, int, List<T>) value;