web/data/excanvas.js
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 17 Feb 2010 16:27:01 +0100
branchstable
changeset 4617 9422469b8acb
parent 4220 713434095f0d
child 7621 55b2d0cce69b
permissions -rw-r--r--
oops, should have been in my previous commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
// Copyright 2006 Google Inc.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     2
//
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
// Licensed under the Apache License, Version 2.0 (the "License");
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     4
// you may not use this file except in compliance with the License.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     5
// You may obtain a copy of the License at
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     6
//
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
//   http://www.apache.org/licenses/LICENSE-2.0
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     8
//
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     9
// Unless required by applicable law or agreed to in writing, software
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
// distributed under the License is distributed on an "AS IS" BASIS,
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    12
// See the License for the specific language governing permissions and
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    13
// limitations under the License.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    14
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    15
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
// Known Issues:
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    17
//
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
// * Patterns are not implemented.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
// * Radial gradient are not implemented. The VML version of these look very
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
//   different from the canvas one.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
// * Clipping paths are not implemented.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
// * Coordsize. The width and height attribute have higher priority than the
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
//   width and height style values which isn't correct.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
// * Painting mode isn't implemented.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
// * Canvas width/height should is using content-box by default. IE in
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
//   Quirks mode will draw the canvas using border-box. Either change your
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
//   doctype to HTML5
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
//   (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype)
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
//   or use Box Sizing Behavior from WebFX
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
//   (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    31
// * Non uniform scaling does not correctly scale strokes.
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
// * Optimize. There is always room for speed improvements.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    34
// Only add this code if we do not already have a canvas implementation
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    35
if (!document.createElement('canvas').getContext) {
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    37
(function() {
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
  // alias some functions to make (compiled) code shorter
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
  var m = Math;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
  var mr = m.round;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
  var ms = m.sin;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
  var mc = m.cos;
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    44
  var abs = m.abs;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    45
  var sqrt = m.sqrt;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
  // this is used for sub pixel precision
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    48
  var Z = 10;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    49
  var Z2 = Z / 2;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    51
  /**
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    52
   * This funtion is assigned to the <canvas> elements as element.getContext().
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    53
   * @this {HTMLElement}
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    54
   * @return {CanvasRenderingContext2D_}
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    55
   */
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    56
  function getContext() {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    57
    return this.context_ ||
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    58
        (this.context_ = new CanvasRenderingContext2D_(this));
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    59
  }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    60
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    61
  var slice = Array.prototype.slice;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    62
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    63
  /**
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    64
   * Binds a function to an object. The returned function will always use the
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    65
   * passed in {@code obj} as {@code this}.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    66
   *
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    67
   * Example:
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    68
   *
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    69
   *   g = bind(f, obj, a, b)
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    70
   *   g(c, d) // will do f.call(obj, a, b, c, d)
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    71
   *
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    72
   * @param {Function} f The function to bind the object to
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    73
   * @param {Object} obj The object that should act as this when the function
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    74
   *     is called
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    75
   * @param {*} var_args Rest arguments that will be used as the initial
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    76
   *     arguments when the function is called
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    77
   * @return {Function} A new function that has bound this
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    78
   */
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    79
  function bind(f, obj, var_args) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    80
    var a = slice.call(arguments, 2);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    81
    return function() {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    82
      return f.apply(obj, a.concat(slice.call(arguments)));
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    83
    };
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    84
  }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    85
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    86
  var G_vmlCanvasManager_ = {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    87
    init: function(opt_doc) {
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    88
      if (/MSIE/.test(navigator.userAgent) && !window.opera) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    89
        var doc = opt_doc || document;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    90
        // Create a dummy element so that IE will allow canvas elements to be
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    91
        // recognized.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    92
        doc.createElement('canvas');
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    93
        doc.attachEvent('onreadystatechange', bind(this.init_, this, doc));
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    94
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    95
    },
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    97
    init_: function(doc) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    98
      // create xmlns
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    99
      if (!doc.namespaces['g_vml_']) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   100
        doc.namespaces.add('g_vml_', 'urn:schemas-microsoft-com:vml',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   101
                           '#default#VML');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   103
      }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   104
      if (!doc.namespaces['g_o_']) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   105
        doc.namespaces.add('g_o_', 'urn:schemas-microsoft-com:office:office',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   106
                           '#default#VML');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   107
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   108
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   109
      // Setup default CSS.  Only add one style sheet per document
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   110
      if (!doc.styleSheets['ex_canvas_']) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   111
        var ss = doc.createStyleSheet();
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   112
        ss.owningElement.id = 'ex_canvas_';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   113
        ss.cssText = 'canvas{display:inline-block;overflow:hidden;' +
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   114
            // default size is 300x150 in Gecko and Opera
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   115
            'text-align:left;width:300px;height:150px}' +
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   116
            'g_vml_\\:*{behavior:url(#default#VML)}' +
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   117
            'g_o_\\:*{behavior:url(#default#VML)}';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   118
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   119
      }
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   120
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   121
      // find all canvas elements
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   122
      var els = doc.getElementsByTagName('canvas');
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   123
      for (var i = 0; i < els.length; i++) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   124
        this.initElement(els[i]);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   125
      }
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
    },
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   127
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   128
    /**
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
     * Public initializes a canvas element so that it can be used as canvas
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   130
     * element from now on. This is called automatically before the page is
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   131
     * loaded but if you are creating elements using createElement you need to
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   132
     * make sure this is called on the element.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   133
     * @param {HTMLElement} el The canvas element to initialize.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   134
     * @return {HTMLElement} the element that was created.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   135
     */
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   136
    initElement: function(el) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   137
      if (!el.getContext) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   138
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   139
        el.getContext = getContext;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   140
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   141
        // Remove fallback content. There is no way to hide text nodes so we
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   142
        // just remove all childNodes. We could hide all elements and remove
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   143
        // text nodes but who really cares about the fallback content.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   144
        el.innerHTML = '';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   145
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   146
        // do not use inline function because that will leak memory
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   147
        el.attachEvent('onpropertychange', onPropertyChange);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   148
        el.attachEvent('onresize', onResize);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   150
        var attrs = el.attributes;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   151
        if (attrs.width && attrs.width.specified) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   152
          // TODO: use runtimeStyle and coordsize
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   153
          // el.getContext().setWidth_(attrs.width.nodeValue);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   154
          el.style.width = attrs.width.nodeValue + 'px';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   155
        } else {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   156
          el.width = el.clientWidth;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   157
        }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   158
        if (attrs.height && attrs.height.specified) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   159
          // TODO: use runtimeStyle and coordsize
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   160
          // el.getContext().setHeight_(attrs.height.nodeValue);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   161
          el.style.height = attrs.height.nodeValue + 'px';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   162
        } else {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   163
          el.height = el.clientHeight;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   164
        }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   165
        //el.getContext().setCoordsize_()
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   166
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   167
      return el;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   168
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   169
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   170
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   171
  function onPropertyChange(e) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   172
    var el = e.srcElement;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   173
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   174
    switch (e.propertyName) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   175
      case 'width':
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   176
        el.style.width = el.attributes.width.nodeValue + 'px';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   177
        el.getContext().clearRect();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   178
        break;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   179
      case 'height':
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   180
        el.style.height = el.attributes.height.nodeValue + 'px';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   181
        el.getContext().clearRect();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   182
        break;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   183
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   184
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   185
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   186
  function onResize(e) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   187
    var el = e.srcElement;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   188
    if (el.firstChild) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   189
      el.firstChild.style.width =  el.clientWidth + 'px';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   190
      el.firstChild.style.height = el.clientHeight + 'px';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   191
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   192
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   193
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   194
  G_vmlCanvasManager_.init();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   195
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   196
  // precompute "00" to "FF"
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   197
  var dec2hex = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   198
  for (var i = 0; i < 16; i++) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   199
    for (var j = 0; j < 16; j++) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   200
      dec2hex[i * 16 + j] = i.toString(16) + j.toString(16);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   201
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   202
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   203
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   204
  function createMatrixIdentity() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   205
    return [
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   206
      [1, 0, 0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   207
      [0, 1, 0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   208
      [0, 0, 1]
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   209
    ];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   210
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   211
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   212
  function matrixMultiply(m1, m2) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   213
    var result = createMatrixIdentity();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   214
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   215
    for (var x = 0; x < 3; x++) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   216
      for (var y = 0; y < 3; y++) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   217
        var sum = 0;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   218
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   219
        for (var z = 0; z < 3; z++) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   220
          sum += m1[x][z] * m2[z][y];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   221
        }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   222
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   223
        result[x][y] = sum;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   224
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   225
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   226
    return result;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   227
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   228
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   229
  function copyState(o1, o2) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   230
    o2.fillStyle     = o1.fillStyle;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   231
    o2.lineCap       = o1.lineCap;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   232
    o2.lineJoin      = o1.lineJoin;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   233
    o2.lineWidth     = o1.lineWidth;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   234
    o2.miterLimit    = o1.miterLimit;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   235
    o2.shadowBlur    = o1.shadowBlur;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   236
    o2.shadowColor   = o1.shadowColor;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   237
    o2.shadowOffsetX = o1.shadowOffsetX;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   238
    o2.shadowOffsetY = o1.shadowOffsetY;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   239
    o2.strokeStyle   = o1.strokeStyle;
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   240
    o2.globalAlpha   = o1.globalAlpha;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   241
    o2.arcScaleX_    = o1.arcScaleX_;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   242
    o2.arcScaleY_    = o1.arcScaleY_;
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   243
    o2.lineScale_    = o1.lineScale_;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   244
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   245
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   246
  function processStyle(styleString) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   247
    var str, alpha = 1;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   248
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   249
    styleString = String(styleString);
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   250
    if (styleString.substring(0, 3) == 'rgb') {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   251
      var start = styleString.indexOf('(', 3);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   252
      var end = styleString.indexOf(')', start + 1);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   253
      var guts = styleString.substring(start + 1, end).split(',');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   254
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   255
      str = '#';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   256
      for (var i = 0; i < 3; i++) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   257
        str += dec2hex[Number(guts[i])];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   258
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   259
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   260
      if (guts.length == 4 && styleString.substr(3, 1) == 'a') {
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   261
        alpha = guts[3];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   262
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   263
    } else {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   264
      str = styleString;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   265
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   266
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   267
    return {color: str, alpha: alpha};
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   268
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   269
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   270
  function processLineCap(lineCap) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   271
    switch (lineCap) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   272
      case 'butt':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   273
        return 'flat';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   274
      case 'round':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   275
        return 'round';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   276
      case 'square':
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   277
      default:
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   278
        return 'square';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   279
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   280
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   281
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   282
  /**
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   283
   * This class implements CanvasRenderingContext2D interface as described by
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   284
   * the WHATWG.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   285
   * @param {HTMLElement} surfaceElement The element that the 2D context should
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   286
   * be associated with
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   287
   */
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   288
  function CanvasRenderingContext2D_(surfaceElement) {
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   289
    this.m_ = createMatrixIdentity();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   290
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   291
    this.mStack_ = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   292
    this.aStack_ = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   293
    this.currentPath_ = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   294
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   295
    // Canvas context properties
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   296
    this.strokeStyle = '#000';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   297
    this.fillStyle = '#000';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   298
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   299
    this.lineWidth = 1;
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   300
    this.lineJoin = 'miter';
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   301
    this.lineCap = 'butt';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   302
    this.miterLimit = Z * 1;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   303
    this.globalAlpha = 1;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   304
    this.canvas = surfaceElement;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   305
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   306
    var el = surfaceElement.ownerDocument.createElement('div');
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   307
    el.style.width =  surfaceElement.clientWidth + 'px';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   308
    el.style.height = surfaceElement.clientHeight + 'px';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   309
    el.style.overflow = 'hidden';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   310
    el.style.position = 'absolute';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   311
    surfaceElement.appendChild(el);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   312
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   313
    this.element_ = el;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   314
    this.arcScaleX_ = 1;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   315
    this.arcScaleY_ = 1;
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   316
    this.lineScale_ = 1;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   317
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   318
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   319
  var contextPrototype = CanvasRenderingContext2D_.prototype;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   320
  contextPrototype.clearRect = function() {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   321
    this.element_.innerHTML = '';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   322
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   323
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   324
  contextPrototype.beginPath = function() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   325
    // TODO: Branch current matrix so that save/restore has no effect
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   326
    //       as per safari docs.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   327
    this.currentPath_ = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   328
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   329
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   330
  contextPrototype.moveTo = function(aX, aY) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   331
    var p = this.getCoords_(aX, aY);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   332
    this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y});
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   333
    this.currentX_ = p.x;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   334
    this.currentY_ = p.y;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   335
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   336
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   337
  contextPrototype.lineTo = function(aX, aY) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   338
    var p = this.getCoords_(aX, aY);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   339
    this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y});
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   340
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   341
    this.currentX_ = p.x;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   342
    this.currentY_ = p.y;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   343
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   344
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   345
  contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   346
                                            aCP2x, aCP2y,
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   347
                                            aX, aY) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   348
    var p = this.getCoords_(aX, aY);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   349
    var cp1 = this.getCoords_(aCP1x, aCP1y);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   350
    var cp2 = this.getCoords_(aCP2x, aCP2y);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   351
    bezierCurveTo(this, cp1, cp2, p);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   352
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   353
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   354
  // Helper function that takes the already fixed cordinates.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   355
  function bezierCurveTo(self, cp1, cp2, p) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   356
    self.currentPath_.push({
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   357
      type: 'bezierCurveTo',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   358
      cp1x: cp1.x,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   359
      cp1y: cp1.y,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   360
      cp2x: cp2.x,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   361
      cp2y: cp2.y,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   362
      x: p.x,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   363
      y: p.y
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   364
    });
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   365
    self.currentX_ = p.x;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   366
    self.currentY_ = p.y;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   367
  }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   368
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   369
  contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   370
    // the following is lifted almost directly from
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   371
    // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   372
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   373
    var cp = this.getCoords_(aCPx, aCPy);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   374
    var p = this.getCoords_(aX, aY);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   375
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   376
    var cp1 = {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   377
      x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_),
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   378
      y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_)
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   379
    };
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   380
    var cp2 = {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   381
      x: cp1.x + (p.x - this.currentX_) / 3.0,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   382
      y: cp1.y + (p.y - this.currentY_) / 3.0
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   383
    };
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   384
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   385
    bezierCurveTo(this, cp1, cp2, p);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   386
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   387
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   388
  contextPrototype.arc = function(aX, aY, aRadius,
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   389
                                  aStartAngle, aEndAngle, aClockwise) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   390
    aRadius *= Z;
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   391
    var arcType = aClockwise ? 'at' : 'wa';
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   392
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   393
    var xStart = aX + mc(aStartAngle) * aRadius - Z2;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   394
    var yStart = aY + ms(aStartAngle) * aRadius - Z2;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   395
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   396
    var xEnd = aX + mc(aEndAngle) * aRadius - Z2;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   397
    var yEnd = aY + ms(aEndAngle) * aRadius - Z2;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   398
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   399
    // IE won't render arches drawn counter clockwise if xStart == xEnd.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   400
    if (xStart == xEnd && !aClockwise) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   401
      xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   402
                       // that can be represented in binary
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   403
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   404
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   405
    var p = this.getCoords_(aX, aY);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   406
    var pStart = this.getCoords_(xStart, yStart);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   407
    var pEnd = this.getCoords_(xEnd, yEnd);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   408
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   409
    this.currentPath_.push({type: arcType,
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   410
                           x: p.x,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   411
                           y: p.y,
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   412
                           radius: aRadius,
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   413
                           xStart: pStart.x,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   414
                           yStart: pStart.y,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   415
                           xEnd: pEnd.x,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   416
                           yEnd: pEnd.y});
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   417
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   418
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   419
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   420
  contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   421
    this.moveTo(aX, aY);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   422
    this.lineTo(aX + aWidth, aY);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   423
    this.lineTo(aX + aWidth, aY + aHeight);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   424
    this.lineTo(aX, aY + aHeight);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   425
    this.closePath();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   426
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   427
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   428
  contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   429
    var oldPath = this.currentPath_;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   430
    this.beginPath();
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   431
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   432
    this.moveTo(aX, aY);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   433
    this.lineTo(aX + aWidth, aY);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   434
    this.lineTo(aX + aWidth, aY + aHeight);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   435
    this.lineTo(aX, aY + aHeight);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   436
    this.closePath();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   437
    this.stroke();
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   438
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   439
    this.currentPath_ = oldPath;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   440
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   441
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   442
  contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   443
    var oldPath = this.currentPath_;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   444
    this.beginPath();
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   445
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   446
    this.moveTo(aX, aY);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   447
    this.lineTo(aX + aWidth, aY);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   448
    this.lineTo(aX + aWidth, aY + aHeight);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   449
    this.lineTo(aX, aY + aHeight);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   450
    this.closePath();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   451
    this.fill();
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   452
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   453
    this.currentPath_ = oldPath;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   454
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   455
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   456
  contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   457
    var gradient = new CanvasGradient_('gradient');
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   458
    gradient.x0_ = aX0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   459
    gradient.y0_ = aY0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   460
    gradient.x1_ = aX1;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   461
    gradient.y1_ = aY1;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   462
    return gradient;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   463
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   464
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   465
  contextPrototype.createRadialGradient = function(aX0, aY0, aR0,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   466
                                                   aX1, aY1, aR1) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   467
    var gradient = new CanvasGradient_('gradientradial');
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   468
    gradient.x0_ = aX0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   469
    gradient.y0_ = aY0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   470
    gradient.r0_ = aR0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   471
    gradient.x1_ = aX1;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   472
    gradient.y1_ = aY1;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   473
    gradient.r1_ = aR1;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   474
    return gradient;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   475
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   476
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   477
  contextPrototype.drawImage = function(image, var_args) {
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   478
    var dx, dy, dw, dh, sx, sy, sw, sh;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   479
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   480
    // to find the original width we overide the width and height
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   481
    var oldRuntimeWidth = image.runtimeStyle.width;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   482
    var oldRuntimeHeight = image.runtimeStyle.height;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   483
    image.runtimeStyle.width = 'auto';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   484
    image.runtimeStyle.height = 'auto';
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   485
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   486
    // get the original size
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   487
    var w = image.width;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   488
    var h = image.height;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   489
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   490
    // and remove overides
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   491
    image.runtimeStyle.width = oldRuntimeWidth;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   492
    image.runtimeStyle.height = oldRuntimeHeight;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   493
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   494
    if (arguments.length == 3) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   495
      dx = arguments[1];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   496
      dy = arguments[2];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   497
      sx = sy = 0;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   498
      sw = dw = w;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   499
      sh = dh = h;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   500
    } else if (arguments.length == 5) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   501
      dx = arguments[1];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   502
      dy = arguments[2];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   503
      dw = arguments[3];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   504
      dh = arguments[4];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   505
      sx = sy = 0;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   506
      sw = w;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   507
      sh = h;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   508
    } else if (arguments.length == 9) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   509
      sx = arguments[1];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   510
      sy = arguments[2];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   511
      sw = arguments[3];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   512
      sh = arguments[4];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   513
      dx = arguments[5];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   514
      dy = arguments[6];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   515
      dw = arguments[7];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   516
      dh = arguments[8];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   517
    } else {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   518
      throw Error('Invalid number of arguments');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   519
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   520
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   521
    var d = this.getCoords_(dx, dy);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   522
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   523
    var w2 = sw / 2;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   524
    var h2 = sh / 2;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   525
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   526
    var vmlStr = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   527
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   528
    var W = 10;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   529
    var H = 10;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   530
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   531
    // For some reason that I've now forgotten, using divs didn't work
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   532
    vmlStr.push(' <g_vml_:group',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   533
                ' coordsize="', Z * W, ',', Z * H, '"',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   534
                ' coordorigin="0,0"' ,
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   535
                ' style="width:', W, 'px;height:', H, 'px;position:absolute;');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   536
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   537
    // If filters are necessary (rotation exists), create them
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   538
    // filters are bog-slow, so only create them if abbsolutely necessary
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   539
    // The following check doesn't account for skews (which don't exist
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   540
    // in the canvas spec (yet) anyway.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   541
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   542
    if (this.m_[0][0] != 1 || this.m_[0][1]) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   543
      var filter = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   544
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   545
      // Note the 12/21 reversal
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   546
      filter.push('M11=', this.m_[0][0], ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   547
                  'M12=', this.m_[1][0], ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   548
                  'M21=', this.m_[0][1], ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   549
                  'M22=', this.m_[1][1], ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   550
                  'Dx=', mr(d.x / Z), ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   551
                  'Dy=', mr(d.y / Z), '');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   552
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   553
      // Bounding box calculation (need to minimize displayed area so that
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   554
      // filters don't waste time on unused pixels.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   555
      var max = d;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   556
      var c2 = this.getCoords_(dx + dw, dy);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   557
      var c3 = this.getCoords_(dx, dy + dh);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   558
      var c4 = this.getCoords_(dx + dw, dy + dh);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   559
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   560
      max.x = m.max(max.x, c2.x, c3.x, c4.x);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   561
      max.y = m.max(max.y, c2.y, c3.y, c4.y);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   562
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   563
      vmlStr.push('padding:0 ', mr(max.x / Z), 'px ', mr(max.y / Z),
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   564
                  'px 0;filter:progid:DXImageTransform.Microsoft.Matrix(',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   565
                  filter.join(''), ", sizingmethod='clip');")
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   566
    } else {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   567
      vmlStr.push('top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px;');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   568
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   569
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   570
    vmlStr.push(' ">' ,
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   571
                '<g_vml_:image src="', image.src, '"',
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   572
                ' style="width:', Z * dw, 'px;',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   573
                ' height:', Z * dh, 'px;"',
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   574
                ' cropleft="', sx / w, '"',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   575
                ' croptop="', sy / h, '"',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   576
                ' cropright="', (w - sx - sw) / w, '"',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   577
                ' cropbottom="', (h - sy - sh) / h, '"',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   578
                ' />',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   579
                '</g_vml_:group>');
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   580
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   581
    this.element_.insertAdjacentHTML('BeforeEnd',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   582
                                    vmlStr.join(''));
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   583
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   584
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   585
  contextPrototype.stroke = function(aFill) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   586
    var lineStr = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   587
    var lineOpen = false;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   588
    var a = processStyle(aFill ? this.fillStyle : this.strokeStyle);
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   589
    var color = a.color;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   590
    var opacity = a.alpha * this.globalAlpha;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   591
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   592
    var W = 10;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   593
    var H = 10;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   594
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   595
    lineStr.push('<g_vml_:shape',
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   596
                 ' filled="', !!aFill, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   597
                 ' style="position:absolute;width:', W, 'px;height:', H, 'px;"',
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   598
                 ' coordorigin="0 0" coordsize="', Z * W, ' ', Z * H, '"',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   599
                 ' stroked="', !aFill, '"',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   600
                 ' path="');
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   601
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   602
    var newSeq = false;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   603
    var min = {x: null, y: null};
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   604
    var max = {x: null, y: null};
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   605
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   606
    for (var i = 0; i < this.currentPath_.length; i++) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   607
      var p = this.currentPath_[i];
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   608
      var c;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   609
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   610
      switch (p.type) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   611
        case 'moveTo':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   612
          c = p;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   613
          lineStr.push(' m ', mr(p.x), ',', mr(p.y));
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   614
          break;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   615
        case 'lineTo':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   616
          lineStr.push(' l ', mr(p.x), ',', mr(p.y));
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   617
          break;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   618
        case 'close':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   619
          lineStr.push(' x ');
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   620
          p = null;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   621
          break;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   622
        case 'bezierCurveTo':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   623
          lineStr.push(' c ',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   624
                       mr(p.cp1x), ',', mr(p.cp1y), ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   625
                       mr(p.cp2x), ',', mr(p.cp2y), ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   626
                       mr(p.x), ',', mr(p.y));
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   627
          break;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   628
        case 'at':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   629
        case 'wa':
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   630
          lineStr.push(' ', p.type, ' ',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   631
                       mr(p.x - this.arcScaleX_ * p.radius), ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   632
                       mr(p.y - this.arcScaleY_ * p.radius), ' ',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   633
                       mr(p.x + this.arcScaleX_ * p.radius), ',',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   634
                       mr(p.y + this.arcScaleY_ * p.radius), ' ',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   635
                       mr(p.xStart), ',', mr(p.yStart), ' ',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   636
                       mr(p.xEnd), ',', mr(p.yEnd));
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   637
          break;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   638
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   639
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   640
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   641
      // TODO: Following is broken for curves due to
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   642
      //       move to proper paths.
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   643
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   644
      // Figure out dimensions so we can do gradient fills
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   645
      // properly
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   646
      if (p) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   647
        if (min.x == null || p.x < min.x) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   648
          min.x = p.x;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   649
        }
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   650
        if (max.x == null || p.x > max.x) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   651
          max.x = p.x;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   652
        }
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   653
        if (min.y == null || p.y < min.y) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   654
          min.y = p.y;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   655
        }
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   656
        if (max.y == null || p.y > max.y) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   657
          max.y = p.y;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   658
        }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   659
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   660
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   661
    lineStr.push(' ">');
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   662
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   663
    if (!aFill) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   664
      var lineWidth = this.lineScale_ * this.lineWidth;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   665
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   666
      // VML cannot correctly render a line if the width is less than 1px.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   667
      // In that case, we dilute the color to make the line look thinner.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   668
      if (lineWidth < 1) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   669
        opacity *= lineWidth;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   670
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   671
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   672
      lineStr.push(
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   673
        '<g_vml_:stroke',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   674
        ' opacity="', opacity, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   675
        ' joinstyle="', this.lineJoin, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   676
        ' miterlimit="', this.miterLimit, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   677
        ' endcap="', processLineCap(this.lineCap), '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   678
        ' weight="', lineWidth, 'px"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   679
        ' color="', color, '" />'
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   680
      );
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   681
    } else if (typeof this.fillStyle == 'object') {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   682
      var fillStyle = this.fillStyle;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   683
      var angle = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   684
      var focus = {x: 0, y: 0};
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   685
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   686
      // additional offset
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   687
      var shift = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   688
      // scale factor for offset
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   689
      var expansion = 1;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   690
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   691
      if (fillStyle.type_ == 'gradient') {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   692
        var x0 = fillStyle.x0_ / this.arcScaleX_;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   693
        var y0 = fillStyle.y0_ / this.arcScaleY_;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   694
        var x1 = fillStyle.x1_ / this.arcScaleX_;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   695
        var y1 = fillStyle.y1_ / this.arcScaleY_;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   696
        var p0 = this.getCoords_(x0, y0);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   697
        var p1 = this.getCoords_(x1, y1);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   698
        var dx = p1.x - p0.x;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   699
        var dy = p1.y - p0.y;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   700
        angle = Math.atan2(dx, dy) * 180 / Math.PI;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   701
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   702
        // The angle should be a non-negative number.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   703
        if (angle < 0) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   704
          angle += 360;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   705
        }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   706
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   707
        // Very small angles produce an unexpected result because they are
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   708
        // converted to a scientific notation string.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   709
        if (angle < 1e-6) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   710
          angle = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   711
        }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   712
      } else {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   713
        var p0 = this.getCoords_(fillStyle.x0_, fillStyle.y0_);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   714
        var width  = max.x - min.x;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   715
        var height = max.y - min.y;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   716
        focus = {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   717
          x: (p0.x - min.x) / width,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   718
          y: (p0.y - min.y) / height
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   719
        };
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   720
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   721
        width  /= this.arcScaleX_ * Z;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   722
        height /= this.arcScaleY_ * Z;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   723
        var dimension = m.max(width, height);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   724
        shift = 2 * fillStyle.r0_ / dimension;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   725
        expansion = 2 * fillStyle.r1_ / dimension - shift;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   726
      }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   727
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   728
      // We need to sort the color stops in ascending order by offset,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   729
      // otherwise IE won't interpret it correctly.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   730
      var stops = fillStyle.colors_;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   731
      stops.sort(function(cs1, cs2) {
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   732
        return cs1.offset - cs2.offset;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   733
      });
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   734
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   735
      var length = stops.length;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   736
      var color1 = stops[0].color;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   737
      var color2 = stops[length - 1].color;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   738
      var opacity1 = stops[0].alpha * this.globalAlpha;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   739
      var opacity2 = stops[length - 1].alpha * this.globalAlpha;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   740
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   741
      var colors = [];
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   742
      for (var i = 0; i < length; i++) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   743
        var stop = stops[i];
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   744
        colors.push(stop.offset * expansion + shift + ' ' + stop.color);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   745
      }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   746
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   747
      // When colors attribute is used, the meanings of opacity and o:opacity2
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   748
      // are reversed.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   749
      lineStr.push('<g_vml_:fill type="', fillStyle.type_, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   750
                   ' method="none" focus="100%"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   751
                   ' color="', color1, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   752
                   ' color2="', color2, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   753
                   ' colors="', colors.join(','), '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   754
                   ' opacity="', opacity2, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   755
                   ' g_o_:opacity2="', opacity1, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   756
                   ' angle="', angle, '"',
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   757
                   ' focusposition="', focus.x, ',', focus.y, '" />');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   758
    } else {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   759
      lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   760
                   '" />');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   761
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   762
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   763
    lineStr.push('</g_vml_:shape>');
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   764
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   765
    this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   766
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   767
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   768
  contextPrototype.fill = function() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   769
    this.stroke(true);
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   770
  }
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   771
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   772
  contextPrototype.closePath = function() {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   773
    this.currentPath_.push({type: 'close'});
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   774
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   775
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   776
  /**
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   777
   * @private
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   778
   */
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   779
  contextPrototype.getCoords_ = function(aX, aY) {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   780
    var m = this.m_;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   781
    return {
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   782
      x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   783
      y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   784
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   785
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   786
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   787
  contextPrototype.save = function() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   788
    var o = {};
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   789
    copyState(this, o);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   790
    this.aStack_.push(o);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   791
    this.mStack_.push(this.m_);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   792
    this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   793
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   794
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   795
  contextPrototype.restore = function() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   796
    copyState(this.aStack_.pop(), this);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   797
    this.m_ = this.mStack_.pop();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   798
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   799
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   800
  function matrixIsFinite(m) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   801
    for (var j = 0; j < 3; j++) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   802
      for (var k = 0; k < 2; k++) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   803
        if (!isFinite(m[j][k]) || isNaN(m[j][k])) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   804
          return false;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   805
        }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   806
      }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   807
    }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   808
    return true;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   809
  }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   810
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   811
  function setM(ctx, m, updateLineScale) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   812
    if (!matrixIsFinite(m)) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   813
      return;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   814
    }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   815
    ctx.m_ = m;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   816
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   817
    if (updateLineScale) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   818
      // Get the line scale.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   819
      // Determinant of this.m_ means how much the area is enlarged by the
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   820
      // transformation. So its square root can be used as a scale factor
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   821
      // for width.
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   822
      var det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   823
      ctx.lineScale_ = sqrt(abs(det));
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   824
    }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   825
  }
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   826
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   827
  contextPrototype.translate = function(aX, aY) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   828
    var m1 = [
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   829
      [1,  0,  0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   830
      [0,  1,  0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   831
      [aX, aY, 1]
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   832
    ];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   833
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   834
    setM(this, matrixMultiply(m1, this.m_), false);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   835
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   836
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   837
  contextPrototype.rotate = function(aRot) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   838
    var c = mc(aRot);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   839
    var s = ms(aRot);
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   840
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   841
    var m1 = [
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   842
      [c,  s, 0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   843
      [-s, c, 0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   844
      [0,  0, 1]
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   845
    ];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   846
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   847
    setM(this, matrixMultiply(m1, this.m_), false);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   848
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   849
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   850
  contextPrototype.scale = function(aX, aY) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   851
    this.arcScaleX_ *= aX;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   852
    this.arcScaleY_ *= aY;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   853
    var m1 = [
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   854
      [aX, 0,  0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   855
      [0,  aY, 0],
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   856
      [0,  0,  1]
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   857
    ];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   858
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   859
    setM(this, matrixMultiply(m1, this.m_), true);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   860
  };
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   861
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   862
  contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   863
    var m1 = [
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   864
      [m11, m12, 0],
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   865
      [m21, m22, 0],
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   866
      [dx,  dy,  1]
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   867
    ];
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   868
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   869
    setM(this, matrixMultiply(m1, this.m_), true);
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   870
  };
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   871
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   872
  contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) {
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   873
    var m = [
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   874
      [m11, m12, 0],
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   875
      [m21, m22, 0],
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   876
      [dx,  dy,  1]
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   877
    ];
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   878
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   879
    setM(this, m, true);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   880
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   881
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   882
  /******** STUBS ********/
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   883
  contextPrototype.clip = function() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   884
    // TODO: Implement
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   885
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   886
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   887
  contextPrototype.arcTo = function() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   888
    // TODO: Implement
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   889
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   890
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   891
  contextPrototype.createPattern = function() {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   892
    return new CanvasPattern_;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   893
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   894
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   895
  // Gradient / Pattern Stubs
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   896
  function CanvasGradient_(aType) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   897
    this.type_ = aType;
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   898
    this.x0_ = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   899
    this.y0_ = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   900
    this.r0_ = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   901
    this.x1_ = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   902
    this.y1_ = 0;
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   903
    this.r1_ = 0;
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   904
    this.colors_ = [];
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   905
  }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   906
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   907
  CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   908
    aColor = processStyle(aColor);
4220
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   909
    this.colors_.push({offset: aOffset,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   910
                       color: aColor.color,
713434095f0d [javascript] upgrade excanvas.js (rev. M3, mars 2009): this fixes plot widgets rendering in IE
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
   911
                       alpha: aColor.alpha});
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   912
  };
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   913
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   914
  function CanvasPattern_() {}
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   915
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   916
  // set up externs
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   917
  G_vmlCanvasManager = G_vmlCanvasManager_;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   918
  CanvasRenderingContext2D = CanvasRenderingContext2D_;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   919
  CanvasGradient = CanvasGradient_;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   920
  CanvasPattern = CanvasPattern_;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   921
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   922
})();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   923
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   924
} // if