New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chartjs-plugin-watermark

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chartjs-plugin-watermark - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

7

chartjs-plugin-watermark.js

@@ -190,5 +190,8 @@ /* chartjs-plugin-watermark | AlbinoDrought | MIT License | https://github.com/AlbinoDrought/chartjs-plugin-watermark/blob/master/LICENSE */

// If used in browser, register globally
if (window.Chart) {
window.Chart.register(watermarkPlugin);
if (window !== undefined) {
if (window.Chart) {
window.Chart.register(watermarkPlugin);
}
}
},{}]},{},[1]);
/* chartjs-plugin-watermark | AlbinoDrought | MIT License | https://github.com/AlbinoDrought/chartjs-plugin-watermark/blob/master/LICENSE */
!function(){function t(e,r,a){function i(o,c){if(!r[o]){if(!e[o]){var s="function"==typeof require&&require;if(!c&&s)return s(o,!0);if(n)return n(o,!0);var g=new Error("Cannot find module '"+o+"'");throw g.code="MODULE_NOT_FOUND",g}var f=r[o]={exports:{}};e[o][0].call(f.exports,function(t){return i(e[o][1][t]||t)},f,f.exports,t,e,r,a)}return r[o].exports}for(var n="function"==typeof require&&require,o=0;o<a.length;o++)i(a[o]);return i}return t}()({1:[function(t,e,r){var a={id:"watermark",defaultOptions:{x:0,y:0,height:!1,width:!1,alignX:"top",alignY:"left",alignToChartArea:!1,position:"front",opacity:1,image:!1},isPercentage:function(t){return"string"==typeof t&&"%"==t.charAt(t.length-1)},calcPercentage:function(t,e){var r=t.substr(0,t.length-1);return r=parseFloat(r),e*(r/100)},autoPercentage:function(t,e){return this.isPercentage(t)&&(t=this.calcPercentage(t,e)),t},imageFromString:function(t){var e=new Image;return e.src=t,e},drawWatermark:function(t,e){var r=t.watermark;if(r.position==e&&r.image){var a,i,n=r.image,o=t.ctx,c=o.canvas,s=0,g=0;if(r.alignToChartArea){var f=t.chartArea;a=f.bottom-f.top,i=f.right-f.left,s=f.left,g=f.top}else a=c.clientHeight||c.height,i=c.clientWidth||c.width;var u=r.height||n.height;u=this.autoPercentage(u,a);var h=r.width||n.width;h=this.autoPercentage(h,i);var l=this.autoPercentage(r.x,i),w=this.autoPercentage(r.y,a);switch(r.alignX){case"right":l=i-l-h;break;case"middle":l=i/2-h/2-l}switch(r.alignY){case"bottom":w=a-w-u;break;case"middle":w=a/2-u/2-w}o.save(),o.globalAlpha=r.opacity,o.drawImage(n,s+l,g+w,h,u),o.restore()}},beforeInit:function(t){t.watermark={};var e=t.options;if(e.watermark){var r=Object.assign({},this.defaultOptions),a=Object.assign(r,e.watermark);if(a.image){var i=a.image;"string"==typeof i&&(i=this.imageFromString(i)),i.onload=function(){t.ctx&&t.update()},a.image=i}t.watermark=a}},beforeDraw:function(t){this.drawWatermark(t,"back")},afterDraw:function(t){this.drawWatermark(t,"front")},afterDatasetsDraw:function(t){this.drawWatermark(t,"between")}};e.exports=a,window.Chart&&window.Chart.register(a)},{}]},{},[1]);
!function(){function t(e,r,a){function i(o,c){if(!r[o]){if(!e[o]){var s="function"==typeof require&&require;if(!c&&s)return s(o,!0);if(n)return n(o,!0);var g=new Error("Cannot find module '"+o+"'");throw g.code="MODULE_NOT_FOUND",g}var f=r[o]={exports:{}};e[o][0].call(f.exports,function(t){return i(e[o][1][t]||t)},f,f.exports,t,e,r,a)}return r[o].exports}for(var n="function"==typeof require&&require,o=0;o<a.length;o++)i(a[o]);return i}return t}()({1:[function(t,e,r){var a={id:"watermark",defaultOptions:{x:0,y:0,height:!1,width:!1,alignX:"top",alignY:"left",alignToChartArea:!1,position:"front",opacity:1,image:!1},isPercentage:function(t){return"string"==typeof t&&"%"==t.charAt(t.length-1)},calcPercentage:function(t,e){var r=t.substr(0,t.length-1);return r=parseFloat(r),e*(r/100)},autoPercentage:function(t,e){return this.isPercentage(t)&&(t=this.calcPercentage(t,e)),t},imageFromString:function(t){var e=new Image;return e.src=t,e},drawWatermark:function(t,e){var r=t.watermark;if(r.position==e&&r.image){var a,i,n=r.image,o=t.ctx,c=o.canvas,s=0,g=0;if(r.alignToChartArea){var f=t.chartArea;a=f.bottom-f.top,i=f.right-f.left,s=f.left,g=f.top}else a=c.clientHeight||c.height,i=c.clientWidth||c.width;var u=r.height||n.height;u=this.autoPercentage(u,a);var h=r.width||n.width;h=this.autoPercentage(h,i);var w=this.autoPercentage(r.x,i),l=this.autoPercentage(r.y,a);switch(r.alignX){case"right":w=i-w-h;break;case"middle":w=i/2-h/2-w}switch(r.alignY){case"bottom":l=a-l-u;break;case"middle":l=a/2-u/2-l}o.save(),o.globalAlpha=r.opacity,o.drawImage(n,s+w,g+l,h,u),o.restore()}},beforeInit:function(t){t.watermark={};var e=t.options;if(e.watermark){var r=Object.assign({},this.defaultOptions),a=Object.assign(r,e.watermark);if(a.image){var i=a.image;"string"==typeof i&&(i=this.imageFromString(i)),i.onload=function(){t.ctx&&t.update()},a.image=i}t.watermark=a}},beforeDraw:function(t){this.drawWatermark(t,"back")},afterDraw:function(t){this.drawWatermark(t,"front")},afterDatasetsDraw:function(t){this.drawWatermark(t,"between")}};e.exports=a,void 0!==window&&window.Chart&&window.Chart.register(a)},{}]},{},[1]);
{
"name": "chartjs-plugin-watermark",
"version": "2.0.0",
"version": "2.0.1",
"description": "A simple watermark plugin for Chart.js",

@@ -5,0 +5,0 @@ "main": "src/chart.plugin.watermark.js",

@@ -188,4 +188,6 @@ /**

// If used in browser, register globally
if (window.Chart) {
window.Chart.register(watermarkPlugin);
}
if (window !== undefined) {
if (window.Chart) {
window.Chart.register(watermarkPlugin);
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc