3.0.0 • Published 7 months ago

@sigma/node-piechart v3.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Sigma.js - Node pie-chart renderer

This package contains a node pie-chart renderer for sigma.js. Its API is inspired by @sigma/node-border.

Because sigma render nodes using WebGL, the program cannot handle a dynamic number of pie slices. For this reason, instead of a program, this package exposes createNodePiechartProgram, a factory that creates a program to render nodes as pie-charts, with the description of what slices must represent given as input.

How to use

Within your application that uses sigma.js, you can use @sigma/node-piechart as following:

import { createNodePiechartProgram } from "@sigma/node-piechart";

const graph = new Graph();
graph.addNode("some-node", {
  x: 0,
  y: 0,
  size: 10,
  type: "piechart",
  label: "Some node",
  positive: 10,
  neutral: 17,
  negative: 14,
});

const NodePiechartProgram = createNodePiechartProgram({
  defaultColor: "#BCB7C4",
  slices: [
    { color: { value: "#F05454" }, value: { attribute: "negative" } },
    { color: { value: "#7798FA" }, value: { attribute: "neutral" } },
    { color: { value: "#6DDB55" }, value: { attribute: "positive" } },
  ],
});

const sigma = new Sigma(graph, container, {
  nodeProgramClasses: {
    piechart: NodePiechartProgram,
  },
});

Please check the related Storybook for more advanced examples.

3.0.0

7 months ago

3.0.0-beta.5

10 months ago

3.0.0-beta.6

10 months ago

3.0.0-beta.3

12 months ago

3.0.0-beta.4

10 months ago

3.0.0-beta.2

1 year ago

3.0.0-beta.1

1 year ago