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, D>> toSeriesList() {
  Series<Node<N, L>, D> nodeSeries = Series(
    id: '${id}_nodes',
    data: nodes,
    domainFn: nodeDomainFn,
    measureFn: nodeMeasureFn,
    colorFn: nodeColorFn,
    fillColorFn: nodeFillColorFn,
    fillPatternFn: nodeFillPatternFn,
    strokeWidthPxFn: nodeStrokeWidthPxFn,
  )..attributes.mergeFrom(nodeAttributes);

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