web/data/jquery.flot.js
author Julien Cristau <julien.cristau@logilab.fr>
Tue, 21 Oct 2014 18:01:06 +0200
changeset 10101 476c850f8cd5
parent 4207 0198acbae080
permissions -rw-r--r--
[web] Replace minified copy of jquery.flot.js 0.6 with non-minified version Related to #3851121
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10101
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     1
/* Javascript plotting library for jQuery, v. 0.6.
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     2
 *
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     3
 * Released under the MIT license by IOLA, December 2007.
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     4
 *
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     5
 */
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     6
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     7
// first an inline dependency, jquery.colorhelpers.js, we inline it here
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     8
// for convenience
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
     9
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    10
/* Plugin for jQuery for working with colors.
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    11
 * 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    12
 * Version 1.0.
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    13
 * 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    14
 * Inspiration from jQuery color animation plugin by John Resig.
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    15
 *
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    16
 * Released under the MIT license by Ole Laursen, October 2009.
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    17
 *
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    18
 * Examples:
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    19
 *
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    20
 *   $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    21
 *   var c = $.color.extract($("#mydiv"), 'background-color');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    22
 *   console.log(c.r, c.g, c.b, c.a);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    23
 *   $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    24
 *
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    25
 * Note that .scale() and .add() work in-place instead of returning
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    26
 * new objects.
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    27
 */ 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    28
