Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/jqplot/src/jqplot.axisTickRenderer.js @ 15802

Last change on this file since 15802 was 9062, checked in by fschoepp, 12 years ago

#1888:
Backend changes:

  • Simplified job state detection (only one hive call will be made to detect all states now, instead of one additional call per job)
  • Reorganized classes (moved model classes into Model folder)

Website changes:

  • Website now heavily uses JavaScript to achieve better user experience
  • JavaScript degrades gracefully, except for plots
  • Tables: Added jquery-datatable-plugin to extend tables (pagination + search functionality)
  • OaaS-Website now uses the design of the HL websites (found in WebApplication branch)
  • Added jqplot to render zoomable line plots for HL-Datatables
  • Styling.js: Plots will be generated by using an ajax call; additional jquery-styling occurs within this file.
  • Added jquery-ui-1.9.2 which is capable of handling/rendering tabs, accordions and resizers.
File size: 5.6 KB
Line 
1/**
2 * jqPlot
3 * Pure JavaScript plotting plugin using jQuery
4 *
5 * Version: @VERSION
6 *
7 * Copyright (c) 2009-2011 Chris Leonello
8 * jqPlot is currently available for use in all personal or commercial projects
9 * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
10 * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
11 * choose the license that best suits your project and use it accordingly.
12 *
13 * Although not required, the author would appreciate an email letting him
14 * know of any substantial use of jqPlot.  You can reach the author at:
15 * chris at jqplot dot com or see http://www.jqplot.com/info.php .
16 *
17 * If you are feeling kind and generous, consider supporting the project by
18 * making a donation at: http://www.jqplot.com/donate.php .
19 *
20 * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
21 *
22 *     version 2007.04.27
23 *     author Ash Searle
24 *     http://hexmen.com/blog/2007/03/printf-sprintf/
25 *     http://hexmen.com/js/sprintf.js
26 *     The author (Ash Searle) has placed this code in the public domain:
27 *     "This code is unrestricted: you are free to use it however you like."
28 *
29 */
30(function($) {
31    // class: $.jqplot.AxisTickRenderer
32    // A "tick" object showing the value of a tick/gridline on the plot.
33    $.jqplot.AxisTickRenderer = function(options) {
34        // Group: Properties
35        $.jqplot.ElemContainer.call(this);
36        // prop: mark
37        // tick mark on the axis.  One of 'inside', 'outside', 'cross', '' or null.
38        this.mark = 'outside';
39        // name of the axis associated with this tick
40        this.axis;
41        // prop: showMark
42        // wether or not to show the mark on the axis.
43        this.showMark = true;
44        // prop: showGridline
45        // wether or not to draw the gridline on the grid at this tick.
46        this.showGridline = true;
47        // prop: isMinorTick
48        // if this is a minor tick.
49        this.isMinorTick = false;
50        // prop: size
51        // Length of the tick beyond the grid in pixels.
52        // DEPRECATED: This has been superceeded by markSize
53        this.size = 4;
54        // prop:  markSize
55        // Length of the tick marks in pixels.  For 'cross' style, length
56        // will be stoked above and below axis, so total length will be twice this.
57        this.markSize = 6;
58        // prop: show
59        // wether or not to show the tick (mark and label).
60        // Setting this to false requires more testing.  It is recommended
61        // to set showLabel and showMark to false instead.
62        this.show = true;
63        // prop: showLabel
64        // wether or not to show the label.
65        this.showLabel = true;
66        this.label = '';
67        this.value = null;
68        this._styles = {};
69        // prop: formatter
70        // A class of a formatter for the tick text.  sprintf by default.
71        this.formatter = $.jqplot.DefaultTickFormatter;
72        // prop: prefix
73        // String to prepend to the tick label.
74        // Prefix is prepended to the formatted tick label.
75        this.prefix = '';
76        // prop: formatString
77        // string passed to the formatter.
78        this.formatString = '';
79        // prop: fontFamily
80        // css spec for the font-family css attribute.
81        this.fontFamily;
82        // prop: fontSize
83        // css spec for the font-size css attribute.
84        this.fontSize;
85        // prop: textColor
86        // css spec for the color attribute.
87        this.textColor;
88        this._elem;
89    this._breakTick = false;
90       
91        $.extend(true, this, options);
92    };
93   
94    $.jqplot.AxisTickRenderer.prototype.init = function(options) {
95        $.extend(true, this, options);
96    };
97   
98    $.jqplot.AxisTickRenderer.prototype = new $.jqplot.ElemContainer();
99    $.jqplot.AxisTickRenderer.prototype.constructor = $.jqplot.AxisTickRenderer;
100   
101    $.jqplot.AxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
102        this.value = value;
103        this.axis = axisName;
104        if (isMinor) {
105            this.isMinorTick = true;
106        }
107        return this;
108    };
109   
110    $.jqplot.AxisTickRenderer.prototype.draw = function() {
111        if (!this.label) {
112            this.label = this.prefix + this.formatter(this.formatString, this.value);
113        }
114        var style = {position: 'absolute'};
115        if (Number(this.label)) {
116            style['whitSpace'] = 'nowrap';
117        }
118       
119        // Memory Leaks patch
120        if (this._elem) {
121            this._elem.emptyForce();
122            this._elem = null;
123        }
124
125        this._elem = $(document.createElement('div'));
126        this._elem.addClass("jqplot-"+this.axis+"-tick");
127        this._elem.text(this.label);
128        this._elem.css(style);
129
130        for (var s in this._styles) {
131            this._elem.css(s, this._styles[s]);
132        }
133        if (this.fontFamily) {
134            this._elem.css('font-family', this.fontFamily);
135        }
136        if (this.fontSize) {
137            this._elem.css('font-size', this.fontSize);
138        }
139        if (this.textColor) {
140            this._elem.css('color', this.textColor);
141        }
142    if (this._breakTick) {
143      this._elem.addClass('jqplot-breakTick');
144    }
145       
146        return this._elem;
147    };
148       
149    $.jqplot.DefaultTickFormatter = function (format, val) {
150        if (typeof val == 'number') {
151            if (!format) {
152                format = $.jqplot.config.defaultTickFormatString;
153            }
154            return $.jqplot.sprintf(format, val);
155        }
156        else {
157            return String(val);
158        }
159    };
160   
161    $.jqplot.AxisTickRenderer.prototype.pack = function() {
162    };
163})(jQuery);
Note: See TracBrowser for help on using the repository browser.