| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| (function($) { |
| |
| |
| $.jqplot.MarkerRenderer = function(options){ |
| |
| |
| |
| |
| this.show = true; |
| |
| |
| this.style = 'filledCircle'; |
| |
| |
| this.lineWidth = 2; |
| |
| |
| this.size = 9.0; |
| |
| |
| this.color = '#666666'; |
| |
| |
| this.shadow = true; |
| |
| |
| this.shadowAngle = 45; |
| |
| |
| this.shadowOffset = 1; |
| |
| |
| this.shadowDepth = 3; |
| |
| |
| this.shadowAlpha = '0.07'; |
| |
| |
| this.shadowRenderer = new $.jqplot.ShadowRenderer(); |
| |
| |
| this.shapeRenderer = new $.jqplot.ShapeRenderer(); |
| |
| $.extend(true, this, options); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.init = function(options) { |
| $.extend(true, this, options); |
| var sdopt = {angle:this.shadowAngle, offset:this.shadowOffset, alpha:this.shadowAlpha, lineWidth:this.lineWidth, depth:this.shadowDepth, closePath:true}; |
| if (this.style.indexOf('filled') != -1) { |
| sdopt.fill = true; |
| } |
| if (this.style.indexOf('ircle') != -1) { |
| sdopt.isarc = true; |
| sdopt.closePath = false; |
| } |
| this.shadowRenderer.init(sdopt); |
| |
| var shopt = {fill:false, isarc:false, strokeStyle:this.color, fillStyle:this.color, lineWidth:this.lineWidth, closePath:true}; |
| if (this.style.indexOf('filled') != -1) { |
| shopt.fill = true; |
| } |
| if (this.style.indexOf('ircle') != -1) { |
| shopt.isarc = true; |
| shopt.closePath = false; |
| } |
| this.shapeRenderer.init(shopt); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.drawDiamond = function(x, y, ctx, fill, options) { |
| var stretch = 1.2; |
| var dx = this.size/2/stretch; |
| var dy = this.size/2*stretch; |
| var points = [[x-dx, y], [x, y+dy], [x+dx, y], [x, y-dy]]; |
| if (this.shadow) { |
| this.shadowRenderer.draw(ctx, points); |
| } |
| this.shapeRenderer.draw(ctx, points, options); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.drawPlus = function(x, y, ctx, fill, options) { |
| var stretch = 1.0; |
| var dx = this.size/2*stretch; |
| var dy = this.size/2*stretch; |
| var points1 = [[x, y-dy], [x, y+dy]]; |
| var points2 = [[x+dx, y], [x-dx, y]]; |
| var opts = $.extend(true, {}, this.options, {closePath:false}); |
| if (this.shadow) { |
| this.shadowRenderer.draw(ctx, points1, {closePath:false}); |
| this.shadowRenderer.draw(ctx, points2, {closePath:false}); |
| } |
| this.shapeRenderer.draw(ctx, points1, opts); |
| this.shapeRenderer.draw(ctx, points2, opts); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.drawX = function(x, y, ctx, fill, options) { |
| var stretch = 1.0; |
| var dx = this.size/2*stretch; |
| var dy = this.size/2*stretch; |
| var opts = $.extend(true, {}, this.options, {closePath:false}); |
| var points1 = [[x-dx, y-dy], [x+dx, y+dy]]; |
| var points2 = [[x-dx, y+dy], [x+dx, y-dy]]; |
| if (this.shadow) { |
| this.shadowRenderer.draw(ctx, points1, {closePath:false}); |
| this.shadowRenderer.draw(ctx, points2, {closePath:false}); |
| } |
| this.shapeRenderer.draw(ctx, points1, opts); |
| this.shapeRenderer.draw(ctx, points2, opts); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.drawDash = function(x, y, ctx, fill, options) { |
| var stretch = 1.0; |
| var dx = this.size/2*stretch; |
| var dy = this.size/2*stretch; |
| var points = [[x-dx, y], [x+dx, y]]; |
| if (this.shadow) { |
| this.shadowRenderer.draw(ctx, points); |
| } |
| this.shapeRenderer.draw(ctx, points, options); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.drawLine = function(p1, p2, ctx, fill, options) { |
| var points = [p1, p2]; |
| if (this.shadow) { |
| this.shadowRenderer.draw(ctx, points); |
| } |
| this.shapeRenderer.draw(ctx, points, options); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.drawSquare = function(x, y, ctx, fill, options) { |
| var stretch = 1.0; |
| var dx = this.size/2/stretch; |
| var dy = this.size/2*stretch; |
| var points = [[x-dx, y-dy], [x-dx, y+dy], [x+dx, y+dy], [x+dx, y-dy]]; |
| if (this.shadow) { |
| this.shadowRenderer.draw(ctx, points); |
| } |
| this.shapeRenderer.draw(ctx, points, options); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.drawCircle = function(x, y, ctx, fill, options) { |
| var radius = this.size/2; |
| var end = 2*Math.PI; |
| var points = [x, y, radius, 0, end, true]; |
| if (this.shadow) { |
| this.shadowRenderer.draw(ctx, points); |
| } |
| this.shapeRenderer.draw(ctx, points, options); |
| }; |
| |
| $.jqplot.MarkerRenderer.prototype.draw = function(x, y, ctx, options) { |
| options = options || {}; |
| |
| |
| if (options.show == null || options.show != false) { |
| if (options.color && !options.fillStyle) { |
| options.fillStyle = options.color; |
| } |
| if (options.color && !options.strokeStyle) { |
| options.strokeStyle = options.color; |
| } |
| switch (this.style) { |
| case 'diamond': |
| this.drawDiamond(x,y,ctx, false, options); |
| break; |
| case 'filledDiamond': |
| this.drawDiamond(x,y,ctx, true, options); |
| break; |
| case 'circle': |
| this.drawCircle(x,y,ctx, false, options); |
| break; |
| case 'filledCircle': |
| this.drawCircle(x,y,ctx, true, options); |
| break; |
| case 'square': |
| this.drawSquare(x,y,ctx, false, options); |
| break; |
| case 'filledSquare': |
| this.drawSquare(x,y,ctx, true, options); |
| break; |
| case 'x': |
| this.drawX(x,y,ctx, true, options); |
| break; |
| case 'plus': |
| this.drawPlus(x,y,ctx, true, options); |
| break; |
| case 'dash': |
| this.drawDash(x,y,ctx, true, options); |
| break; |
| case 'line': |
| this.drawLine(x, y, ctx, false, options); |
| break; |
| default: |
| this.drawDiamond(x,y,ctx, false, options); |
| break; |
| } |
| } |
| }; |
| })(jQuery); |