npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

radar-canvas

v1.0.9

Published

原生canvas渲染的雷达图,具有基本的功能配置

Readme

radar-canvas

原生canvas渲染的雷达图,具有基本的功能配置

目录

安装

npm:

 npm install radar-canvas

CDN:

<script src="./../dist/index.js"></script>

示例

克隆这个仓库,用浏览器打开 example 目录下 index.html 文件查看效果

const cw = 500;
const ch = 500;
const radius = 200;
const canvas_node = document.getElementById("radar");
canvas_node.width = cw;
canvas_node.height = ch;

const ctx = canvas_node.getContext("2d");

const radar = new Radar({
  ctx,
  /**
   * 雷达图半径
   **/
  radius,
  /**
   * 指示器轴的分割段数
   **/
  splitNumber: 4,
  /**
   * 雷达图的指示器,用来指定雷达图中的多个变量(维度)
   **/
  indicator: [
    { text: "语文", max: 150 },
    { text: "数学", max: 150 },
    { text: "英语", max: 150 },
    { text: "物理", max: 100 },
    { text: "化学", max: 100 },
    { text: "生物", max: 100 },
  ],
  /**
   * 雷达图的数据
   **/
  data: {
    /**
     * 其中的value项数组是具体的数据,每个值跟 indicator 一一对应。
     **/
    value: [100, 110, 150, 80, 80, 30],
    /**
     * 数据区域填充的颜色
     **/
    fill: [
      [0, "rgba(120, 208, 248, 0.1)"],
      [1, "rgba(120, 208, 248, 0.9)"],
    ],
    /**
     *  sharp 锐角 sharp 平滑的
     **/
    type: "smooth",
    // type: "sharp",
    /**
     * 绘制点
     **/
    symbol: {
      show: false,
      pointStyle: {
        size: 6,
        color: "#0182ff",
      },
    },
    /**
     * 控制bezier控制点的偏移,控制这个值可以控制圆角,只有在 type 为smooth时生效
     **/
    bezierOffset: 20,
    /**
     * 绘制边线
     **/
    line: {
      show: false,
      lineStyle: {
        color: "#56a3f1",
      },
    },
  },
  /**
   * 指示器轴的分割线的类型,polygon 多边形、circle 圆形
   **/
  shape: "circle",
  /**
   * 雷达图在canvas上渲染的坐标
   **/
  x: 50,
  y: 50,
  /**
   * 坐标系起始角度,也就是第一个指示器轴的角度。
   **/
  startAngle: 90,
  /**
   * 指示器轴线
   **/
  axisLine: {
    lineStyle: {
      color: "#78D0F8",
    },
  },
  /**
   * 指示器轴的分割线
   **/
  splitLine: {
    lineStyle: {
      color: "#78D0F8",
    },
  },
});

radar.render();

配置参数

具体查看 index.d.ts 文件

License

MIT