123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- (function($) {
-
- $.jqplot.CanvasAxisTickRenderer = function(options) {
-
-
-
-
- this.mark = 'outside';
-
-
- this.showMark = true;
-
-
- this.showGridline = true;
-
-
- this.isMinorTick = false;
-
-
- this.angle = 0;
-
-
-
- this.markSize = 4;
-
-
- this.show = true;
-
-
- this.showLabel = true;
-
-
-
-
- this.labelPosition = 'auto';
- this.label = '';
- this.value = null;
- this._styles = {};
-
-
-
- this.formatter = $.jqplot.DefaultTickFormatter;
-
-
- this.formatString = '';
-
-
-
- this.prefix = '';
-
-
- this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
-
-
- this.fontSize = '10pt';
-
-
- this.fontWeight = 'normal';
-
-
-
- this.fontStretch = 1.0;
-
-
- this.textColor = '#666666';
-
-
-
-
- this.enableFontSupport = true;
-
-
-
-
-
-
-
- this.pt2px = null;
-
- this._elem;
- this._ctx;
- this._plotWidth;
- this._plotHeight;
- this._plotDimensions = {height:null, width:null};
-
- $.extend(true, this, options);
-
- var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
- if (this.pt2px) {
- ropts.pt2px = this.pt2px;
- }
-
- if (this.enableFontSupport) {
- if ($.jqplot.support_canvas_text()) {
- this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
- }
-
- else {
- this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
- }
- }
- else {
- this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
- }
- };
-
- $.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) {
- $.extend(true, this, options);
- this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
- };
-
-
-
-
- $.jqplot.CanvasAxisTickRenderer.prototype.getWidth = function(ctx) {
- if (this._elem) {
- return this._elem.outerWidth(true);
- }
- else {
- var tr = this._textRenderer;
- var l = tr.getWidth(ctx);
- var h = tr.getHeight(ctx);
- var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
- return w;
- }
- };
-
-
- $.jqplot.CanvasAxisTickRenderer.prototype.getHeight = function(ctx) {
- if (this._elem) {
- return this._elem.outerHeight(true);
- }
- else {
- var tr = this._textRenderer;
- var l = tr.getWidth(ctx);
- var h = tr.getHeight(ctx);
- var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
- return w;
- }
- };
-
- $.jqplot.CanvasAxisTickRenderer.prototype.getTop = function(ctx) {
- if (this._elem) {
- return this._elem.position().top;
- }
- else {
- return null;
- }
- };
-
- $.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad = function() {
- var a = this.angle * Math.PI/180;
- return a;
- };
-
-
- $.jqplot.CanvasAxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
- this.value = value;
- if (isMinor) {
- this.isMinorTick = true;
- }
- return this;
- };
-
- $.jqplot.CanvasAxisTickRenderer.prototype.draw = function(ctx, plot) {
- if (!this.label) {
- this.label = this.prefix + this.formatter(this.formatString, this.value);
- }
-
-
- if (this._elem) {
- if ($.jqplot.use_excanvas && window.G_vmlCanvasManager.uninitElement !== undefined) {
- window.G_vmlCanvasManager.uninitElement(this._elem.get(0));
- }
-
- this._elem.emptyForce();
- this._elem = null;
- }
-
-
- var elem = plot.canvasManager.getCanvas();
- this._textRenderer.setText(this.label, ctx);
- var w = this.getWidth(ctx);
- var h = this.getHeight(ctx);
-
- elem.width = w;
- elem.height = h;
- elem.style.width = w;
- elem.style.height = h;
- elem.style.textAlign = 'left';
- elem.style.position = 'absolute';
- elem = plot.canvasManager.initCanvas(elem);
- this._elem = $(elem);
- this._elem.css(this._styles);
- this._elem.addClass('jqplot-'+this.axis+'-tick');
- elem = null;
- return this._elem;
- };
-
- $.jqplot.CanvasAxisTickRenderer.prototype.pack = function() {
- this._textRenderer.draw(this._elem.get(0).getContext("2d"), this.label);
- };
-
- })(jQuery);
|