@blueking/watermark

0.0.2 • Public • Published

canvas 水印插件

配置项

名称(name) 类型(type) 默认值(default) 描述(description)
factor number 10 水印密度因子
opacity number 0.05 透明度
rotate number 30 旋转角度(0 - 90),目前只对文案水印有效
repeat string repeat 如何重复图像 repeat、repeat-x 、repeat-y 、no-repeat
image Image或者string 图片水印路径或者base64类型的图片
text string 水印 文案水印
fontSize number 12 文案水印字体
fontFamily string auto 文案水印字体
fontColor string black 文案水印颜色

案例

alt 图片水印 alt 文本水印

<!DOCTYPE html>
<html>
<head>
<title>watermark</title>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.1.2/dist/echarts.min.js"></script>
<script src="./watermark.js"></script>
</head>
<body>
<canvas id="canvas" width="800" height="600"></canvas>
<script>

const canvas = document.getElementById('canvas');
const myChart = echarts.init(canvas);

const option = {
    title: {
        text: 'ECharts 入门示例'
    },
    tooltip: {},
    legend: {
        data:['销量']
    },
    xAxis: {
        data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
    },
    yAxis: {},
    series: [{
        name: '销量',
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20]
    }]
};

// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);

const watermark = new Watermark(canvas, {
    text: '水印', // 文案
    fontColor: 'blue',
    factor: 20
});

myChart.on('rendered', () => {
    watermark.draw();
});
</script>
</body>
</html>

Package Sidebar

Install

npm i @blueking/watermark

Weekly Downloads

0

Version

0.0.2

License

ISC

Unpacked Size

3.81 MB

Total Files

11

Last publish

Collaborators

  • blueking