首页 > 解决方案 > 将水印/徽标添加到 Chart.js

问题描述

我一直在查看文档和其他 SO 帖子,但似乎以前没有人问过这个问题。

有什么方法可以在 Chart.js 制作的图表中添加水印或徽标?

我需要这个主要是因为当人们将图表作为图像下载时,我不太关心它是否显示在我的网站上,只要用户下载它时它就在那里。

谁能指出我正确的方向?

非常感谢!:)

标签: javascripthtmlcanvaschart.js

解决方案


I'm sorry for finding an answer myself minutes after posting the question, but for the life of me I couldn't find this before :(

This Chart.js plugin will do exactly that: https://www.npmjs.com/package/chartjs-plugin-watermark

options: {

      watermark: {

          image: "//imgurlhere.jpg",
          x: 20,
          y: 10,
          width: 53,
          height: 60,
          opacity: 0.25,
          alignX: "left",
          alignY: "top",
          alignToChartArea: true,
          position: "back"

      },

}


推荐阅读