(function(){jQuery.color={};jQuery.color.make=function(E,D,B,C){var F={};F.r=E||0;F.g=D||0;F.b=B||0;F.a=C!=null?C:1;F.add=function(I,H){for(var G=0;G<I.length;++G){F[I.charAt(G)]+=H}return F.normalize()};F.scale=function(I,H){for(var G=0;G<I.length;++G){F[I.charAt(G)]*=H}return F.normalize()};F.toString=function(){if(F.a>=1){return"rgb("+[F.r,F.g,F.b].join(",")+")"}else{return"rgba("+[F.r,F.g,F.b,F.a].join(",")+")"}};F.normalize=function(){function G(I,J,H){return J<I?I:(J>H?H:J)}F.r=G(0,parseInt(F.r),255);F.g=G(0,parseInt(F.g),255);F.b=G(0,parseInt(F.b),255);F.a=G(0,F.a,1);return F};F.clone=function(){return jQuery.color.make(F.r,F.b,F.g,F.a)};return F.normalize()};jQuery.color.extract=function(C,B){var D;do{D=C.css(B).toLowerCase();if(D!=""&&D!="transparent"){break}C=C.parent()}while(!jQuery.nodeName(C.get(0),"body"));if(D=="rgba(0, 0, 0, 0)"){D="transparent"}return jQuery.color.parse(D)};jQuery.color.parse=function(E){var D,B=jQuery.color.make;if(D=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(E)){return B(parseInt(D[1],10),parseInt(D[2],10),parseInt(D[3],10))}if(D=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(E)){return B(parseInt(D[1],10),parseInt(D[2],10),parseInt(D[3],10),parseFloat(D[4]))}if(D=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(E)){return B(parseFloat(D[1])*2.55,parseFloat(D[2])*2.55,parseFloat(D[3])*2.55)}if(D=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(E)){return B(parseFloat(D[1])*2.55,parseFloat(D[2])*2.55,parseFloat(D[3])*2.55,parseFloat(D[4]))}if(D=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(E)){return B(parseInt(D[1],16),parseInt(D[2],16),parseInt(D[3],16))}if(D=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(E)){return B(parseInt(D[1]+D[1],16),parseInt(D[2]+D[2],16),parseInt(D[3]+D[3],16))}var C=jQuery.trim(E).toLowerCase();if(C=="transparent"){return B(255,255,255,0)}else{D=A[C];return B(D[0],D[1],D[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    29
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    30
// the actual Flot code
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    31
(function($) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    32
    function Plot(placeholder, data_, options_, plugins) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    33
        // data is on the form:
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    34
        //   [ series1, series2 ... ]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    35
        // where series is either just the data as [ [x1, y1], [x2, y2], ... ]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    36
        // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    37
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    38
        var series = [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    39
            options = {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    40
                // the color theme used for graphs
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    41
                colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    42
                legend: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    43
                    show: true,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    44
                    noColumns: 1, // number of colums in legend table
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    45
                    labelFormatter: null, // fn: string -> string
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    46
                    labelBoxBorderColor: "#ccc", // border color for the little label boxes
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    47
                    container: null, // container (as jQuery object) to put legend in, null means default on top of graph
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    48
                    position: "ne", // position of default legend container within plot
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    49
                    margin: 5, // distance from grid edge to default legend container within plot
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    50
                    backgroundColor: null, // null means auto-detect
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    51
                    backgroundOpacity: 0.85 // set to 0 to avoid background
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    52
                },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    53
                xaxis: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    54
                    mode: null, // null or "time"
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    55
                    transform: null, // null or f: number -> number to transform axis
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    56
                    inverseTransform: null, // if transform is set, this should be the inverse function
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    57
                    min: null, // min. value to show, null means set automatically
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    58
                    max: null, // max. value to show, null means set automatically
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    59
                    autoscaleMargin: null, // margin in % to add if auto-setting min/max
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    60
                    ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    61
                    tickFormatter: null, // fn: number -> string
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    62
                    labelWidth: null, // size of tick labels in pixels
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    63
                    labelHeight: null,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    64
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    65
                    // mode specific options
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    66
                    tickDecimals: null, // no. of decimals, null means auto
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    67
                    tickSize: null, // number or [number, "unit"]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    68
                    minTickSize: null, // number or [number, "unit"]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    69
                    monthNames: null, // list of names of months
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    70
                    timeformat: null, // format string to use
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    71
                    twelveHourClock: false // 12 or 24 time in time mode
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    72
                },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    73
                yaxis: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    74
                    autoscaleMargin: 0.02
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    75
                },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    76
                x2axis: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    77
                    autoscaleMargin: null
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    78
                },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    79
                y2axis: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    80
                    autoscaleMargin: 0.02
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    81
                },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    82
                series: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    83
                    points: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    84
                        show: false,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    85
                        radius: 3,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    86
                        lineWidth: 2, // in pixels
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    87
                        fill: true,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    88
                        fillColor: "#ffffff"
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    89
                    },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    90
                    lines: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    91
                        // we don't put in show: false so we can see
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    92
                        // whether lines were actively disabled 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    93
                        lineWidth: 2, // in pixels
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    94
                        fill: false,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    95
                        fillColor: null,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    96
                        steps: false
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    97
                    },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    98
                    bars: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
    99
                        show: false,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   100
                        lineWidth: 2, // in pixels
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   101
                        barWidth: 1, // in units of the x axis
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   102
                        fill: true,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   103
                        fillColor: null,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   104
                        align: "left", // or "center" 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   105
                        horizontal: false // when horizontal, left is now top
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   106
                    },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   107
                    shadowSize: 3
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   108
                },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   109
                grid: {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   110
                    show: true,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   111
                    aboveData: false,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   112
                    color: "#545454", // primary color used for outline and labels
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   113
                    backgroundColor: null, // null for transparent, else color
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   114
                    tickColor: "rgba(0,0,0,0.15)", // color used for the ticks
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   115
                    labelMargin: 5, // in pixels
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   116
                    borderWidth: 2, // in pixels
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   117
                    borderColor: null, // set if different from the grid color
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   118
                    markings: null, // array of ranges or fn: axes -> array of ranges
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   119
                    markingsColor: "#f4f4f4",
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   120
                    markingsLineWidth: 2,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   121
                    // interactive stuff
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   122
                    clickable: false,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   123
                    hoverable: false,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   124
                    autoHighlight: true, // highlight in case mouse is near
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   125
                    mouseActiveRadius: 10 // how far the mouse can be away to activate an item
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   126
                },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   127
                hooks: {}
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   128
            },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   129
        canvas = null,      // the canvas for the plot itself
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   130
        overlay = null,     // canvas for interactive stuff on top of plot
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   131
        eventHolder = null, // jQuery object that events should be bound to
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   132
        ctx = null, octx = null,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   133
        axes = { xaxis: {}, yaxis: {}, x2axis: {}, y2axis: {} },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   134
        plotOffset = { left: 0, right: 0, top: 0, bottom: 0},
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   135
        canvasWidth = 0, canvasHeight = 0,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   136
        plotWidth = 0, plotHeight = 0,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   137
        hooks = {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   138
            processOptions: [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   139
            processRawData: [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   140
            processDatapoints: [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   141
            draw: [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   142
            bindEvents: [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   143
            drawOverlay: []
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   144
        },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   145
        plot = this;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   146
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   147
        // public functions
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   148
        plot.setData = setData;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   149
        plot.setupGrid = setupGrid;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   150
        plot.draw = draw;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   151
        plot.getPlaceholder = function() { return placeholder; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   152
        plot.getCanvas = function() { return canvas; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   153
        plot.getPlotOffset = function() { return plotOffset; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   154
        plot.width = function () { return plotWidth; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   155
        plot.height = function () { return plotHeight; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   156
        plot.offset = function () {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   157
            var o = eventHolder.offset();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   158
            o.left += plotOffset.left;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   159
            o.top += plotOffset.top;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   160
            return o;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   161
        };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   162
        plot.getData = function() { return series; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   163
        plot.getAxes = function() { return axes; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   164
        plot.getOptions = function() { return options; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   165
        plot.highlight = highlight;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   166
        plot.unhighlight = unhighlight;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   167
        plot.triggerRedrawOverlay = triggerRedrawOverlay;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   168
        plot.pointOffset = function(point) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   169
            return { left: parseInt(axisSpecToRealAxis(point, "xaxis").p2c(+point.x) + plotOffset.left),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   170
                     top: parseInt(axisSpecToRealAxis(point, "yaxis").p2c(+point.y) + plotOffset.top) };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   171
        };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   172
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   173
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   174
        // public attributes
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   175
        plot.hooks = hooks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   176
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   177
        // initialize
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   178
        initPlugins(plot);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   179
        parseOptions(options_);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   180
        constructCanvas();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   181
        setData(data_);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   182
        setupGrid();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   183
        draw();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   184
        bindEvents();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   185
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   186
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   187
        function executeHooks(hook, args) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   188
            args = [plot].concat(args);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   189
            for (var i = 0; i < hook.length; ++i)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   190
                hook[i].apply(this, args);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   191
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   192
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   193
        function initPlugins() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   194
            for (var i = 0; i < plugins.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   195
                var p = plugins[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   196
                p.init(plot);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   197
                if (p.options)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   198
                    $.extend(true, options, p.options);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   199
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   200
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   201
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   202
        function parseOptions(opts) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   203
            $.extend(true, options, opts);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   204
            if (options.grid.borderColor == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   205
                options.grid.borderColor = options.grid.color;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   206
            // backwards compatibility, to be removed in future
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   207
            if (options.xaxis.noTicks && options.xaxis.ticks == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   208
                options.xaxis.ticks = options.xaxis.noTicks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   209
            if (options.yaxis.noTicks && options.yaxis.ticks == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   210
                options.yaxis.ticks = options.yaxis.noTicks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   211
            if (options.grid.coloredAreas)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   212
                options.grid.markings = options.grid.coloredAreas;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   213
            if (options.grid.coloredAreasColor)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   214
                options.grid.markingsColor = options.grid.coloredAreasColor;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   215
            if (options.lines)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   216
                $.extend(true, options.series.lines, options.lines);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   217
            if (options.points)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   218
                $.extend(true, options.series.points, options.points);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   219
            if (options.bars)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   220
                $.extend(true, options.series.bars, options.bars);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   221
            if (options.shadowSize)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   222
                options.series.shadowSize = options.shadowSize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   223
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   224
            for (var n in hooks)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   225
                if (options.hooks[n] && options.hooks[n].length)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   226
                    hooks[n] = hooks[n].concat(options.hooks[n]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   227
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   228
            executeHooks(hooks.processOptions, [options]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   229
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   230
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   231
        function setData(d) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   232
            series = parseData(d);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   233
            fillInSeriesOptions();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   234
            processData();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   235
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   236
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   237
        function parseData(d) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   238
            var res = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   239
            for (var i = 0; i < d.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   240
                var s = $.extend(true, {}, options.series);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   241
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   242
                if (d[i].data) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   243
                    s.data = d[i].data; // move the data instead of deep-copy
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   244
                    delete d[i].data;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   245
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   246
                    $.extend(true, s, d[i]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   247
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   248
                    d[i].data = s.data;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   249
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   250
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   251
                    s.data = d[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   252
                res.push(s);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   253
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   254
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   255
            return res;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   256
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   257
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   258
        function axisSpecToRealAxis(obj, attr) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   259
            var a = obj[attr];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   260
            if (!a || a == 1)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   261
                return axes[attr];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   262
            if (typeof a == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   263
                return axes[attr.charAt(0) + a + attr.slice(1)];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   264
            return a; // assume it's OK
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   265
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   266
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   267
        function fillInSeriesOptions() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   268
            var i;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   269
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   270
            // collect what we already got of colors
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   271
            var neededColors = series.length,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   272
                usedColors = [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   273
                assignedColors = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   274
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   275
                var sc = series[i].color;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   276
                if (sc != null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   277
                    --neededColors;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   278
                    if (typeof sc == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   279
                        assignedColors.push(sc);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   280
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   281
                        usedColors.push($.color.parse(series[i].color));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   282
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   283
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   284
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   285
            // we might need to generate more colors if higher indices
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   286
            // are assigned
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   287
            for (i = 0; i < assignedColors.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   288
                neededColors = Math.max(neededColors, assignedColors[i] + 1);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   289
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   290
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   291
            // produce colors as needed
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   292
            var colors = [], variation = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   293
            i = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   294
            while (colors.length < neededColors) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   295
                var c;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   296
                if (options.colors.length == i) // check degenerate case
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   297
                    c = $.color.make(100, 100, 100);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   298
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   299
                    c = $.color.parse(options.colors[i]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   300
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   301
                // vary color if needed
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   302
                var sign = variation % 2 == 1 ? -1 : 1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   303
                c.scale('rgb', 1 + sign * Math.ceil(variation / 2) * 0.2)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   304
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   305
                // FIXME: if we're getting to close to something else,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   306
                // we should probably skip this one
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   307
                colors.push(c);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   308
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   309
                ++i;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   310
                if (i >= options.colors.length) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   311
                    i = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   312
                    ++variation;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   313
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   314
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   315
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   316
            // fill in the options
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   317
            var colori = 0, s;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   318
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   319
                s = series[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   320
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   321
                // assign colors
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   322
                if (s.color == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   323
                    s.color = colors[colori].toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   324
                    ++colori;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   325
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   326
                else if (typeof s.color == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   327
                    s.color = colors[s.color].toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   328
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   329
                // turn on lines automatically in case nothing is set
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   330
                if (s.lines.show == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   331
                    var v, show = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   332
                    for (v in s)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   333
                        if (s[v].show) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   334
                            show = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   335
                            break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   336
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   337
                    if (show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   338
                        s.lines.show = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   339
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   340
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   341
                // setup axes
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   342
                s.xaxis = axisSpecToRealAxis(s, "xaxis");
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   343
                s.yaxis = axisSpecToRealAxis(s, "yaxis");
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   344
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   345
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   346
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   347
        function processData() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   348
            var topSentry = Number.POSITIVE_INFINITY,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   349
                bottomSentry = Number.NEGATIVE_INFINITY,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   350
                i, j, k, m, length,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   351
                s, points, ps, x, y, axis, val, f, p;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   352
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   353
            for (axis in axes) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   354
                axes[axis].datamin = topSentry;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   355
                axes[axis].datamax = bottomSentry;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   356
                axes[axis].used = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   357
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   358
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   359
            function updateAxis(axis, min, max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   360
                if (min < axis.datamin)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   361
                    axis.datamin = min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   362
                if (max > axis.datamax)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   363
                    axis.datamax = max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   364
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   365
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   366
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   367
                s = series[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   368
                s.datapoints = { points: [] };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   369
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   370
                executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   371
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   372
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   373
            // first pass: clean and copy data
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   374
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   375
                s = series[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   376
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   377
                var data = s.data, format = s.datapoints.format;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   378
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   379
                if (!format) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   380
                    format = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   381
                    // find out how to copy
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   382
                    format.push({ x: true, number: true, required: true });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   383
                    format.push({ y: true, number: true, required: true });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   384
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   385
                    if (s.bars.show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   386
                        format.push({ y: true, number: true, required: false, defaultValue: 0 });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   387
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   388
                    s.datapoints.format = format;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   389
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   390
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   391
                if (s.datapoints.pointsize != null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   392
                    continue; // already filled in
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   393
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   394
                if (s.datapoints.pointsize == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   395
                    s.datapoints.pointsize = format.length;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   396
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   397
                ps = s.datapoints.pointsize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   398
                points = s.datapoints.points;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   399
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   400
                insertSteps = s.lines.show && s.lines.steps;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   401
                s.xaxis.used = s.yaxis.used = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   402
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   403
                for (j = k = 0; j < data.length; ++j, k += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   404
                    p = data[j];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   405
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   406
                    var nullify = p == null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   407
                    if (!nullify) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   408
                        for (m = 0; m < ps; ++m) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   409
                            val = p[m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   410
                            f = format[m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   411
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   412
                            if (f) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   413
                                if (f.number && val != null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   414
                                    val = +val; // convert to number
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   415
                                    if (isNaN(val))
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   416
                                        val = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   417
                                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   418
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   419
                                if (val == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   420
                                    if (f.required)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   421
                                        nullify = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   422
                                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   423
                                    if (f.defaultValue != null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   424
                                        val = f.defaultValue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   425
                                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   426
                            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   427
                            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   428
                            points[k + m] = val;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   429
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   430
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   431
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   432
                    if (nullify) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   433
                        for (m = 0; m < ps; ++m) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   434
                            val = points[k + m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   435
                            if (val != null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   436
                                f = format[m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   437
                                // extract min/max info
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   438
                                if (f.x)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   439
                                    updateAxis(s.xaxis, val, val);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   440
                                if (f.y)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   441
                                    updateAxis(s.yaxis, val, val);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   442
                            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   443
                            points[k + m] = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   444
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   445
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   446
                    else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   447
                        // a little bit of line specific stuff that
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   448
                        // perhaps shouldn't be here, but lacking
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   449
                        // better means...
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   450
                        if (insertSteps && k > 0
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   451
                            && points[k - ps] != null
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   452
                            && points[k - ps] != points[k]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   453
                            && points[k - ps + 1] != points[k + 1]) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   454
                            // copy the point to make room for a middle point
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   455
                            for (m = 0; m < ps; ++m)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   456
                                points[k + ps + m] = points[k + m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   457
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   458
                            // middle point has same y
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   459
                            points[k + 1] = points[k - ps + 1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   460
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   461
                            // we've added a point, better reflect that
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   462
                            k += ps;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   463
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   464
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   465
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   466
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   467
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   468
            // give the hooks a chance to run
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   469
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   470
                s = series[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   471
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   472
                executeHooks(hooks.processDatapoints, [ s, s.datapoints]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   473
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   474
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   475
            // second pass: find datamax/datamin for auto-scaling
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   476
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   477
                s = series[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   478
                points = s.datapoints.points,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   479
                ps = s.datapoints.pointsize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   480
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   481
                var xmin = topSentry, ymin = topSentry,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   482
                    xmax = bottomSentry, ymax = bottomSentry;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   483
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   484
                for (j = 0; j < points.length; j += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   485
                    if (points[j] == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   486
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   487
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   488
                    for (m = 0; m < ps; ++m) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   489
                        val = points[j + m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   490
                        f = format[m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   491
                        if (!f)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   492
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   493
                        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   494
                        if (f.x) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   495
                            if (val < xmin)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   496
                                xmin = val;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   497
                            if (val > xmax)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   498
                                xmax = val;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   499
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   500
                        if (f.y) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   501
                            if (val < ymin)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   502
                                ymin = val;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   503
                            if (val > ymax)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   504
                                ymax = val;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   505
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   506
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   507
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   508
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   509
                if (s.bars.show) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   510
                    // make sure we got room for the bar on the dancing floor
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   511
                    var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   512
                    if (s.bars.horizontal) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   513
                        ymin += delta;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   514
                        ymax += delta + s.bars.barWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   515
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   516
                    else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   517
                        xmin += delta;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   518
                        xmax += delta + s.bars.barWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   519
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   520
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   521
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   522
                updateAxis(s.xaxis, xmin, xmax);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   523
                updateAxis(s.yaxis, ymin, ymax);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   524
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   525
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   526
            for (axis in axes) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   527
                if (axes[axis].datamin == topSentry)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   528
                    axes[axis].datamin = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   529
                if (axes[axis].datamax == bottomSentry)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   530
                    axes[axis].datamax = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   531
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   532
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   533
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   534
        function constructCanvas() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   535
            function makeCanvas(width, height) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   536
                var c = document.createElement('canvas');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   537
                c.width = width;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   538
                c.height = height;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   539
                if ($.browser.msie) // excanvas hack
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   540
                    c = window.G_vmlCanvasManager.initElement(c);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   541
                return c;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   542
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   543
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   544
            canvasWidth = placeholder.width();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   545
            canvasHeight = placeholder.height();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   546
            placeholder.html(""); // clear placeholder
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   547
            if (placeholder.css("position") == 'static')
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   548
                placeholder.css("position", "relative"); // for positioning labels and overlay
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   549
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   550
            if (canvasWidth <= 0 || canvasHeight <= 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   551
                throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   552
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   553
            if ($.browser.msie) // excanvas hack
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   554
                window.G_vmlCanvasManager.init_(document); // make sure everything is setup
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   555
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   556
            // the canvas
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   557
            canvas = $(makeCanvas(canvasWidth, canvasHeight)).appendTo(placeholder).get(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   558
            ctx = canvas.getContext("2d");
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   559
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   560
            // overlay canvas for interactive features
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   561
            overlay = $(makeCanvas(canvasWidth, canvasHeight)).css({ position: 'absolute', left: 0, top: 0 }).appendTo(placeholder).get(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   562
            octx = overlay.getContext("2d");
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   563
            octx.stroke();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   564
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   565
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   566
        function bindEvents() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   567
            // we include the canvas in the event holder too, because IE 7
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   568
            // sometimes has trouble with the stacking order
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   569
            eventHolder = $([overlay, canvas]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   570
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   571
            // bind events
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   572
            if (options.grid.hoverable)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   573
                eventHolder.mousemove(onMouseMove);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   574
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   575
            if (options.grid.clickable)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   576
                eventHolder.click(onClick);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   577
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   578
            executeHooks(hooks.bindEvents, [eventHolder]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   579
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   580
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   581
        function setupGrid() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   582
            function setTransformationHelpers(axis, o) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   583
                function identity(x) { return x; }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   584
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   585
                var s, m, t = o.transform || identity,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   586
                    it = o.inverseTransform;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   587
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   588
                // add transformation helpers
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   589
                if (axis == axes.xaxis || axis == axes.x2axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   590
                    // precompute how much the axis is scaling a point
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   591
                    // in canvas space
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   592
                    s = axis.scale = plotWidth / (t(axis.max) - t(axis.min));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   593
                    m = t(axis.min);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   594
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   595
                    // data point to canvas coordinate
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   596
                    if (t == identity) // slight optimization
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   597
                        axis.p2c = function (p) { return (p - m) * s; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   598
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   599
                        axis.p2c = function (p) { return (t(p) - m) * s; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   600
                    // canvas coordinate to data point
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   601
                    if (!it)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   602
                        axis.c2p = function (c) { return m + c / s; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   603
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   604
                        axis.c2p = function (c) { return it(m + c / s); };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   605
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   606
                else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   607
                    s = axis.scale = plotHeight / (t(axis.max) - t(axis.min));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   608
                    m = t(axis.max);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   609
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   610
                    if (t == identity)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   611
                        axis.p2c = function (p) { return (m - p) * s; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   612
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   613
                        axis.p2c = function (p) { return (m - t(p)) * s; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   614
                    if (!it)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   615
                        axis.c2p = function (c) { return m - c / s; };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   616
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   617
                        axis.c2p = function (c) { return it(m - c / s); };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   618
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   619
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   620
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   621
            function measureLabels(axis, axisOptions) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   622
                var i, labels = [], l;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   623
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   624
                axis.labelWidth = axisOptions.labelWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   625
                axis.labelHeight = axisOptions.labelHeight;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   626
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   627
                if (axis == axes.xaxis || axis == axes.x2axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   628
                    // to avoid measuring the widths of the labels, we
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   629
                    // construct fixed-size boxes and put the labels inside
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   630
                    // them, we don't need the exact figures and the
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   631
                    // fixed-size box content is easy to center
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   632
                    if (axis.labelWidth == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   633
                        axis.labelWidth = canvasWidth / (axis.ticks.length > 0 ? axis.ticks.length : 1);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   634
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   635
                    // measure x label heights
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   636
                    if (axis.labelHeight == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   637
                        labels = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   638
                        for (i = 0; i < axis.ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   639
                            l = axis.ticks[i].label;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   640
                            if (l)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   641
                                labels.push('<div class="tickLabel" style="float:left;width:' + axis.labelWidth + 'px">' + l + '</div>');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   642
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   643
                        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   644
                        if (labels.length > 0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   645
                            var dummyDiv = $('<div style="position:absolute;top:-10000px;width:10000px;font-size:smaller">'
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   646
                                             + labels.join("") + '<div style="clear:left"></div></div>').appendTo(placeholder);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   647
                            axis.labelHeight = dummyDiv.height();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   648
                            dummyDiv.remove();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   649
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   650
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   651
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   652
                else if (axis.labelWidth == null || axis.labelHeight == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   653
                    // calculate y label dimensions
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   654
                    for (i = 0; i < axis.ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   655
                        l = axis.ticks[i].label;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   656
                        if (l)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   657
                            labels.push('<div class="tickLabel">' + l + '</div>');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   658
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   659
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   660
                    if (labels.length > 0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   661
                        var dummyDiv = $('<div style="position:absolute;top:-10000px;font-size:smaller">'
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   662
                                         + labels.join("") + '</div>').appendTo(placeholder);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   663
                        if (axis.labelWidth == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   664
                            axis.labelWidth = dummyDiv.width();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   665
                        if (axis.labelHeight == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   666
                            axis.labelHeight = dummyDiv.find("div").height();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   667
                        dummyDiv.remove();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   668
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   669
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   670
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   671
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   672
                if (axis.labelWidth == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   673
                    axis.labelWidth = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   674
                if (axis.labelHeight == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   675
                    axis.labelHeight = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   676
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   677
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   678
            function setGridSpacing() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   679
                // get the most space needed around the grid for things
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   680
                // that may stick out
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   681
                var maxOutset = options.grid.borderWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   682
                for (i = 0; i < series.length; ++i)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   683
                    maxOutset = Math.max(maxOutset, 2 * (series[i].points.radius + series[i].points.lineWidth/2));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   684
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   685
                plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = maxOutset;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   686
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   687
                var margin = options.grid.labelMargin + options.grid.borderWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   688
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   689
                if (axes.xaxis.labelHeight > 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   690
                    plotOffset.bottom = Math.max(maxOutset, axes.xaxis.labelHeight + margin);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   691
                if (axes.yaxis.labelWidth > 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   692
                    plotOffset.left = Math.max(maxOutset, axes.yaxis.labelWidth + margin);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   693
                if (axes.x2axis.labelHeight > 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   694
                    plotOffset.top = Math.max(maxOutset, axes.x2axis.labelHeight + margin);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   695
                if (axes.y2axis.labelWidth > 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   696
                    plotOffset.right = Math.max(maxOutset, axes.y2axis.labelWidth + margin);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   697
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   698
                plotWidth = canvasWidth - plotOffset.left - plotOffset.right;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   699
                plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   700
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   701
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   702
            var axis;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   703
            for (axis in axes)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   704
                setRange(axes[axis], options[axis]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   705
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   706
            if (options.grid.show) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   707
                for (axis in axes) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   708
                    prepareTickGeneration(axes[axis], options[axis]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   709
                    setTicks(axes[axis], options[axis]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   710
                    measureLabels(axes[axis], options[axis]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   711
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   712
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   713
                setGridSpacing();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   714
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   715
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   716
                plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   717
                plotWidth = canvasWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   718
                plotHeight = canvasHeight;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   719
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   720
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   721
            for (axis in axes)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   722
                setTransformationHelpers(axes[axis], options[axis]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   723
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   724
            if (options.grid.show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   725
                insertLabels();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   726
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   727
            insertLegend();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   728
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   729
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   730
        function setRange(axis, axisOptions) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   731
            var min = +(axisOptions.min != null ? axisOptions.min : axis.datamin),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   732
                max = +(axisOptions.max != null ? axisOptions.max : axis.datamax),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   733
                delta = max - min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   734
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   735
            if (delta == 0.0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   736
                // degenerate case
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   737
                var widen = max == 0 ? 1 : 0.01;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   738
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   739
                if (axisOptions.min == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   740
                    min -= widen;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   741
                // alway widen max if we couldn't widen min to ensure we
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   742
                // don't fall into min == max which doesn't work
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   743
                if (axisOptions.max == null || axisOptions.min != null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   744
                    max += widen;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   745
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   746
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   747
                // consider autoscaling
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   748
                var margin = axisOptions.autoscaleMargin;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   749
                if (margin != null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   750
                    if (axisOptions.min == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   751
                        min -= delta * margin;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   752
                        // make sure we don't go below zero if all values
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   753
                        // are positive
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   754
                        if (min < 0 && axis.datamin != null && axis.datamin >= 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   755
                            min = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   756
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   757
                    if (axisOptions.max == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   758
                        max += delta * margin;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   759
                        if (max > 0 && axis.datamax != null && axis.datamax <= 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   760
                            max = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   761
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   762
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   763
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   764
            axis.min = min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   765
            axis.max = max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   766
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   767
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   768
        function prepareTickGeneration(axis, axisOptions) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   769
            // estimate number of ticks
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   770
            var noTicks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   771
            if (typeof axisOptions.ticks == "number" && axisOptions.ticks > 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   772
                noTicks = axisOptions.ticks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   773
            else if (axis == axes.xaxis || axis == axes.x2axis)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   774
                 // heuristic based on the model a*sqrt(x) fitted to
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   775
                 // some reasonable data points
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   776
                noTicks = 0.3 * Math.sqrt(canvasWidth);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   777
            else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   778
                noTicks = 0.3 * Math.sqrt(canvasHeight);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   779
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   780
            var delta = (axis.max - axis.min) / noTicks,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   781
                size, generator, unit, formatter, i, magn, norm;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   782
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   783
            if (axisOptions.mode == "time") {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   784
                // pretty handling of time
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   785
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   786
                // map of app. size of time units in milliseconds
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   787
                var timeUnitSize = {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   788
                    "second": 1000,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   789
                    "minute": 60 * 1000,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   790
                    "hour": 60 * 60 * 1000,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   791
                    "day": 24 * 60 * 60 * 1000,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   792
                    "month": 30 * 24 * 60 * 60 * 1000,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   793
                    "year": 365.2425 * 24 * 60 * 60 * 1000
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   794
                };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   795
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   796
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   797
                // the allowed tick sizes, after 1 year we use
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   798
                // an integer algorithm
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   799
                var spec = [
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   800
                    [1, "second"], [2, "second"], [5, "second"], [10, "second"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   801
                    [30, "second"], 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   802
                    [1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   803
                    [30, "minute"], 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   804
                    [1, "hour"], [2, "hour"], [4, "hour"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   805
                    [8, "hour"], [12, "hour"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   806
                    [1, "day"], [2, "day"], [3, "day"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   807
                    [0.25, "month"], [0.5, "month"], [1, "month"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   808
                    [2, "month"], [3, "month"], [6, "month"],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   809
                    [1, "year"]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   810
                ];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   811
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   812
                var minSize = 0;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   813
                if (axisOptions.minTickSize != null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   814
                    if (typeof axisOptions.tickSize == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   815
                        minSize = axisOptions.tickSize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   816
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   817
                        minSize = axisOptions.minTickSize[0] * timeUnitSize[axisOptions.minTickSize[1]];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   818
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   819
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   820
                for (i = 0; i < spec.length - 1; ++i)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   821
                    if (delta < (spec[i][0] * timeUnitSize[spec[i][1]]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   822
                                 + spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   823
                       && spec[i][0] * timeUnitSize[spec[i][1]] >= minSize)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   824
                        break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   825
                size = spec[i][0];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   826
                unit = spec[i][1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   827
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   828
                // special-case the possibility of several years
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   829
                if (unit == "year") {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   830
                    magn = Math.pow(10, Math.floor(Math.log(delta / timeUnitSize.year) / Math.LN10));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   831
                    norm = (delta / timeUnitSize.year) / magn;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   832
                    if (norm < 1.5)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   833
                        size = 1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   834
                    else if (norm < 3)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   835
                        size = 2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   836
                    else if (norm < 7.5)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   837
                        size = 5;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   838
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   839
                        size = 10;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   840
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   841
                    size *= magn;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   842
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   843
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   844
                if (axisOptions.tickSize) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   845
                    size = axisOptions.tickSize[0];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   846
                    unit = axisOptions.tickSize[1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   847
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   848
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   849
                generator = function(axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   850
                    var ticks = [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   851
                        tickSize = axis.tickSize[0], unit = axis.tickSize[1],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   852
                        d = new Date(axis.min);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   853
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   854
                    var step = tickSize * timeUnitSize[unit];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   855
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   856
                    if (unit == "second")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   857
                        d.setUTCSeconds(floorInBase(d.getUTCSeconds(), tickSize));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   858
                    if (unit == "minute")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   859
                        d.setUTCMinutes(floorInBase(d.getUTCMinutes(), tickSize));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   860
                    if (unit == "hour")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   861
                        d.setUTCHours(floorInBase(d.getUTCHours(), tickSize));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   862
                    if (unit == "month")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   863
                        d.setUTCMonth(floorInBase(d.getUTCMonth(), tickSize));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   864
                    if (unit == "year")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   865
                        d.setUTCFullYear(floorInBase(d.getUTCFullYear(), tickSize));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   866
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   867
                    // reset smaller components
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   868
                    d.setUTCMilliseconds(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   869
                    if (step >= timeUnitSize.minute)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   870
                        d.setUTCSeconds(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   871
                    if (step >= timeUnitSize.hour)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   872
                        d.setUTCMinutes(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   873
                    if (step >= timeUnitSize.day)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   874
                        d.setUTCHours(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   875
                    if (step >= timeUnitSize.day * 4)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   876
                        d.setUTCDate(1);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   877
                    if (step >= timeUnitSize.year)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   878
                        d.setUTCMonth(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   879
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   880
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   881
                    var carry = 0, v = Number.NaN, prev;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   882
                    do {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   883
                        prev = v;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   884
                        v = d.getTime();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   885
                        ticks.push({ v: v, label: axis.tickFormatter(v, axis) });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   886
                        if (unit == "month") {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   887
                            if (tickSize < 1) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   888
                                // a bit complicated - we'll divide the month
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   889
                                // up but we need to take care of fractions
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   890
                                // so we don't end up in the middle of a day
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   891
                                d.setUTCDate(1);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   892
                                var start = d.getTime();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   893
                                d.setUTCMonth(d.getUTCMonth() + 1);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   894
                                var end = d.getTime();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   895
                                d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   896
                                carry = d.getUTCHours();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   897
                                d.setUTCHours(0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   898
                            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   899
                            else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   900
                                d.setUTCMonth(d.getUTCMonth() + tickSize);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   901
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   902
                        else if (unit == "year") {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   903
                            d.setUTCFullYear(d.getUTCFullYear() + tickSize);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   904
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   905
                        else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   906
                            d.setTime(v + step);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   907
                    } while (v < axis.max && v != prev);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   908
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   909
                    return ticks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   910
                };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   911
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   912
                formatter = function (v, axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   913
                    var d = new Date(v);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   914
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   915
                    // first check global format
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   916
                    if (axisOptions.timeformat != null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   917
                        return $.plot.formatDate(d, axisOptions.timeformat, axisOptions.monthNames);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   918
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   919
                    var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   920
                    var span = axis.max - axis.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   921
                    var suffix = (axisOptions.twelveHourClock) ? " %p" : "";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   922
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   923
                    if (t < timeUnitSize.minute)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   924
                        fmt = "%h:%M:%S" + suffix;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   925
                    else if (t < timeUnitSize.day) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   926
                        if (span < 2 * timeUnitSize.day)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   927
                            fmt = "%h:%M" + suffix;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   928
                        else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   929
                            fmt = "%b %d %h:%M" + suffix;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   930
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   931
                    else if (t < timeUnitSize.month)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   932
                        fmt = "%b %d";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   933
                    else if (t < timeUnitSize.year) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   934
                        if (span < timeUnitSize.year)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   935
                            fmt = "%b";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   936
                        else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   937
                            fmt = "%b %y";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   938
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   939
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   940
                        fmt = "%y";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   941
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   942
                    return $.plot.formatDate(d, fmt, axisOptions.monthNames);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   943
                };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   944
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   945
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   946
                // pretty rounding of base-10 numbers
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   947
                var maxDec = axisOptions.tickDecimals;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   948
                var dec = -Math.floor(Math.log(delta) / Math.LN10);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   949
                if (maxDec != null && dec > maxDec)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   950
                    dec = maxDec;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   951
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   952
                magn = Math.pow(10, -dec);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   953
                norm = delta / magn; // norm is between 1.0 and 10.0
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   954
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   955
                if (norm < 1.5)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   956
                    size = 1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   957
                else if (norm < 3) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   958
                    size = 2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   959
                    // special case for 2.5, requires an extra decimal
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   960
                    if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   961
                        size = 2.5;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   962
                        ++dec;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   963
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   964
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   965
                else if (norm < 7.5)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   966
                    size = 5;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   967
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   968
                    size = 10;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   969
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   970
                size *= magn;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   971
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   972
                if (axisOptions.minTickSize != null && size < axisOptions.minTickSize)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   973
                    size = axisOptions.minTickSize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   974
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   975
                if (axisOptions.tickSize != null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   976
                    size = axisOptions.tickSize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   977
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   978
                axis.tickDecimals = Math.max(0, (maxDec != null) ? maxDec : dec);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   979
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   980
                generator = function (axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   981
                    var ticks = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   982
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   983
                    // spew out all possible ticks
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   984
                    var start = floorInBase(axis.min, axis.tickSize),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   985
                        i = 0, v = Number.NaN, prev;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   986
                    do {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   987
                        prev = v;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   988
                        v = start + i * axis.tickSize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   989
                        ticks.push({ v: v, label: axis.tickFormatter(v, axis) });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   990
                        ++i;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   991
                    } while (v < axis.max && v != prev);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   992
                    return ticks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   993
                };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   994
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   995
                formatter = function (v, axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   996
                    return v.toFixed(axis.tickDecimals);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   997
                };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   998
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
   999
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1000
            axis.tickSize = unit ? [size, unit] : size;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1001
            axis.tickGenerator = generator;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1002
            if ($.isFunction(axisOptions.tickFormatter))
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1003
                axis.tickFormatter = function (v, axis) { return "" + axisOptions.tickFormatter(v, axis); };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1004
            else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1005
                axis.tickFormatter = formatter;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1006
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1007
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1008
        function setTicks(axis, axisOptions) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1009
            axis.ticks = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1010
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1011
            if (!axis.used)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1012
                return;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1013
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1014
            if (axisOptions.ticks == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1015
                axis.ticks = axis.tickGenerator(axis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1016
            else if (typeof axisOptions.ticks == "number") {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1017
                if (axisOptions.ticks > 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1018
                    axis.ticks = axis.tickGenerator(axis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1019
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1020
            else if (axisOptions.ticks) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1021
                var ticks = axisOptions.ticks;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1022
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1023
                if ($.isFunction(ticks))
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1024
                    // generate the ticks
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1025
                    ticks = ticks({ min: axis.min, max: axis.max });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1026
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1027
                // clean up the user-supplied ticks, copy them over
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1028
                var i, v;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1029
                for (i = 0; i < ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1030
                    var label = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1031
                    var t = ticks[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1032
                    if (typeof t == "object") {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1033
                        v = t[0];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1034
                        if (t.length > 1)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1035
                            label = t[1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1036
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1037
                    else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1038
                        v = t;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1039
                    if (label == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1040
                        label = axis.tickFormatter(v, axis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1041
                    axis.ticks[i] = { v: v, label: label };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1042
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1043
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1044
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1045
            if (axisOptions.autoscaleMargin != null && axis.ticks.length > 0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1046
                // snap to ticks
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1047
                if (axisOptions.min == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1048
                    axis.min = Math.min(axis.min, axis.ticks[0].v);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1049
                if (axisOptions.max == null && axis.ticks.length > 1)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1050
                    axis.max = Math.max(axis.max, axis.ticks[axis.ticks.length - 1].v);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1051
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1052
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1053
      
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1054
        function draw() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1055
            ctx.clearRect(0, 0, canvasWidth, canvasHeight);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1056
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1057
            var grid = options.grid;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1058
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1059
            if (grid.show && !grid.aboveData)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1060
                drawGrid();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1061
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1062
            for (var i = 0; i < series.length; ++i)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1063
                drawSeries(series[i]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1064
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1065
            executeHooks(hooks.draw, [ctx]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1066
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1067
            if (grid.show && grid.aboveData)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1068
                drawGrid();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1069
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1070
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1071
        function extractRange(ranges, coord) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1072
            var firstAxis = coord + "axis",
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1073
                secondaryAxis = coord + "2axis",
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1074
                axis, from, to, reverse;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1075
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1076
            if (ranges[firstAxis]) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1077
                axis = axes[firstAxis];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1078
                from = ranges[firstAxis].from;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1079
                to = ranges[firstAxis].to;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1080
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1081
            else if (ranges[secondaryAxis]) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1082
                axis = axes[secondaryAxis];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1083
                from = ranges[secondaryAxis].from;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1084
                to = ranges[secondaryAxis].to;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1085
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1086
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1087
                // backwards-compat stuff - to be removed in future
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1088
                axis = axes[firstAxis];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1089
                from = ranges[coord + "1"];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1090
                to = ranges[coord + "2"];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1091
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1092
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1093
            // auto-reverse as an added bonus
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1094
            if (from != null && to != null && from > to)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1095
                return { from: to, to: from, axis: axis };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1096
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1097
            return { from: from, to: to, axis: axis };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1098
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1099
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1100
        function drawGrid() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1101
            var i;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1102
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1103
            ctx.save();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1104
            ctx.translate(plotOffset.left, plotOffset.top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1105
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1106
            // draw background, if any
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1107
            if (options.grid.backgroundColor) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1108
                ctx.fillStyle = getColorOrGradient(options.grid.backgroundColor, plotHeight, 0, "rgba(255, 255, 255, 0)");
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1109
                ctx.fillRect(0, 0, plotWidth, plotHeight);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1110
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1111
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1112
            // draw markings
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1113
            var markings = options.grid.markings;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1114
            if (markings) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1115
                if ($.isFunction(markings))
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1116
                    // xmin etc. are backwards-compatible, to be removed in future
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1117
                    markings = markings({ xmin: axes.xaxis.min, xmax: axes.xaxis.max, ymin: axes.yaxis.min, ymax: axes.yaxis.max, xaxis: axes.xaxis, yaxis: axes.yaxis, x2axis: axes.x2axis, y2axis: axes.y2axis });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1118
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1119
                for (i = 0; i < markings.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1120
                    var m = markings[i],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1121
                        xrange = extractRange(m, "x"),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1122
                        yrange = extractRange(m, "y");
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1123
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1124
                    // fill in missing
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1125
                    if (xrange.from == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1126
                        xrange.from = xrange.axis.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1127
                    if (xrange.to == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1128
                        xrange.to = xrange.axis.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1129
                    if (yrange.from == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1130
                        yrange.from = yrange.axis.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1131
                    if (yrange.to == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1132
                        yrange.to = yrange.axis.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1133
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1134
                    // clip
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1135
                    if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max ||
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1136
                        yrange.to < yrange.axis.min || yrange.from > yrange.axis.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1137
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1138
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1139
                    xrange.from = Math.max(xrange.from, xrange.axis.min);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1140
                    xrange.to = Math.min(xrange.to, xrange.axis.max);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1141
                    yrange.from = Math.max(yrange.from, yrange.axis.min);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1142
                    yrange.to = Math.min(yrange.to, yrange.axis.max);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1143
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1144
                    if (xrange.from == xrange.to && yrange.from == yrange.to)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1145
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1146
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1147
                    // then draw
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1148
                    xrange.from = xrange.axis.p2c(xrange.from);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1149
                    xrange.to = xrange.axis.p2c(xrange.to);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1150
                    yrange.from = yrange.axis.p2c(yrange.from);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1151
                    yrange.to = yrange.axis.p2c(yrange.to);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1152
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1153
                    if (xrange.from == xrange.to || yrange.from == yrange.to) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1154
                        // draw line
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1155
                        ctx.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1156
                        ctx.strokeStyle = m.color || options.grid.markingsColor;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1157
                        ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1158
                        //ctx.moveTo(Math.floor(xrange.from), yrange.from);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1159
                        //ctx.lineTo(Math.floor(xrange.to), yrange.to);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1160
                        ctx.moveTo(xrange.from, yrange.from);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1161
                        ctx.lineTo(xrange.to, yrange.to);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1162
                        ctx.stroke();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1163
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1164
                    else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1165
                        // fill area
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1166
                        ctx.fillStyle = m.color || options.grid.markingsColor;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1167
                        ctx.fillRect(xrange.from, yrange.to,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1168
                                     xrange.to - xrange.from,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1169
                                     yrange.from - yrange.to);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1170
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1171
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1172
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1173
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1174
            // draw the inner grid
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1175
            ctx.lineWidth = 1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1176
            ctx.strokeStyle = options.grid.tickColor;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1177
            ctx.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1178
            var v, axis = axes.xaxis;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1179
            for (i = 0; i < axis.ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1180
                v = axis.ticks[i].v;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1181
                if (v <= axis.min || v >= axes.xaxis.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1182
                    continue;   // skip those lying on the axes
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1183
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1184
                ctx.moveTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, 0);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1185
                ctx.lineTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, plotHeight);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1186
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1187
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1188
            axis = axes.yaxis;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1189
            for (i = 0; i < axis.ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1190
                v = axis.ticks[i].v;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1191
                if (v <= axis.min || v >= axis.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1192
                    continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1193
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1194
                ctx.moveTo(0, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1195
                ctx.lineTo(plotWidth, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1196
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1197
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1198
            axis = axes.x2axis;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1199
            for (i = 0; i < axis.ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1200
                v = axis.ticks[i].v;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1201
                if (v <= axis.min || v >= axis.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1202
                    continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1203
    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1204
                ctx.moveTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, -5);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1205
                ctx.lineTo(Math.floor(axis.p2c(v)) + ctx.lineWidth/2, 5);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1206
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1207
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1208
            axis = axes.y2axis;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1209
            for (i = 0; i < axis.ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1210
                v = axis.ticks[i].v;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1211
                if (v <= axis.min || v >= axis.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1212
                    continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1213
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1214
                ctx.moveTo(plotWidth-5, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1215
                ctx.lineTo(plotWidth+5, Math.floor(axis.p2c(v)) + ctx.lineWidth/2);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1216
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1217
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1218
            ctx.stroke();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1219
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1220
            if (options.grid.borderWidth) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1221
                // draw border
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1222
                var bw = options.grid.borderWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1223
                ctx.lineWidth = bw;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1224
                ctx.strokeStyle = options.grid.borderColor;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1225
                ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1226
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1227
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1228
            ctx.restore();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1229
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1230
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1231
        function insertLabels() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1232
            placeholder.find(".tickLabels").remove();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1233
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1234
            var html = ['<div class="tickLabels" style="font-size:smaller;color:' + options.grid.color + '">'];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1235
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1236
            function addLabels(axis, labelGenerator) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1237
                for (var i = 0; i < axis.ticks.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1238
                    var tick = axis.ticks[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1239
                    if (!tick.label || tick.v < axis.min || tick.v > axis.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1240
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1241
                    html.push(labelGenerator(tick, axis));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1242
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1243
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1244
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1245
            var margin = options.grid.labelMargin + options.grid.borderWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1246
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1247
            addLabels(axes.xaxis, function (tick, axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1248
                return '<div style="position:absolute;top:' + (plotOffset.top + plotHeight + margin) + 'px;left:' + Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2) + 'px;width:' + axis.labelWidth + 'px;text-align:center" class="tickLabel">' + tick.label + "</div>";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1249
            });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1250
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1251
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1252
            addLabels(axes.yaxis, function (tick, axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1253
                return '<div style="position:absolute;top:' + Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2) + 'px;right:' + (plotOffset.right + plotWidth + margin) + 'px;width:' + axis.labelWidth + 'px;text-align:right" class="tickLabel">' + tick.label + "</div>";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1254
            });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1255
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1256
            addLabels(axes.x2axis, function (tick, axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1257
                return '<div style="position:absolute;bottom:' + (plotOffset.bottom + plotHeight + margin) + 'px;left:' + Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2) + 'px;width:' + axis.labelWidth + 'px;text-align:center" class="tickLabel">' + tick.label + "</div>";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1258
            });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1259
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1260
            addLabels(axes.y2axis, function (tick, axis) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1261
                return '<div style="position:absolute;top:' + Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2) + 'px;left:' + (plotOffset.left + plotWidth + margin) +'px;width:' + axis.labelWidth + 'px;text-align:left" class="tickLabel">' + tick.label + "</div>";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1262
            });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1263
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1264
            html.push('</div>');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1265
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1266
            placeholder.append(html.join(""));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1267
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1268
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1269
        function drawSeries(series) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1270
            if (series.lines.show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1271
                drawSeriesLines(series);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1272
            if (series.bars.show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1273
                drawSeriesBars(series);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1274
            if (series.points.show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1275
                drawSeriesPoints(series);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1276
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1277
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1278
        function drawSeriesLines(series) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1279
            function plotLine(datapoints, xoffset, yoffset, axisx, axisy) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1280
                var points = datapoints.points,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1281
                    ps = datapoints.pointsize,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1282
                    prevx = null, prevy = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1283
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1284
                ctx.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1285
                for (var i = ps; i < points.length; i += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1286
                    var x1 = points[i - ps], y1 = points[i - ps + 1],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1287
                        x2 = points[i], y2 = points[i + 1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1288
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1289
                    if (x1 == null || x2 == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1290
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1291
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1292
                    // clip with ymin
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1293
                    if (y1 <= y2 && y1 < axisy.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1294
                        if (y2 < axisy.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1295
                            continue;   // line segment is outside
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1296
                        // compute new intersection point
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1297
                        x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1298
                        y1 = axisy.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1299
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1300
                    else if (y2 <= y1 && y2 < axisy.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1301
                        if (y1 < axisy.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1302
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1303
                        x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1304
                        y2 = axisy.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1305
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1306
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1307
                    // clip with ymax
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1308
                    if (y1 >= y2 && y1 > axisy.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1309
                        if (y2 > axisy.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1310
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1311
                        x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1312
                        y1 = axisy.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1313
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1314
                    else if (y2 >= y1 && y2 > axisy.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1315
                        if (y1 > axisy.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1316
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1317
                        x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1318
                        y2 = axisy.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1319
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1320
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1321
                    // clip with xmin
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1322
                    if (x1 <= x2 && x1 < axisx.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1323
                        if (x2 < axisx.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1324
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1325
                        y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1326
                        x1 = axisx.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1327
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1328
                    else if (x2 <= x1 && x2 < axisx.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1329
                        if (x1 < axisx.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1330
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1331
                        y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1332
                        x2 = axisx.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1333
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1334
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1335
                    // clip with xmax
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1336
                    if (x1 >= x2 && x1 > axisx.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1337
                        if (x2 > axisx.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1338
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1339
                        y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1340
                        x1 = axisx.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1341
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1342
                    else if (x2 >= x1 && x2 > axisx.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1343
                        if (x1 > axisx.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1344
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1345
                        y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1346
                        x2 = axisx.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1347
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1348
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1349
                    if (x1 != prevx || y1 != prevy)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1350
                        ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1351
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1352
                    prevx = x2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1353
                    prevy = y2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1354
                    ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1355
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1356
                ctx.stroke();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1357
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1358
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1359
            function plotLineArea(datapoints, axisx, axisy) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1360
                var points = datapoints.points,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1361
                    ps = datapoints.pointsize,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1362
                    bottom = Math.min(Math.max(0, axisy.min), axisy.max),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1363
                    top, lastX = 0, areaOpen = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1364
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1365
                for (var i = ps; i < points.length; i += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1366
                    var x1 = points[i - ps], y1 = points[i - ps + 1],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1367
                        x2 = points[i], y2 = points[i + 1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1368
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1369
                    if (areaOpen && x1 != null && x2 == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1370
                        // close area
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1371
                        ctx.lineTo(axisx.p2c(lastX), axisy.p2c(bottom));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1372
                        ctx.fill();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1373
                        areaOpen = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1374
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1375
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1376
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1377
                    if (x1 == null || x2 == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1378
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1379
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1380
                    // clip x values
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1381
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1382
                    // clip with xmin
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1383
                    if (x1 <= x2 && x1 < axisx.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1384
                        if (x2 < axisx.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1385
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1386
                        y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1387
                        x1 = axisx.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1388
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1389
                    else if (x2 <= x1 && x2 < axisx.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1390
                        if (x1 < axisx.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1391
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1392
                        y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1393
                        x2 = axisx.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1394
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1395
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1396
                    // clip with xmax
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1397
                    if (x1 >= x2 && x1 > axisx.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1398
                        if (x2 > axisx.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1399
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1400
                        y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1401
                        x1 = axisx.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1402
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1403
                    else if (x2 >= x1 && x2 > axisx.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1404
                        if (x1 > axisx.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1405
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1406
                        y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1407
                        x2 = axisx.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1408
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1409
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1410
                    if (!areaOpen) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1411
                        // open area
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1412
                        ctx.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1413
                        ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1414
                        areaOpen = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1415
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1416
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1417
                    // now first check the case where both is outside
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1418
                    if (y1 >= axisy.max && y2 >= axisy.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1419
                        ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1420
                        ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1421
                        lastX = x2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1422
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1423
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1424
                    else if (y1 <= axisy.min && y2 <= axisy.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1425
                        ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1426
                        ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1427
                        lastX = x2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1428
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1429
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1430
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1431
                    // else it's a bit more complicated, there might
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1432
                    // be two rectangles and two triangles we need to fill
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1433
                    // in; to find these keep track of the current x values
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1434
                    var x1old = x1, x2old = x2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1435
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1436
                    // and clip the y values, without shortcutting
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1437
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1438
                    // clip with ymin
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1439
                    if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1440
                        x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1441
                        y1 = axisy.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1442
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1443
                    else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1444
                        x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1445
                        y2 = axisy.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1446
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1447
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1448
                    // clip with ymax
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1449
                    if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1450
                        x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1451
                        y1 = axisy.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1452
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1453
                    else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1454
                        x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1455
                        y2 = axisy.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1456
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1457
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1458
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1459
                    // if the x value was changed we got a rectangle
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1460
                    // to fill
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1461
                    if (x1 != x1old) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1462
                        if (y1 <= axisy.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1463
                            top = axisy.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1464
                        else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1465
                            top = axisy.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1466
                        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1467
                        ctx.lineTo(axisx.p2c(x1old), axisy.p2c(top));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1468
                        ctx.lineTo(axisx.p2c(x1), axisy.p2c(top));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1469
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1470
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1471
                    // fill the triangles
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1472
                    ctx.lineTo(axisx.p2c(x1), axisy.p2c(y1));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1473
                    ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1474
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1475
                    // fill the other rectangle if it's there
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1476
                    if (x2 != x2old) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1477
                        if (y2 <= axisy.min)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1478
                            top = axisy.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1479
                        else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1480
                            top = axisy.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1481
                        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1482
                        ctx.lineTo(axisx.p2c(x2), axisy.p2c(top));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1483
                        ctx.lineTo(axisx.p2c(x2old), axisy.p2c(top));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1484
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1485
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1486
                    lastX = Math.max(x2, x2old);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1487
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1488
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1489
                if (areaOpen) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1490
                    ctx.lineTo(axisx.p2c(lastX), axisy.p2c(bottom));
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1491
                    ctx.fill();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1492
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1493
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1494
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1495
            ctx.save();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1496
            ctx.translate(plotOffset.left, plotOffset.top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1497
            ctx.lineJoin = "round";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1498
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1499
            var lw = series.lines.lineWidth,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1500
                sw = series.shadowSize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1501
            // FIXME: consider another form of shadow when filling is turned on
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1502
            if (lw > 0 && sw > 0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1503
                // draw shadow as a thick and thin line with transparency
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1504
                ctx.lineWidth = sw;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1505
                ctx.strokeStyle = "rgba(0,0,0,0.1)";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1506
                // position shadow at angle from the mid of line
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1507
                var angle = Math.PI/18;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1508
                plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1509
                ctx.lineWidth = sw/2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1510
                plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1511
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1512
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1513
            ctx.lineWidth = lw;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1514
            ctx.strokeStyle = series.color;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1515
            var fillStyle = getFillStyle(series.lines, series.color, 0, plotHeight);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1516
            if (fillStyle) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1517
                ctx.fillStyle = fillStyle;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1518
                plotLineArea(series.datapoints, series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1519
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1520
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1521
            if (lw > 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1522
                plotLine(series.datapoints, 0, 0, series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1523
            ctx.restore();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1524
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1525
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1526
        function drawSeriesPoints(series) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1527
            function plotPoints(datapoints, radius, fillStyle, offset, circumference, axisx, axisy) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1528
                var points = datapoints.points, ps = datapoints.pointsize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1529
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1530
                for (var i = 0; i < points.length; i += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1531
                    var x = points[i], y = points[i + 1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1532
                    if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1533
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1534
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1535
                    ctx.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1536
                    ctx.arc(axisx.p2c(x), axisy.p2c(y) + offset, radius, 0, circumference, false);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1537
                    if (fillStyle) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1538
                        ctx.fillStyle = fillStyle;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1539
                        ctx.fill();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1540
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1541
                    ctx.stroke();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1542
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1543
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1544
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1545
            ctx.save();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1546
            ctx.translate(plotOffset.left, plotOffset.top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1547
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1548
            var lw = series.lines.lineWidth,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1549
                sw = series.shadowSize,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1550
                radius = series.points.radius;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1551
            if (lw > 0 && sw > 0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1552
                // draw shadow in two steps
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1553
                var w = sw / 2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1554
                ctx.lineWidth = w;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1555
                ctx.strokeStyle = "rgba(0,0,0,0.1)";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1556
                plotPoints(series.datapoints, radius, null, w + w/2, Math.PI,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1557
                           series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1558
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1559
                ctx.strokeStyle = "rgba(0,0,0,0.2)";
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1560
                plotPoints(series.datapoints, radius, null, w/2, Math.PI,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1561
                           series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1562
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1563
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1564
            ctx.lineWidth = lw;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1565
            ctx.strokeStyle = series.color;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1566
            plotPoints(series.datapoints, radius,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1567
                       getFillStyle(series.points, series.color), 0, 2 * Math.PI,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1568
                       series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1569
            ctx.restore();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1570
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1571
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1572
        function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1573
            var left, right, bottom, top,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1574
                drawLeft, drawRight, drawTop, drawBottom,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1575
                tmp;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1576
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1577
            if (horizontal) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1578
                drawBottom = drawRight = drawTop = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1579
                drawLeft = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1580
                left = b;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1581
                right = x;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1582
                top = y + barLeft;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1583
                bottom = y + barRight;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1584
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1585
                // account for negative bars
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1586
                if (right < left) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1587
                    tmp = right;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1588
                    right = left;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1589
                    left = tmp;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1590
                    drawLeft = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1591
                    drawRight = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1592
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1593
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1594
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1595
                drawLeft = drawRight = drawTop = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1596
                drawBottom = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1597
                left = x + barLeft;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1598
                right = x + barRight;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1599
                bottom = b;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1600
                top = y;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1601
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1602
                // account for negative bars
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1603
                if (top < bottom) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1604
                    tmp = top;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1605
                    top = bottom;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1606
                    bottom = tmp;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1607
                    drawBottom = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1608
                    drawTop = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1609
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1610
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1611
           
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1612
            // clip
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1613
            if (right < axisx.min || left > axisx.max ||
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1614
                top < axisy.min || bottom > axisy.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1615
                return;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1616
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1617
            if (left < axisx.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1618
                left = axisx.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1619
                drawLeft = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1620
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1621
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1622
            if (right > axisx.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1623
                right = axisx.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1624
                drawRight = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1625
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1626
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1627
            if (bottom < axisy.min) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1628
                bottom = axisy.min;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1629
                drawBottom = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1630
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1631
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1632
            if (top > axisy.max) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1633
                top = axisy.max;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1634
                drawTop = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1635
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1636
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1637
            left = axisx.p2c(left);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1638
            bottom = axisy.p2c(bottom);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1639
            right = axisx.p2c(right);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1640
            top = axisy.p2c(top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1641
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1642
            // fill the bar
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1643
            if (fillStyleCallback) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1644
                c.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1645
                c.moveTo(left, bottom);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1646
                c.lineTo(left, top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1647
                c.lineTo(right, top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1648
                c.lineTo(right, bottom);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1649
                c.fillStyle = fillStyleCallback(bottom, top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1650
                c.fill();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1651
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1652
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1653
            // draw outline
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1654
            if (drawLeft || drawRight || drawTop || drawBottom) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1655
                c.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1656
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1657
                // FIXME: inline moveTo is buggy with excanvas
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1658
                c.moveTo(left, bottom + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1659
                if (drawLeft)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1660
                    c.lineTo(left, top + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1661
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1662
                    c.moveTo(left, top + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1663
                if (drawTop)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1664
                    c.lineTo(right, top + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1665
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1666
                    c.moveTo(right, top + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1667
                if (drawRight)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1668
                    c.lineTo(right, bottom + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1669
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1670
                    c.moveTo(right, bottom + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1671
                if (drawBottom)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1672
                    c.lineTo(left, bottom + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1673
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1674
                    c.moveTo(left, bottom + offset);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1675
                c.stroke();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1676
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1677
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1678
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1679
        function drawSeriesBars(series) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1680
            function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1681
                var points = datapoints.points, ps = datapoints.pointsize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1682
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1683
                for (var i = 0; i < points.length; i += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1684
                    if (points[i] == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1685
                        continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1686
                    drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1687
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1688
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1689
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1690
            ctx.save();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1691
            ctx.translate(plotOffset.left, plotOffset.top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1692
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1693
            // FIXME: figure out a way to add shadows (for instance along the right edge)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1694
            ctx.lineWidth = series.bars.lineWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1695
            ctx.strokeStyle = series.color;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1696
            var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1697
            var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1698
            plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1699
            ctx.restore();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1700
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1701
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1702
        function getFillStyle(filloptions, seriesColor, bottom, top) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1703
            var fill = filloptions.fill;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1704
            if (!fill)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1705
                return null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1706
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1707
            if (filloptions.fillColor)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1708
                return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1709
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1710
            var c = $.color.parse(seriesColor);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1711
            c.a = typeof fill == "number" ? fill : 0.4;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1712
            c.normalize();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1713
            return c.toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1714
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1715
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1716
        function insertLegend() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1717
            placeholder.find(".legend").remove();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1718
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1719
            if (!options.legend.show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1720
                return;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1721
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1722
            var fragments = [], rowStarted = false,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1723
                lf = options.legend.labelFormatter, s, label;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1724
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1725
                s = series[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1726
                label = s.label;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1727
                if (!label)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1728
                    continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1729
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1730
                if (i % options.legend.noColumns == 0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1731
                    if (rowStarted)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1732
                        fragments.push('</tr>');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1733
                    fragments.push('<tr>');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1734
                    rowStarted = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1735
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1736
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1737
                if (lf)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1738
                    label = lf(label, s);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1739
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1740
                fragments.push(
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1741
                    '<td class="legendColorBox"><div style="border:1px solid ' + options.legend.labelBoxBorderColor + ';padding:1px"><div style="width:4px;height:0;border:5px solid ' + s.color + ';overflow:hidden"></div></div></td>' +
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1742
                    '<td class="legendLabel">' + label + '</td>');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1743
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1744
            if (rowStarted)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1745
                fragments.push('</tr>');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1746
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1747
            if (fragments.length == 0)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1748
                return;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1749
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1750
            var table = '<table style="font-size:smaller;color:' + options.grid.color + '">' + fragments.join("") + '</table>';
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1751
            if (options.legend.container != null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1752
                $(options.legend.container).html(table);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1753
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1754
                var pos = "",
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1755
                    p = options.legend.position,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1756
                    m = options.legend.margin;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1757
                if (m[0] == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1758
                    m = [m, m];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1759
                if (p.charAt(0) == "n")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1760
                    pos += 'top:' + (m[1] + plotOffset.top) + 'px;';
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1761
                else if (p.charAt(0) == "s")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1762
                    pos += 'bottom:' + (m[1] + plotOffset.bottom) + 'px;';
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1763
                if (p.charAt(1) == "e")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1764
                    pos += 'right:' + (m[0] + plotOffset.right) + 'px;';
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1765
                else if (p.charAt(1) == "w")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1766
                    pos += 'left:' + (m[0] + plotOffset.left) + 'px;';
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1767
                var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(placeholder);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1768
                if (options.legend.backgroundOpacity != 0.0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1769
                    // put in the transparent background
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1770
                    // separately to avoid blended labels and
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1771
                    // label boxes
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1772
                    var c = options.legend.backgroundColor;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1773
                    if (c == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1774
                        c = options.grid.backgroundColor;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1775
                        if (c && typeof c == "string")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1776
                            c = $.color.parse(c);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1777
                        else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1778
                            c = $.color.extract(legend, 'background-color');
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1779
                        c.a = 1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1780
                        c = c.toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1781
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1782
                    var div = legend.children();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1783
                    $('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1784
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1785
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1786
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1787
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1788
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1789
        // interactive features
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1790
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1791
        var highlights = [],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1792
            redrawTimeout = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1793
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1794
        // returns the data item the mouse is over, or null if none is found
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1795
        function findNearbyItem(mouseX, mouseY, seriesFilter) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1796
            var maxDistance = options.grid.mouseActiveRadius,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1797
                smallestDistance = maxDistance * maxDistance + 1,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1798
                item = null, foundPoint = false, i, j;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1799
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1800
            for (i = 0; i < series.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1801
                if (!seriesFilter(series[i]))
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1802
                    continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1803
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1804
                var s = series[i],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1805
                    axisx = s.xaxis,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1806
                    axisy = s.yaxis,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1807
                    points = s.datapoints.points,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1808
                    ps = s.datapoints.pointsize,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1809
                    mx = axisx.c2p(mouseX), // precompute some stuff to make the loop faster
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1810
                    my = axisy.c2p(mouseY),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1811
                    maxx = maxDistance / axisx.scale,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1812
                    maxy = maxDistance / axisy.scale;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1813
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1814
                if (s.lines.show || s.points.show) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1815
                    for (j = 0; j < points.length; j += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1816
                        var x = points[j], y = points[j + 1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1817
                        if (x == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1818
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1819
                        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1820
                        // For points and lines, the cursor must be within a
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1821
                        // certain distance to the data point
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1822
                        if (x - mx > maxx || x - mx < -maxx ||
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1823
                            y - my > maxy || y - my < -maxy)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1824
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1825
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1826
                        // We have to calculate distances in pixels, not in
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1827
                        // data units, because the scales of the axes may be different
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1828
                        var dx = Math.abs(axisx.p2c(x) - mouseX),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1829
                            dy = Math.abs(axisy.p2c(y) - mouseY),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1830
                            dist = dx * dx + dy * dy; // we save the sqrt
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1831
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1832
                        // use <= to ensure last point takes precedence
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1833
                        // (last generally means on top of)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1834
                        if (dist <= smallestDistance) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1835
                            smallestDistance = dist;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1836
                            item = [i, j / ps];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1837
                        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1838
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1839
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1840
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1841
                if (s.bars.show && !item) { // no other point can be nearby
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1842
                    var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1843
                        barRight = barLeft + s.bars.barWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1844
                    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1845
                    for (j = 0; j < points.length; j += ps) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1846
                        var x = points[j], y = points[j + 1], b = points[j + 2];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1847
                        if (x == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1848
                            continue;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1849
  
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1850
                        // for a bar graph, the cursor must be inside the bar
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1851
                        if (series[i].bars.horizontal ? 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1852
                            (mx <= Math.max(b, x) && mx >= Math.min(b, x) && 
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1853
                             my >= y + barLeft && my <= y + barRight) :
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1854
                            (mx >= x + barLeft && mx <= x + barRight &&
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1855
                             my >= Math.min(b, y) && my <= Math.max(b, y)))
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1856
                                item = [i, j / ps];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1857
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1858
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1859
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1860
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1861
            if (item) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1862
                i = item[0];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1863
                j = item[1];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1864
                ps = series[i].datapoints.pointsize;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1865
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1866
                return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1867
                         dataIndex: j,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1868
                         series: series[i],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1869
                         seriesIndex: i };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1870
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1871
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1872
            return null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1873
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1874
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1875
        function onMouseMove(e) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1876
            if (options.grid.hoverable)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1877
                triggerClickHoverEvent("plothover", e,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1878
                                       function (s) { return s["hoverable"] != false; });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1879
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1880
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1881
        function onClick(e) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1882
            triggerClickHoverEvent("plotclick", e,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1883
                                   function (s) { return s["clickable"] != false; });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1884
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1885
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1886
        // trigger click or hover event (they send the same parameters
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1887
        // so we share their code)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1888
        function triggerClickHoverEvent(eventname, event, seriesFilter) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1889
            var offset = eventHolder.offset(),
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1890
                pos = { pageX: event.pageX, pageY: event.pageY },
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1891
                canvasX = event.pageX - offset.left - plotOffset.left,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1892
                canvasY = event.pageY - offset.top - plotOffset.top;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1893
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1894
            if (axes.xaxis.used)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1895
                pos.x = axes.xaxis.c2p(canvasX);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1896
            if (axes.yaxis.used)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1897
                pos.y = axes.yaxis.c2p(canvasY);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1898
            if (axes.x2axis.used)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1899
                pos.x2 = axes.x2axis.c2p(canvasX);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1900
            if (axes.y2axis.used)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1901
                pos.y2 = axes.y2axis.c2p(canvasY);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1902
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1903
            var item = findNearbyItem(canvasX, canvasY, seriesFilter);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1904
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1905
            if (item) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1906
                // fill in mouse pos for any listeners out there
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1907
                item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left + plotOffset.left);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1908
                item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top + plotOffset.top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1909
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1910
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1911
            if (options.grid.autoHighlight) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1912
                // clear auto-highlights
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1913
                for (var i = 0; i < highlights.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1914
                    var h = highlights[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1915
                    if (h.auto == eventname &&
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1916
                        !(item && h.series == item.series && h.point == item.datapoint))
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1917
                        unhighlight(h.series, h.point);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1918
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1919
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1920
                if (item)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1921
                    highlight(item.series, item.datapoint, eventname);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1922
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1923
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1924
            placeholder.trigger(eventname, [ pos, item ]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1925
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1926
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1927
        function triggerRedrawOverlay() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1928
            if (!redrawTimeout)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1929
                redrawTimeout = setTimeout(drawOverlay, 30);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1930
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1931
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1932
        function drawOverlay() {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1933
            redrawTimeout = null;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1934
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1935
            // draw highlights
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1936
            octx.save();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1937
            octx.clearRect(0, 0, canvasWidth, canvasHeight);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1938
            octx.translate(plotOffset.left, plotOffset.top);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1939
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1940
            var i, hi;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1941
            for (i = 0; i < highlights.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1942
                hi = highlights[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1943
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1944
                if (hi.series.bars.show)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1945
                    drawBarHighlight(hi.series, hi.point);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1946
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1947
                    drawPointHighlight(hi.series, hi.point);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1948
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1949
            octx.restore();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1950
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1951
            executeHooks(hooks.drawOverlay, [octx]);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1952
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1953
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1954
        function highlight(s, point, auto) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1955
            if (typeof s == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1956
                s = series[s];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1957
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1958
            if (typeof point == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1959
                point = s.data[point];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1960
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1961
            var i = indexOfHighlight(s, point);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1962
            if (i == -1) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1963
                highlights.push({ series: s, point: point, auto: auto });
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1964
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1965
                triggerRedrawOverlay();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1966
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1967
            else if (!auto)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1968
                highlights[i].auto = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1969
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1970
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1971
        function unhighlight(s, point) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1972
            if (s == null && point == null) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1973
                highlights = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1974
                triggerRedrawOverlay();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1975
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1976
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1977
            if (typeof s == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1978
                s = series[s];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1979
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1980
            if (typeof point == "number")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1981
                point = s.data[point];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1982
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1983
            var i = indexOfHighlight(s, point);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1984
            if (i != -1) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1985
                highlights.splice(i, 1);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1986
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1987
                triggerRedrawOverlay();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1988
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1989
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1990
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1991
        function indexOfHighlight(s, p) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1992
            for (var i = 0; i < highlights.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1993
                var h = highlights[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1994
                if (h.series == s && h.point[0] == p[0]
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1995
                    && h.point[1] == p[1])
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1996
                    return i;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1997
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1998
            return -1;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  1999
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2000
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2001
        function drawPointHighlight(series, point) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2002
            var x = point[0], y = point[1],
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2003
                axisx = series.xaxis, axisy = series.yaxis;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2004
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2005
            if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2006
                return;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2007
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2008
            var pointRadius = series.points.radius + series.points.lineWidth / 2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2009
            octx.lineWidth = pointRadius;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2010
            octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2011
            var radius = 1.5 * pointRadius;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2012
            octx.beginPath();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2013
            octx.arc(axisx.p2c(x), axisy.p2c(y), radius, 0, 2 * Math.PI, false);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2014
            octx.stroke();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2015
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2016
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2017
        function drawBarHighlight(series, point) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2018
            octx.lineWidth = series.bars.lineWidth;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2019
            octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2020
            var fillStyle = $.color.parse(series.color).scale('a', 0.5).toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2021
            var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2022
            drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth,
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2023
                    0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2024
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2025
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2026
        function getColorOrGradient(spec, bottom, top, defaultColor) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2027
            if (typeof spec == "string")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2028
                return spec;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2029
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2030
                // assume this is a gradient spec; IE currently only
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2031
                // supports a simple vertical gradient properly, so that's
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2032
                // what we support too
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2033
                var gradient = ctx.createLinearGradient(0, top, 0, bottom);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2034
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2035
                for (var i = 0, l = spec.colors.length; i < l; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2036
                    var c = spec.colors[i];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2037
                    if (typeof c != "string") {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2038
                        c = $.color.parse(defaultColor).scale('rgb', c.brightness);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2039
                        c.a *= c.opacity;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2040
                        c = c.toString();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2041
                    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2042
                    gradient.addColorStop(i / (l - 1), c);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2043
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2044
                
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2045
                return gradient;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2046
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2047
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2048
    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2049
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2050
    $.plot = function(placeholder, data, options) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2051
        var plot = new Plot($(placeholder), data, options, $.plot.plugins);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2052
        /*var t0 = new Date();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2053
        var t1 = new Date();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2054
        var tstr = "time used (msecs): " + (t1.getTime() - t0.getTime())
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2055
        if (window.console)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2056
            console.log(tstr);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2057
        else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2058
            alert(tstr);*/
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2059
        return plot;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2060
    };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2061
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2062
    $.plot.plugins = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2063
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2064
    // returns a string with the date d formatted according to fmt
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2065
    $.plot.formatDate = function(d, fmt, monthNames) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2066
        var leftPad = function(n) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2067
            n = "" + n;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2068
            return n.length == 1 ? "0" + n : n;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2069
        };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2070
        
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2071
        var r = [];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2072
        var escape = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2073
        var hours = d.getUTCHours();
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2074
        var isAM = hours < 12;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2075
        if (monthNames == null)
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2076
            monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2077
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2078
        if (fmt.search(/%p|%P/) != -1) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2079
            if (hours > 12) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2080
                hours = hours - 12;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2081
            } else if (hours == 0) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2082
                hours = 12;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2083
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2084
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2085
        for (var i = 0; i < fmt.length; ++i) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2086
            var c = fmt.charAt(i);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2087
            
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2088
            if (escape) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2089
                switch (c) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2090
                case 'h': c = "" + hours; break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2091
                case 'H': c = leftPad(hours); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2092
                case 'M': c = leftPad(d.getUTCMinutes()); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2093
                case 'S': c = leftPad(d.getUTCSeconds()); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2094
                case 'd': c = "" + d.getUTCDate(); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2095
                case 'm': c = "" + (d.getUTCMonth() + 1); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2096
                case 'y': c = "" + d.getUTCFullYear(); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2097
                case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2098
                case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2099
                case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2100
                }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2101
                r.push(c);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2102
                escape = false;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2103
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2104
            else {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2105
                if (c == "%")
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2106
                    escape = true;
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2107
                else
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2108
                    r.push(c);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2109
            }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2110
        }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2111
        return r.join("");
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2112
    };
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2113
    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2114
    // round to nearby lower multiple of base
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2115
    function floorInBase(n, base) {
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2116
        return base * Math.floor(n / base);
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2117
    }
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2118
    
476c850f8cd5 [web] Replace minified copy of jquery.flot.js 0.6 with non-minified version
Julien Cristau <julien.cristau@logilab.fr>
parents: 4207
diff changeset
  2119
})(jQuery);