| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| (function($) { |
| |
| |
| $.jqplot.ShadowRenderer = function(options){ |
| |
| |
| |
| |
| this.angle = 45; |
| |
| |
| this.offset = 1; |
| |
| |
| this.alpha = 0.07; |
| |
| |
| this.lineWidth = 1.5; |
| |
| |
| this.lineJoin = 'miter'; |
| |
| |
| this.lineCap = 'round'; |
| |
| |
| this.closePath = false; |
| |
| |
| this.fill = false; |
| |
| |
| this.depth = 3; |
| this.strokeStyle = 'rgba(0,0,0,0.1)'; |
| |
| |
| this.isarc = false; |
| |
| $.extend(true, this, options); |
| }; |
| |
| $.jqplot.ShadowRenderer.prototype.init = function(options) { |
| $.extend(true, this, options); |
| }; |
| |
| |
| |
| |
| |
| |
| $.jqplot.ShadowRenderer.prototype.draw = function(ctx, points, options) { |
| ctx.save(); |
| var opts = (options != null) ? options : {}; |
| var fill = (opts.fill != null) ? opts.fill : this.fill; |
| var fillRect = (opts.fillRect != null) ? opts.fillRect : this.fillRect; |
| var closePath = (opts.closePath != null) ? opts.closePath : this.closePath; |
| var offset = (opts.offset != null) ? opts.offset : this.offset; |
| var alpha = (opts.alpha != null) ? opts.alpha : this.alpha; |
| var depth = (opts.depth != null) ? opts.depth : this.depth; |
| var isarc = (opts.isarc != null) ? opts.isarc : this.isarc; |
| var linePattern = (opts.linePattern != null) ? opts.linePattern : this.linePattern; |
| ctx.lineWidth = (opts.lineWidth != null) ? opts.lineWidth : this.lineWidth; |
| ctx.lineJoin = (opts.lineJoin != null) ? opts.lineJoin : this.lineJoin; |
| ctx.lineCap = (opts.lineCap != null) ? opts.lineCap : this.lineCap; |
| ctx.strokeStyle = opts.strokeStyle || this.strokeStyle || 'rgba(0,0,0,'+alpha+')'; |
| ctx.fillStyle = opts.fillStyle || this.fillStyle || 'rgba(0,0,0,'+alpha+')'; |
| for (var j=0; j<depth; j++) { |
| var ctxPattern = $.jqplot.LinePattern(ctx, linePattern); |
| ctx.translate(Math.cos(this.angle*Math.PI/180)*offset, Math.sin(this.angle*Math.PI/180)*offset); |
| ctxPattern.beginPath(); |
| if (isarc) { |
| ctx.arc(points[0], points[1], points[2], points[3], points[4], true); |
| } |
| else if (fillRect) { |
| if (fillRect) { |
| ctx.fillRect(points[0], points[1], points[2], points[3]); |
| } |
| } |
| else if (points && points.length){ |
| var move = true; |
| for (var i=0; i<points.length; i++) { |
| |
| if (points[i][0] != null && points[i][1] != null) { |
| if (move) { |
| ctxPattern.moveTo(points[i][0], points[i][1]); |
| move = false; |
| } |
| else { |
| ctxPattern.lineTo(points[i][0], points[i][1]); |
| } |
| } |
| else { |
| move = true; |
| } |
| } |
| |
| } |
| if (closePath) { |
| ctxPattern.closePath(); |
| } |
| if (fill) { |
| ctx.fill(); |
| } |
| else { |
| ctx.stroke(); |
| } |
| } |
| ctx.restore(); |
| }; |
| })(jQuery); |