web/data/excanvas.js
author Julien Cristau <julien.cristau@logilab.fr>
Thu, 18 Dec 2014 17:54:29 +0100
changeset 10121 23af005426bf
parent 8173 5bc91cc51fe3
permissions -rw-r--r--
[web] everything old is new again Kill the "new" cubicweb.css, and move cubicweb.old.css back in its place. Closes #4763360.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7893
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     1
// Memory Leaks patch from http://explorercanvas.googlecode.com/svn/trunk/ 
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     2
//  svn : r73
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     3
// ------------------------------------------------------------------
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     4
// Copyright 2006 Google Inc.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     5
//
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     6
// Licensed under the Apache License, Version 2.0 (the "License");
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     7
// you may not use this file except in compliance with the License.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     8
// You may obtain a copy of the License at
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
     9
//
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    10
//   http://www.apache.org/licenses/LICENSE-2.0
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    11
//
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    12
// Unless required by applicable law or agreed to in writing, software
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    13
// distributed under the License is distributed on an "AS IS" BASIS,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    14
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    15
// See the License for the specific language governing permissions and
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    16
// limitations under the License.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    17
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    18
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    19
// Known Issues:
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    20
//
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    21
// * Patterns only support repeat.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    22
// * Radial gradient are not implemented. The VML version of these look very
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    23
//   different from the canvas one.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    24
// * Clipping paths are not implemented.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    25
// * Coordsize. The width and height attribute have higher priority than the
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    26
//   width and height style values which isn't correct.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    27
// * Painting mode isn't implemented.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    28
// * Canvas width/height should is using content-box by default. IE in
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    29
//   Quirks mode will draw the canvas using border-box. Either change your
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    30
//   doctype to HTML5
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    31
//   (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    32
//   or use Box Sizing Behavior from WebFX
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    33
//   (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    34
// * Non uniform scaling does not correctly scale strokes.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    35
// * Optimize. There is always room for speed improvements.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    36
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    37
// Only add this code if we do not already have a canvas implementation
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    38
if (!document.createElement('canvas').getContext) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    39
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    40
(function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    41
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    42
  // alias some functions to make (compiled) code shorter
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    43
  var m = Math;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    44
  var mr = m.round;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    45
  var ms = m.sin;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    46
  var mc = m.cos;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    47
  var abs = m.abs;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    48
  var sqrt = m.sqrt;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    49
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    50
  // this is used for sub pixel precision
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    51
  var Z = 10;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    52
  var Z2 = Z / 2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    53
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    54
  var IE_VERSION = +navigator.userAgent.match(/MSIE ([\d.]+)?/)[1];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    55
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    56
  /**
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    57
   * This funtion is assigned to the <canvas> elements as element.getContext().
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    58
   * @this {HTMLElement}
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    59
   * @return {CanvasRenderingContext2D_}
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    60
   */
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    61
  function getContext() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    62
    return this.context_ ||
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    63
        (this.context_ = new CanvasRenderingContext2D_(this));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    64
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    65
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    66
  var slice = Array.prototype.slice;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    67
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    68
  /**
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    69
   * Binds a function to an object. The returned function will always use the
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    70
   * passed in {@code obj} as {@code this}.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    71
   *
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    72
   * Example:
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    73
   *
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    74
   *   g = bind(f, obj, a, b)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    75
   *   g(c, d) // will do f.call(obj, a, b, c, d)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    76
   *
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    77
   * @param {Function} f The function to bind the object to
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    78
   * @param {Object} obj The object that should act as this when the function
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    79
   *     is called
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    80
   * @param {*} var_args Rest arguments that will be used as the initial
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    81
   *     arguments when the function is called
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    82
   * @return {Function} A new function that has bound this
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    83
   */
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    84
  function bind(f, obj, var_args) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    85
    var a = slice.call(arguments, 2);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    86
    return function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    87
      return f.apply(obj, a.concat(slice.call(arguments)));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    88
    };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    89
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    90
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    91
  function encodeHtmlAttribute(s) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    92
    return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    93
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    94
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    95
  function addNamespace(doc, prefix, urn) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    96
    if (!doc.namespaces[prefix]) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    97
      doc.namespaces.add(prefix, urn, '#default#VML');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    98
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
    99
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   100
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   101
  function addNamespacesAndStylesheet(doc) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   102
    addNamespace(doc, 'g_vml_', 'urn:schemas-microsoft-com:vml');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   103
    addNamespace(doc, 'g_o_', 'urn:schemas-microsoft-com:office:office');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   104
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   105
    // Setup default CSS.  Only add one style sheet per document
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   106
    if (!doc.styleSheets['ex_canvas_']) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   107
      var ss = doc.createStyleSheet();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   108
      ss.owningElement.id = 'ex_canvas_';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   109
      ss.cssText = 'canvas{display:inline-block;overflow:hidden;' +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   110
          // default size is 300x150 in Gecko and Opera
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   111
          'text-align:left;width:300px;height:150px}';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   112
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   113
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   114
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   115
  // Add namespaces and stylesheet at startup.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   116
  addNamespacesAndStylesheet(document);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   117
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   118
  var G_vmlCanvasManager_ = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   119
    init: function(opt_doc) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   120
      var doc = opt_doc || document;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   121
      // Create a dummy element so that IE will allow canvas elements to be
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   122
      // recognized.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   123
      doc.createElement('canvas');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   124
      doc.attachEvent('onreadystatechange', bind(this.init_, this, doc));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   125
    },
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   126
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   127
    init_: function(doc) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   128
      // find all canvas elements
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   129
      var els = doc.getElementsByTagName('canvas');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   130
      for (var i = 0; i < els.length; i++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   131
        this.initElement(els[i]);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   132
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   133
    },
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   134
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   135
    /**
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   136
     * Public initializes a canvas element so that it can be used as canvas
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   137
     * element from now on. This is called automatically before the page is
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   138
     * loaded but if you are creating elements using createElement you need to
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   139
     * make sure this is called on the element.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   140
     * @param {HTMLElement} el The canvas element to initialize.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   141
     * @return {HTMLElement} the element that was created.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   142
     */
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   143
    initElement: function(el) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   144
      if (!el.getContext) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   145
        el.getContext = getContext;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   146
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   147
        // Add namespaces and stylesheet to document of the element.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   148
        addNamespacesAndStylesheet(el.ownerDocument);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   149
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   150
        // Remove fallback content. There is no way to hide text nodes so we
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   151
        // just remove all childNodes. We could hide all elements and remove
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   152
        // text nodes but who really cares about the fallback content.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   153
        el.innerHTML = '';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   154
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   155
        // do not use inline function because that will leak memory
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   156
        el.attachEvent('onpropertychange', onPropertyChange);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   157
        el.attachEvent('onresize', onResize);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   158
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   159
        var attrs = el.attributes;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   160
        if (attrs.width && attrs.width.specified) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   161
          // TODO: use runtimeStyle and coordsize
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   162
          // el.getContext().setWidth_(attrs.width.nodeValue);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   163
          el.style.width = attrs.width.nodeValue + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   164
        } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   165
          el.width = el.clientWidth;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   166
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   167
        if (attrs.height && attrs.height.specified) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   168
          // TODO: use runtimeStyle and coordsize
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   169
          // el.getContext().setHeight_(attrs.height.nodeValue);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   170
          el.style.height = attrs.height.nodeValue + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   171
        } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   172
          el.height = el.clientHeight;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   173
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   174
        //el.getContext().setCoordsize_()
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   175
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   176
      return el;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   177
    },
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   178
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   179
    // Memory Leaks patch : see http://code.google.com/p/explorercanvas/issues/detail?id=82
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   180
    uninitElement: function(el){
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   181
      if (el.getContext) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   182
        var ctx = el.getContext();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   183
        delete ctx.element_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   184
        delete ctx.canvas;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   185
        el.innerHTML = "";
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   186
        //el.outerHTML = "";
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   187
        el.context_ = null;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   188
        el.getContext = null;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   189
        el.detachEvent("onpropertychange", onPropertyChange);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   190
        el.detachEvent("onresize", onResize);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   191
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   192
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   193
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   194
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   195
  function onPropertyChange(e) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   196
    var el = e.srcElement;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   197
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   198
    switch (e.propertyName) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   199
      case 'width':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   200
        el.getContext().clearRect();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   201
        el.style.width = el.attributes.width.nodeValue + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   202
        // In IE8 this does not trigger onresize.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   203
        el.firstChild.style.width =  el.clientWidth + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   204
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   205
      case 'height':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   206
        el.getContext().clearRect();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   207
        el.style.height = el.attributes.height.nodeValue + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   208
        el.firstChild.style.height = el.clientHeight + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   209
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   210
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   211
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   212
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   213
  function onResize(e) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   214
    var el = e.srcElement;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   215
    if (el.firstChild) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   216
      el.firstChild.style.width =  el.clientWidth + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   217
      el.firstChild.style.height = el.clientHeight + 'px';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   218
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   219
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   220
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   221
  G_vmlCanvasManager_.init();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   222
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   223
  // precompute "00" to "FF"
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   224
  var decToHex = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   225
  for (var i = 0; i < 16; i++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   226
    for (var j = 0; j < 16; j++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   227
      decToHex[i * 16 + j] = i.toString(16) + j.toString(16);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   228
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   229
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   230
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   231
  function createMatrixIdentity() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   232
    return [
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   233
      [1, 0, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   234
      [0, 1, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   235
      [0, 0, 1]
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   236
    ];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   237
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   238
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   239
  function matrixMultiply(m1, m2) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   240
    var result = createMatrixIdentity();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   241
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   242
    for (var x = 0; x < 3; x++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   243
      for (var y = 0; y < 3; y++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   244
        var sum = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   245
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   246
        for (var z = 0; z < 3; z++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   247
          sum += m1[x][z] * m2[z][y];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   248
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   249
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   250
        result[x][y] = sum;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   251
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   252
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   253
    return result;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   254
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   255
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   256
  function copyState(o1, o2) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   257
    o2.fillStyle     = o1.fillStyle;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   258
    o2.lineCap       = o1.lineCap;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   259
    o2.lineJoin      = o1.lineJoin;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   260
    o2.lineWidth     = o1.lineWidth;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   261
    o2.miterLimit    = o1.miterLimit;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   262
    o2.shadowBlur    = o1.shadowBlur;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   263
    o2.shadowColor   = o1.shadowColor;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   264
    o2.shadowOffsetX = o1.shadowOffsetX;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   265
    o2.shadowOffsetY = o1.shadowOffsetY;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   266
    o2.strokeStyle   = o1.strokeStyle;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   267
    o2.globalAlpha   = o1.globalAlpha;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   268
    o2.font          = o1.font;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   269
    o2.textAlign     = o1.textAlign;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   270
    o2.textBaseline  = o1.textBaseline;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   271
    o2.arcScaleX_    = o1.arcScaleX_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   272
    o2.arcScaleY_    = o1.arcScaleY_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   273
    o2.lineScale_    = o1.lineScale_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   274
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   275
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   276
  var colorData = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   277
    aliceblue: '#F0F8FF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   278
    antiquewhite: '#FAEBD7',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   279
    aquamarine: '#7FFFD4',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   280
    azure: '#F0FFFF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   281
    beige: '#F5F5DC',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   282
    bisque: '#FFE4C4',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   283
    black: '#000000',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   284
    blanchedalmond: '#FFEBCD',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   285
    blueviolet: '#8A2BE2',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   286
    brown: '#A52A2A',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   287
    burlywood: '#DEB887',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   288
    cadetblue: '#5F9EA0',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   289
    chartreuse: '#7FFF00',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   290
    chocolate: '#D2691E',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   291
    coral: '#FF7F50',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   292
    cornflowerblue: '#6495ED',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   293
    cornsilk: '#FFF8DC',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   294
    crimson: '#DC143C',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   295
    cyan: '#00FFFF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   296
    darkblue: '#00008B',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   297
    darkcyan: '#008B8B',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   298
    darkgoldenrod: '#B8860B',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   299
    darkgray: '#A9A9A9',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   300
    darkgreen: '#006400',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   301
    darkgrey: '#A9A9A9',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   302
    darkkhaki: '#BDB76B',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   303
    darkmagenta: '#8B008B',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   304
    darkolivegreen: '#556B2F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   305
    darkorange: '#FF8C00',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   306
    darkorchid: '#9932CC',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   307
    darkred: '#8B0000',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   308
    darksalmon: '#E9967A',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   309
    darkseagreen: '#8FBC8F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   310
    darkslateblue: '#483D8B',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   311
    darkslategray: '#2F4F4F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   312
    darkslategrey: '#2F4F4F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   313
    darkturquoise: '#00CED1',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   314
    darkviolet: '#9400D3',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   315
    deeppink: '#FF1493',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   316
    deepskyblue: '#00BFFF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   317
    dimgray: '#696969',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   318
    dimgrey: '#696969',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   319
    dodgerblue: '#1E90FF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   320
    firebrick: '#B22222',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   321
    floralwhite: '#FFFAF0',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   322
    forestgreen: '#228B22',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   323
    gainsboro: '#DCDCDC',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   324
    ghostwhite: '#F8F8FF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   325
    gold: '#FFD700',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   326
    goldenrod: '#DAA520',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   327
    grey: '#808080',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   328
    greenyellow: '#ADFF2F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   329
    honeydew: '#F0FFF0',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   330
    hotpink: '#FF69B4',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   331
    indianred: '#CD5C5C',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   332
    indigo: '#4B0082',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   333
    ivory: '#FFFFF0',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   334
    khaki: '#F0E68C',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   335
    lavender: '#E6E6FA',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   336
    lavenderblush: '#FFF0F5',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   337
    lawngreen: '#7CFC00',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   338
    lemonchiffon: '#FFFACD',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   339
    lightblue: '#ADD8E6',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   340
    lightcoral: '#F08080',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   341
    lightcyan: '#E0FFFF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   342
    lightgoldenrodyellow: '#FAFAD2',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   343
    lightgreen: '#90EE90',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   344
    lightgrey: '#D3D3D3',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   345
    lightpink: '#FFB6C1',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   346
    lightsalmon: '#FFA07A',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   347
    lightseagreen: '#20B2AA',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   348
    lightskyblue: '#87CEFA',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   349
    lightslategray: '#778899',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   350
    lightslategrey: '#778899',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   351
    lightsteelblue: '#B0C4DE',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   352
    lightyellow: '#FFFFE0',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   353
    limegreen: '#32CD32',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   354
    linen: '#FAF0E6',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   355
    magenta: '#FF00FF',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   356
    mediumaquamarine: '#66CDAA',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   357
    mediumblue: '#0000CD',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   358
    mediumorchid: '#BA55D3',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   359
    mediumpurple: '#9370DB',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   360
    mediumseagreen: '#3CB371',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   361
    mediumslateblue: '#7B68EE',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   362
    mediumspringgreen: '#00FA9A',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   363
    mediumturquoise: '#48D1CC',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   364
    mediumvioletred: '#C71585',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   365
    midnightblue: '#191970',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   366
    mintcream: '#F5FFFA',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   367
    mistyrose: '#FFE4E1',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   368
    moccasin: '#FFE4B5',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   369
    navajowhite: '#FFDEAD',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   370
    oldlace: '#FDF5E6',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   371
    olivedrab: '#6B8E23',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   372
    orange: '#FFA500',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   373
    orangered: '#FF4500',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   374
    orchid: '#DA70D6',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   375
    palegoldenrod: '#EEE8AA',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   376
    palegreen: '#98FB98',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   377
    paleturquoise: '#AFEEEE',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   378
    palevioletred: '#DB7093',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   379
    papayawhip: '#FFEFD5',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   380
    peachpuff: '#FFDAB9',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   381
    peru: '#CD853F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   382
    pink: '#FFC0CB',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   383
    plum: '#DDA0DD',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   384
    powderblue: '#B0E0E6',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   385
    rosybrown: '#BC8F8F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   386
    royalblue: '#4169E1',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   387
    saddlebrown: '#8B4513',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   388
    salmon: '#FA8072',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   389
    sandybrown: '#F4A460',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   390
    seagreen: '#2E8B57',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   391
    seashell: '#FFF5EE',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   392
    sienna: '#A0522D',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   393
    skyblue: '#87CEEB',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   394
    slateblue: '#6A5ACD',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   395
    slategray: '#708090',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   396
    slategrey: '#708090',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   397
    snow: '#FFFAFA',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   398
    springgreen: '#00FF7F',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   399
    steelblue: '#4682B4',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   400
    tan: '#D2B48C',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   401
    thistle: '#D8BFD8',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   402
    tomato: '#FF6347',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   403
    turquoise: '#40E0D0',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   404
    violet: '#EE82EE',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   405
    wheat: '#F5DEB3',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   406
    whitesmoke: '#F5F5F5',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   407
    yellowgreen: '#9ACD32'
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   408
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   409
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   410
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   411
  function getRgbHslContent(styleString) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   412
    var start = styleString.indexOf('(', 3);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   413
    var end = styleString.indexOf(')', start + 1);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   414
    var parts = styleString.substring(start + 1, end).split(',');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   415
    // add alpha if needed
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   416
    if (parts.length != 4 || styleString.charAt(3) != 'a') {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   417
      parts[3] = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   418
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   419
    return parts;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   420
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   421
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   422
  function percent(s) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   423
    return parseFloat(s) / 100;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   424
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   425
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   426
  function clamp(v, min, max) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   427
    return Math.min(max, Math.max(min, v));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   428
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   429
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   430
  function hslToRgb(parts){
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   431
    var r, g, b, h, s, l;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   432
    h = parseFloat(parts[0]) / 360 % 360;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   433
    if (h < 0)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   434
      h++;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   435
    s = clamp(percent(parts[1]), 0, 1);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   436
    l = clamp(percent(parts[2]), 0, 1);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   437
    if (s == 0) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   438
      r = g = b = l; // achromatic
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   439
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   440
      var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   441
      var p = 2 * l - q;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   442
      r = hueToRgb(p, q, h + 1 / 3);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   443
      g = hueToRgb(p, q, h);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   444
      b = hueToRgb(p, q, h - 1 / 3);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   445
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   446
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   447
    return '#' + decToHex[Math.floor(r * 255)] +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   448
        decToHex[Math.floor(g * 255)] +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   449
        decToHex[Math.floor(b * 255)];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   450
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   451
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   452
  function hueToRgb(m1, m2, h) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   453
    if (h < 0)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   454
      h++;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   455
    if (h > 1)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   456
      h--;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   457
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   458
    if (6 * h < 1)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   459
      return m1 + (m2 - m1) * 6 * h;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   460
    else if (2 * h < 1)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   461
      return m2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   462
    else if (3 * h < 2)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   463
      return m1 + (m2 - m1) * (2 / 3 - h) * 6;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   464
    else
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   465
      return m1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   466
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   467
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   468
  var processStyleCache = {};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   469
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   470
  function processStyle(styleString) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   471
    if (styleString in processStyleCache) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   472
      return processStyleCache[styleString];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   473
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   474
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   475
    var str, alpha = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   476
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   477
    styleString = String(styleString);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   478
    if (styleString.charAt(0) == '#') {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   479
      str = styleString;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   480
    } else if (/^rgb/.test(styleString)) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   481
      var parts = getRgbHslContent(styleString);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   482
      var str = '#', n;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   483
      for (var i = 0; i < 3; i++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   484
        if (parts[i].indexOf('%') != -1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   485
          n = Math.floor(percent(parts[i]) * 255);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   486
        } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   487
          n = +parts[i];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   488
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   489
        str += decToHex[clamp(n, 0, 255)];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   490
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   491
      alpha = +parts[3];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   492
    } else if (/^hsl/.test(styleString)) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   493
      var parts = getRgbHslContent(styleString);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   494
      str = hslToRgb(parts);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   495
      alpha = parts[3];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   496
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   497
      str = colorData[styleString] || styleString;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   498
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   499
    return processStyleCache[styleString] = {color: str, alpha: alpha};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   500
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   501
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   502
  var DEFAULT_STYLE = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   503
    style: 'normal',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   504
    variant: 'normal',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   505
    weight: 'normal',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   506
    size: 10,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   507
    family: 'sans-serif'
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   508
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   509
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   510
  // Internal text style cache
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   511
  var fontStyleCache = {};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   512
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   513
  function processFontStyle(styleString) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   514
    if (fontStyleCache[styleString]) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   515
      return fontStyleCache[styleString];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   516
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   517
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   518
    var el = document.createElement('div');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   519
    var style = el.style;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   520
    try {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   521
      style.font = styleString;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   522
    } catch (ex) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   523
      // Ignore failures to set to invalid font.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   524
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   525
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   526
    return fontStyleCache[styleString] = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   527
      style: style.fontStyle || DEFAULT_STYLE.style,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   528
      variant: style.fontVariant || DEFAULT_STYLE.variant,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   529
      weight: style.fontWeight || DEFAULT_STYLE.weight,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   530
      size: style.fontSize || DEFAULT_STYLE.size,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   531
      family: style.fontFamily || DEFAULT_STYLE.family
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   532
    };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   533
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   534
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   535
  function getComputedStyle(style, element) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   536
    var computedStyle = {};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   537
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   538
    for (var p in style) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   539
      computedStyle[p] = style[p];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   540
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   541
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   542
    // Compute the size
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   543
    var canvasFontSize = parseFloat(element.currentStyle.fontSize),
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   544
        fontSize = parseFloat(style.size);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   545
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   546
    if (typeof style.size == 'number') {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   547
      computedStyle.size = style.size;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   548
    } else if (style.size.indexOf('px') != -1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   549
      computedStyle.size = fontSize;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   550
    } else if (style.size.indexOf('em') != -1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   551
      computedStyle.size = canvasFontSize * fontSize;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   552
    } else if(style.size.indexOf('%') != -1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   553
      computedStyle.size = (canvasFontSize / 100) * fontSize;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   554
    } else if (style.size.indexOf('pt') != -1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   555
      computedStyle.size = fontSize / .75;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   556
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   557
      computedStyle.size = canvasFontSize;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   558
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   559
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   560
    // Different scaling between normal text and VML text. This was found using
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   561
    // trial and error to get the same size as non VML text.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   562
    computedStyle.size *= 0.981;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   563
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   564
    // Fix for VML handling of bare font family names.  Add a '' around font family names.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   565
    computedStyle.family =  "'" + computedStyle.family.replace(/(\'|\")/g,'').replace(/\s*,\s*/g, "', '") + "'";
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   566
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   567
    return computedStyle;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   568
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   569
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   570
  function buildStyle(style) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   571
    return style.style + ' ' + style.variant + ' ' + style.weight + ' ' +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   572
        style.size + 'px ' + style.family;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   573
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   574
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   575
  var lineCapMap = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   576
    'butt': 'flat',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   577
    'round': 'round'
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   578
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   579
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   580
  function processLineCap(lineCap) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   581
    return lineCapMap[lineCap] || 'square';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   582
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   583
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   584
  /**
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   585
   * This class implements CanvasRenderingContext2D interface as described by
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   586
   * the WHATWG.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   587
   * @param {HTMLElement} canvasElement The element that the 2D context should
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   588
   * be associated with
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   589
   */
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   590
  function CanvasRenderingContext2D_(canvasElement) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   591
    this.m_ = createMatrixIdentity();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   592
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   593
    this.mStack_ = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   594
    this.aStack_ = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   595
    this.currentPath_ = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   596
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   597
    // Canvas context properties
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   598
    this.strokeStyle = '#000';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   599
    this.fillStyle = '#000';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   600
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   601
    this.lineWidth = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   602
    this.lineJoin = 'miter';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   603
    this.lineCap = 'butt';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   604
    this.miterLimit = Z * 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   605
    this.globalAlpha = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   606
    this.font = '10px sans-serif';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   607
    this.textAlign = 'left';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   608
    this.textBaseline = 'alphabetic';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   609
    this.canvas = canvasElement;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   610
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   611
    var cssText = 'width:' + canvasElement.clientWidth + 'px;height:' +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   612
        canvasElement.clientHeight + 'px;overflow:hidden;position:absolute';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   613
    var el = canvasElement.ownerDocument.createElement('div');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   614
    el.style.cssText = cssText;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   615
    canvasElement.appendChild(el);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   616
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   617
    var overlayEl = el.cloneNode(false);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   618
    // Use a non transparent background.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   619
    overlayEl.style.backgroundColor = 'red';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   620
    overlayEl.style.filter = 'alpha(opacity=0)';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   621
    canvasElement.appendChild(overlayEl);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   622
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   623
    this.element_ = el;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   624
    this.arcScaleX_ = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   625
    this.arcScaleY_ = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   626
    this.lineScale_ = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   627
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   628
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   629
  var contextPrototype = CanvasRenderingContext2D_.prototype;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   630
  contextPrototype.clearRect = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   631
    if (this.textMeasureEl_) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   632
      this.textMeasureEl_.removeNode(true);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   633
      this.textMeasureEl_ = null;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   634
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   635
    this.element_.innerHTML = '';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   636
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   637
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   638
  contextPrototype.beginPath = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   639
    // TODO: Branch current matrix so that save/restore has no effect
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   640
    //       as per safari docs.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   641
    this.currentPath_ = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   642
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   643
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   644
  contextPrototype.moveTo = function(aX, aY) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   645
    var p = getCoords(this, aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   646
    this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y});
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   647
    this.currentX_ = p.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   648
    this.currentY_ = p.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   649
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   650
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   651
  contextPrototype.lineTo = function(aX, aY) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   652
    var p = getCoords(this, aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   653
    this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y});
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   654
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   655
    this.currentX_ = p.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   656
    this.currentY_ = p.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   657
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   658
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   659
  contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   660
                                            aCP2x, aCP2y,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   661
                                            aX, aY) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   662
    var p = getCoords(this, aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   663
    var cp1 = getCoords(this, aCP1x, aCP1y);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   664
    var cp2 = getCoords(this, aCP2x, aCP2y);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   665
    bezierCurveTo(this, cp1, cp2, p);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   666
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   667
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   668
  // Helper function that takes the already fixed cordinates.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   669
  function bezierCurveTo(self, cp1, cp2, p) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   670
    self.currentPath_.push({
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   671
      type: 'bezierCurveTo',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   672
      cp1x: cp1.x,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   673
      cp1y: cp1.y,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   674
      cp2x: cp2.x,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   675
      cp2y: cp2.y,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   676
      x: p.x,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   677
      y: p.y
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   678
    });
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   679
    self.currentX_ = p.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   680
    self.currentY_ = p.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   681
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   682
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   683
  contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   684
    // the following is lifted almost directly from
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   685
    // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   686
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   687
    var cp = getCoords(this, aCPx, aCPy);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   688
    var p = getCoords(this, aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   689
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   690
    var cp1 = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   691
      x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_),
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   692
      y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_)
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   693
    };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   694
    var cp2 = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   695
      x: cp1.x + (p.x - this.currentX_) / 3.0,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   696
      y: cp1.y + (p.y - this.currentY_) / 3.0
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   697
    };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   698
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   699
    bezierCurveTo(this, cp1, cp2, p);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   700
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   701
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   702
  contextPrototype.arc = function(aX, aY, aRadius,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   703
                                  aStartAngle, aEndAngle, aClockwise) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   704
    aRadius *= Z;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   705
    var arcType = aClockwise ? 'at' : 'wa';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   706
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   707
    var xStart = aX + mc(aStartAngle) * aRadius - Z2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   708
    var yStart = aY + ms(aStartAngle) * aRadius - Z2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   709
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   710
    var xEnd = aX + mc(aEndAngle) * aRadius - Z2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   711
    var yEnd = aY + ms(aEndAngle) * aRadius - Z2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   712
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   713
    // IE won't render arches drawn counter clockwise if xStart == xEnd.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   714
    if (xStart == xEnd && !aClockwise) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   715
      xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   716
                       // that can be represented in binary
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   717
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   718
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   719
    var p = getCoords(this, aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   720
    var pStart = getCoords(this, xStart, yStart);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   721
    var pEnd = getCoords(this, xEnd, yEnd);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   722
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   723
    this.currentPath_.push({type: arcType,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   724
                           x: p.x,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   725
                           y: p.y,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   726
                           radius: aRadius,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   727
                           xStart: pStart.x,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   728
                           yStart: pStart.y,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   729
                           xEnd: pEnd.x,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   730
                           yEnd: pEnd.y});
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   731
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   732
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   733
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   734
  contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   735
    this.moveTo(aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   736
    this.lineTo(aX + aWidth, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   737
    this.lineTo(aX + aWidth, aY + aHeight);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   738
    this.lineTo(aX, aY + aHeight);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   739
    this.closePath();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   740
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   741
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   742
  contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   743
    var oldPath = this.currentPath_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   744
    this.beginPath();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   745
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   746
    this.moveTo(aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   747
    this.lineTo(aX + aWidth, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   748
    this.lineTo(aX + aWidth, aY + aHeight);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   749
    this.lineTo(aX, aY + aHeight);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   750
    this.closePath();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   751
    this.stroke();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   752
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   753
    this.currentPath_ = oldPath;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   754
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   755
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   756
  contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   757
    var oldPath = this.currentPath_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   758
    this.beginPath();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   759
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   760
    this.moveTo(aX, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   761
    this.lineTo(aX + aWidth, aY);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   762
    this.lineTo(aX + aWidth, aY + aHeight);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   763
    this.lineTo(aX, aY + aHeight);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   764
    this.closePath();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   765
    this.fill();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   766
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   767
    this.currentPath_ = oldPath;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   768
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   769
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   770
  contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   771
    var gradient = new CanvasGradient_('gradient');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   772
    gradient.x0_ = aX0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   773
    gradient.y0_ = aY0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   774
    gradient.x1_ = aX1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   775
    gradient.y1_ = aY1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   776
    return gradient;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   777
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   778
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   779
  contextPrototype.createRadialGradient = function(aX0, aY0, aR0,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   780
                                                   aX1, aY1, aR1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   781
    var gradient = new CanvasGradient_('gradientradial');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   782
    gradient.x0_ = aX0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   783
    gradient.y0_ = aY0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   784
    gradient.r0_ = aR0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   785
    gradient.x1_ = aX1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   786
    gradient.y1_ = aY1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   787
    gradient.r1_ = aR1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   788
    return gradient;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   789
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   790
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   791
  contextPrototype.drawImage = function(image, var_args) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   792
    var dx, dy, dw, dh, sx, sy, sw, sh;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   793
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   794
    // to find the original width we overide the width and height
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   795
    var oldRuntimeWidth = image.runtimeStyle.width;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   796
    var oldRuntimeHeight = image.runtimeStyle.height;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   797
    image.runtimeStyle.width = 'auto';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   798
    image.runtimeStyle.height = 'auto';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   799
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   800
    // get the original size
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   801
    var w = image.width;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   802
    var h = image.height;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   803
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   804
    // and remove overides
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   805
    image.runtimeStyle.width = oldRuntimeWidth;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   806
    image.runtimeStyle.height = oldRuntimeHeight;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   807
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   808
    if (arguments.length == 3) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   809
      dx = arguments[1];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   810
      dy = arguments[2];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   811
      sx = sy = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   812
      sw = dw = w;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   813
      sh = dh = h;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   814
    } else if (arguments.length == 5) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   815
      dx = arguments[1];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   816
      dy = arguments[2];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   817
      dw = arguments[3];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   818
      dh = arguments[4];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   819
      sx = sy = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   820
      sw = w;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   821
      sh = h;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   822
    } else if (arguments.length == 9) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   823
      sx = arguments[1];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   824
      sy = arguments[2];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   825
      sw = arguments[3];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   826
      sh = arguments[4];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   827
      dx = arguments[5];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   828
      dy = arguments[6];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   829
      dw = arguments[7];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   830
      dh = arguments[8];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   831
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   832
      throw Error('Invalid number of arguments');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   833
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   834
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   835
    var d = getCoords(this, dx, dy);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   836
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   837
    var w2 = sw / 2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   838
    var h2 = sh / 2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   839
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   840
    var vmlStr = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   841
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   842
    var W = 10;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   843
    var H = 10;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   844
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   845
    // For some reason that I've now forgotten, using divs didn't work
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   846
    vmlStr.push(' <g_vml_:group',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   847
                ' coordsize="', Z * W, ',', Z * H, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   848
                ' coordorigin="0,0"' ,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   849
                ' style="width:', W, 'px;height:', H, 'px;position:absolute;');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   850
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   851
    // If filters are necessary (rotation exists), create them
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   852
    // filters are bog-slow, so only create them if abbsolutely necessary
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   853
    // The following check doesn't account for skews (which don't exist
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   854
    // in the canvas spec (yet) anyway.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   855
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   856
    if (this.m_[0][0] != 1 || this.m_[0][1] ||
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   857
        this.m_[1][1] != 1 || this.m_[1][0]) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   858
      var filter = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   859
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   860
      // Note the 12/21 reversal
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   861
      filter.push('M11=', this.m_[0][0], ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   862
                  'M12=', this.m_[1][0], ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   863
                  'M21=', this.m_[0][1], ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   864
                  'M22=', this.m_[1][1], ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   865
                  'Dx=', mr(d.x / Z), ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   866
                  'Dy=', mr(d.y / Z), '');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   867
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   868
      // Bounding box calculation (need to minimize displayed area so that
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   869
      // filters don't waste time on unused pixels.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   870
      var max = d;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   871
      var c2 = getCoords(this, dx + dw, dy);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   872
      var c3 = getCoords(this, dx, dy + dh);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   873
      var c4 = getCoords(this, dx + dw, dy + dh);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   874
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   875
      max.x = m.max(max.x, c2.x, c3.x, c4.x);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   876
      max.y = m.max(max.y, c2.y, c3.y, c4.y);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   877
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   878
      vmlStr.push('padding:0 ', mr(max.x / Z), 'px ', mr(max.y / Z),
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   879
                  'px 0;filter:progid:DXImageTransform.Microsoft.Matrix(',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   880
                  filter.join(''), ", sizingmethod='clip');");
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   881
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   882
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   883
      vmlStr.push('top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px;');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   884
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   885
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   886
    vmlStr.push(' ">' ,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   887
                '<g_vml_:image src="', image.src, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   888
                ' style="width:', Z * dw, 'px;',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   889
                ' height:', Z * dh, 'px"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   890
                ' cropleft="', sx / w, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   891
                ' croptop="', sy / h, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   892
                ' cropright="', (w - sx - sw) / w, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   893
                ' cropbottom="', (h - sy - sh) / h, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   894
                ' />',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   895
                '</g_vml_:group>');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   896
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   897
    this.element_.insertAdjacentHTML('BeforeEnd', vmlStr.join(''));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   898
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   899
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   900
  contextPrototype.stroke = function(aFill) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   901
    var lineStr = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   902
    var lineOpen = false;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   903
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   904
    var W = 10;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   905
    var H = 10;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   906
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   907
    lineStr.push('<g_vml_:shape',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   908
                 ' filled="', !!aFill, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   909
                 ' style="position:absolute;width:', W, 'px;height:', H, 'px;"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   910
                 ' coordorigin="0,0"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   911
                 ' coordsize="', Z * W, ',', Z * H, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   912
                 ' stroked="', !aFill, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   913
                 ' path="');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   914
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   915
    var newSeq = false;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   916
    var min = {x: null, y: null};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   917
    var max = {x: null, y: null};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   918
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   919
    for (var i = 0; i < this.currentPath_.length; i++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   920
      var p = this.currentPath_[i];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   921
      var c;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   922
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   923
      switch (p.type) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   924
        case 'moveTo':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   925
          c = p;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   926
          lineStr.push(' m ', mr(p.x), ',', mr(p.y));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   927
          break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   928
        case 'lineTo':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   929
          lineStr.push(' l ', mr(p.x), ',', mr(p.y));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   930
          break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   931
        case 'close':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   932
          lineStr.push(' x ');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   933
          p = null;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   934
          break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   935
        case 'bezierCurveTo':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   936
          lineStr.push(' c ',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   937
                       mr(p.cp1x), ',', mr(p.cp1y), ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   938
                       mr(p.cp2x), ',', mr(p.cp2y), ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   939
                       mr(p.x), ',', mr(p.y));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   940
          break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   941
        case 'at':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   942
        case 'wa':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   943
          lineStr.push(' ', p.type, ' ',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   944
                       mr(p.x - this.arcScaleX_ * p.radius), ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   945
                       mr(p.y - this.arcScaleY_ * p.radius), ' ',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   946
                       mr(p.x + this.arcScaleX_ * p.radius), ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   947
                       mr(p.y + this.arcScaleY_ * p.radius), ' ',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   948
                       mr(p.xStart), ',', mr(p.yStart), ' ',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   949
                       mr(p.xEnd), ',', mr(p.yEnd));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   950
          break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   951
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   952
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   953
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   954
      // TODO: Following is broken for curves due to
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   955
      //       move to proper paths.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   956
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   957
      // Figure out dimensions so we can do gradient fills
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   958
      // properly
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   959
      if (p) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   960
        if (min.x == null || p.x < min.x) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   961
          min.x = p.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   962
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   963
        if (max.x == null || p.x > max.x) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   964
          max.x = p.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   965
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   966
        if (min.y == null || p.y < min.y) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   967
          min.y = p.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   968
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   969
        if (max.y == null || p.y > max.y) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   970
          max.y = p.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   971
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   972
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   973
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   974
    lineStr.push(' ">');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   975
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   976
    if (!aFill) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   977
      appendStroke(this, lineStr);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   978
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   979
      appendFill(this, lineStr, min, max);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   980
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   981
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   982
    lineStr.push('</g_vml_:shape>');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   983
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   984
    this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   985
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   986
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   987
  function appendStroke(ctx, lineStr) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   988
    var a = processStyle(ctx.strokeStyle);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   989
    var color = a.color;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   990
    var opacity = a.alpha * ctx.globalAlpha;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   991
    var lineWidth = ctx.lineScale_ * ctx.lineWidth;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   992
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   993
    // VML cannot correctly render a line if the width is less than 1px.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   994
    // In that case, we dilute the color to make the line look thinner.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   995
    if (lineWidth < 1) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   996
      opacity *= lineWidth;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   997
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   998
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
   999
    lineStr.push(
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1000
      '<g_vml_:stroke',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1001
      ' opacity="', opacity, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1002
      ' joinstyle="', ctx.lineJoin, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1003
      ' miterlimit="', ctx.miterLimit, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1004
      ' endcap="', processLineCap(ctx.lineCap), '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1005
      ' weight="', lineWidth, 'px"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1006
      ' color="', color, '" />'
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1007
    );
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1008
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1009
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1010
  function appendFill(ctx, lineStr, min, max) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1011
    var fillStyle = ctx.fillStyle;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1012
    var arcScaleX = ctx.arcScaleX_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1013
    var arcScaleY = ctx.arcScaleY_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1014
    var width = max.x - min.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1015
    var height = max.y - min.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1016
    if (fillStyle instanceof CanvasGradient_) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1017
      // TODO: Gradients transformed with the transformation matrix.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1018
      var angle = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1019
      var focus = {x: 0, y: 0};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1020
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1021
      // additional offset
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1022
      var shift = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1023
      // scale factor for offset
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1024
      var expansion = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1025
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1026
      if (fillStyle.type_ == 'gradient') {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1027
        var x0 = fillStyle.x0_ / arcScaleX;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1028
        var y0 = fillStyle.y0_ / arcScaleY;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1029
        var x1 = fillStyle.x1_ / arcScaleX;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1030
        var y1 = fillStyle.y1_ / arcScaleY;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1031
        var p0 = getCoords(ctx, x0, y0);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1032
        var p1 = getCoords(ctx, x1, y1);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1033
        var dx = p1.x - p0.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1034
        var dy = p1.y - p0.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1035
        angle = Math.atan2(dx, dy) * 180 / Math.PI;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1036
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1037
        // The angle should be a non-negative number.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1038
        if (angle < 0) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1039
          angle += 360;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1040
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1041
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1042
        // Very small angles produce an unexpected result because they are
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1043
        // converted to a scientific notation string.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1044
        if (angle < 1e-6) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1045
          angle = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1046
        }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1047
      } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1048
        var p0 = getCoords(ctx, fillStyle.x0_, fillStyle.y0_);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1049
        focus = {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1050
          x: (p0.x - min.x) / width,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1051
          y: (p0.y - min.y) / height
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1052
        };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1053
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1054
        width  /= arcScaleX * Z;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1055
        height /= arcScaleY * Z;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1056
        var dimension = m.max(width, height);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1057
        shift = 2 * fillStyle.r0_ / dimension;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1058
        expansion = 2 * fillStyle.r1_ / dimension - shift;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1059
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1060
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1061
      // We need to sort the color stops in ascending order by offset,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1062
      // otherwise IE won't interpret it correctly.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1063
      var stops = fillStyle.colors_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1064
      stops.sort(function(cs1, cs2) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1065
        return cs1.offset - cs2.offset;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1066
      });
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1067
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1068
      var length = stops.length;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1069
      var color1 = stops[0].color;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1070
      var color2 = stops[length - 1].color;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1071
      var opacity1 = stops[0].alpha * ctx.globalAlpha;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1072
      var opacity2 = stops[length - 1].alpha * ctx.globalAlpha;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1073
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1074
      var colors = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1075
      for (var i = 0; i < length; i++) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1076
        var stop = stops[i];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1077
        colors.push(stop.offset * expansion + shift + ' ' + stop.color);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1078
      }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1079
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1080
      // When colors attribute is used, the meanings of opacity and o:opacity2
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1081
      // are reversed.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1082
      lineStr.push('<g_vml_:fill type="', fillStyle.type_, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1083
                   ' method="none" focus="100%"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1084
                   ' color="', color1, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1085
                   ' color2="', color2, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1086
                   ' colors="', colors.join(','), '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1087
                   ' opacity="', opacity2, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1088
                   ' g_o_:opacity2="', opacity1, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1089
                   ' angle="', angle, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1090
                   ' focusposition="', focus.x, ',', focus.y, '" />');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1091
    } else if (fillStyle instanceof CanvasPattern_) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1092
      if (width && height) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1093
        var deltaLeft = -min.x;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1094
        var deltaTop = -min.y;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1095
        lineStr.push('<g_vml_:fill',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1096
                     ' position="',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1097
                     deltaLeft / width * arcScaleX * arcScaleX, ',',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1098
                     deltaTop / height * arcScaleY * arcScaleY, '"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1099
                     ' type="tile"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1100
                     // TODO: Figure out the correct size to fit the scale.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1101
                     //' size="', w, 'px ', h, 'px"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1102
                     ' src="', fillStyle.src_, '" />');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1103
       }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1104
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1105
      var a = processStyle(ctx.fillStyle);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1106
      var color = a.color;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1107
      var opacity = a.alpha * ctx.globalAlpha;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1108
      lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1109
                   '" />');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1110
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1111
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1112
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1113
  contextPrototype.fill = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1114
    this.stroke(true);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1115
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1116
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1117
  contextPrototype.closePath = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1118
    this.currentPath_.push({type: 'close'});
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1119
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1120
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1121
  function getCoords(ctx, aX, aY) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1122
    var m = ctx.m_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1123
    return {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1124
      x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1125
      y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1126
    };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1127
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1128
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1129
  contextPrototype.save = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1130
    var o = {};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1131
    copyState(this, o);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1132
    this.aStack_.push(o);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1133
    this.mStack_.push(this.m_);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1134
    this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1135
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1136
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1137
  contextPrototype.restore = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1138
    if (this.aStack_.length) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1139
      copyState(this.aStack_.pop(), this);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1140
      this.m_ = this.mStack_.pop();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1141
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1142
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1143
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1144
  function matrixIsFinite(m) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1145
    return isFinite(m[0][0]) && isFinite(m[0][1]) &&
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1146
        isFinite(m[1][0]) && isFinite(m[1][1]) &&
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1147
        isFinite(m[2][0]) && isFinite(m[2][1]);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1148
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1149
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1150
  function setM(ctx, m, updateLineScale) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1151
    if (!matrixIsFinite(m)) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1152
      return;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1153
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1154
    ctx.m_ = m;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1155
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1156
    if (updateLineScale) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1157
      // Get the line scale.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1158
      // Determinant of this.m_ means how much the area is enlarged by the
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1159
      // transformation. So its square root can be used as a scale factor
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1160
      // for width.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1161
      var det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1162
      ctx.lineScale_ = sqrt(abs(det));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1163
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1164
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1165
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1166
  contextPrototype.translate = function(aX, aY) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1167
    var m1 = [
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1168
      [1,  0,  0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1169
      [0,  1,  0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1170
      [aX, aY, 1]
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1171
    ];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1172
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1173
    setM(this, matrixMultiply(m1, this.m_), false);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1174
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1175
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1176
  contextPrototype.rotate = function(aRot) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1177
    var c = mc(aRot);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1178
    var s = ms(aRot);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1179
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1180
    var m1 = [
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1181
      [c,  s, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1182
      [-s, c, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1183
      [0,  0, 1]
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1184
    ];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1185
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1186
    setM(this, matrixMultiply(m1, this.m_), false);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1187
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1188
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1189
  contextPrototype.scale = function(aX, aY) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1190
    this.arcScaleX_ *= aX;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1191
    this.arcScaleY_ *= aY;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1192
    var m1 = [
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1193
      [aX, 0,  0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1194
      [0,  aY, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1195
      [0,  0,  1]
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1196
    ];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1197
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1198
    setM(this, matrixMultiply(m1, this.m_), true);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1199
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1200
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1201
  contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1202
    var m1 = [
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1203
      [m11, m12, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1204
      [m21, m22, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1205
      [dx,  dy,  1]
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1206
    ];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1207
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1208
    setM(this, matrixMultiply(m1, this.m_), true);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1209
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1210
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1211
  contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1212
    var m = [
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1213
      [m11, m12, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1214
      [m21, m22, 0],
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1215
      [dx,  dy,  1]
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1216
    ];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1217
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1218
    setM(this, m, true);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1219
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1220
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1221
  /**
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1222
   * The text drawing function.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1223
   * The maxWidth argument isn't taken in account, since no browser supports
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1224
   * it yet.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1225
   */
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1226
  contextPrototype.drawText_ = function(text, x, y, maxWidth, stroke) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1227
    var m = this.m_,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1228
        delta = 1000,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1229
        left = 0,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1230
        right = delta,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1231
        offset = {x: 0, y: 0},
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1232
        lineStr = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1233
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1234
    var fontStyle = getComputedStyle(processFontStyle(this.font), this.element_);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1235
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1236
    var fontStyleString = buildStyle(fontStyle);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1237
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1238
    var elementStyle = this.element_.currentStyle;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1239
    var textAlign = this.textAlign.toLowerCase();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1240
    switch (textAlign) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1241
      case 'left':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1242
      case 'center':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1243
      case 'right':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1244
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1245
      case 'end':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1246
        textAlign = elementStyle.direction == 'ltr' ? 'right' : 'left';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1247
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1248
      case 'start':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1249
        textAlign = elementStyle.direction == 'rtl' ? 'right' : 'left';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1250
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1251
      default:
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1252
        textAlign = 'left';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1253
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1254
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1255
    // 1.75 is an arbitrary number, as there is no info about the text baseline
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1256
    switch (this.textBaseline) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1257
      case 'hanging':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1258
      case 'top':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1259
        offset.y = fontStyle.size / 1.75;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1260
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1261
      case 'middle':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1262
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1263
      default:
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1264
      case null:
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1265
      case 'alphabetic':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1266
      case 'ideographic':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1267
      case 'bottom':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1268
        offset.y = -fontStyle.size / 2.25;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1269
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1270
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1271
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1272
    switch(textAlign) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1273
      case 'right':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1274
        left = delta;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1275
        right = 0.05;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1276
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1277
      case 'center':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1278
        left = right = delta / 2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1279
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1280
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1281
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1282
    var d = getCoords(this, x + offset.x, y + offset.y);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1283
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1284
    lineStr.push('<g_vml_:line from="', -left ,' 0" to="', right ,' 0.05" ',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1285
                 ' coordsize="100 100" coordorigin="0 0"',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1286
                 ' filled="', !stroke, '" stroked="', !!stroke,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1287
                 '" style="position:absolute;width:1px;height:1px;">');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1288
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1289
    if (stroke) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1290
      appendStroke(this, lineStr);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1291
    } else {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1292
      // TODO: Fix the min and max params.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1293
      appendFill(this, lineStr, {x: -left, y: 0},
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1294
                 {x: right, y: fontStyle.size});
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1295
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1296
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1297
    var skewM = m[0][0].toFixed(3) + ',' + m[1][0].toFixed(3) + ',' +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1298
                m[0][1].toFixed(3) + ',' + m[1][1].toFixed(3) + ',0,0';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1299
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1300
    var skewOffset = mr(d.x / Z + 1 - m[0][0]) + ',' + mr(d.y / Z - 2 * m[1][0]);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1301
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1302
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1303
    lineStr.push('<g_vml_:skew on="t" matrix="', skewM ,'" ',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1304
                 ' offset="', skewOffset, '" origin="', left ,' 0" />',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1305
                 '<g_vml_:path textpathok="true" />',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1306
                 '<g_vml_:textpath on="true" string="',
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1307
                 encodeHtmlAttribute(text),
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1308
                 '" style="v-text-align:', textAlign,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1309
                 ';font:', encodeHtmlAttribute(fontStyleString),
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1310
                 '" /></g_vml_:line>');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1311
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1312
    this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1313
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1314
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1315
  contextPrototype.fillText = function(text, x, y, maxWidth) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1316
    this.drawText_(text, x, y, maxWidth, false);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1317
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1318
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1319
  contextPrototype.strokeText = function(text, x, y, maxWidth) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1320
    this.drawText_(text, x, y, maxWidth, true);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1321
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1322
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1323
  contextPrototype.measureText = function(text) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1324
    if (!this.textMeasureEl_) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1325
      var s = '<span style="position:absolute;' +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1326
          'top:-20000px;left:0;padding:0;margin:0;border:none;' +
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1327
          'white-space:pre;"></span>';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1328
      this.element_.insertAdjacentHTML('beforeEnd', s);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1329
      this.textMeasureEl_ = this.element_.lastChild;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1330
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1331
    var doc = this.element_.ownerDocument;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1332
    this.textMeasureEl_.innerHTML = '';
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1333
    this.textMeasureEl_.style.font = this.font;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1334
    // Don't use innerHTML or innerText because they allow markup/whitespace.
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1335
    this.textMeasureEl_.appendChild(doc.createTextNode(text));
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1336
    return {width: this.textMeasureEl_.offsetWidth};
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1337
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1338
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1339
  /******** STUBS ********/
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1340
  contextPrototype.clip = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1341
    // TODO: Implement
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1342
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1343
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1344
  contextPrototype.arcTo = function() {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1345
    // TODO: Implement
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1346
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1347
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1348
  contextPrototype.createPattern = function(image, repetition) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1349
    return new CanvasPattern_(image, repetition);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1350
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1351
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1352
  // Gradient / Pattern Stubs
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1353
  function CanvasGradient_(aType) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1354
    this.type_ = aType;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1355
    this.x0_ = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1356
    this.y0_ = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1357
    this.r0_ = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1358
    this.x1_ = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1359
    this.y1_ = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1360
    this.r1_ = 0;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1361
    this.colors_ = [];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1362
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1363
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1364
  CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1365
    aColor = processStyle(aColor);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1366
    this.colors_.push({offset: aOffset,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1367
                       color: aColor.color,
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1368
                       alpha: aColor.alpha});
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1369
  };
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1370
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1371
  function CanvasPattern_(image, repetition) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1372
    assertImageIsValid(image);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1373
    switch (repetition) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1374
      case 'repeat':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1375
      case null:
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1376
      case '':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1377
        this.repetition_ = 'repeat';
8173
5bc91cc51fe3 [excanvas js] missing comma
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7893
diff changeset
  1378
        break;
7893
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1379
      case 'repeat-x':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1380
      case 'repeat-y':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1381
      case 'no-repeat':
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1382
        this.repetition_ = repetition;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1383
        break;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1384
      default:
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1385
        throwException('SYNTAX_ERR');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1386
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1387
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1388
    this.src_ = image.src;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1389
    this.width_ = image.width;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1390
    this.height_ = image.height;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1391
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1392
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1393
  function throwException(s) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1394
    throw new DOMException_(s);
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1395
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1396
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1397
  function assertImageIsValid(img) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1398
    if (!img || img.nodeType != 1 || img.tagName != 'IMG') {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1399
      throwException('TYPE_MISMATCH_ERR');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1400
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1401
    if (img.readyState != 'complete') {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1402
      throwException('INVALID_STATE_ERR');
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1403
    }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1404
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1405
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1406
  function DOMException_(s) {
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1407
    this.code = this[s];
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1408
    this.message = s +': DOM Exception ' + this.code;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1409
  }
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1410
  var p = DOMException_.prototype = new Error;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1411
  p.INDEX_SIZE_ERR = 1;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1412
  p.DOMSTRING_SIZE_ERR = 2;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1413
  p.HIERARCHY_REQUEST_ERR = 3;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1414
  p.WRONG_DOCUMENT_ERR = 4;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1415
  p.INVALID_CHARACTER_ERR = 5;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1416
  p.NO_DATA_ALLOWED_ERR = 6;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1417
  p.NO_MODIFICATION_ALLOWED_ERR = 7;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1418
  p.NOT_FOUND_ERR = 8;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1419
  p.NOT_SUPPORTED_ERR = 9;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1420
  p.INUSE_ATTRIBUTE_ERR = 10;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1421
  p.INVALID_STATE_ERR = 11;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1422
  p.SYNTAX_ERR = 12;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1423
  p.INVALID_MODIFICATION_ERR = 13;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1424
  p.NAMESPACE_ERR = 14;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1425
  p.INVALID_ACCESS_ERR = 15;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1426
  p.VALIDATION_ERR = 16;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1427
  p.TYPE_MISMATCH_ERR = 17;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1428
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1429
  // set up externs
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1430
  G_vmlCanvasManager = G_vmlCanvasManager_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1431
  CanvasRenderingContext2D = CanvasRenderingContext2D_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1432
  CanvasGradient = CanvasGradient_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1433
  CanvasPattern = CanvasPattern_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1434
  DOMException = DOMException_;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1435
  G_vmlCanvasManager._version = 888;
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1436
})();
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1437
8da3caff3291 [js] add proper excanvas.js (patched version provided with jqplot, but with proper copyrights
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7621
diff changeset
  1438
} // if