Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/jqplot/src/jqplot.shadowRenderer.js @ 13401

Last change on this file since 13401 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.2 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.shadowRenderer
32    // The default jqPlot shadow renderer, rendering shadows behind shapes.
33    $.jqplot.ShadowRenderer = function(options){
34        // Group: Properties
35       
36        // prop: angle
37        // Angle of the shadow in degrees.  Measured counter-clockwise from the x axis.
38        this.angle = 45;
39        // prop: offset
40        // Pixel offset at the given shadow angle of each shadow stroke from the last stroke.
41        this.offset = 1;
42        // prop: alpha
43        // alpha transparency of shadow stroke.
44        this.alpha = 0.07;
45        // prop: lineWidth
46        // width of the shadow line stroke.
47        this.lineWidth = 1.5;
48        // prop: lineJoin
49        // How line segments of the shadow are joined.
50        this.lineJoin = 'miter';
51        // prop: lineCap
52        // how ends of the shadow line are rendered.
53        this.lineCap = 'round';
54        // prop; closePath
55        // whether line path segment is closed upon itself.
56        this.closePath = false;
57        // prop: fill
58        // whether to fill the shape.
59        this.fill = false;
60        // prop: depth
61        // how many times the shadow is stroked.  Each stroke will be offset by offset at angle degrees.
62        this.depth = 3;
63        this.strokeStyle = 'rgba(0,0,0,0.1)';
64        // prop: isarc
65        // wether the shadow is an arc or not.
66        this.isarc = false;
67       
68        $.extend(true, this, options);
69    };
70   
71    $.jqplot.ShadowRenderer.prototype.init = function(options) {
72        $.extend(true, this, options);
73    };
74   
75    // function: draw
76    // draws an transparent black (i.e. gray) shadow.
77    //
78    // ctx - canvas drawing context
79    // points - array of points or [x, y, radius, start angle (rad), end angle (rad)]
80    $.jqplot.ShadowRenderer.prototype.draw = function(ctx, points, options) {
81        ctx.save();
82        var opts = (options != null) ? options : {};
83        var fill = (opts.fill != null) ? opts.fill : this.fill;
84        var closePath = (opts.closePath != null) ? opts.closePath : this.closePath;
85        var offset = (opts.offset != null) ? opts.offset : this.offset;
86        var alpha = (opts.alpha != null) ? opts.alpha : this.alpha;
87        var depth = (opts.depth != null) ? opts.depth : this.depth;
88        var isarc = (opts.isarc != null) ? opts.isarc : this.isarc;
89        ctx.lineWidth = (opts.lineWidth != null) ? opts.lineWidth : this.lineWidth;
90        ctx.lineJoin = (opts.lineJoin != null) ? opts.lineJoin : this.lineJoin;
91        ctx.lineCap = (opts.lineCap != null) ? opts.lineCap : this.lineCap;
92        ctx.strokeStyle = opts.strokeStyle || this.strokeStyle || 'rgba(0,0,0,'+alpha+')';
93        ctx.fillStyle = opts.fillStyle || this.fillStyle || 'rgba(0,0,0,'+alpha+')';
94        for (var j=0; j<depth; j++) {
95            ctx.translate(Math.cos(this.angle*Math.PI/180)*offset, Math.sin(this.angle*Math.PI/180)*offset);
96            ctx.beginPath();
97            if (isarc) {
98                ctx.arc(points[0], points[1], points[2], points[3], points[4], true);               
99            }
100            else if (points && points.length){
101                var move = true;
102                for (var i=0; i<points.length; i++) {
103                    // skip to the first non-null point and move to it.
104                    if (points[i][0] != null && points[i][1] != null) {
105                        if (move) {
106                            ctx.moveTo(points[i][0], points[i][1]);
107                            move = false;
108                        }
109                        else {
110                            ctx.lineTo(points[i][0], points[i][1]);
111                        }
112                    }
113                    else {
114                        move = true;
115                    }
116                }
117               
118            }
119            if (closePath) {
120                ctx.closePath();
121            }
122            if (fill) {
123                ctx.fill();
124            }
125            else {
126                ctx.stroke();
127            }
128        }
129        ctx.restore();
130    };
131})(jQuery);   
Note: See TracBrowser for help on using the repository browser.