项目作者: barbarbar338

项目描述 :
An easy-to-use canvas based pie chart generator 👀
高级语言: TypeScript
项目地址: git://github.com/barbarbar338/canvas-pie-chart.git
创建时间: 2020-10-03T21:09:47Z
项目社区:https://github.com/barbarbar338/canvas-pie-chart

开源协议:MIT License

下载


✨ Canvas Based Pie Chart Generator

  • An easy-to-use canvas based pie chart generator 👀
  • specify labels and size, and leave the rest to the system. 🦄

🔥 Installation

  • Download package with command npm install canvas-pie-chart or yarn add canvas-pie-chart

💡 CommonJS Example

  1. const { PieChart } = require("canvas-pie-chart"); // import chart generator
  2. /*
  3. Create a new PieChard instance
  4. options:
  5. - labels: {
  6. text: label text
  7. size: label size
  8. }
  9. blackOrWhiteInvert: if true, labels are written on a black-and-white basis else written in contrasting colors
  10. size: chart image size
  11. */
  12. const chart = new PieChart({
  13. labels: [
  14. {
  15. text: "Option one",
  16. size: 4
  17. },
  18. {
  19. text: "Option two",
  20. size: 7
  21. },
  22. {
  23. text: "Option three",
  24. size: 15
  25. }
  26. ],
  27. blackOrWhiteInvert: true,
  28. size: 1024
  29. });
  30. // draw chart output
  31. const buffer = chart.draw();

💡 ES6 Example

  1. import { PieChart } from "canvas-pie-chart"; // import chart generator
  2. /*
  3. Create a new PieChard instance
  4. options:
  5. - labels: {
  6. text: label text
  7. size: label size
  8. }
  9. blackOrWhiteInvert: if true, labels are written on a black-and-white basis else written in contrasting colors
  10. size: chart image size
  11. */
  12. const chart = new PieChart({
  13. labels: [
  14. {
  15. text: "Option one",
  16. size: 4
  17. },
  18. {
  19. text: "Option two",
  20. size: 7
  21. },
  22. {
  23. text: "Option three",
  24. size: 15
  25. }
  26. ],
  27. blackOrWhiteInvert: true,
  28. size: 1024
  29. });
  30. // draw chart output
  31. const buffer = chart.draw();