toSeriesList method

List<Series<GraphElement, D>> toSeriesList()

Transform graph data given by links and nodes into a Series list.

Output should contain two Series with the format: [Series<Node<N,L>> nodeSeries, Series<Link<N,L>> linkSeries]

Implementation

List<Series<GraphElement<dynamic>, D>> toSeriesList() {
  final nodeSeries = Series<Node<N, L>, D>(
    id: '${id}_nodes',
    data: nodes,
    domainFn: nodeDomainFn,
    measureFn: nodeMeasureFn,
    colorFn: nodeColorFn,
    fillColorFn: nodeFillColorFn,
    fillPatternFn: nodeFillPatternFn,
    strokeWidthPxFn: nodeStrokeWidthPxFn,
  )..attributes.mergeFrom(nodeAttributes);

  final linkSeries = Series<Link<N, L>, D>(
    id: '${id}_links',
    data: links,
    domainFn: linkDomainFn,
    measureFn: linkMeasureFn,
    fillColorFn: linkFillColorFn,
  )..attributes.mergeFrom(linkAttributes);
  return [nodeSeries, linkSeries];
}