bootstrap_template 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/Rakefile +1 -0
- data/bootstrap_template.gemspec +23 -0
- data/lib/bootstrap_template.rb +6 -0
- data/lib/bootstrap_template/version.rb +3 -0
- data/vendor/assets/javascripts/bootstrap.js +11 -0
- data/vendor/assets/javascripts/bootstrap_template.js +5 -0
- data/vendor/assets/javascripts/morris-0.4.3.min.js +1 -0
- data/vendor/assets/javascripts/plugins/flot/chart-data-flot.js +237 -0
- data/vendor/assets/javascripts/plugins/flot/excanvas.min.js +1 -0
- data/vendor/assets/javascripts/plugins/flot/jquery.flot.js +2599 -0
- data/vendor/assets/javascripts/plugins/flot/jquery.flot.pie.js +750 -0
- data/vendor/assets/javascripts/plugins/flot/jquery.flot.resize.js +60 -0
- data/vendor/assets/javascripts/plugins/flot/jquery.flot.tooltip.min.js +12 -0
- data/vendor/assets/javascripts/plugins/morris/chart-data-morris.js +128 -0
- data/vendor/assets/javascripts/plugins/tablesorter/jquery.tablesorter.js +1031 -0
- data/vendor/assets/javascripts/plugins/tablesorter/tables.js +3 -0
- data/vendor/assets/javascripts/raphael-min.js +10 -0
- data/vendor/assets/stylesheets/bootstrap.css +5909 -0
- data/vendor/assets/stylesheets/bootstrap_template.css +153 -0
- data/vendor/assets/stylesheets/font-awesome/css/font-awesome.css +1361 -0
- data/vendor/assets/stylesheets/font-awesome/css/font-awesome.min.css +395 -0
- data/vendor/assets/stylesheets/font-awesome/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.svg +414 -0
- data/vendor/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/stylesheets/font-awesome/fonts/fontawesome-webfont.woff +0 -0
- metadata +108 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 李虹霖
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# BootstrapTemplate
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bootstrap_template/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bootstrap_template"
|
8
|
+
spec.version = BootstrapTemplate::VERSION
|
9
|
+
spec.authors = ["李虹霖"]
|
10
|
+
spec.email = ["894849464@qq.com"]
|
11
|
+
spec.description = %q{This is a bootstrap template}
|
12
|
+
spec.summary = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap v3.0.0
|
3
|
+
*
|
4
|
+
* Copyright 2013 Twitter, Inc
|
5
|
+
* Licensed under the Apache License v2.0
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
*
|
8
|
+
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
9
|
+
*/
|
10
|
+
|
11
|
+
+function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function f(){e.trigger("closed.bs.alert").remove()}var c=a(this),d=c.attr("data-target");d||(d=c.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,""));var e=a(d);b&&b.preventDefault(),e.length||(e=c.hasClass("alert")?c:c.parent()),e.trigger(b=a.Event("close.bs.alert"));if(b.isDefaultPrevented())return;e.removeClass("in"),a.support.transition&&e.hasClass("fade")?e.one(a.support.transition.end,f).emulateTransitionEnd(150):f()};var d=a.fn.alert;a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("bs.alert");e||d.data("bs.alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a.fn.alert.noConflict=function(){return a.fn.alert=d,this},a(document).on("click.bs.alert.data-api",b,c.prototype.close)}(window.jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d)};b.DEFAULTS={loadingText:"loading..."},b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.is("input")?"val":"html",e=c.data();a+="Text",e.resetText||c.data("resetText",c[d]()),c[d](e[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.closest('[data-toggle="buttons"]');if(a.length){var b=this.$element.find("input").prop("checked",!this.$element.hasClass("active")).trigger("change");b.prop("type")==="radio"&&a.find(".active").removeClass("active")}this.$element.toggleClass("active")};var c=a.fn.button;a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("bs.button"),f=typeof c=="object"&&c;e||d.data("bs.button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.Constructor=b,a.fn.button.noConflict=function(){return a.fn.button=c,this},a(document).on("click.bs.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle"),b.preventDefault()})}(window.jQuery),+function(a){"use strict";var b=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=this.sliding=this.interval=this.$active=this.$items=null,this.options.pause=="hover"&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},b.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},b.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},b.prototype.to=function(b){var c=this,d=this.getActiveIndex();if(b>this.$items.length-1||b<0)return;return this.sliding?this.$element.one("slid",function(){c.to(b)}):d==b?this.pause().cycle():this.slide(b>d?"next":"prev",a(this.$items[b]))},b.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition.end&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},b.prototype.next=function(){if(this.sliding)return;return this.slide("next")},b.prototype.prev=function(){if(this.sliding)return;return this.slide("prev")},b.prototype.slide=function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g=b=="next"?"left":"right",h=b=="next"?"first":"last",i=this;if(!e.length){if(!this.options.wrap)return;e=this.$element.find(".item")[h]()}this.sliding=!0,f&&this.pause();var j=a.Event("slide.bs.carousel",{relatedTarget:e[0],direction:g});if(e.hasClass("active"))return;this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid",function(){var b=a(i.$indicators.children()[i.getActiveIndex()]);b&&b.addClass("active")}));if(a.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(j);if(j.isDefaultPrevented())return;e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),d.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid")},0)}).emulateTransitionEnd(600)}else{this.$element.trigger(j);if(j.isDefaultPrevented())return;d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return f&&this.cycle(),this};var c=a.fn.carousel;a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},b.DEFAULTS,d.data(),typeof c=="object"&&c),g=typeof c=="string"?c:f.slide;e||d.data("bs.carousel",e=new b(this,f)),typeof c=="number"?e.to(c):g?e[g]():f.interval&&e.pause().cycle()})},a.fn.carousel.Constructor=b,a.fn.carousel.noConflict=function(){return a.fn.carousel=c,this},a(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=a.extend({},e.data(),c.data()),g=c.attr("data-slide-to");g&&(f.interval=!1),e.carousel(f),(g=c.attr("data-slide-to"))&&e.data("bs.carousel").to(g),b.preventDefault()}),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var b=a(this);b.carousel(b.data())})})}(window.jQuery),+function(a){function e(){a(b).remove(),a(c).each(function(b){var c=f(a(this));if(!c.hasClass("open"))return;c.trigger(b=a.Event("hide.bs.dropdown"));if(b.isDefaultPrevented())return;c.removeClass("open").trigger("hidden.bs.dropdown")})}function f(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}"use strict";var b=".dropdown-backdrop",c="[data-toggle=dropdown]",d=function(b){var c=a(b).on("click.bs.dropdown",this.toggle)};d.prototype.toggle=function(b){var c=a(this);if(c.is(".disabled, :disabled"))return;var d=f(c),g=d.hasClass("open");e();if(!g){"ontouchstart"in document.documentElement&&!d.closest(".navbar-nav").length&&a('<div class="dropdown-backdrop"/>').insertAfter(a(this)).on("click",e),d.trigger(b=a.Event("show.bs.dropdown"));if(b.isDefaultPrevented())return;d.toggleClass("open").trigger("shown.bs.dropdown"),c.focus()}return!1},d.prototype.keydown=function(b){if(!/(38|40|27)/.test(b.keyCode))return;var d=a(this);b.preventDefault(),b.stopPropagation();if(d.is(".disabled, :disabled"))return;var e=f(d),g=e.hasClass("open");if(!g||g&&b.keyCode==27)return b.which==27&&e.find(c).focus(),d.click();var h=a("[role=menu] li:not(.divider):visible a",e);if(!h.length)return;var i=h.index(h.filter(":focus"));b.keyCode==38&&i>0&&i--,b.keyCode==40&&i<h.length-1&&i++,~i||(i=0),h.eq(i).focus()};var g=a.fn.dropdown;a.fn.dropdown=function(b){return this.each(function(){var c=a(this),e=c.data("dropdown");e||c.data("dropdown",e=new d(this)),typeof b=="string"&&e[b].call(c)})},a.fn.dropdown.Constructor=d,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=g,this},a(document).on("click.bs.dropdown.data-api",e).on("click.bs.dropdown.data-api",".dropdown form",function(a){a.stopPropagation()}).on("click.bs.dropdown.data-api",c,d.prototype.toggle).on("keydown.bs.dropdown.data-api",c+", [role=menu]",d.prototype.keydown)}(window.jQuery),+function(a){"use strict";var b=function(b,c){this.options=c,this.$element=a(b),this.$backdrop=this.isShown=null,this.options.remote&&this.$element.load(this.options.remote)};b.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},b.prototype.toggle=function(a){return this[this.isShown?"hide":"show"](a)},b.prototype.show=function(b){var c=this,d=a.Event("show.bs.modal",{relatedTarget:b});this.$element.trigger(d);if(this.isShown||d.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.$element.on("click.dismiss.modal",'[data-dismiss="modal"]',a.proxy(this.hide,this)),this.backdrop(function(){var d=a.support.transition&&c.$element.hasClass("fade");c.$element.parent().length||c.$element.appendTo(document.body),c.$element.show(),d&&c.$element[0].offsetWidth,c.$element.addClass("in").attr("aria-hidden",!1),c.enforceFocus();var e=a.Event("shown.bs.modal",{relatedTarget:b});d?c.$element.find(".modal-dialog").one(a.support.transition.end,function(){c.$element.focus().trigger(e)}).emulateTransitionEnd(300):c.$element.focus().trigger(e)})},b.prototype.hide=function(b){b&&b.preventDefault(),b=a.Event("hide.bs.modal"),this.$element.trigger(b);if(!this.isShown||b.isDefaultPrevented())return;this.isShown=!1,this.escape(),a(document).off("focusin.bs.modal"),this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.modal"),a.support.transition&&this.$element.hasClass("fade")?this.$element.one(a.support.transition.end,a.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal()},b.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(a){this.$element[0]!==a.target&&!this.$element.has(a.target).length&&this.$element.focus()},this))},b.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.bs.modal",a.proxy(function(a){a.which==27&&this.hide()},this)):this.isShown||this.$element.off("keyup.dismiss.bs.modal")},b.prototype.hideModal=function(){var a=this;this.$element.hide(),this.backdrop(function(){a.removeBackdrop(),a.$element.trigger("hidden.bs.modal")})},b.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},b.prototype.backdrop=function(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.$element.on("click.dismiss.modal",a.proxy(function(a){if(a.target!==a.currentTarget)return;this.options.backdrop=="static"?this.$element[0].focus.call(this.$element[0]):this.hide.call(this)},this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in");if(!b)return;e?this.$backdrop.one(a.support.transition.end,b).emulateTransitionEnd(150):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,b).emulateTransitionEnd(150):b()):b&&b()};var c=a.fn.modal;a.fn.modal=function(c,d){return this.each(function(){var e=a(this),f=e.data("bs.modal"),g=a.extend({},b.DEFAULTS,e.data(),typeof c=="object"&&c);f||e.data("bs.modal",f=new b(this,g)),typeof c=="string"?f[c](d):g.show&&f.show(d)})},a.fn.modal.Constructor=b,a.fn.modal.noConflict=function(){return a.fn.modal=c,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d=c.attr("href"),e=a(c.attr("data-target")||d&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({remote:!/#/.test(d)&&d},e.data(),c.data());b.preventDefault(),e.modal(f,this).one("hide",function(){c.is(":visible")&&c.focus()})}),a(document).on("show.bs.modal",".modal",function(){a(document.body).addClass("modal-open")}).on("hidden.bs.modal",".modal",function(){a(document.body).removeClass("modal-open")})}(window.jQuery),+function(a){"use strict";var b=function(a,b){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.$element=null,this.init("tooltip",a,b)};b.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1},b.prototype.init=function(b,c,d){this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d);var e=this.options.trigger.split(" ");for(var f=e.length;f--;){var g=e[f];if(g=="click")this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if(g!="manual"){var h=g=="hover"?"mouseenter":"focus",i=g=="hover"?"mouseleave":"blur";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},b.prototype.getDefaults=function(){return b.DEFAULTS},b.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},b.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},b.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);clearTimeout(c.timeout),c.hoverState="in";if(!c.options.delay||!c.options.delay.show)return c.show();c.timeout=setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show)},b.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type);clearTimeout(c.timeout),c.hoverState="out";if(!c.options.delay||!c.options.delay.hide)return c.hide();c.timeout=setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide)},b.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);if(b.isDefaultPrevented())return;var c=this.tip();this.setContent(),this.options.animation&&c.addClass("fade");var d=typeof this.options.placement=="function"?this.options.placement.call(this,c[0],this.$element[0]):this.options.placement,e=/\s?auto?\s?/i,f=e.test(d);f&&(d=d.replace(e,"")||"top"),c.detach().css({top:0,left:0,display:"block"}).addClass(d),this.options.container?c.appendTo(this.options.container):c.insertAfter(this.$element);var g=this.getPosition(),h=c[0].offsetWidth,i=c[0].offsetHeight;if(f){var j=this.$element.parent(),k=d,l=document.documentElement.scrollTop||document.body.scrollTop,m=this.options.container=="body"?window.innerWidth:j.outerWidth(),n=this.options.container=="body"?window.innerHeight:j.outerHeight(),o=this.options.container=="body"?0:j.offset().left;d=d=="bottom"&&g.top+g.height+i-l>n?"top":d=="top"&&g.top-l-i<0?"bottom":d=="right"&&g.right+h>m?"left":d=="left"&&g.left-h<o?"right":d,c.removeClass(k).addClass(d)}var p=this.getCalculatedOffset(d,g,h,i);this.applyPlacement(p,d),this.$element.trigger("shown.bs."+this.type)}},b.prototype.applyPlacement=function(a,b){var c,d=this.tip(),e=d[0].offsetWidth,f=d[0].offsetHeight,g=parseInt(d.css("margin-top"),10),h=parseInt(d.css("margin-left"),10);isNaN(g)&&(g=0),isNaN(h)&&(h=0),a.top=a.top+g,a.left=a.left+h,d.offset(a).addClass("in");var i=d[0].offsetWidth,j=d[0].offsetHeight;b=="top"&&j!=f&&(c=!0,a.top=a.top+f-j);if(/bottom|top/.test(b)){var k=0;a.left<0&&(k=a.left*-2,a.left=0,d.offset(a),i=d[0].offsetWidth,j=d[0].offsetHeight),this.replaceArrow(k-e+i,i,"left")}else this.replaceArrow(j-f,j,"top");c&&d.offset(a)},b.prototype.replaceArrow=function(a,b,c){this.arrow().css(c,a?50*(1-a/b)+"%":"")},b.prototype.setContent=function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},b.prototype.hide=function(){function e(){b.hoverState!="in"&&c.detach()}var b=this,c=this.tip(),d=a.Event("hide.bs."+this.type);this.$element.trigger(d);if(d.isDefaultPrevented())return;return c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?c.one(a.support.transition.end,e).emulateTransitionEnd(150):e(),this.$element.trigger("hidden.bs."+this.type),this},b.prototype.fixTitle=function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").attr("title","")},b.prototype.hasContent=function(){return this.getTitle()},b.prototype.getPosition=function(){var b=this.$element[0];return a.extend({},typeof b.getBoundingClientRect=="function"?b.getBoundingClientRect():{width:b.offsetWidth,height:b.offsetHeight},this.$element.offset())},b.prototype.getCalculatedOffset=function(a,b,c,d){return a=="bottom"?{top:b.top+b.height,left:b.left+b.width/2-c/2}:a=="top"?{top:b.top-d,left:b.left+b.width/2-c/2}:a=="left"?{top:b.top+b.height/2-d/2,left:b.left-c}:{top:b.top+b.height/2-d/2,left:b.left+b.width}},b.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a},b.prototype.tip=function(){return this.$tip=this.$tip||a(this.options.template)},b.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},b.prototype.validate=function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},b.prototype.enable=function(){this.enabled=!0},b.prototype.disable=function(){this.enabled=!1},b.prototype.toggleEnabled=function(){this.enabled=!this.enabled},b.prototype.toggle=function(b){var c=b?a(b.currentTarget)[this.type](this.getDelegateOptions()).data("bs."+this.type):this;c.tip().hasClass("in")?c.leave(c):c.enter(c)},b.prototype.destroy=function(){this.hide().$element.off("."+this.type).removeData("bs."+this.type)};var c=a.fn.tooltip;a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("bs.tooltip"),f=typeof c=="object"&&c;e||d.data("bs.tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=c,this}}(window.jQuery),+function(a){"use strict";var b=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");b.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),b.prototype.constructor=b,b.prototype.getDefaults=function(){return b.DEFAULTS},b.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content")[this.options.html?"html":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},b.prototype.hasContent=function(){return this.getTitle()||this.getContent()},b.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||(typeof b.content=="function"?b.content.call(a[0]):b.content)},b.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},b.prototype.tip=function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip};var c=a.fn.popover;a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f=typeof c=="object"&&c;e||d.data("bs.popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.noConflict=function(){return a.fn.popover=c,this}}(window.jQuery),+function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype.show=function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.attr("data-target");d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,""));if(b.parent("li").hasClass("active"))return;var e=c.find(".active:last a")[0],f=a.Event("show.bs.tab",{relatedTarget:e});b.trigger(f);if(f.isDefaultPrevented())return;var g=a(d);this.activate(b.parent("li"),c),this.activate(g,g.parent(),function(){b.trigger({type:"shown.bs.tab",relatedTarget:e})})},b.prototype.activate=function(b,c,d){function g(){e.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),f?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var e=c.find("> .active"),f=d&&a.support.transition&&e.hasClass("fade");f?e.one(a.support.transition.end,g).emulateTransitionEnd(150):g(),e.removeClass("in")};var c=a.fn.tab;a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("bs.tab");e||d.data("bs.tab",e=new b(this)),typeof c=="string"&&e[c]()})},a.fn.tab.Constructor=b,a.fn.tab.noConflict=function(){return a.fn.tab=c,this},a(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})}(window.jQuery),+function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,d),this.$window=a(window).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(c),this.affixed=this.unpin=null,this.checkPosition()};b.RESET="affix affix-top affix-bottom",b.DEFAULTS={offset:0},b.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},b.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var c=a(document).height(),d=this.$window.scrollTop(),e=this.$element.offset(),f=this.options.offset,g=f.top,h=f.bottom;typeof f!="object"&&(h=g=f),typeof g=="function"&&(g=f.top()),typeof h=="function"&&(h=f.bottom());var i=this.unpin!=null&&d+this.unpin<=e.top?!1:h!=null&&e.top+this.$element.height()>=c-h?"bottom":g!=null&&d<=g?"top":!1;if(this.affixed===i)return;this.unpin&&this.$element.css("top",""),this.affixed=i,this.unpin=i=="bottom"?e.top-d:null,this.$element.removeClass(b.RESET).addClass("affix"+(i?"-"+i:"")),i=="bottom"&&this.$element.offset({top:document.body.offsetHeight-h-this.$element.height()})};var c=a.fn.affix;a.fn.affix=function(c){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f=typeof c=="object"&&c;e||d.data("bs.affix",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.affix.Constructor=b,a.fn.affix.noConflict=function(){return a.fn.affix=c,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var b=a(this),c=b.data();c.offset=c.offset||{},c.offsetBottom&&(c.offset.bottom=c.offsetBottom),c.offsetTop&&(c.offset.top=c.offsetTop),b.affix(c)})})}(window.jQuery),+function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.DEFAULTS,d),this.transitioning=null,this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.DEFAULTS={toggle:!0},b.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},b.prototype.show=function(){if(this.transitioning||this.$element.hasClass("in"))return;var b=a.Event("show.bs.collapse");this.$element.trigger(b);if(b.isDefaultPrevented())return;var c=this.$parent&&this.$parent.find("> .panel > .in");if(c&&c.length){var d=c.data("bs.collapse");if(d&&d.transitioning)return;c.collapse("hide"),d||c.data("bs.collapse",null)}var e=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[e](0),this.transitioning=1;var f=function(){this.$element.removeClass("collapsing").addClass("in")[e]("auto"),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return f.call(this);var g=a.camelCase(["scroll",e].join("-"));this.$element.one(a.support.transition.end,a.proxy(f,this)).emulateTransitionEnd(350)[e](this.$element[0][g])},b.prototype.hide=function(){if(this.transitioning||!this.$element.hasClass("in"))return;var b=a.Event("hide.bs.collapse");this.$element.trigger(b);if(b.isDefaultPrevented())return;var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var d=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};if(!a.support.transition)return d.call(this);this.$element[c](0).one(a.support.transition.end,a.proxy(d,this)).emulateTransitionEnd(350)},b.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var c=a.fn.collapse;a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("bs.collapse"),f=a.extend({},b.DEFAULTS,d.data(),typeof c=="object"&&c);e||d.data("bs.collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.Constructor=b,a.fn.collapse.noConflict=function(){return a.fn.collapse=c,this},a(document).on("click.bs.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e),g=f.data("bs.collapse"),h=g?"toggle":c.data(),i=c.attr("data-parent"),j=i&&a(i);if(!g||!g.transitioning)j&&j.find('[data-toggle=collapse][data-parent="'+i+'"]').not(c).addClass("collapsed"),c[f.hasClass("in")?"addClass":"removeClass"]("collapsed");f.collapse(h)})}(window.jQuery),+function(a){function b(c,d){var e,f=a.proxy(this.process,this);this.$element=a(c).is("body")?a(window):a(c),this.$body=a("body"),this.$scrollElement=this.$element.on("scroll.bs.scroll-spy.data-api",f),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||(e=a(c).attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.offsets=a([]),this.targets=a([]),this.activeTarget=null,this.refresh(),this.process()}"use strict",b.DEFAULTS={offset:10},b.prototype.refresh=function(){var b=this.$element[0]==window?"offset":"position";this.offsets=a([]),this.targets=a([]);var c=this,d=this.$body.find(this.selector).map(function(){var d=a(this),e=d.data("target")||d.attr("href"),f=/^#\w/.test(e)&&a(e);return f&&f.length&&[[f[b]().top+(!a.isWindow(c.$scrollElement.get(0))&&c.$scrollElement.scrollTop()),e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){c.offsets.push(this[0]),c.targets.push(this[1])})},b.prototype.process=function(){var a=this.$scrollElement.scrollTop()+this.options.offset,b=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,c=b-this.$scrollElement.height(),d=this.offsets,e=this.targets,f=this.activeTarget,g;if(a>=c)return f!=(g=e.last()[0])&&this.activate(g);for(g=d.length;g--;)f!=e[g]&&a>=d[g]&&(!d[g+1]||a<=d[g+1])&&this.activate(e[g])},b.prototype.activate=function(b){this.activeTarget=b,a(this.selector).parents(".active").removeClass("active");var c=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',d=a(c).parents("li").addClass("active");d.parent(".dropdown-menu").length&&(d=d.closest("li.dropdown").addClass("active")),d.trigger("activate")};var c=a.fn.scrollspy;a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f=typeof c=="object"&&c;e||d.data("bs.scrollspy",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.noConflict=function(){return a.fn.scrollspy=c,this},a(window).on("load",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(window.jQuery),+function(a){function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(a.style[c]!==undefined)return{end:b[c]}}"use strict",a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one(a.support.transition.end,function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b()})}(window.jQuery)
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(){var e,t,n,r,i=[].slice,s={}.hasOwnProperty,o=function(e,t){function r(){this.constructor=e}for(var n in t)s.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e},u=function(e,t){return function(){return e.apply(t,arguments)}},a=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1};t=window.Morris={},e=jQuery,t.EventEmitter=function(){function e(){}return e.prototype.on=function(e,t){return this.handlers==null&&(this.handlers={}),this.handlers[e]==null&&(this.handlers[e]=[]),this.handlers[e].push(t),this},e.prototype.fire=function(){var e,t,n,r,s,o,u;n=arguments[0],e=2<=arguments.length?i.call(arguments,1):[];if(this.handlers!=null&&this.handlers[n]!=null){o=this.handlers[n],u=[];for(r=0,s=o.length;r<s;r++)t=o[r],u.push(t.apply(null,e));return u}},e}(),t.commas=function(e){var t,n,r,i;return e!=null?(r=e<0?"-":"",t=Math.abs(e),n=Math.floor(t).toFixed(0),r+=n.replace(/(?=(?:\d{3})+$)(?!^)/g,","),i=t.toString(),i.length>n.length&&(r+=i.slice(n.length)),r):"-"},t.pad2=function(e){return(e<10?"0":"")+e},t.Grid=function(n){function r(t){var n=this;typeof t.element=="string"?this.el=e(document.getElementById(t.element)):this.el=e(t.element);if(this.el==null||this.el.length===0)throw new Error("Graph container element not found");this.el.css("position")==="static"&&this.el.css("position","relative"),this.options=e.extend({},this.gridDefaults,this.defaults||{},t),typeof this.options.units=="string"&&(this.options.postUnits=t.units),this.raphael=new Raphael(this.el[0]),this.elementWidth=null,this.elementHeight=null,this.dirty=!1,this.init&&this.init(),this.setData(this.options.data),this.el.bind("mousemove",function(e){var t;return t=n.el.offset(),n.fire("hovermove",e.pageX-t.left,e.pageY-t.top)}),this.el.bind("mouseout",function(e){return n.fire("hoverout")}),this.el.bind("touchstart touchmove touchend",function(e){var t,r;return r=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0],t=n.el.offset(),n.fire("hover",r.pageX-t.left,r.pageY-t.top),r}),this.el.bind("click",function(e){var t;return t=n.el.offset(),n.fire("gridclick",e.pageX-t.left,e.pageY-t.top)}),this.postInit&&this.postInit()}return o(r,n),r.prototype.gridDefaults={dateFormat:null,axes:!0,grid:!0,gridLineColor:"#aaa",gridStrokeWidth:.5,gridTextColor:"#888",gridTextSize:12,gridTextFamily:"sans-serif",gridTextWeight:"normal",hideHover:!1,yLabelFormat:null,xLabelAngle:0,numLines:5,padding:25,parseTime:!0,postUnits:"",preUnits:"",ymax:"auto",ymin:"auto 0",goals:[],goalStrokeWidth:1,goalLineColors:["#666633","#999966","#cc6666","#663333"],events:[],eventStrokeWidth:1,eventLineColors:["#005a04","#ccffbb","#3a5f0b","#005502"]},r.prototype.setData=function(e,n){var r,i,s,o,u,a,f,l,c,h,p,d,v,m;n==null&&(n=!0),this.options.data=e;if(e==null||e.length===0){this.data=[],this.raphael.clear(),this.hover!=null&&this.hover.hide();return}d=this.cumulative?0:null,v=this.cumulative?0:null,this.options.goals.length>0&&(u=Math.min.apply(null,this.options.goals),o=Math.max.apply(null,this.options.goals),v=v!=null?Math.min(v,u):u,d=d!=null?Math.max(d,o):o),this.data=function(){var n,r,o;o=[];for(s=n=0,r=e.length;n<r;s=++n)f=e[s],a={},a.label=f[this.options.xkey],this.options.parseTime?(a.x=t.parseDate(a.label),this.options.dateFormat?a.label=this.options.dateFormat(a.x):typeof a.label=="number"&&(a.label=(new Date(a.label)).toString())):(a.x=s,this.options.xLabelFormat&&(a.label=this.options.xLabelFormat(a))),c=0,a.y=function(){var e,t,n,r;n=this.options.ykeys,r=[];for(i=e=0,t=n.length;e<t;i=++e)p=n[i],m=f[p],typeof m=="string"&&(m=parseFloat(m)),m!=null&&typeof m!="number"&&(m=null),m!=null&&(this.cumulative?c+=m:d!=null?(d=Math.max(m,d),v=Math.min(m,v)):d=v=m),this.cumulative&&c!=null&&(d=Math.max(c,d),v=Math.min(c,v)),r.push(m);return r}.call(this),o.push(a);return o}.call(this),this.options.parseTime&&(this.data=this.data.sort(function(e,t){return(e.x>t.x)-(t.x>e.x)})),this.xmin=this.data[0].x,this.xmax=this.data[this.data.length-1].x,this.events=[],this.options.parseTime&&this.options.events.length>0&&(this.events=function(){var e,n,i,s;i=this.options.events,s=[];for(e=0,n=i.length;e<n;e++)r=i[e],s.push(t.parseDate(r));return s}.call(this),this.xmax=Math.max(this.xmax,Math.max.apply(null,this.events)),this.xmin=Math.min(this.xmin,Math.min.apply(null,this.events))),this.xmin===this.xmax&&(this.xmin-=1,this.xmax+=1),this.ymin=this.yboundary("min",v),this.ymax=this.yboundary("max",d),this.ymin===this.ymax&&(v&&(this.ymin-=1),this.ymax+=1);if(this.options.axes===!0||this.options.grid===!0)this.options.ymax===this.gridDefaults.ymax&&this.options.ymin===this.gridDefaults.ymin?(this.grid=this.autoGridLines(this.ymin,this.ymax,this.options.numLines),this.ymin=Math.min(this.ymin,this.grid[0]),this.ymax=Math.max(this.ymax,this.grid[this.grid.length-1])):(l=(this.ymax-this.ymin)/(this.options.numLines-1),this.grid=function(){var e,t,n,r;r=[];for(h=e=t=this.ymin,n=this.ymax;t<=n?e<=n:e>=n;h=e+=l)r.push(h);return r}.call(this));this.dirty=!0;if(n)return this.redraw()},r.prototype.yboundary=function(e,t){var n,r;return n=this.options["y"+e],typeof n=="string"?n.slice(0,4)==="auto"?n.length>5?(r=parseInt(n.slice(5),10),t==null?r:Math[e](t,r)):t!=null?t:0:parseInt(n,10):n},r.prototype.autoGridLines=function(e,t,n){var r,i,s,o,u,a,f,l,c;return u=t-e,c=Math.floor(Math.log(u)/Math.log(10)),f=Math.pow(10,c),i=Math.floor(e/f)*f,r=Math.ceil(t/f)*f,a=(r-i)/(n-1),f===1&&a>1&&Math.ceil(a)!==a&&(a=Math.ceil(a),r=i+a*(n-1)),i<0&&r>0&&(i=Math.floor(e/a)*a,r=Math.ceil(t/a)*a),a<1?(o=Math.floor(Math.log(a)/Math.log(10)),s=function(){var e,t;t=[];for(l=e=i;i<=r?e<=r:e>=r;l=e+=a)t.push(parseFloat(l.toFixed(1-o)));return t}()):s=function(){var e,t;t=[];for(l=e=i;i<=r?e<=r:e>=r;l=e+=a)t.push(l);return t}(),s},r.prototype._calc=function(){var e,t,n,r,i,s;i=this.el.width(),n=this.el.height();if(this.elementWidth!==i||this.elementHeight!==n||this.dirty){this.elementWidth=i,this.elementHeight=n,this.dirty=!1,this.left=this.options.padding,this.right=this.elementWidth-this.options.padding,this.top=this.options.padding,this.bottom=this.elementHeight-this.options.padding,this.options.axes&&(s=function(){var e,n,r,i;r=this.grid,i=[];for(e=0,n=r.length;e<n;e++)t=r[e],i.push(this.measureText(this.yAxisFormat(t)).width);return i}.call(this),this.left+=Math.max.apply(Math,s),e=function(){var e,t,n;n=[];for(r=e=0,t=this.data.length;0<=t?e<t:e>t;r=0<=t?++e:--e)n.push(this.measureText(this.data[r].text,-this.options.xLabelAngle).height);return n}.call(this),this.bottom-=Math.max.apply(Math,e)),this.width=Math.max(1,this.right-this.left),this.height=Math.max(1,this.bottom-this.top),this.dx=this.width/(this.xmax-this.xmin),this.dy=this.height/(this.ymax-this.ymin);if(this.calc)return this.calc()}},r.prototype.transY=function(e){return this.bottom-(e-this.ymin)*this.dy},r.prototype.transX=function(e){return this.data.length===1?(this.left+this.right)/2:this.left+(e-this.xmin)*this.dx},r.prototype.redraw=function(){this.raphael.clear(),this._calc(),this.drawGrid(),this.drawGoals(),this.drawEvents();if(this.draw)return this.draw()},r.prototype.measureText=function(e,t){var n,r;return t==null&&(t=0),r=this.raphael.text(100,100,e).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).rotate(t),n=r.getBBox(),r.remove(),n},r.prototype.yAxisFormat=function(e){return this.yLabelFormat(e)},r.prototype.yLabelFormat=function(e){return typeof this.options.yLabelFormat=="function"?this.options.yLabelFormat(e):""+this.options.preUnits+t.commas(e)+this.options.postUnits},r.prototype.updateHover=function(e,t){var n,r;n=this.hitTest(e,t);if(n!=null)return(r=this.hover).update.apply(r,n)},r.prototype.drawGrid=function(){var e,t,n,r,i,s;if(this.options.grid===!1&&this.options.axes===!1)return;i=this.grid,s=[];for(n=0,r=i.length;n<r;n++)e=i[n],t=this.transY(e),this.options.axes&&this.drawYAxisLabel(this.left-this.options.padding/2,t,this.yAxisFormat(e)),this.options.grid?s.push(this.drawGridLine("M"+this.left+","+t+"H"+(this.left+this.width))):s.push(void 0);return s},r.prototype.drawGoals=function(){var e,t,n,r,i,s,o;s=this.options.goals,o=[];for(n=r=0,i=s.length;r<i;n=++r)t=s[n],e=this.options.goalLineColors[n%this.options.goalLineColors.length],o.push(this.drawGoal(t,e));return o},r.prototype.drawEvents=function(){var e,t,n,r,i,s,o;s=this.events,o=[];for(n=r=0,i=s.length;r<i;n=++r)t=s[n],e=this.options.eventLineColors[n%this.options.eventLineColors.length],o.push(this.drawEvent(t,e));return o},r.prototype.drawGoal=function(e,t){return this.raphael.path("M"+this.left+","+this.transY(e)+"H"+this.right).attr("stroke",t).attr("stroke-width",this.options.goalStrokeWidth)},r.prototype.drawEvent=function(e,t){return this.raphael.path("M"+this.transX(e)+","+this.bottom+"V"+this.top).attr("stroke",t).attr("stroke-width",this.options.eventStrokeWidth)},r.prototype.drawYAxisLabel=function(e,t,n){return this.raphael.text(e,t,n).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor).attr("text-anchor","end")},r.prototype.drawGridLine=function(e){return this.raphael.path(e).attr("stroke",this.options.gridLineColor).attr("stroke-width",this.options.gridStrokeWidth)},r}(t.EventEmitter),t.parseDate=function(e){var t,n,r,i,s,o,u,a,f,l,c;return typeof e=="number"?e:(n=e.match(/^(\d+) Q(\d)$/),i=e.match(/^(\d+)-(\d+)$/),s=e.match(/^(\d+)-(\d+)-(\d+)$/),u=e.match(/^(\d+) W(\d+)$/),a=e.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/),f=e.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/),n?(new Date(parseInt(n[1],10),parseInt(n[2],10)*3-1,1)).getTime():i?(new Date(parseInt(i[1],10),parseInt(i[2],10)-1,1)).getTime():s?(new Date(parseInt(s[1],10),parseInt(s[2],10)-1,parseInt(s[3],10))).getTime():u?(l=new Date(parseInt(u[1],10),0,1),l.getDay()!==4&&l.setMonth(0,1+(4-l.getDay()+7)%7),l.getTime()+parseInt(u[2],10)*6048e5):a?a[6]?(o=0,a[6]!=="Z"&&(o=parseInt(a[8],10)*60+parseInt(a[9],10),a[7]==="+"&&(o=0-o)),Date.UTC(parseInt(a[1],10),parseInt(a[2],10)-1,parseInt(a[3],10),parseInt(a[4],10),parseInt(a[5],10)+o)):(new Date(parseInt(a[1],10),parseInt(a[2],10)-1,parseInt(a[3],10),parseInt(a[4],10),parseInt(a[5],10))).getTime():f?(c=parseFloat(f[6]),t=Math.floor(c),r=Math.round((c-t)*1e3),f[8]?(o=0,f[8]!=="Z"&&(o=parseInt(f[10],10)*60+parseInt(f[11],10),f[9]==="+"&&(o=0-o)),Date.UTC(parseInt(f[1],10),parseInt(f[2],10)-1,parseInt(f[3],10),parseInt(f[4],10),parseInt(f[5],10)+o,t,r)):(new Date(parseInt(f[1],10),parseInt(f[2],10)-1,parseInt(f[3],10),parseInt(f[4],10),parseInt(f[5],10),t,r)).getTime()):(new Date(parseInt(e,10),0,1)).getTime())},t.Hover=function(){function n(n){n==null&&(n={}),this.options=e.extend({},t.Hover.defaults,n),this.el=e("<div class='"+this.options["class"]+"'></div>"),this.el.hide(),this.options.parent.append(this.el)}return n.defaults={"class":"morris-hover morris-default-style"},n.prototype.update=function(e,t,n){return this.html(e),this.show(),this.moveTo(t,n)},n.prototype.html=function(e){return this.el.html(e)},n.prototype.moveTo=function(e,t){var n,r,i,s,o,u;return o=this.options.parent.innerWidth(),s=this.options.parent.innerHeight(),r=this.el.outerWidth(),n=this.el.outerHeight(),i=Math.min(Math.max(0,e-r/2),o-r),t!=null?(u=t-n-10,u<0&&(u=t+10,u+n>s&&(u=s/2-n/2))):u=s/2-n/2,this.el.css({left:i+"px",top:parseInt(u)+"px"})},n.prototype.show=function(){return this.el.show()},n.prototype.hide=function(){return this.el.hide()},n}(),t.Line=function(e){function n(e){this.hilight=u(this.hilight,this),this.onHoverOut=u(this.onHoverOut,this),this.onHoverMove=u(this.onHoverMove,this),this.onGridClick=u(this.onGridClick,this);if(!(this instanceof t.Line))return new t.Line(e);n.__super__.constructor.call(this,e)}return o(n,e),n.prototype.init=function(){this.pointGrow=Raphael.animation({r:this.options.pointSize+3},25,"linear"),this.pointShrink=Raphael.animation({r:this.options.pointSize},25,"linear");if(this.options.hideHover!=="always")return this.hover=new t.Hover({parent:this.el}),this.on("hovermove",this.onHoverMove),this.on("hoverout",this.onHoverOut),this.on("gridclick",this.onGridClick)},n.prototype.defaults={lineWidth:3,pointSize:4,lineColors:["#0b62a4","#7A92A3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],pointWidths:[1],pointStrokeColors:["#ffffff"],pointFillColors:[],smooth:!0,xLabels:"auto",xLabelFormat:null,xLabelMargin:24,continuousLine:!0,hideHover:!1},n.prototype.calc=function(){return this.calcPoints(),this.generatePaths()},n.prototype.calcPoints=function(){var e,t,n,r,i,s;i=this.data,s=[];for(n=0,r=i.length;n<r;n++)e=i[n],e._x=this.transX(e.x),e._y=function(){var n,r,i,s;i=e.y,s=[];for(n=0,r=i.length;n<r;n++)t=i[n],t!=null?s.push(this.transY(t)):s.push(t);return s}.call(this),s.push(e._ymax=Math.min.apply(null,[this.bottom].concat(function(){var n,r,i,s;i=e._y,s=[];for(n=0,r=i.length;n<r;n++)t=i[n],t!=null&&s.push(t);return s}())));return s},n.prototype.hitTest=function(e,t){var n,r,i,s,o;if(this.data.length===0)return null;o=this.data.slice(1);for(n=i=0,s=o.length;i<s;n=++i){r=o[n];if(e<(r._x+this.data[n]._x)/2)break}return n},n.prototype.onGridClick=function(e,t){var n;return n=this.hitTest(e,t),this.fire("click",n,this.options.data[n],e,t)},n.prototype.onHoverMove=function(e,t){var n;return n=this.hitTest(e,t),this.displayHoverForRow(n)},n.prototype.onHoverOut=function(){if(this.options.hideHover!==!1)return this.displayHoverForRow(null)},n.prototype.displayHoverForRow=function(e){var t;return e!=null?((t=this.hover).update.apply(t,this.hoverContentForRow(e)),this.hilight(e)):(this.hover.hide(),this.hilight())},n.prototype.hoverContentForRow=function(e){var t,n,r,i,s,o,u;r=this.data[e],t="<div class='morris-hover-row-label'>"+r.label+"</div>",u=r.y;for(n=s=0,o=u.length;s<o;n=++s)i=u[n],t+="<div class='morris-hover-point' style='color: "+this.colorFor(r,n,"label")+"'>\n "+this.options.labels[n]+":\n "+this.yLabelFormat(i)+"\n</div>";return typeof this.options.hoverCallback=="function"&&(t=this.options.hoverCallback(e,this.options,t)),[t,r._x,r._ymax]},n.prototype.generatePaths=function(){var e,n,r,i,s;return this.paths=function(){var o,u,f,l;l=[];for(r=o=0,u=this.options.ykeys.length;0<=u?o<u:o>u;r=0<=u?++o:--o)s=this.options.smooth===!0||(f=this.options.ykeys[r],a.call(this.options.smooth,f)>=0),n=function(){var e,t,n,s;n=this.data,s=[];for(e=0,t=n.length;e<t;e++)i=n[e],i._y[r]!==void 0&&s.push({x:i._x,y:i._y[r]});return s}.call(this),this.options.continuousLine&&(n=function(){var t,r,i;i=[];for(t=0,r=n.length;t<r;t++)e=n[t],e.y!==null&&i.push(e);return i}()),n.length>1?l.push(t.Line.createPath(n,s,this.bottom)):l.push(null);return l}.call(this)},n.prototype.draw=function(){this.options.axes&&this.drawXAxis(),this.drawSeries();if(this.options.hideHover===!1)return this.displayHoverForRow(this.data.length-1)},n.prototype.drawXAxis=function(){var e,n,r,i,s,o,u,a,f,l,c=this;u=this.bottom+this.options.padding/2,s=null,i=null,e=function(e,t){var n,r,o,a,f;return n=c.drawXAxisLabel(c.transX(t),u,e),f=n.getBBox(),n.transform("r"+ -c.options.xLabelAngle),r=n.getBBox(),n.transform("t0,"+r.height/2+"..."),c.options.xLabelAngle!==0&&(a=-0.5*f.width*Math.cos(c.options.xLabelAngle*Math.PI/180),n.transform("t"+a+",0...")),r=n.getBBox(),(s==null||s>=r.x+r.width||i!=null&&i>=r.x)&&r.x>=0&&r.x+r.width<c.el.width()?(c.options.xLabelAngle!==0&&(o=1.25*c.options.gridTextSize/Math.sin(c.options.xLabelAngle*Math.PI/180),i=r.x-o),s=r.x-c.options.xLabelMargin):n.remove()},this.options.parseTime?this.data.length===1&&this.options.xLabels==="auto"?r=[[this.data[0].label,this.data[0].x]]:r=t.labelSeries(this.xmin,this.xmax,this.width,this.options.xLabels,this.options.xLabelFormat):r=function(){var e,t,n,r;n=this.data,r=[];for(e=0,t=n.length;e<t;e++)o=n[e],r.push([o.label,o.x]);return r}.call(this),r.reverse(),l=[];for(a=0,f=r.length;a<f;a++)n=r[a],l.push(e(n[0],n[1]));return l},n.prototype.drawSeries=function(){var e,t,n,r,i,s;this.seriesPoints=[];for(e=t=r=this.options.ykeys.length-1;r<=0?t<=0:t>=0;e=r<=0?++t:--t)this._drawLineFor(e);s=[];for(e=n=i=this.options.ykeys.length-1;i<=0?n<=0:n>=0;e=i<=0?++n:--n)s.push(this._drawPointFor(e));return s},n.prototype._drawPointFor=function(e){var t,n,r,i,s,o;this.seriesPoints[e]=[],s=this.data,o=[];for(r=0,i=s.length;r<i;r++)n=s[r],t=null,n._y[e]!=null&&(t=this.drawLinePoint(n._x,n._y[e],this.options.pointSize,this.colorFor(n,e,"point"),e)),o.push(this.seriesPoints[e].push(t));return o},n.prototype._drawLineFor=function(e){var t;t=this.paths[e];if(t!==null)return this.drawLinePath(t,this.colorFor(null,e,"line"))},n.createPath=function(e,n,r){var i,s,o,u,a,f,l,c,h,p,d,v,m,g;l="",n&&(o=t.Line.gradients(e)),c={y:null};for(u=m=0,g=e.length;m<g;u=++m){i=e[u];if(i.y!=null)if(c.y!=null)n?(s=o[u],f=o[u-1],a=(i.x-c.x)/4,h=c.x+a,d=Math.min(r,c.y+a*f),p=i.x-a,v=Math.min(r,i.y-a*s),l+="C"+h+","+d+","+p+","+v+","+i.x+","+i.y):l+="L"+i.x+","+i.y;else if(!n||o[u]!=null)l+="M"+i.x+","+i.y;c=i}return l},n.gradients=function(e){var t,n,r,i,s,o,u,a;n=function(e,t){return(e.y-t.y)/(e.x-t.x)},a=[];for(r=o=0,u=e.length;o<u;r=++o)t=e[r],t.y!=null?(i=e[r+1]||{y:null},s=e[r-1]||{y:null},s.y!=null&&i.y!=null?a.push(n(s,i)):s.y!=null?a.push(n(s,t)):i.y!=null?a.push(n(t,i)):a.push(null)):a.push(null);return a},n.prototype.hilight=function(e){var t,n,r,i,s;if(this.prevHilight!==null&&this.prevHilight!==e)for(t=n=0,i=this.seriesPoints.length-1;0<=i?n<=i:n>=i;t=0<=i?++n:--n)this.seriesPoints[t][this.prevHilight]&&this.seriesPoints[t][this.prevHilight].animate(this.pointShrink);if(e!==null&&this.prevHilight!==e)for(t=r=0,s=this.seriesPoints.length-1;0<=s?r<=s:r>=s;t=0<=s?++r:--r)this.seriesPoints[t][e]&&this.seriesPoints[t][e].animate(this.pointGrow);return this.prevHilight=e},n.prototype.colorFor=function(e,t,n){return typeof this.options.lineColors=="function"?this.options.lineColors.call(this,e,t,n):n==="point"?this.options.pointFillColors[t%this.options.pointFillColors.length]||this.options.lineColors[t%this.options.lineColors.length]:this.options.lineColors[t%this.options.lineColors.length]},n.prototype.drawXAxisLabel=function(e,t,n){return this.raphael.text(e,t,n).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)},n.prototype.drawLinePath=function(e,t){return this.raphael.path(e).attr("stroke",t).attr("stroke-width",this.options.lineWidth)},n.prototype.drawLinePoint=function(e,t,n,r,i){return this.raphael.circle(e,t,n).attr("fill",r).attr("stroke-width",this.strokeWidthForSeries(i)).attr("stroke",this.strokeForSeries(i))},n.prototype.strokeWidthForSeries=function(e){return this.options.pointWidths[e%this.options.pointWidths.length]},n.prototype.strokeForSeries=function(e){return this.options.pointStrokeColors[e%this.options.pointStrokeColors.length]},n}(t.Grid),t.labelSeries=function(n,r,i,s,o){var u,a,f,l,c,h,p,d,v,m,g;f=200*(r-n)/i,a=new Date(n),p=t.LABEL_SPECS[s];if(p===void 0){g=t.AUTO_LABEL_ORDER;for(v=0,m=g.length;v<m;v++){l=g[v],h=t.LABEL_SPECS[l];if(f>=h.span){p=h;break}}}p===void 0&&(p=t.LABEL_SPECS.second),o&&(p=e.extend({},p,{fmt:o})),u=p.start(a),c=[];while((d=u.getTime())<=r)d>=n&&c.push([p.fmt(u),d]),p.incr(u);return c},n=function(e){return{span:e*60*1e3,start:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours())},fmt:function(e){return""+t.pad2(e.getHours())+":"+t.pad2(e.getMinutes())},incr:function(t){return t.setUTCMinutes(t.getUTCMinutes()+e)}}},r=function(e){return{span:e*1e3,start:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes())},fmt:function(e){return""+t.pad2(e.getHours())+":"+t.pad2(e.getMinutes())+":"+t.pad2(e.getSeconds())},incr:function(t){return t.setUTCSeconds(t.getUTCSeconds()+e)}}},t.LABEL_SPECS={decade:{span:1728e8,start:function(e){return new Date(e.getFullYear()-e.getFullYear()%10,0,1)},fmt:function(e){return""+e.getFullYear()},incr:function(e){return e.setFullYear(e.getFullYear()+10)}},year:{span:1728e7,start:function(e){return new Date(e.getFullYear(),0,1)},fmt:function(e){return""+e.getFullYear()},incr:function(e){return e.setFullYear(e.getFullYear()+1)}},month:{span:24192e5,start:function(e){return new Date(e.getFullYear(),e.getMonth(),1)},fmt:function(e){return""+e.getFullYear()+"-"+t.pad2(e.getMonth()+1)},incr:function(e){return e.setMonth(e.getMonth()+1)}},day:{span:864e5,start:function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())},fmt:function(e){return""+e.getFullYear()+"-"+t.pad2(e.getMonth()+1)+"-"+t.pad2(e.getDate())},incr:function(e){return e.setDate(e.getDate()+1)}},hour:n(60),"30min":n(30),"15min":n(15),"10min":n(10),"5min":n(5),minute:n(1),"30sec":r(30),"15sec":r(15),"10sec":r(10),"5sec":r(5),second:r(1)},t.AUTO_LABEL_ORDER=["decade","year","month","day","hour","30min","15min","10min","5min","minute","30sec","15sec","10sec","5sec","second"],t.Area=function(n){function i(n){var s;if(!(this instanceof t.Area))return new t.Area(n);s=e.extend({},r,n),this.cumulative=!s.behaveLikeLine,s.fillOpacity==="auto"&&(s.fillOpacity=s.behaveLikeLine?.8:1),i.__super__.constructor.call(this,s)}var r;return o(i,n),r={fillOpacity:"auto",behaveLikeLine:!1},i.prototype.calcPoints=function(){var e,t,n,r,i,s,o;s=this.data,o=[];for(r=0,i=s.length;r<i;r++)e=s[r],e._x=this.transX(e.x),t=0,e._y=function(){var r,i,s,o;s=e.y,o=[];for(r=0,i=s.length;r<i;r++)n=s[r],this.options.behaveLikeLine?o.push(this.transY(n)):(t+=n||0,o.push(this.transY(t)));return o}.call(this),o.push(e._ymax=Math.max.apply(Math,e._y));return o},i.prototype.drawSeries=function(){var e,t,n,r,i,s,o,u,a,f,l;this.seriesPoints=[],this.options.behaveLikeLine?t=function(){a=[];for(var e=0,t=this.options.ykeys.length-1;0<=t?e<=t:e>=t;0<=t?e++:e--)a.push(e);return a}.apply(this):t=function(){f=[];for(var e=u=this.options.ykeys.length-1;u<=0?e<=0:e>=0;u<=0?e++:e--)f.push(e);return f}.apply(this),l=[];for(i=0,s=t.length;i<s;i++)e=t[i],this._drawFillFor(e),this._drawLineFor(e),l.push(this._drawPointFor(e));return l},i.prototype._drawFillFor=function(e){var t;t=this.paths[e];if(t!==null)return t+="L"+this.transX(this.xmax)+","+this.bottom+"L"+this.transX(this.xmin)+","+this.bottom+"Z",this.drawFilledPath(t,this.fillForSeries(e))},i.prototype.fillForSeries=function(e){var t;return t=Raphael.rgb2hsl(this.colorFor(this.data[e],e,"line")),Raphael.hsl(t.h,this.options.behaveLikeLine?t.s*.9:t.s*.75,Math.min(.98,this.options.behaveLikeLine?t.l*1.2:t.l*1.25))},i.prototype.drawFilledPath=function(e,t){return this.raphael.path(e).attr("fill",t).attr("fill-opacity",this.options.fillOpacity).attr("stroke-width",0)},i}(t.Line),t.Bar=function(n){function r(n){this.onHoverOut=u(this.onHoverOut,this),this.onHoverMove=u(this.onHoverMove,this),this.onGridClick=u(this.onGridClick,this);if(!(this instanceof t.Bar))return new t.Bar(n);r.__super__.constructor.call(this,e.extend({},n,{parseTime:!1}))}return o(r,n),r.prototype.init=function(){this.cumulative=this.options.stacked;if(this.options.hideHover!=="always")return this.hover=new t.Hover({parent:this.el}),this.on("hovermove",this.onHoverMove),this.on("hoverout",this.onHoverOut),this.on("gridclick",this.onGridClick)},r.prototype.defaults={barSizeRatio:.75,barGap:3,barColors:["#0b62a4","#7a92a3","#4da74d","#afd8f8","#edc240","#cb4b4b","#9440ed"],xLabelMargin:50},r.prototype.calc=function(){var e;this.calcBars();if(this.options.hideHover===!1)return(e=this.hover).update.apply(e,this.hoverContentForRow(this.data.length-1))},r.prototype.calcBars=function(){var e,t,n,r,i,s,o;s=this.data,o=[];for(e=r=0,i=s.length;r<i;e=++r)t=s[e],t._x=this.left+this.width*(e+.5)/this.data.length,o.push(t._y=function(){var e,r,i,s;i=t.y,s=[];for(e=0,r=i.length;e<r;e++)n=i[e],n!=null?s.push(this.transY(n)):s.push(null);return s}.call(this));return o},r.prototype.draw=function(){return this.options.axes&&this.drawXAxis(),this.drawSeries()},r.prototype.drawXAxis=function(){var e,t,n,r,i,s,o,u,a,f,l,c,h;f=this.bottom+this.options.padding/2,o=null,s=null,h=[];for(e=l=0,c=this.data.length;0<=c?l<c:l>c;e=0<=c?++l:--l)u=this.data[this.data.length-1-e],t=this.drawXAxisLabel(u._x,f,u.label),a=t.getBBox(),t.transform("r"+ -this.options.xLabelAngle),n=t.getBBox(),t.transform("t0,"+n.height/2+"..."),this.options.xLabelAngle!==0&&(i=-0.5*a.width*Math.cos(this.options.xLabelAngle*Math.PI/180),t.transform("t"+i+",0...")),(o==null||o>=n.x+n.width||s!=null&&s>=n.x)&&n.x>=0&&n.x+n.width<this.el.width()?(this.options.xLabelAngle!==0&&(r=1.25*this.options.gridTextSize/Math.sin(this.options.xLabelAngle*Math.PI/180),s=n.x-r),h.push(o=n.x-this.options.xLabelMargin)):h.push(t.remove());return h},r.prototype.drawSeries=function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p;return n=this.width/this.options.data.length,u=this.options.stacked!=null?1:this.options.ykeys.length,e=(n*this.options.barSizeRatio-this.options.barGap*(u-1))/u,o=n*(1-this.options.barSizeRatio)/2,p=this.ymin<=0&&this.ymax>=0?this.transY(0):null,this.bars=function(){var u,d,v,m;v=this.data,m=[];for(r=u=0,d=v.length;u<d;r=++u)a=v[r],i=0,m.push(function(){var u,d,v,m;v=a._y,m=[];for(f=u=0,d=v.length;u<d;f=++u)h=v[f],h!==null?(p?(c=Math.min(h,p),t=Math.max(h,p)):(c=h,t=this.bottom),s=this.left+r*n+o,this.options.stacked||(s+=f*(e+this.options.barGap)),l=t-c,this.options.stacked&&(c-=i),this.drawBar(s,c,e,l,this.colorFor(a,f,"bar")),m.push(i+=l)):m.push(null);return m}.call(this));return m}.call(this)},r.prototype.colorFor=function(e,t,n){var r,i;return typeof this.options.barColors=="function"?(r={x:e.x,y:e.y[t],label:e.label},i={index:t,key:this.options.ykeys[t],label:this.options.labels[t]},this.options.barColors.call(this,r,i,n)):this.options.barColors[t%this.options.barColors.length]},r.prototype.hitTest=function(e,t){return this.data.length===0?null:(e=Math.max(Math.min(e,this.right),this.left),Math.min(this.data.length-1,Math.floor((e-this.left)/(this.width/this.data.length))))},r.prototype.onGridClick=function(e,t){var n;return n=this.hitTest(e,t),this.fire("click",n,this.options.data[n],e,t)},r.prototype.onHoverMove=function(e,t){var n,r;return n=this.hitTest(e,t),(r=this.hover).update.apply(r,this.hoverContentForRow(n))},r.prototype.onHoverOut=function(){if(this.options.hideHover!==!1)return this.hover.hide()},r.prototype.hoverContentForRow=function(e){var t,n,r,i,s,o,u,a;r=this.data[e],t="<div class='morris-hover-row-label'>"+r.label+"</div>",a=r.y;for(n=o=0,u=a.length;o<u;n=++o)s=a[n],t+="<div class='morris-hover-point' style='color: "+this.colorFor(r,n,"label")+"'>\n "+this.options.labels[n]+":\n "+this.yLabelFormat(s)+"\n</div>";return typeof this.options.hoverCallback=="function"&&(t=this.options.hoverCallback(e,this.options,t)),i=this.left+(e+.5)*this.width/this.data.length,[t,i]},r.prototype.drawXAxisLabel=function(e,t,n){var r;return r=this.raphael.text(e,t,n).attr("font-size",this.options.gridTextSize).attr("font-family",this.options.gridTextFamily).attr("font-weight",this.options.gridTextWeight).attr("fill",this.options.gridTextColor)},r.prototype.drawBar=function(e,t,n,r,i){return this.raphael.rect(e,t,n,r).attr("fill",i).attr("stroke-width",0)},r}(t.Grid),t.Donut=function(n){function r(n){this.select=u(this.select,this),this.click=u(this.click,this);var r;if(!(this instanceof t.Donut))return new t.Donut(n);typeof n.element=="string"?this.el=e(document.getElementById(n.element)):this.el=e(n.element),this.options=e.extend({},this.defaults,n);if(this.el===null||this.el.length===0)throw new Error("Graph placeholder not found.");if(n.data===void 0||n.data.length===0)return;this.data=n.data,this.values=function(){var e,t,n,i;n=this.data,i=[];for(e=0,t=n.length;e<t;e++)r=n[e],i.push(parseFloat(r.value));return i}.call(this),this.redraw()}return o(r,n),r.prototype.defaults={colors:["#0B62A4","#3980B5","#679DC6","#95BBD7","#B0CCE1","#095791","#095085","#083E67","#052C48","#042135"],backgroundColor:"#FFFFFF",labelColor:"#000000",formatter:t.commas},r.prototype.redraw=function(){var e,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x;this.el.empty(),this.raphael=new Raphael(this.el[0]),n=this.el.width()/2,r=this.el.height()/2,p=(Math.min(n,r)-10)/3,c=0,w=this.values;for(d=0,g=w.length;d<g;d++)h=w[d],c+=h;a=5/(2*p),e=1.9999*Math.PI-a*this.data.length,o=0,s=0,this.segments=[],E=this.values;for(i=v=0,y=E.length;v<y;i=++v)h=E[i],f=o+a+e*(h/c),l=new t.DonutSegment(n,r,p*2,p,o,f,this.options.colors[s%this.options.colors.length],this.options.backgroundColor,s,this.raphael),l.render(),this.segments.push(l),l.on("hover",this.select),l.on("click",this.click),o=f,s+=1;this.text1=this.drawEmptyDonutLabel(n,r-10,this.options.labelColor,15,800),this.text2=this.drawEmptyDonutLabel(n,r+10,this.options.labelColor,14),u=Math.max.apply(null,function(){var e,t,n,r;n=this.values,r=[];for(e=0,t=n.length;e<t;e++)h=n[e],r.push(h);return r}.call(this)),s=0,S=this.values,x=[];for(m=0,b=S.length;m<b;m++){h=S[m];if(h===u){this.select(s);break}x.push(s+=1)}return x},r.prototype.click=function(e){return this.fire("click",e,this.data[e])},r.prototype.select=function(e){var t,n,r,i,s,o;o=this.segments;for(i=0,s=o.length;i<s;i++)n=o[i],n.deselect();return r=this.segments[e],r.select(),t=this.data[e],this.setLabels(t.label,this.options.formatter(t.value,t))},r.prototype.setLabels=function(e,t){var n,r,i,s,o,u,a,f;return n=(Math.min(this.el.width()/2,this.el.height()/2)-10)*2/3,s=1.8*n,i=n/2,r=n/3,this.text1.attr({text:e,transform:""}),o=this.text1.getBBox(),u=Math.min(s/o.width,i/o.height),this.text1.attr({transform:"S"+u+","+u+","+(o.x+o.width/2)+","+(o.y+o.height)}),this.text2.attr({text:t,transform:""}),a=this.text2.getBBox(),f=Math.min(s/a.width,r/a.height),this.text2.attr({transform:"S"+f+","+f+","+(a.x+a.width/2)+","+a.y})},r.prototype.drawEmptyDonutLabel=function(e,t,n,r,i){var s;return s=this.raphael.text(e,t,"").attr("font-size",r).attr("fill",n),i!=null&&s.attr("font-weight",i),s},r}(t.EventEmitter),t.DonutSegment=function(e){function t(e,t,n,r,i,s,o,a,f,l){this.cx=e,this.cy=t,this.inner=n,this.outer=r,this.color=o,this.backgroundColor=a,this.index=f,this.raphael=l,this.deselect=u(this.deselect,this),this.select=u(this.select,this),this.sin_p0=Math.sin(i),this.cos_p0=Math.cos(i),this.sin_p1=Math.sin(s),this.cos_p1=Math.cos(s),this.is_long=s-i>Math.PI?1:0,this.path=this.calcSegment(this.inner+3,this.inner+this.outer-5),this.selectedPath=this.calcSegment(this.inner+3,this.inner+this.outer),this.hilight=this.calcArc(this.inner)}return o(t,e),t.prototype.calcArcPoints=function(e){return[this.cx+e*this.sin_p0,this.cy+e*this.cos_p0,this.cx+e*this.sin_p1,this.cy+e*this.cos_p1]},t.prototype.calcSegment=function(e,t){var n,r,i,s,o,u,a,f,l,c;return l=this.calcArcPoints(e),n=l[0],i=l[1],r=l[2],s=l[3],c=this.calcArcPoints(t),o=c[0],a=c[1],u=c[2],f=c[3],"M"+n+","+i+("A"+e+","+e+",0,"+this.is_long+",0,"+r+","+s)+("L"+u+","+f)+("A"+t+","+t+",0,"+this.is_long+",1,"+o+","+a)+"Z"},t.prototype.calcArc=function(e){var t,n,r,i,s;return s=this.calcArcPoints(e),t=s[0],r=s[1],n=s[2],i=s[3],"M"+t+","+r+("A"+e+","+e+",0,"+this.is_long+",0,"+n+","+i)},t.prototype.render=function(){var e=this;return this.arc=this.drawDonutArc(this.hilight,this.color),this.seg=this.drawDonutSegment(this.path,this.color,this.backgroundColor,function(){return e.fire("hover",e.index)},function(){return e.fire("click",e.index)})},t.prototype.drawDonutArc=function(e,t){return this.raphael.path(e).attr({stroke:t,"stroke-width":2,opacity:0})},t.prototype.drawDonutSegment=function(e,t,n,r,i){return this.raphael.path(e).attr({fill:t,stroke:n,"stroke-width":3}).hover(r).click(i)},t.prototype.select=function(){if(!this.selected)return this.seg.animate({path:this.selectedPath},150,"<>"),this.arc.animate({opacity:1},150,"<>"),this.selected=!0},t.prototype.deselect=function(){if(this.selected)return this.seg.animate({path:this.path},150,"<>"),this.arc.animate({opacity:0},150,"<>"),this.selected=!1},t}(t.EventEmitter)}).call(this);
|
@@ -0,0 +1,237 @@
|
|
1
|
+
//Flot Line Chart with Tooltips
|
2
|
+
$(document).ready(function(){
|
3
|
+
console.log("document ready");
|
4
|
+
var offset = 0;
|
5
|
+
plot();
|
6
|
+
function plot(){
|
7
|
+
var sin = [], cos = [];
|
8
|
+
for (var i = 0; i < 12; i += 0.2) {
|
9
|
+
sin.push([i, Math.sin(i + offset)]);
|
10
|
+
cos.push([i, Math.cos(i + offset)]);
|
11
|
+
}
|
12
|
+
|
13
|
+
var options = {
|
14
|
+
series: {
|
15
|
+
lines: { show: true },
|
16
|
+
points: { show: true }
|
17
|
+
},
|
18
|
+
grid: {
|
19
|
+
hoverable: true //IMPORTANT! this is needed for tooltip to work
|
20
|
+
},
|
21
|
+
yaxis: { min: -1.2, max: 1.2 },
|
22
|
+
tooltip: true,
|
23
|
+
tooltipOpts: {
|
24
|
+
content: "'%s' of %x.1 is %y.4",
|
25
|
+
shifts: {
|
26
|
+
x: -60,
|
27
|
+
y: 25
|
28
|
+
}
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
var plotObj = $.plot( $("#flot-chart-line"),
|
33
|
+
[ { data: sin, label: "sin(x)"}, { data: cos, label: "cos(x)" } ],
|
34
|
+
options );
|
35
|
+
}
|
36
|
+
});
|
37
|
+
|
38
|
+
//Flot Pie Chart with Tooltips
|
39
|
+
$(function () {
|
40
|
+
|
41
|
+
var data = [
|
42
|
+
{ label: "Series 0", data: 1 },
|
43
|
+
{ label: "Series 1", data: 3 },
|
44
|
+
{ label: "Series 2", data: 9 },
|
45
|
+
{ label: "Series 3", data: 20 }
|
46
|
+
];
|
47
|
+
|
48
|
+
var plotObj = $.plot($("#flot-chart-pie"), data, {
|
49
|
+
series: {
|
50
|
+
pie: {
|
51
|
+
show: true
|
52
|
+
}
|
53
|
+
},
|
54
|
+
grid: {
|
55
|
+
hoverable: true
|
56
|
+
},
|
57
|
+
tooltip: true,
|
58
|
+
tooltipOpts: {
|
59
|
+
content: "%p.0%, %s", // show percentages, rounding to 2 decimal places
|
60
|
+
shifts: {
|
61
|
+
x: 20,
|
62
|
+
y: 0
|
63
|
+
},
|
64
|
+
defaultTheme: false
|
65
|
+
}
|
66
|
+
});
|
67
|
+
|
68
|
+
});
|
69
|
+
|
70
|
+
//Flot Line Charts - Multiple Axes - With Data
|
71
|
+
$(function () {
|
72
|
+
var oilprices = [[1167692400000,61.05], [1167778800000,58.32], [1167865200000,57.35], [1167951600000,56.31], [1168210800000,55.55], [1168297200000,55.64], [1168383600000,54.02], [1168470000000,51.88], [1168556400000,52.99], [1168815600000,52.99], [1168902000000,51.21], [1168988400000,52.24], [1169074800000,50.48], [1169161200000,51.99], [1169420400000,51.13], [1169506800000,55.04], [1169593200000,55.37], [1169679600000,54.23], [1169766000000,55.42], [1170025200000,54.01], [1170111600000,56.97], [1170198000000,58.14], [1170284400000,58.14], [1170370800000,59.02], [1170630000000,58.74], [1170716400000,58.88], [1170802800000,57.71], [1170889200000,59.71], [1170975600000,59.89], [1171234800000,57.81], [1171321200000,59.06], [1171407600000,58.00], [1171494000000,57.99], [1171580400000,59.39], [1171839600000,59.39], [1171926000000,58.07], [1172012400000,60.07], [1172098800000,61.14], [1172444400000,61.39], [1172530800000,61.46], [1172617200000,61.79], [1172703600000,62.00], [1172790000000,60.07], [1173135600000,60.69], [1173222000000,61.82], [1173308400000,60.05], [1173654000000,58.91], [1173740400000,57.93], [1173826800000,58.16], [1173913200000,57.55], [1173999600000,57.11], [1174258800000,56.59], [1174345200000,59.61], [1174518000000,61.69], [1174604400000,62.28], [1174860000000,62.91], [1174946400000,62.93], [1175032800000,64.03], [1175119200000,66.03], [1175205600000,65.87], [1175464800000,64.64], [1175637600000,64.38], [1175724000000,64.28], [1175810400000,64.28], [1176069600000,61.51], [1176156000000,61.89], [1176242400000,62.01], [1176328800000,63.85], [1176415200000,63.63], [1176674400000,63.61], [1176760800000,63.10], [1176847200000,63.13], [1176933600000,61.83], [1177020000000,63.38], [1177279200000,64.58], [1177452000000,65.84], [1177538400000,65.06], [1177624800000,66.46], [1177884000000,64.40], [1178056800000,63.68], [1178143200000,63.19], [1178229600000,61.93], [1178488800000,61.47], [1178575200000,61.55], [1178748000000,61.81], [1178834400000,62.37], [1179093600000,62.46], [1179180000000,63.17], [1179266400000,62.55], [1179352800000,64.94], [1179698400000,66.27], [1179784800000,65.50], [1179871200000,65.77], [1179957600000,64.18], [1180044000000,65.20], [1180389600000,63.15], [1180476000000,63.49], [1180562400000,65.08], [1180908000000,66.30], [1180994400000,65.96], [1181167200000,66.93], [1181253600000,65.98], [1181599200000,65.35], [1181685600000,66.26], [1181858400000,68.00], [1182117600000,69.09], [1182204000000,69.10], [1182290400000,68.19], [1182376800000,68.19], [1182463200000,69.14], [1182722400000,68.19], [1182808800000,67.77], [1182895200000,68.97], [1182981600000,69.57], [1183068000000,70.68], [1183327200000,71.09], [1183413600000,70.92], [1183586400000,71.81], [1183672800000,72.81], [1183932000000,72.19], [1184018400000,72.56], [1184191200000,72.50], [1184277600000,74.15], [1184623200000,75.05], [1184796000000,75.92], [1184882400000,75.57], [1185141600000,74.89], [1185228000000,73.56], [1185314400000,75.57], [1185400800000,74.95], [1185487200000,76.83], [1185832800000,78.21], [1185919200000,76.53], [1186005600000,76.86], [1186092000000,76.00], [1186437600000,71.59], [1186696800000,71.47], [1186956000000,71.62], [1187042400000,71.00], [1187301600000,71.98], [1187560800000,71.12], [1187647200000,69.47], [1187733600000,69.26], [1187820000000,69.83], [1187906400000,71.09], [1188165600000,71.73], [1188338400000,73.36], [1188511200000,74.04], [1188856800000,76.30], [1189116000000,77.49], [1189461600000,78.23], [1189548000000,79.91], [1189634400000,80.09], [1189720800000,79.10], [1189980000000,80.57], [1190066400000,81.93], [1190239200000,83.32], [1190325600000,81.62], [1190584800000,80.95], [1190671200000,79.53], [1190757600000,80.30], [1190844000000,82.88], [1190930400000,81.66], [1191189600000,80.24], [1191276000000,80.05], [1191362400000,79.94], [1191448800000,81.44], [1191535200000,81.22], [1191794400000,79.02], [1191880800000,80.26], [1191967200000,80.30], [1192053600000,83.08], [1192140000000,83.69], [1192399200000,86.13], [1192485600000,87.61], [1192572000000,87.40], [1192658400000,89.47], [1192744800000,88.60], [1193004000000,87.56], [1193090400000,87.56], [1193176800000,87.10], [1193263200000,91.86], [1193612400000,93.53], [1193698800000,94.53], [1193871600000,95.93], [1194217200000,93.98], [1194303600000,96.37], [1194476400000,95.46], [1194562800000,96.32], [1195081200000,93.43], [1195167600000,95.10], [1195426800000,94.64], [1195513200000,95.10], [1196031600000,97.70], [1196118000000,94.42], [1196204400000,90.62], [1196290800000,91.01], [1196377200000,88.71], [1196636400000,88.32], [1196809200000,90.23], [1196982000000,88.28], [1197241200000,87.86], [1197327600000,90.02], [1197414000000,92.25], [1197586800000,90.63], [1197846000000,90.63], [1197932400000,90.49], [1198018800000,91.24], [1198105200000,91.06], [1198191600000,90.49], [1198710000000,96.62], [1198796400000,96.00], [1199142000000,99.62], [1199314800000,99.18], [1199401200000,95.09], [1199660400000,96.33], [1199833200000,95.67], [1200351600000,91.90], [1200438000000,90.84], [1200524400000,90.13], [1200610800000,90.57], [1200956400000,89.21], [1201042800000,86.99], [1201129200000,89.85], [1201474800000,90.99], [1201561200000,91.64], [1201647600000,92.33], [1201734000000,91.75], [1202079600000,90.02], [1202166000000,88.41], [1202252400000,87.14], [1202338800000,88.11], [1202425200000,91.77], [1202770800000,92.78], [1202857200000,93.27], [1202943600000,95.46], [1203030000000,95.46], [1203289200000,101.74], [1203462000000,98.81], [1203894000000,100.88], [1204066800000,99.64], [1204153200000,102.59], [1204239600000,101.84], [1204498800000,99.52], [1204585200000,99.52], [1204671600000,104.52], [1204758000000,105.47], [1204844400000,105.15], [1205103600000,108.75], [1205276400000,109.92], [1205362800000,110.33], [1205449200000,110.21], [1205708400000,105.68], [1205967600000,101.84], [1206313200000,100.86], [1206399600000,101.22], [1206486000000,105.90], [1206572400000,107.58], [1206658800000,105.62], [1206914400000,101.58], [1207000800000,100.98], [1207173600000,103.83], [1207260000000,106.23], [1207605600000,108.50], [1207778400000,110.11], [1207864800000,110.14], [1208210400000,113.79], [1208296800000,114.93], [1208383200000,114.86], [1208728800000,117.48], [1208815200000,118.30], [1208988000000,116.06], [1209074400000,118.52], [1209333600000,118.75], [1209420000000,113.46], [1209592800000,112.52], [1210024800000,121.84], [1210111200000,123.53], [1210197600000,123.69], [1210543200000,124.23], [1210629600000,125.80], [1210716000000,126.29], [1211148000000,127.05], [1211320800000,129.07], [1211493600000,132.19], [1211839200000,128.85], [1212357600000,127.76], [1212703200000,138.54], [1212962400000,136.80], [1213135200000,136.38], [1213308000000,134.86], [1213653600000,134.01], [1213740000000,136.68], [1213912800000,135.65], [1214172000000,134.62], [1214258400000,134.62], [1214344800000,134.62], [1214431200000,139.64], [1214517600000,140.21], [1214776800000,140.00], [1214863200000,140.97], [1214949600000,143.57], [1215036000000,145.29], [1215381600000,141.37], [1215468000000,136.04], [1215727200000,146.40], [1215986400000,145.18], [1216072800000,138.74], [1216159200000,134.60], [1216245600000,129.29], [1216332000000,130.65], [1216677600000,127.95], [1216850400000,127.95], [1217282400000,122.19], [1217455200000,124.08], [1217541600000,125.10], [1217800800000,121.41], [1217887200000,119.17], [1217973600000,118.58], [1218060000000,120.02], [1218405600000,114.45], [1218492000000,113.01], [1218578400000,116.00], [1218751200000,113.77], [1219010400000,112.87], [1219096800000,114.53], [1219269600000,114.98], [1219356000000,114.98], [1219701600000,116.27], [1219788000000,118.15], [1219874400000,115.59], [1219960800000,115.46], [1220306400000,109.71], [1220392800000,109.35], [1220565600000,106.23], [1220824800000,106.34]];
|
73
|
+
var exchangerates = [[1167606000000,0.7580], [1167692400000,0.7580], [1167778800000,0.75470], [1167865200000,0.75490], [1167951600000,0.76130], [1168038000000,0.76550], [1168124400000,0.76930], [1168210800000,0.76940], [1168297200000,0.76880], [1168383600000,0.76780], [1168470000000,0.77080], [1168556400000,0.77270], [1168642800000,0.77490], [1168729200000,0.77410], [1168815600000,0.77410], [1168902000000,0.77320], [1168988400000,0.77270], [1169074800000,0.77370], [1169161200000,0.77240], [1169247600000,0.77120], [1169334000000,0.7720], [1169420400000,0.77210], [1169506800000,0.77170], [1169593200000,0.77040], [1169679600000,0.7690], [1169766000000,0.77110], [1169852400000,0.7740], [1169938800000,0.77450], [1170025200000,0.77450], [1170111600000,0.7740], [1170198000000,0.77160], [1170284400000,0.77130], [1170370800000,0.76780], [1170457200000,0.76880], [1170543600000,0.77180], [1170630000000,0.77180], [1170716400000,0.77280], [1170802800000,0.77290], [1170889200000,0.76980], [1170975600000,0.76850], [1171062000000,0.76810], [1171148400000,0.7690], [1171234800000,0.7690], [1171321200000,0.76980], [1171407600000,0.76990], [1171494000000,0.76510], [1171580400000,0.76130], [1171666800000,0.76160], [1171753200000,0.76140], [1171839600000,0.76140], [1171926000000,0.76070], [1172012400000,0.76020], [1172098800000,0.76110], [1172185200000,0.76220], [1172271600000,0.76150], [1172358000000,0.75980], [1172444400000,0.75980], [1172530800000,0.75920], [1172617200000,0.75730], [1172703600000,0.75660], [1172790000000,0.75670], [1172876400000,0.75910], [1172962800000,0.75820], [1173049200000,0.75850], [1173135600000,0.76130], [1173222000000,0.76310], [1173308400000,0.76150], [1173394800000,0.760], [1173481200000,0.76130], [1173567600000,0.76270], [1173654000000,0.76270], [1173740400000,0.76080], [1173826800000,0.75830], [1173913200000,0.75750], [1173999600000,0.75620], [1174086000000,0.7520], [1174172400000,0.75120], [1174258800000,0.75120], [1174345200000,0.75170], [1174431600000,0.7520], [1174518000000,0.75110], [1174604400000,0.7480], [1174690800000,0.75090], [1174777200000,0.75310], [1174860000000,0.75310], [1174946400000,0.75270], [1175032800000,0.74980], [1175119200000,0.74930], [1175205600000,0.75040], [1175292000000,0.750], [1175378400000,0.74910], [1175464800000,0.74910], [1175551200000,0.74850], [1175637600000,0.74840], [1175724000000,0.74920], [1175810400000,0.74710], [1175896800000,0.74590], [1175983200000,0.74770], [1176069600000,0.74770], [1176156000000,0.74830], [1176242400000,0.74580], [1176328800000,0.74480], [1176415200000,0.7430], [1176501600000,0.73990], [1176588000000,0.73950], [1176674400000,0.73950], [1176760800000,0.73780], [1176847200000,0.73820], [1176933600000,0.73620], [1177020000000,0.73550], [1177106400000,0.73480], [1177192800000,0.73610], [1177279200000,0.73610], [1177365600000,0.73650], [1177452000000,0.73620], [1177538400000,0.73310], [1177624800000,0.73390], [1177711200000,0.73440], [1177797600000,0.73270], [1177884000000,0.73270], [1177970400000,0.73360], [1178056800000,0.73330], [1178143200000,0.73590], [1178229600000,0.73590], [1178316000000,0.73720], [1178402400000,0.7360], [1178488800000,0.7360], [1178575200000,0.7350], [1178661600000,0.73650], [1178748000000,0.73840], [1178834400000,0.73950], [1178920800000,0.74130], [1179007200000,0.73970], [1179093600000,0.73960], [1179180000000,0.73850], [1179266400000,0.73780], [1179352800000,0.73660], [1179439200000,0.740], [1179525600000,0.74110], [1179612000000,0.74060], [1179698400000,0.74050], [1179784800000,0.74140], [1179871200000,0.74310], [1179957600000,0.74310], [1180044000000,0.74380], [1180130400000,0.74430], [1180216800000,0.74430], [1180303200000,0.74430], [1180389600000,0.74340], [1180476000000,0.74290], [1180562400000,0.74420], [1180648800000,0.7440], [1180735200000,0.74390], [1180821600000,0.74370], [1180908000000,0.74370], [1180994400000,0.74290], [1181080800000,0.74030], [1181167200000,0.73990], [1181253600000,0.74180], [1181340000000,0.74680], [1181426400000,0.7480], [1181512800000,0.7480], [1181599200000,0.7490], [1181685600000,0.74940], [1181772000000,0.75220], [1181858400000,0.75150], [1181944800000,0.75020], [1182031200000,0.74720], [1182117600000,0.74720], [1182204000000,0.74620], [1182290400000,0.74550], [1182376800000,0.74490], [1182463200000,0.74670], [1182549600000,0.74580], [1182636000000,0.74270], [1182722400000,0.74270], [1182808800000,0.7430], [1182895200000,0.74290], [1182981600000,0.7440], [1183068000000,0.7430], [1183154400000,0.74220], [1183240800000,0.73880], [1183327200000,0.73880], [1183413600000,0.73690], [1183500000000,0.73450], [1183586400000,0.73450], [1183672800000,0.73450], [1183759200000,0.73520], [1183845600000,0.73410], [1183932000000,0.73410], [1184018400000,0.7340], [1184104800000,0.73240], [1184191200000,0.72720], [1184277600000,0.72640], [1184364000000,0.72550], [1184450400000,0.72580], [1184536800000,0.72580], [1184623200000,0.72560], [1184709600000,0.72570], [1184796000000,0.72470], [1184882400000,0.72430], [1184968800000,0.72440], [1185055200000,0.72350], [1185141600000,0.72350], [1185228000000,0.72350], [1185314400000,0.72350], [1185400800000,0.72620], [1185487200000,0.72880], [1185573600000,0.73010], [1185660000000,0.73370], [1185746400000,0.73370], [1185832800000,0.73240], [1185919200000,0.72970], [1186005600000,0.73170], [1186092000000,0.73150], [1186178400000,0.72880], [1186264800000,0.72630], [1186351200000,0.72630], [1186437600000,0.72420], [1186524000000,0.72530], [1186610400000,0.72640], [1186696800000,0.7270], [1186783200000,0.73120], [1186869600000,0.73050], [1186956000000,0.73050], [1187042400000,0.73180], [1187128800000,0.73580], [1187215200000,0.74090], [1187301600000,0.74540], [1187388000000,0.74370], [1187474400000,0.74240], [1187560800000,0.74240], [1187647200000,0.74150], [1187733600000,0.74190], [1187820000000,0.74140], [1187906400000,0.73770], [1187992800000,0.73550], [1188079200000,0.73150], [1188165600000,0.73150], [1188252000000,0.7320], [1188338400000,0.73320], [1188424800000,0.73460], [1188511200000,0.73280], [1188597600000,0.73230], [1188684000000,0.7340], [1188770400000,0.7340], [1188856800000,0.73360], [1188943200000,0.73510], [1189029600000,0.73460], [1189116000000,0.73210], [1189202400000,0.72940], [1189288800000,0.72660], [1189375200000,0.72660], [1189461600000,0.72540], [1189548000000,0.72420], [1189634400000,0.72130], [1189720800000,0.71970], [1189807200000,0.72090], [1189893600000,0.7210], [1189980000000,0.7210], [1190066400000,0.7210], [1190152800000,0.72090], [1190239200000,0.71590], [1190325600000,0.71330], [1190412000000,0.71050], [1190498400000,0.70990], [1190584800000,0.70990], [1190671200000,0.70930], [1190757600000,0.70930], [1190844000000,0.70760], [1190930400000,0.7070], [1191016800000,0.70490], [1191103200000,0.70120], [1191189600000,0.70110], [1191276000000,0.70190], [1191362400000,0.70460], [1191448800000,0.70630], [1191535200000,0.70890], [1191621600000,0.70770], [1191708000000,0.70770], [1191794400000,0.70770], [1191880800000,0.70910], [1191967200000,0.71180], [1192053600000,0.70790], [1192140000000,0.70530], [1192226400000,0.7050], [1192312800000,0.70550], [1192399200000,0.70550], [1192485600000,0.70450], [1192572000000,0.70510], [1192658400000,0.70510], [1192744800000,0.70170], [1192831200000,0.70], [1192917600000,0.69950], [1193004000000,0.69940], [1193090400000,0.70140], [1193176800000,0.70360], [1193263200000,0.70210], [1193349600000,0.70020], [1193436000000,0.69670], [1193522400000,0.6950], [1193612400000,0.6950], [1193698800000,0.69390], [1193785200000,0.6940], [1193871600000,0.69220], [1193958000000,0.69190], [1194044400000,0.69140], [1194130800000,0.68940], [1194217200000,0.68910], [1194303600000,0.69040], [1194390000000,0.6890], [1194476400000,0.68340], [1194562800000,0.68230], [1194649200000,0.68070], [1194735600000,0.68150], [1194822000000,0.68150], [1194908400000,0.68470], [1194994800000,0.68590], [1195081200000,0.68220], [1195167600000,0.68270], [1195254000000,0.68370], [1195340400000,0.68230], [1195426800000,0.68220], [1195513200000,0.68220], [1195599600000,0.67920], [1195686000000,0.67460], [1195772400000,0.67350], [1195858800000,0.67310], [1195945200000,0.67420], [1196031600000,0.67440], [1196118000000,0.67390], [1196204400000,0.67310], [1196290800000,0.67610], [1196377200000,0.67610], [1196463600000,0.67850], [1196550000000,0.68180], [1196636400000,0.68360], [1196722800000,0.68230], [1196809200000,0.68050], [1196895600000,0.67930], [1196982000000,0.68490], [1197068400000,0.68330], [1197154800000,0.68250], [1197241200000,0.68250], [1197327600000,0.68160], [1197414000000,0.67990], [1197500400000,0.68130], [1197586800000,0.68090], [1197673200000,0.68680], [1197759600000,0.69330], [1197846000000,0.69330], [1197932400000,0.69450], [1198018800000,0.69440], [1198105200000,0.69460], [1198191600000,0.69640], [1198278000000,0.69650], [1198364400000,0.69560], [1198450800000,0.69560], [1198537200000,0.6950], [1198623600000,0.69480], [1198710000000,0.69280], [1198796400000,0.68870], [1198882800000,0.68240], [1198969200000,0.67940], [1199055600000,0.67940], [1199142000000,0.68030], [1199228400000,0.68550], [1199314800000,0.68240], [1199401200000,0.67910], [1199487600000,0.67830], [1199574000000,0.67850], [1199660400000,0.67850], [1199746800000,0.67970], [1199833200000,0.680], [1199919600000,0.68030], [1200006000000,0.68050], [1200092400000,0.6760], [1200178800000,0.6770], [1200265200000,0.6770], [1200351600000,0.67360], [1200438000000,0.67260], [1200524400000,0.67640], [1200610800000,0.68210], [1200697200000,0.68310], [1200783600000,0.68420], [1200870000000,0.68420], [1200956400000,0.68870], [1201042800000,0.69030], [1201129200000,0.68480], [1201215600000,0.68240], [1201302000000,0.67880], [1201388400000,0.68140], [1201474800000,0.68140], [1201561200000,0.67970], [1201647600000,0.67690], [1201734000000,0.67650], [1201820400000,0.67330], [1201906800000,0.67290], [1201993200000,0.67580], [1202079600000,0.67580], [1202166000000,0.6750], [1202252400000,0.6780], [1202338800000,0.68330], [1202425200000,0.68560], [1202511600000,0.69030], [1202598000000,0.68960], [1202684400000,0.68960], [1202770800000,0.68820], [1202857200000,0.68790], [1202943600000,0.68620], [1203030000000,0.68520], [1203116400000,0.68230], [1203202800000,0.68130], [1203289200000,0.68130], [1203375600000,0.68220], [1203462000000,0.68020], [1203548400000,0.68020], [1203634800000,0.67840], [1203721200000,0.67480], [1203807600000,0.67470], [1203894000000,0.67470], [1203980400000,0.67480], [1204066800000,0.67330], [1204153200000,0.6650], [1204239600000,0.66110], [1204326000000,0.65830], [1204412400000,0.6590], [1204498800000,0.6590], [1204585200000,0.65810], [1204671600000,0.65780], [1204758000000,0.65740], [1204844400000,0.65320], [1204930800000,0.65020], [1205017200000,0.65140], [1205103600000,0.65140], [1205190000000,0.65070], [1205276400000,0.6510], [1205362800000,0.64890], [1205449200000,0.64240], [1205535600000,0.64060], [1205622000000,0.63820], [1205708400000,0.63820], [1205794800000,0.63410], [1205881200000,0.63440], [1205967600000,0.63780], [1206054000000,0.64390], [1206140400000,0.64780], [1206226800000,0.64810], [1206313200000,0.64810], [1206399600000,0.64940], [1206486000000,0.64380], [1206572400000,0.63770], [1206658800000,0.63290], [1206745200000,0.63360], [1206831600000,0.63330], [1206914400000,0.63330], [1207000800000,0.6330], [1207087200000,0.63710], [1207173600000,0.64030], [1207260000000,0.63960], [1207346400000,0.63640], [1207432800000,0.63560], [1207519200000,0.63560], [1207605600000,0.63680], [1207692000000,0.63570], [1207778400000,0.63540], [1207864800000,0.6320], [1207951200000,0.63320], [1208037600000,0.63280], [1208124000000,0.63310], [1208210400000,0.63420], [1208296800000,0.63210], [1208383200000,0.63020], [1208469600000,0.62780], [1208556000000,0.63080], [1208642400000,0.63240], [1208728800000,0.63240], [1208815200000,0.63070], [1208901600000,0.62770], [1208988000000,0.62690], [1209074400000,0.63350], [1209160800000,0.63920], [1209247200000,0.640], [1209333600000,0.64010], [1209420000000,0.63960], [1209506400000,0.64070], [1209592800000,0.64230], [1209679200000,0.64290], [1209765600000,0.64720], [1209852000000,0.64850], [1209938400000,0.64860], [1210024800000,0.64670], [1210111200000,0.64440], [1210197600000,0.64670], [1210284000000,0.65090], [1210370400000,0.64780], [1210456800000,0.64610], [1210543200000,0.64610], [1210629600000,0.64680], [1210716000000,0.64490], [1210802400000,0.6470], [1210888800000,0.64610], [1210975200000,0.64520], [1211061600000,0.64220], [1211148000000,0.64220], [1211234400000,0.64250], [1211320800000,0.64140], [1211407200000,0.63660], [1211493600000,0.63460], [1211580000000,0.6350], [1211666400000,0.63460], [1211752800000,0.63460], [1211839200000,0.63430], [1211925600000,0.63460], [1212012000000,0.63790], [1212098400000,0.64160], [1212184800000,0.64420], [1212271200000,0.64310], [1212357600000,0.64310], [1212444000000,0.64350], [1212530400000,0.6440], [1212616800000,0.64730], [1212703200000,0.64690], [1212789600000,0.63860], [1212876000000,0.63560], [1212962400000,0.6340], [1213048800000,0.63460], [1213135200000,0.6430], [1213221600000,0.64520], [1213308000000,0.64670], [1213394400000,0.65060], [1213480800000,0.65040], [1213567200000,0.65030], [1213653600000,0.64810], [1213740000000,0.64510], [1213826400000,0.6450], [1213912800000,0.64410], [1213999200000,0.64140], [1214085600000,0.64090], [1214172000000,0.64090], [1214258400000,0.64280], [1214344800000,0.64310], [1214431200000,0.64180], [1214517600000,0.63710], [1214604000000,0.63490], [1214690400000,0.63330], [1214776800000,0.63340], [1214863200000,0.63380], [1214949600000,0.63420], [1215036000000,0.6320], [1215122400000,0.63180], [1215208800000,0.6370], [1215295200000,0.63680], [1215381600000,0.63680], [1215468000000,0.63830], [1215554400000,0.63710], [1215640800000,0.63710], [1215727200000,0.63550], [1215813600000,0.6320], [1215900000000,0.62770], [1215986400000,0.62760], [1216072800000,0.62910], [1216159200000,0.62740], [1216245600000,0.62930], [1216332000000,0.63110], [1216418400000,0.6310], [1216504800000,0.63120], [1216591200000,0.63120], [1216677600000,0.63040], [1216764000000,0.62940], [1216850400000,0.63480], [1216936800000,0.63780], [1217023200000,0.63680], [1217109600000,0.63680], [1217196000000,0.63680], [1217282400000,0.6360], [1217368800000,0.6370], [1217455200000,0.64180], [1217541600000,0.64110], [1217628000000,0.64350], [1217714400000,0.64270], [1217800800000,0.64270], [1217887200000,0.64190], [1217973600000,0.64460], [1218060000000,0.64680], [1218146400000,0.64870], [1218232800000,0.65940], [1218319200000,0.66660], [1218405600000,0.66660], [1218492000000,0.66780], [1218578400000,0.67120], [1218664800000,0.67050], [1218751200000,0.67180], [1218837600000,0.67840], [1218924000000,0.68110], [1219010400000,0.68110], [1219096800000,0.67940], [1219183200000,0.68040], [1219269600000,0.67810], [1219356000000,0.67560], [1219442400000,0.67350], [1219528800000,0.67630], [1219615200000,0.67620], [1219701600000,0.67770], [1219788000000,0.68150], [1219874400000,0.68020], [1219960800000,0.6780], [1220047200000,0.67960], [1220133600000,0.68170], [1220220000000,0.68170], [1220306400000,0.68320], [1220392800000,0.68770], [1220479200000,0.69120], [1220565600000,0.69140], [1220652000000,0.70090], [1220738400000,0.70120], [1220824800000,0.7010], [1220911200000,0.70050]];
|
74
|
+
|
75
|
+
function euroFormatter(v, axis) {
|
76
|
+
return v.toFixed(axis.tickDecimals) +"€";
|
77
|
+
}
|
78
|
+
|
79
|
+
function doPlot(position) {
|
80
|
+
$.plot($("#flot-chart-multiple-axes"),
|
81
|
+
[ { data: oilprices, label: "Oil price ($)" },
|
82
|
+
{ data: exchangerates, label: "USD/EUR exchange rate", yaxis: 2 }],
|
83
|
+
{
|
84
|
+
xaxes: [ { mode: 'time' } ],
|
85
|
+
yaxes: [ { min: 0 },
|
86
|
+
{
|
87
|
+
// align if we are to the right
|
88
|
+
alignTicksWithAxis: position == "right" ? 1 : null,
|
89
|
+
position: position,
|
90
|
+
tickFormatter: euroFormatter
|
91
|
+
} ],
|
92
|
+
legend: { position: 'sw' },
|
93
|
+
grid: {
|
94
|
+
hoverable: true //IMPORTANT! this is needed for tooltip to work
|
95
|
+
},
|
96
|
+
tooltip: true,
|
97
|
+
tooltipOpts: {
|
98
|
+
content: "%s for %x was %y",
|
99
|
+
xDateFormat: "%y-%0m-%0d",
|
100
|
+
|
101
|
+
onHover: function(flotItem, $tooltipEl) {
|
102
|
+
// console.log(flotItem, $tooltipEl);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
});
|
107
|
+
}
|
108
|
+
|
109
|
+
doPlot("right");
|
110
|
+
|
111
|
+
$("button").click(function () {
|
112
|
+
doPlot($(this).text());
|
113
|
+
});
|
114
|
+
});
|
115
|
+
|
116
|
+
//Flot Chart Dynamic Chart
|
117
|
+
|
118
|
+
$(function() {
|
119
|
+
|
120
|
+
var container = $("#flot-chart-moving-line");
|
121
|
+
|
122
|
+
// Determine how many data points to keep based on the placeholder's initial size;
|
123
|
+
// this gives us a nice high-res plot while avoiding more than one point per pixel.
|
124
|
+
|
125
|
+
var maximum = container.outerWidth() / 2 || 300;
|
126
|
+
|
127
|
+
//
|
128
|
+
|
129
|
+
var data = [];
|
130
|
+
|
131
|
+
function getRandomData() {
|
132
|
+
|
133
|
+
if (data.length) {
|
134
|
+
data = data.slice(1);
|
135
|
+
}
|
136
|
+
|
137
|
+
while (data.length < maximum) {
|
138
|
+
var previous = data.length ? data[data.length - 1] : 50;
|
139
|
+
var y = previous + Math.random() * 10 - 5;
|
140
|
+
data.push(y < 0 ? 0 : y > 100 ? 100 : y);
|
141
|
+
}
|
142
|
+
|
143
|
+
// zip the generated y values with the x values
|
144
|
+
|
145
|
+
var res = [];
|
146
|
+
for (var i = 0; i < data.length; ++i) {
|
147
|
+
res.push([i, data[i]])
|
148
|
+
}
|
149
|
+
|
150
|
+
return res;
|
151
|
+
}
|
152
|
+
|
153
|
+
//
|
154
|
+
|
155
|
+
series = [{
|
156
|
+
data: getRandomData(),
|
157
|
+
lines: {
|
158
|
+
fill: true
|
159
|
+
}
|
160
|
+
}];
|
161
|
+
|
162
|
+
//
|
163
|
+
|
164
|
+
var plot = $.plot(container, series, {
|
165
|
+
grid: {
|
166
|
+
borderWidth: 1,
|
167
|
+
minBorderMargin: 20,
|
168
|
+
labelMargin: 10,
|
169
|
+
backgroundColor: {
|
170
|
+
colors: ["#fff", "#e4f4f4"]
|
171
|
+
},
|
172
|
+
margin: {
|
173
|
+
top: 8,
|
174
|
+
bottom: 20,
|
175
|
+
left: 20
|
176
|
+
},
|
177
|
+
markings: function(axes) {
|
178
|
+
var markings = [];
|
179
|
+
var xaxis = axes.xaxis;
|
180
|
+
for (var x = Math.floor(xaxis.min); x < xaxis.max; x += xaxis.tickSize * 2) {
|
181
|
+
markings.push({ xaxis: { from: x, to: x + xaxis.tickSize }, color: "rgba(232, 232, 255, 0.2)" });
|
182
|
+
}
|
183
|
+
return markings;
|
184
|
+
}
|
185
|
+
},
|
186
|
+
xaxis: {
|
187
|
+
tickFormatter: function() {
|
188
|
+
return "";
|
189
|
+
}
|
190
|
+
},
|
191
|
+
yaxis: {
|
192
|
+
min: 0,
|
193
|
+
max: 110
|
194
|
+
},
|
195
|
+
legend: {
|
196
|
+
show: true
|
197
|
+
}
|
198
|
+
});
|
199
|
+
|
200
|
+
// Update the random dataset at 25FPS for a smoothly-animating chart
|
201
|
+
|
202
|
+
setInterval(function updateRandom() {
|
203
|
+
series[0].data = getRandomData();
|
204
|
+
plot.setData(series);
|
205
|
+
plot.draw();
|
206
|
+
}, 40);
|
207
|
+
|
208
|
+
});
|
209
|
+
|
210
|
+
//Flot Chart Bar Graph
|
211
|
+
|
212
|
+
$(function () {
|
213
|
+
|
214
|
+
var barOptions = {
|
215
|
+
series: {
|
216
|
+
bars: { show: true, barWidth: 43200000 }
|
217
|
+
},
|
218
|
+
xaxis: { mode: "time", timeformat: "%m/%d", minTickSize: [1, "day"] },
|
219
|
+
grid: { hoverable: true },
|
220
|
+
legend: { show: false },
|
221
|
+
tooltip: true,
|
222
|
+
tooltipOpts: {
|
223
|
+
content: "x: %x, y: %y"
|
224
|
+
}
|
225
|
+
};
|
226
|
+
var barData = { label: "bar", data: [
|
227
|
+
[1354521600000, 1000],
|
228
|
+
[1355040000000, 2000],
|
229
|
+
[1355223600000, 3000],
|
230
|
+
[1355306400000, 4000],
|
231
|
+
[1355487300000, 5000],
|
232
|
+
[1355571900000, 6000]
|
233
|
+
]};
|
234
|
+
$.plot($("#flot-chart-bar"), [barData], barOptions);
|
235
|
+
|
236
|
+
});
|
237
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
if(!document.createElement("canvas").getContext){(function(){var z=Math;var K=z.round;var J=z.sin;var U=z.cos;var b=z.abs;var k=z.sqrt;var D=10;var F=D/2;function T(){return this.context_||(this.context_=new W(this))}var O=Array.prototype.slice;function G(i,j,m){var Z=O.call(arguments,2);return function(){return i.apply(j,Z.concat(O.call(arguments)))}}function AD(Z){return String(Z).replace(/&/g,"&").replace(/"/g,""")}function r(i){if(!i.namespaces.g_vml_){i.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML")}if(!i.namespaces.g_o_){i.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML")}if(!i.styleSheets.ex_canvas_){var Z=i.createStyleSheet();Z.owningElement.id="ex_canvas_";Z.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}"}}r(document);var E={init:function(Z){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var i=Z||document;i.createElement("canvas");i.attachEvent("onreadystatechange",G(this.init_,this,i))}},init_:function(m){var j=m.getElementsByTagName("canvas");for(var Z=0;Z<j.length;Z++){this.initElement(j[Z])}},initElement:function(i){if(!i.getContext){i.getContext=T;r(i.ownerDocument);i.innerHTML="";i.attachEvent("onpropertychange",S);i.attachEvent("onresize",w);var Z=i.attributes;if(Z.width&&Z.width.specified){i.style.width=Z.width.nodeValue+"px"}else{i.width=i.clientWidth}if(Z.height&&Z.height.specified){i.style.height=Z.height.nodeValue+"px"}else{i.height=i.clientHeight}}return i}};function S(i){var Z=i.srcElement;switch(i.propertyName){case"width":Z.getContext().clearRect();Z.style.width=Z.attributes.width.nodeValue+"px";Z.firstChild.style.width=Z.clientWidth+"px";break;case"height":Z.getContext().clearRect();Z.style.height=Z.attributes.height.nodeValue+"px";Z.firstChild.style.height=Z.clientHeight+"px";break}}function w(i){var Z=i.srcElement;if(Z.firstChild){Z.firstChild.style.width=Z.clientWidth+"px";Z.firstChild.style.height=Z.clientHeight+"px"}}E.init();var I=[];for(var AC=0;AC<16;AC++){for(var AB=0;AB<16;AB++){I[AC*16+AB]=AC.toString(16)+AB.toString(16)}}function V(){return[[1,0,0],[0,1,0],[0,0,1]]}function d(m,j){var i=V();for(var Z=0;Z<3;Z++){for(var AF=0;AF<3;AF++){var p=0;for(var AE=0;AE<3;AE++){p+=m[Z][AE]*j[AE][AF]}i[Z][AF]=p}}return i}function Q(i,Z){Z.fillStyle=i.fillStyle;Z.lineCap=i.lineCap;Z.lineJoin=i.lineJoin;Z.lineWidth=i.lineWidth;Z.miterLimit=i.miterLimit;Z.shadowBlur=i.shadowBlur;Z.shadowColor=i.shadowColor;Z.shadowOffsetX=i.shadowOffsetX;Z.shadowOffsetY=i.shadowOffsetY;Z.strokeStyle=i.strokeStyle;Z.globalAlpha=i.globalAlpha;Z.font=i.font;Z.textAlign=i.textAlign;Z.textBaseline=i.textBaseline;Z.arcScaleX_=i.arcScaleX_;Z.arcScaleY_=i.arcScaleY_;Z.lineScale_=i.lineScale_}var B={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",grey:"#808080",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",oldlace:"#FDF5E6",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",whitesmoke:"#F5F5F5",yellowgreen:"#9ACD32"};function g(i){var m=i.indexOf("(",3);var Z=i.indexOf(")",m+1);var j=i.substring(m+1,Z).split(",");if(j.length==4&&i.substr(3,1)=="a"){alpha=Number(j[3])}else{j[3]=1}return j}function C(Z){return parseFloat(Z)/100}function N(i,j,Z){return Math.min(Z,Math.max(j,i))}function c(AF){var j,i,Z;h=parseFloat(AF[0])/360%360;if(h<0){h++}s=N(C(AF[1]),0,1);l=N(C(AF[2]),0,1);if(s==0){j=i=Z=l}else{var m=l<0.5?l*(1+s):l+s-l*s;var AE=2*l-m;j=A(AE,m,h+1/3);i=A(AE,m,h);Z=A(AE,m,h-1/3)}return"#"+I[Math.floor(j*255)]+I[Math.floor(i*255)]+I[Math.floor(Z*255)]}function A(i,Z,j){if(j<0){j++}if(j>1){j--}if(6*j<1){return i+(Z-i)*6*j}else{if(2*j<1){return Z}else{if(3*j<2){return i+(Z-i)*(2/3-j)*6}else{return i}}}}function Y(Z){var AE,p=1;Z=String(Z);if(Z.charAt(0)=="#"){AE=Z}else{if(/^rgb/.test(Z)){var m=g(Z);var AE="#",AF;for(var j=0;j<3;j++){if(m[j].indexOf("%")!=-1){AF=Math.floor(C(m[j])*255)}else{AF=Number(m[j])}AE+=I[N(AF,0,255)]}p=m[3]}else{if(/^hsl/.test(Z)){var m=g(Z);AE=c(m);p=m[3]}else{AE=B[Z]||Z}}}return{color:AE,alpha:p}}var L={style:"normal",variant:"normal",weight:"normal",size:10,family:"sans-serif"};var f={};function X(Z){if(f[Z]){return f[Z]}var m=document.createElement("div");var j=m.style;try{j.font=Z}catch(i){}return f[Z]={style:j.fontStyle||L.style,variant:j.fontVariant||L.variant,weight:j.fontWeight||L.weight,size:j.fontSize||L.size,family:j.fontFamily||L.family}}function P(j,i){var Z={};for(var AF in j){Z[AF]=j[AF]}var AE=parseFloat(i.currentStyle.fontSize),m=parseFloat(j.size);if(typeof j.size=="number"){Z.size=j.size}else{if(j.size.indexOf("px")!=-1){Z.size=m}else{if(j.size.indexOf("em")!=-1){Z.size=AE*m}else{if(j.size.indexOf("%")!=-1){Z.size=(AE/100)*m}else{if(j.size.indexOf("pt")!=-1){Z.size=m/0.75}else{Z.size=AE}}}}}Z.size*=0.981;return Z}function AA(Z){return Z.style+" "+Z.variant+" "+Z.weight+" "+Z.size+"px "+Z.family}function t(Z){switch(Z){case"butt":return"flat";case"round":return"round";case"square":default:return"square"}}function W(i){this.m_=V();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.strokeStyle="#000";this.fillStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=D*1;this.globalAlpha=1;this.font="10px sans-serif";this.textAlign="left";this.textBaseline="alphabetic";this.canvas=i;var Z=i.ownerDocument.createElement("div");Z.style.width=i.clientWidth+"px";Z.style.height=i.clientHeight+"px";Z.style.overflow="hidden";Z.style.position="absolute";i.appendChild(Z);this.element_=Z;this.arcScaleX_=1;this.arcScaleY_=1;this.lineScale_=1}var M=W.prototype;M.clearRect=function(){if(this.textMeasureEl_){this.textMeasureEl_.removeNode(true);this.textMeasureEl_=null}this.element_.innerHTML=""};M.beginPath=function(){this.currentPath_=[]};M.moveTo=function(i,Z){var j=this.getCoords_(i,Z);this.currentPath_.push({type:"moveTo",x:j.x,y:j.y});this.currentX_=j.x;this.currentY_=j.y};M.lineTo=function(i,Z){var j=this.getCoords_(i,Z);this.currentPath_.push({type:"lineTo",x:j.x,y:j.y});this.currentX_=j.x;this.currentY_=j.y};M.bezierCurveTo=function(j,i,AI,AH,AG,AE){var Z=this.getCoords_(AG,AE);var AF=this.getCoords_(j,i);var m=this.getCoords_(AI,AH);e(this,AF,m,Z)};function e(Z,m,j,i){Z.currentPath_.push({type:"bezierCurveTo",cp1x:m.x,cp1y:m.y,cp2x:j.x,cp2y:j.y,x:i.x,y:i.y});Z.currentX_=i.x;Z.currentY_=i.y}M.quadraticCurveTo=function(AG,j,i,Z){var AF=this.getCoords_(AG,j);var AE=this.getCoords_(i,Z);var AH={x:this.currentX_+2/3*(AF.x-this.currentX_),y:this.currentY_+2/3*(AF.y-this.currentY_)};var m={x:AH.x+(AE.x-this.currentX_)/3,y:AH.y+(AE.y-this.currentY_)/3};e(this,AH,m,AE)};M.arc=function(AJ,AH,AI,AE,i,j){AI*=D;var AN=j?"at":"wa";var AK=AJ+U(AE)*AI-F;var AM=AH+J(AE)*AI-F;var Z=AJ+U(i)*AI-F;var AL=AH+J(i)*AI-F;if(AK==Z&&!j){AK+=0.125}var m=this.getCoords_(AJ,AH);var AG=this.getCoords_(AK,AM);var AF=this.getCoords_(Z,AL);this.currentPath_.push({type:AN,x:m.x,y:m.y,radius:AI,xStart:AG.x,yStart:AG.y,xEnd:AF.x,yEnd:AF.y})};M.rect=function(j,i,Z,m){this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath()};M.strokeRect=function(j,i,Z,m){var p=this.currentPath_;this.beginPath();this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath();this.stroke();this.currentPath_=p};M.fillRect=function(j,i,Z,m){var p=this.currentPath_;this.beginPath();this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath();this.fill();this.currentPath_=p};M.createLinearGradient=function(i,m,Z,j){var p=new v("gradient");p.x0_=i;p.y0_=m;p.x1_=Z;p.y1_=j;return p};M.createRadialGradient=function(m,AE,j,i,p,Z){var AF=new v("gradientradial");AF.x0_=m;AF.y0_=AE;AF.r0_=j;AF.x1_=i;AF.y1_=p;AF.r1_=Z;return AF};M.drawImage=function(AO,j){var AH,AF,AJ,AV,AM,AK,AQ,AX;var AI=AO.runtimeStyle.width;var AN=AO.runtimeStyle.height;AO.runtimeStyle.width="auto";AO.runtimeStyle.height="auto";var AG=AO.width;var AT=AO.height;AO.runtimeStyle.width=AI;AO.runtimeStyle.height=AN;if(arguments.length==3){AH=arguments[1];AF=arguments[2];AM=AK=0;AQ=AJ=AG;AX=AV=AT}else{if(arguments.length==5){AH=arguments[1];AF=arguments[2];AJ=arguments[3];AV=arguments[4];AM=AK=0;AQ=AG;AX=AT}else{if(arguments.length==9){AM=arguments[1];AK=arguments[2];AQ=arguments[3];AX=arguments[4];AH=arguments[5];AF=arguments[6];AJ=arguments[7];AV=arguments[8]}else{throw Error("Invalid number of arguments")}}}var AW=this.getCoords_(AH,AF);var m=AQ/2;var i=AX/2;var AU=[];var Z=10;var AE=10;AU.push(" <g_vml_:group",' coordsize="',D*Z,",",D*AE,'"',' coordorigin="0,0"',' style="width:',Z,"px;height:",AE,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]||this.m_[1][1]!=1||this.m_[1][0]){var p=[];p.push("M11=",this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",K(AW.x/D),",","Dy=",K(AW.y/D),"");var AS=AW;var AR=this.getCoords_(AH+AJ,AF);var AP=this.getCoords_(AH,AF+AV);var AL=this.getCoords_(AH+AJ,AF+AV);AS.x=z.max(AS.x,AR.x,AP.x,AL.x);AS.y=z.max(AS.y,AR.y,AP.y,AL.y);AU.push("padding:0 ",K(AS.x/D),"px ",K(AS.y/D),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",p.join(""),", sizingmethod='clip');")}else{AU.push("top:",K(AW.y/D),"px;left:",K(AW.x/D),"px;")}AU.push(' ">','<g_vml_:image src="',AO.src,'"',' style="width:',D*AJ,"px;"," height:",D*AV,'px"',' cropleft="',AM/AG,'"',' croptop="',AK/AT,'"',' cropright="',(AG-AM-AQ)/AG,'"',' cropbottom="',(AT-AK-AX)/AT,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",AU.join(""))};M.stroke=function(AM){var m=10;var AN=10;var AE=5000;var AG={x:null,y:null};var AL={x:null,y:null};for(var AH=0;AH<this.currentPath_.length;AH+=AE){var AK=[];var AF=false;AK.push("<g_vml_:shape",' filled="',!!AM,'"',' style="position:absolute;width:',m,"px;height:",AN,'px;"',' coordorigin="0,0"',' coordsize="',D*m,",",D*AN,'"',' stroked="',!AM,'"',' path="');var AO=false;for(var AI=AH;AI<Math.min(AH+AE,this.currentPath_.length);AI++){if(AI%AE==0&&AI>0){AK.push(" m ",K(this.currentPath_[AI-1].x),",",K(this.currentPath_[AI-1].y))}var Z=this.currentPath_[AI];var AJ;switch(Z.type){case"moveTo":AJ=Z;AK.push(" m ",K(Z.x),",",K(Z.y));break;case"lineTo":AK.push(" l ",K(Z.x),",",K(Z.y));break;case"close":AK.push(" x ");Z=null;break;case"bezierCurveTo":AK.push(" c ",K(Z.cp1x),",",K(Z.cp1y),",",K(Z.cp2x),",",K(Z.cp2y),",",K(Z.x),",",K(Z.y));break;case"at":case"wa":AK.push(" ",Z.type," ",K(Z.x-this.arcScaleX_*Z.radius),",",K(Z.y-this.arcScaleY_*Z.radius)," ",K(Z.x+this.arcScaleX_*Z.radius),",",K(Z.y+this.arcScaleY_*Z.radius)," ",K(Z.xStart),",",K(Z.yStart)," ",K(Z.xEnd),",",K(Z.yEnd));break}if(Z){if(AG.x==null||Z.x<AG.x){AG.x=Z.x}if(AL.x==null||Z.x>AL.x){AL.x=Z.x}if(AG.y==null||Z.y<AG.y){AG.y=Z.y}if(AL.y==null||Z.y>AL.y){AL.y=Z.y}}}AK.push(' ">');if(!AM){R(this,AK)}else{a(this,AK,AG,AL)}AK.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",AK.join(""))}};function R(j,AE){var i=Y(j.strokeStyle);var m=i.color;var p=i.alpha*j.globalAlpha;var Z=j.lineScale_*j.lineWidth;if(Z<1){p*=Z}AE.push("<g_vml_:stroke",' opacity="',p,'"',' joinstyle="',j.lineJoin,'"',' miterlimit="',j.miterLimit,'"',' endcap="',t(j.lineCap),'"',' weight="',Z,'px"',' color="',m,'" />')}function a(AO,AG,Ah,AP){var AH=AO.fillStyle;var AY=AO.arcScaleX_;var AX=AO.arcScaleY_;var Z=AP.x-Ah.x;var m=AP.y-Ah.y;if(AH instanceof v){var AL=0;var Ac={x:0,y:0};var AU=0;var AK=1;if(AH.type_=="gradient"){var AJ=AH.x0_/AY;var j=AH.y0_/AX;var AI=AH.x1_/AY;var Aj=AH.y1_/AX;var Ag=AO.getCoords_(AJ,j);var Af=AO.getCoords_(AI,Aj);var AE=Af.x-Ag.x;var p=Af.y-Ag.y;AL=Math.atan2(AE,p)*180/Math.PI;if(AL<0){AL+=360}if(AL<0.000001){AL=0}}else{var Ag=AO.getCoords_(AH.x0_,AH.y0_);Ac={x:(Ag.x-Ah.x)/Z,y:(Ag.y-Ah.y)/m};Z/=AY*D;m/=AX*D;var Aa=z.max(Z,m);AU=2*AH.r0_/Aa;AK=2*AH.r1_/Aa-AU}var AS=AH.colors_;AS.sort(function(Ak,i){return Ak.offset-i.offset});var AN=AS.length;var AR=AS[0].color;var AQ=AS[AN-1].color;var AW=AS[0].alpha*AO.globalAlpha;var AV=AS[AN-1].alpha*AO.globalAlpha;var Ab=[];for(var Ae=0;Ae<AN;Ae++){var AM=AS[Ae];Ab.push(AM.offset*AK+AU+" "+AM.color)}AG.push('<g_vml_:fill type="',AH.type_,'"',' method="none" focus="100%"',' color="',AR,'"',' color2="',AQ,'"',' colors="',Ab.join(","),'"',' opacity="',AV,'"',' g_o_:opacity2="',AW,'"',' angle="',AL,'"',' focusposition="',Ac.x,",",Ac.y,'" />')}else{if(AH instanceof u){if(Z&&m){var AF=-Ah.x;var AZ=-Ah.y;AG.push("<g_vml_:fill",' position="',AF/Z*AY*AY,",",AZ/m*AX*AX,'"',' type="tile"',' src="',AH.src_,'" />')}}else{var Ai=Y(AO.fillStyle);var AT=Ai.color;var Ad=Ai.alpha*AO.globalAlpha;AG.push('<g_vml_:fill color="',AT,'" opacity="',Ad,'" />')}}}M.fill=function(){this.stroke(true)};M.closePath=function(){this.currentPath_.push({type:"close"})};M.getCoords_=function(j,i){var Z=this.m_;return{x:D*(j*Z[0][0]+i*Z[1][0]+Z[2][0])-F,y:D*(j*Z[0][1]+i*Z[1][1]+Z[2][1])-F}};M.save=function(){var Z={};Q(this,Z);this.aStack_.push(Z);this.mStack_.push(this.m_);this.m_=d(V(),this.m_)};M.restore=function(){if(this.aStack_.length){Q(this.aStack_.pop(),this);this.m_=this.mStack_.pop()}};function H(Z){return isFinite(Z[0][0])&&isFinite(Z[0][1])&&isFinite(Z[1][0])&&isFinite(Z[1][1])&&isFinite(Z[2][0])&&isFinite(Z[2][1])}function y(i,Z,j){if(!H(Z)){return }i.m_=Z;if(j){var p=Z[0][0]*Z[1][1]-Z[0][1]*Z[1][0];i.lineScale_=k(b(p))}}M.translate=function(j,i){var Z=[[1,0,0],[0,1,0],[j,i,1]];y(this,d(Z,this.m_),false)};M.rotate=function(i){var m=U(i);var j=J(i);var Z=[[m,j,0],[-j,m,0],[0,0,1]];y(this,d(Z,this.m_),false)};M.scale=function(j,i){this.arcScaleX_*=j;this.arcScaleY_*=i;var Z=[[j,0,0],[0,i,0],[0,0,1]];y(this,d(Z,this.m_),true)};M.transform=function(p,m,AF,AE,i,Z){var j=[[p,m,0],[AF,AE,0],[i,Z,1]];y(this,d(j,this.m_),true)};M.setTransform=function(AE,p,AG,AF,j,i){var Z=[[AE,p,0],[AG,AF,0],[j,i,1]];y(this,Z,true)};M.drawText_=function(AK,AI,AH,AN,AG){var AM=this.m_,AQ=1000,i=0,AP=AQ,AF={x:0,y:0},AE=[];var Z=P(X(this.font),this.element_);var j=AA(Z);var AR=this.element_.currentStyle;var p=this.textAlign.toLowerCase();switch(p){case"left":case"center":case"right":break;case"end":p=AR.direction=="ltr"?"right":"left";break;case"start":p=AR.direction=="rtl"?"right":"left";break;default:p="left"}switch(this.textBaseline){case"hanging":case"top":AF.y=Z.size/1.75;break;case"middle":break;default:case null:case"alphabetic":case"ideographic":case"bottom":AF.y=-Z.size/2.25;break}switch(p){case"right":i=AQ;AP=0.05;break;case"center":i=AP=AQ/2;break}var AO=this.getCoords_(AI+AF.x,AH+AF.y);AE.push('<g_vml_:line from="',-i,' 0" to="',AP,' 0.05" ',' coordsize="100 100" coordorigin="0 0"',' filled="',!AG,'" stroked="',!!AG,'" style="position:absolute;width:1px;height:1px;">');if(AG){R(this,AE)}else{a(this,AE,{x:-i,y:0},{x:AP,y:Z.size})}var AL=AM[0][0].toFixed(3)+","+AM[1][0].toFixed(3)+","+AM[0][1].toFixed(3)+","+AM[1][1].toFixed(3)+",0,0";var AJ=K(AO.x/D)+","+K(AO.y/D);AE.push('<g_vml_:skew on="t" matrix="',AL,'" ',' offset="',AJ,'" origin="',i,' 0" />','<g_vml_:path textpathok="true" />','<g_vml_:textpath on="true" string="',AD(AK),'" style="v-text-align:',p,";font:",AD(j),'" /></g_vml_:line>');this.element_.insertAdjacentHTML("beforeEnd",AE.join(""))};M.fillText=function(j,Z,m,i){this.drawText_(j,Z,m,i,false)};M.strokeText=function(j,Z,m,i){this.drawText_(j,Z,m,i,true)};M.measureText=function(j){if(!this.textMeasureEl_){var Z='<span style="position:absolute;top:-20000px;left:0;padding:0;margin:0;border:none;white-space:pre;"></span>';this.element_.insertAdjacentHTML("beforeEnd",Z);this.textMeasureEl_=this.element_.lastChild}var i=this.element_.ownerDocument;this.textMeasureEl_.innerHTML="";this.textMeasureEl_.style.font=this.font;this.textMeasureEl_.appendChild(i.createTextNode(j));return{width:this.textMeasureEl_.offsetWidth}};M.clip=function(){};M.arcTo=function(){};M.createPattern=function(i,Z){return new u(i,Z)};function v(Z){this.type_=Z;this.x0_=0;this.y0_=0;this.r0_=0;this.x1_=0;this.y1_=0;this.r1_=0;this.colors_=[]}v.prototype.addColorStop=function(i,Z){Z=Y(Z);this.colors_.push({offset:i,color:Z.color,alpha:Z.alpha})};function u(i,Z){q(i);switch(Z){case"repeat":case null:case"":this.repetition_="repeat";break;case"repeat-x":case"repeat-y":case"no-repeat":this.repetition_=Z;break;default:n("SYNTAX_ERR")}this.src_=i.src;this.width_=i.width;this.height_=i.height}function n(Z){throw new o(Z)}function q(Z){if(!Z||Z.nodeType!=1||Z.tagName!="IMG"){n("TYPE_MISMATCH_ERR")}if(Z.readyState!="complete"){n("INVALID_STATE_ERR")}}function o(Z){this.code=this[Z];this.message=Z+": DOM Exception "+this.code}var x=o.prototype=new Error;x.INDEX_SIZE_ERR=1;x.DOMSTRING_SIZE_ERR=2;x.HIERARCHY_REQUEST_ERR=3;x.WRONG_DOCUMENT_ERR=4;x.INVALID_CHARACTER_ERR=5;x.NO_DATA_ALLOWED_ERR=6;x.NO_MODIFICATION_ALLOWED_ERR=7;x.NOT_FOUND_ERR=8;x.NOT_SUPPORTED_ERR=9;x.INUSE_ATTRIBUTE_ERR=10;x.INVALID_STATE_ERR=11;x.SYNTAX_ERR=12;x.INVALID_MODIFICATION_ERR=13;x.NAMESPACE_ERR=14;x.INVALID_ACCESS_ERR=15;x.VALIDATION_ERR=16;x.TYPE_MISMATCH_ERR=17;G_vmlCanvasManager=E;CanvasRenderingContext2D=W;CanvasGradient=v;CanvasPattern=u;DOMException=o})()};
|
@@ -0,0 +1,2599 @@
|
|
1
|
+
/*! Javascript plotting library for jQuery, v. 0.7.
|
2
|
+
*
|
3
|
+
* Released under the MIT license by IOLA, December 2007.
|
4
|
+
*
|
5
|
+
*/
|
6
|
+
|
7
|
+
// first an inline dependency, jquery.colorhelpers.js, we inline it here
|
8
|
+
// for convenience
|
9
|
+
|
10
|
+
/* Plugin for jQuery for working with colors.
|
11
|
+
*
|
12
|
+
* Version 1.1.
|
13
|
+
*
|
14
|
+
* Inspiration from jQuery color animation plugin by John Resig.
|
15
|
+
*
|
16
|
+
* Released under the MIT license by Ole Laursen, October 2009.
|
17
|
+
*
|
18
|
+
* Examples:
|
19
|
+
*
|
20
|
+
* $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
|
21
|
+
* var c = $.color.extract($("#mydiv"), 'background-color');
|
22
|
+
* console.log(c.r, c.g, c.b, c.a);
|
23
|
+
* $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
|
24
|
+
*
|
25
|
+
* Note that .scale() and .add() return the same modified object
|
26
|
+
* instead of making a new one.
|
27
|
+
*
|
28
|
+
* V. 1.1: Fix error handling so e.g. parsing an empty string does
|
29
|
+
* produce a color rather than just crashing.
|
30
|
+
*/
|
31
|
+
(function(B){B.color={};B.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]+=I}return G.normalize()};G.scale=function(J,I){for(var H=0;H<J.length;++H){G[J.charAt(H)]*=I}return G.normalize()};G.toString=function(){if(G.a>=1){return"rgb("+[G.r,G.g,G.b].join(",")+")"}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")"}};G.normalize=function(){function H(J,K,I){return K<J?J:(K>I?I:K)}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G};G.clone=function(){return B.color.make(G.r,G.b,G.g,G.a)};return G.normalize()};B.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break}D=D.parent()}while(!B.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent"}return B.color.parse(E)};B.color.parse=function(F){var E,C=B.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10))}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]))}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55)}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]))}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16))}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16))}var D=B.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0)}else{E=A[D]||[0,0,0];return C(E[0],E[1],E[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);
|
32
|
+
|
33
|
+
// the actual Flot code
|
34
|
+
(function($) {
|
35
|
+
function Plot(placeholder, data_, options_, plugins) {
|
36
|
+
// data is on the form:
|
37
|
+
// [ series1, series2 ... ]
|
38
|
+
// where series is either just the data as [ [x1, y1], [x2, y2], ... ]
|
39
|
+
// or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... }
|
40
|
+
|
41
|
+
var series = [],
|
42
|
+
options = {
|
43
|
+
// the color theme used for graphs
|
44
|
+
colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"],
|
45
|
+
legend: {
|
46
|
+
show: true,
|
47
|
+
noColumns: 1, // number of colums in legend table
|
48
|
+
labelFormatter: null, // fn: string -> string
|
49
|
+
labelBoxBorderColor: "#ccc", // border color for the little label boxes
|
50
|
+
container: null, // container (as jQuery object) to put legend in, null means default on top of graph
|
51
|
+
position: "ne", // position of default legend container within plot
|
52
|
+
margin: 5, // distance from grid edge to default legend container within plot
|
53
|
+
backgroundColor: null, // null means auto-detect
|
54
|
+
backgroundOpacity: 0.85 // set to 0 to avoid background
|
55
|
+
},
|
56
|
+
xaxis: {
|
57
|
+
show: null, // null = auto-detect, true = always, false = never
|
58
|
+
position: "bottom", // or "top"
|
59
|
+
mode: null, // null or "time"
|
60
|
+
color: null, // base color, labels, ticks
|
61
|
+
tickColor: null, // possibly different color of ticks, e.g. "rgba(0,0,0,0.15)"
|
62
|
+
transform: null, // null or f: number -> number to transform axis
|
63
|
+
inverseTransform: null, // if transform is set, this should be the inverse function
|
64
|
+
min: null, // min. value to show, null means set automatically
|
65
|
+
max: null, // max. value to show, null means set automatically
|
66
|
+
autoscaleMargin: null, // margin in % to add if auto-setting min/max
|
67
|
+
ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks
|
68
|
+
tickFormatter: null, // fn: number -> string
|
69
|
+
labelWidth: null, // size of tick labels in pixels
|
70
|
+
labelHeight: null,
|
71
|
+
reserveSpace: null, // whether to reserve space even if axis isn't shown
|
72
|
+
tickLength: null, // size in pixels of ticks, or "full" for whole line
|
73
|
+
alignTicksWithAxis: null, // axis number or null for no sync
|
74
|
+
|
75
|
+
// mode specific options
|
76
|
+
tickDecimals: null, // no. of decimals, null means auto
|
77
|
+
tickSize: null, // number or [number, "unit"]
|
78
|
+
minTickSize: null, // number or [number, "unit"]
|
79
|
+
monthNames: null, // list of names of months
|
80
|
+
timeformat: null, // format string to use
|
81
|
+
twelveHourClock: false // 12 or 24 time in time mode
|
82
|
+
},
|
83
|
+
yaxis: {
|
84
|
+
autoscaleMargin: 0.02,
|
85
|
+
position: "left" // or "right"
|
86
|
+
},
|
87
|
+
xaxes: [],
|
88
|
+
yaxes: [],
|
89
|
+
series: {
|
90
|
+
points: {
|
91
|
+
show: false,
|
92
|
+
radius: 3,
|
93
|
+
lineWidth: 2, // in pixels
|
94
|
+
fill: true,
|
95
|
+
fillColor: "#ffffff",
|
96
|
+
symbol: "circle" // or callback
|
97
|
+
},
|
98
|
+
lines: {
|
99
|
+
// we don't put in show: false so we can see
|
100
|
+
// whether lines were actively disabled
|
101
|
+
lineWidth: 2, // in pixels
|
102
|
+
fill: false,
|
103
|
+
fillColor: null,
|
104
|
+
steps: false
|
105
|
+
},
|
106
|
+
bars: {
|
107
|
+
show: false,
|
108
|
+
lineWidth: 2, // in pixels
|
109
|
+
barWidth: 1, // in units of the x axis
|
110
|
+
fill: true,
|
111
|
+
fillColor: null,
|
112
|
+
align: "left", // or "center"
|
113
|
+
horizontal: false
|
114
|
+
},
|
115
|
+
shadowSize: 3
|
116
|
+
},
|
117
|
+
grid: {
|
118
|
+
show: true,
|
119
|
+
aboveData: false,
|
120
|
+
color: "#545454", // primary color used for outline and labels
|
121
|
+
backgroundColor: null, // null for transparent, else color
|
122
|
+
borderColor: null, // set if different from the grid color
|
123
|
+
tickColor: null, // color for the ticks, e.g. "rgba(0,0,0,0.15)"
|
124
|
+
labelMargin: 5, // in pixels
|
125
|
+
axisMargin: 8, // in pixels
|
126
|
+
borderWidth: 2, // in pixels
|
127
|
+
minBorderMargin: null, // in pixels, null means taken from points radius
|
128
|
+
markings: null, // array of ranges or fn: axes -> array of ranges
|
129
|
+
markingsColor: "#f4f4f4",
|
130
|
+
markingsLineWidth: 2,
|
131
|
+
// interactive stuff
|
132
|
+
clickable: false,
|
133
|
+
hoverable: false,
|
134
|
+
autoHighlight: true, // highlight in case mouse is near
|
135
|
+
mouseActiveRadius: 10 // how far the mouse can be away to activate an item
|
136
|
+
},
|
137
|
+
hooks: {}
|
138
|
+
},
|
139
|
+
canvas = null, // the canvas for the plot itself
|
140
|
+
overlay = null, // canvas for interactive stuff on top of plot
|
141
|
+
eventHolder = null, // jQuery object that events should be bound to
|
142
|
+
ctx = null, octx = null,
|
143
|
+
xaxes = [], yaxes = [],
|
144
|
+
plotOffset = { left: 0, right: 0, top: 0, bottom: 0},
|
145
|
+
canvasWidth = 0, canvasHeight = 0,
|
146
|
+
plotWidth = 0, plotHeight = 0,
|
147
|
+
hooks = {
|
148
|
+
processOptions: [],
|
149
|
+
processRawData: [],
|
150
|
+
processDatapoints: [],
|
151
|
+
drawSeries: [],
|
152
|
+
draw: [],
|
153
|
+
bindEvents: [],
|
154
|
+
drawOverlay: [],
|
155
|
+
shutdown: []
|
156
|
+
},
|
157
|
+
plot = this;
|
158
|
+
|
159
|
+
// public functions
|
160
|
+
plot.setData = setData;
|
161
|
+
plot.setupGrid = setupGrid;
|
162
|
+
plot.draw = draw;
|
163
|
+
plot.getPlaceholder = function() { return placeholder; };
|
164
|
+
plot.getCanvas = function() { return canvas; };
|
165
|
+
plot.getPlotOffset = function() { return plotOffset; };
|
166
|
+
plot.width = function () { return plotWidth; };
|
167
|
+
plot.height = function () { return plotHeight; };
|
168
|
+
plot.offset = function () {
|
169
|
+
var o = eventHolder.offset();
|
170
|
+
o.left += plotOffset.left;
|
171
|
+
o.top += plotOffset.top;
|
172
|
+
return o;
|
173
|
+
};
|
174
|
+
plot.getData = function () { return series; };
|
175
|
+
plot.getAxes = function () {
|
176
|
+
var res = {}, i;
|
177
|
+
$.each(xaxes.concat(yaxes), function (_, axis) {
|
178
|
+
if (axis)
|
179
|
+
res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis;
|
180
|
+
});
|
181
|
+
return res;
|
182
|
+
};
|
183
|
+
plot.getXAxes = function () { return xaxes; };
|
184
|
+
plot.getYAxes = function () { return yaxes; };
|
185
|
+
plot.c2p = canvasToAxisCoords;
|
186
|
+
plot.p2c = axisToCanvasCoords;
|
187
|
+
plot.getOptions = function () { return options; };
|
188
|
+
plot.highlight = highlight;
|
189
|
+
plot.unhighlight = unhighlight;
|
190
|
+
plot.triggerRedrawOverlay = triggerRedrawOverlay;
|
191
|
+
plot.pointOffset = function(point) {
|
192
|
+
return {
|
193
|
+
left: parseInt(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left),
|
194
|
+
top: parseInt(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top)
|
195
|
+
};
|
196
|
+
};
|
197
|
+
plot.shutdown = shutdown;
|
198
|
+
plot.resize = function () {
|
199
|
+
getCanvasDimensions();
|
200
|
+
resizeCanvas(canvas);
|
201
|
+
resizeCanvas(overlay);
|
202
|
+
};
|
203
|
+
|
204
|
+
// public attributes
|
205
|
+
plot.hooks = hooks;
|
206
|
+
|
207
|
+
// initialize
|
208
|
+
initPlugins(plot);
|
209
|
+
parseOptions(options_);
|
210
|
+
setupCanvases();
|
211
|
+
setData(data_);
|
212
|
+
setupGrid();
|
213
|
+
draw();
|
214
|
+
bindEvents();
|
215
|
+
|
216
|
+
|
217
|
+
function executeHooks(hook, args) {
|
218
|
+
args = [plot].concat(args);
|
219
|
+
for (var i = 0; i < hook.length; ++i)
|
220
|
+
hook[i].apply(this, args);
|
221
|
+
}
|
222
|
+
|
223
|
+
function initPlugins() {
|
224
|
+
for (var i = 0; i < plugins.length; ++i) {
|
225
|
+
var p = plugins[i];
|
226
|
+
p.init(plot);
|
227
|
+
if (p.options)
|
228
|
+
$.extend(true, options, p.options);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
function parseOptions(opts) {
|
233
|
+
var i;
|
234
|
+
|
235
|
+
$.extend(true, options, opts);
|
236
|
+
|
237
|
+
if (options.xaxis.color == null)
|
238
|
+
options.xaxis.color = options.grid.color;
|
239
|
+
if (options.yaxis.color == null)
|
240
|
+
options.yaxis.color = options.grid.color;
|
241
|
+
|
242
|
+
if (options.xaxis.tickColor == null) // backwards-compatibility
|
243
|
+
options.xaxis.tickColor = options.grid.tickColor;
|
244
|
+
if (options.yaxis.tickColor == null) // backwards-compatibility
|
245
|
+
options.yaxis.tickColor = options.grid.tickColor;
|
246
|
+
|
247
|
+
if (options.grid.borderColor == null)
|
248
|
+
options.grid.borderColor = options.grid.color;
|
249
|
+
if (options.grid.tickColor == null)
|
250
|
+
options.grid.tickColor = $.color.parse(options.grid.color).scale('a', 0.22).toString();
|
251
|
+
|
252
|
+
// fill in defaults in axes, copy at least always the
|
253
|
+
// first as the rest of the code assumes it'll be there
|
254
|
+
for (i = 0; i < Math.max(1, options.xaxes.length); ++i)
|
255
|
+
options.xaxes[i] = $.extend(true, {}, options.xaxis, options.xaxes[i]);
|
256
|
+
for (i = 0; i < Math.max(1, options.yaxes.length); ++i)
|
257
|
+
options.yaxes[i] = $.extend(true, {}, options.yaxis, options.yaxes[i]);
|
258
|
+
|
259
|
+
// backwards compatibility, to be removed in future
|
260
|
+
if (options.xaxis.noTicks && options.xaxis.ticks == null)
|
261
|
+
options.xaxis.ticks = options.xaxis.noTicks;
|
262
|
+
if (options.yaxis.noTicks && options.yaxis.ticks == null)
|
263
|
+
options.yaxis.ticks = options.yaxis.noTicks;
|
264
|
+
if (options.x2axis) {
|
265
|
+
options.xaxes[1] = $.extend(true, {}, options.xaxis, options.x2axis);
|
266
|
+
options.xaxes[1].position = "top";
|
267
|
+
}
|
268
|
+
if (options.y2axis) {
|
269
|
+
options.yaxes[1] = $.extend(true, {}, options.yaxis, options.y2axis);
|
270
|
+
options.yaxes[1].position = "right";
|
271
|
+
}
|
272
|
+
if (options.grid.coloredAreas)
|
273
|
+
options.grid.markings = options.grid.coloredAreas;
|
274
|
+
if (options.grid.coloredAreasColor)
|
275
|
+
options.grid.markingsColor = options.grid.coloredAreasColor;
|
276
|
+
if (options.lines)
|
277
|
+
$.extend(true, options.series.lines, options.lines);
|
278
|
+
if (options.points)
|
279
|
+
$.extend(true, options.series.points, options.points);
|
280
|
+
if (options.bars)
|
281
|
+
$.extend(true, options.series.bars, options.bars);
|
282
|
+
if (options.shadowSize != null)
|
283
|
+
options.series.shadowSize = options.shadowSize;
|
284
|
+
|
285
|
+
// save options on axes for future reference
|
286
|
+
for (i = 0; i < options.xaxes.length; ++i)
|
287
|
+
getOrCreateAxis(xaxes, i + 1).options = options.xaxes[i];
|
288
|
+
for (i = 0; i < options.yaxes.length; ++i)
|
289
|
+
getOrCreateAxis(yaxes, i + 1).options = options.yaxes[i];
|
290
|
+
|
291
|
+
// add hooks from options
|
292
|
+
for (var n in hooks)
|
293
|
+
if (options.hooks[n] && options.hooks[n].length)
|
294
|
+
hooks[n] = hooks[n].concat(options.hooks[n]);
|
295
|
+
|
296
|
+
executeHooks(hooks.processOptions, [options]);
|
297
|
+
}
|
298
|
+
|
299
|
+
function setData(d) {
|
300
|
+
series = parseData(d);
|
301
|
+
fillInSeriesOptions();
|
302
|
+
processData();
|
303
|
+
}
|
304
|
+
|
305
|
+
function parseData(d) {
|
306
|
+
var res = [];
|
307
|
+
for (var i = 0; i < d.length; ++i) {
|
308
|
+
var s = $.extend(true, {}, options.series);
|
309
|
+
|
310
|
+
if (d[i].data != null) {
|
311
|
+
s.data = d[i].data; // move the data instead of deep-copy
|
312
|
+
delete d[i].data;
|
313
|
+
|
314
|
+
$.extend(true, s, d[i]);
|
315
|
+
|
316
|
+
d[i].data = s.data;
|
317
|
+
}
|
318
|
+
else
|
319
|
+
s.data = d[i];
|
320
|
+
res.push(s);
|
321
|
+
}
|
322
|
+
|
323
|
+
return res;
|
324
|
+
}
|
325
|
+
|
326
|
+
function axisNumber(obj, coord) {
|
327
|
+
var a = obj[coord + "axis"];
|
328
|
+
if (typeof a == "object") // if we got a real axis, extract number
|
329
|
+
a = a.n;
|
330
|
+
if (typeof a != "number")
|
331
|
+
a = 1; // default to first axis
|
332
|
+
return a;
|
333
|
+
}
|
334
|
+
|
335
|
+
function allAxes() {
|
336
|
+
// return flat array without annoying null entries
|
337
|
+
return $.grep(xaxes.concat(yaxes), function (a) { return a; });
|
338
|
+
}
|
339
|
+
|
340
|
+
function canvasToAxisCoords(pos) {
|
341
|
+
// return an object with x/y corresponding to all used axes
|
342
|
+
var res = {}, i, axis;
|
343
|
+
for (i = 0; i < xaxes.length; ++i) {
|
344
|
+
axis = xaxes[i];
|
345
|
+
if (axis && axis.used)
|
346
|
+
res["x" + axis.n] = axis.c2p(pos.left);
|
347
|
+
}
|
348
|
+
|
349
|
+
for (i = 0; i < yaxes.length; ++i) {
|
350
|
+
axis = yaxes[i];
|
351
|
+
if (axis && axis.used)
|
352
|
+
res["y" + axis.n] = axis.c2p(pos.top);
|
353
|
+
}
|
354
|
+
|
355
|
+
if (res.x1 !== undefined)
|
356
|
+
res.x = res.x1;
|
357
|
+
if (res.y1 !== undefined)
|
358
|
+
res.y = res.y1;
|
359
|
+
|
360
|
+
return res;
|
361
|
+
}
|
362
|
+
|
363
|
+
function axisToCanvasCoords(pos) {
|
364
|
+
// get canvas coords from the first pair of x/y found in pos
|
365
|
+
var res = {}, i, axis, key;
|
366
|
+
|
367
|
+
for (i = 0; i < xaxes.length; ++i) {
|
368
|
+
axis = xaxes[i];
|
369
|
+
if (axis && axis.used) {
|
370
|
+
key = "x" + axis.n;
|
371
|
+
if (pos[key] == null && axis.n == 1)
|
372
|
+
key = "x";
|
373
|
+
|
374
|
+
if (pos[key] != null) {
|
375
|
+
res.left = axis.p2c(pos[key]);
|
376
|
+
break;
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
for (i = 0; i < yaxes.length; ++i) {
|
382
|
+
axis = yaxes[i];
|
383
|
+
if (axis && axis.used) {
|
384
|
+
key = "y" + axis.n;
|
385
|
+
if (pos[key] == null && axis.n == 1)
|
386
|
+
key = "y";
|
387
|
+
|
388
|
+
if (pos[key] != null) {
|
389
|
+
res.top = axis.p2c(pos[key]);
|
390
|
+
break;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
}
|
394
|
+
|
395
|
+
return res;
|
396
|
+
}
|
397
|
+
|
398
|
+
function getOrCreateAxis(axes, number) {
|
399
|
+
if (!axes[number - 1])
|
400
|
+
axes[number - 1] = {
|
401
|
+
n: number, // save the number for future reference
|
402
|
+
direction: axes == xaxes ? "x" : "y",
|
403
|
+
options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis)
|
404
|
+
};
|
405
|
+
|
406
|
+
return axes[number - 1];
|
407
|
+
}
|
408
|
+
|
409
|
+
function fillInSeriesOptions() {
|
410
|
+
var i;
|
411
|
+
|
412
|
+
// collect what we already got of colors
|
413
|
+
var neededColors = series.length,
|
414
|
+
usedColors = [],
|
415
|
+
assignedColors = [];
|
416
|
+
for (i = 0; i < series.length; ++i) {
|
417
|
+
var sc = series[i].color;
|
418
|
+
if (sc != null) {
|
419
|
+
--neededColors;
|
420
|
+
if (typeof sc == "number")
|
421
|
+
assignedColors.push(sc);
|
422
|
+
else
|
423
|
+
usedColors.push($.color.parse(series[i].color));
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
// we might need to generate more colors if higher indices
|
428
|
+
// are assigned
|
429
|
+
for (i = 0; i < assignedColors.length; ++i) {
|
430
|
+
neededColors = Math.max(neededColors, assignedColors[i] + 1);
|
431
|
+
}
|
432
|
+
|
433
|
+
// produce colors as needed
|
434
|
+
var colors = [], variation = 0;
|
435
|
+
i = 0;
|
436
|
+
while (colors.length < neededColors) {
|
437
|
+
var c;
|
438
|
+
if (options.colors.length == i) // check degenerate case
|
439
|
+
c = $.color.make(100, 100, 100);
|
440
|
+
else
|
441
|
+
c = $.color.parse(options.colors[i]);
|
442
|
+
|
443
|
+
// vary color if needed
|
444
|
+
var sign = variation % 2 == 1 ? -1 : 1;
|
445
|
+
c.scale('rgb', 1 + sign * Math.ceil(variation / 2) * 0.2)
|
446
|
+
|
447
|
+
// FIXME: if we're getting to close to something else,
|
448
|
+
// we should probably skip this one
|
449
|
+
colors.push(c);
|
450
|
+
|
451
|
+
++i;
|
452
|
+
if (i >= options.colors.length) {
|
453
|
+
i = 0;
|
454
|
+
++variation;
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
// fill in the options
|
459
|
+
var colori = 0, s;
|
460
|
+
for (i = 0; i < series.length; ++i) {
|
461
|
+
s = series[i];
|
462
|
+
|
463
|
+
// assign colors
|
464
|
+
if (s.color == null) {
|
465
|
+
s.color = colors[colori].toString();
|
466
|
+
++colori;
|
467
|
+
}
|
468
|
+
else if (typeof s.color == "number")
|
469
|
+
s.color = colors[s.color].toString();
|
470
|
+
|
471
|
+
// turn on lines automatically in case nothing is set
|
472
|
+
if (s.lines.show == null) {
|
473
|
+
var v, show = true;
|
474
|
+
for (v in s)
|
475
|
+
if (s[v] && s[v].show) {
|
476
|
+
show = false;
|
477
|
+
break;
|
478
|
+
}
|
479
|
+
if (show)
|
480
|
+
s.lines.show = true;
|
481
|
+
}
|
482
|
+
|
483
|
+
// setup axes
|
484
|
+
s.xaxis = getOrCreateAxis(xaxes, axisNumber(s, "x"));
|
485
|
+
s.yaxis = getOrCreateAxis(yaxes, axisNumber(s, "y"));
|
486
|
+
}
|
487
|
+
}
|
488
|
+
|
489
|
+
function processData() {
|
490
|
+
var topSentry = Number.POSITIVE_INFINITY,
|
491
|
+
bottomSentry = Number.NEGATIVE_INFINITY,
|
492
|
+
fakeInfinity = Number.MAX_VALUE,
|
493
|
+
i, j, k, m, length,
|
494
|
+
s, points, ps, x, y, axis, val, f, p;
|
495
|
+
|
496
|
+
function updateAxis(axis, min, max) {
|
497
|
+
if (min < axis.datamin && min != -fakeInfinity)
|
498
|
+
axis.datamin = min;
|
499
|
+
if (max > axis.datamax && max != fakeInfinity)
|
500
|
+
axis.datamax = max;
|
501
|
+
}
|
502
|
+
|
503
|
+
$.each(allAxes(), function (_, axis) {
|
504
|
+
// init axis
|
505
|
+
axis.datamin = topSentry;
|
506
|
+
axis.datamax = bottomSentry;
|
507
|
+
axis.used = false;
|
508
|
+
});
|
509
|
+
|
510
|
+
for (i = 0; i < series.length; ++i) {
|
511
|
+
s = series[i];
|
512
|
+
s.datapoints = { points: [] };
|
513
|
+
|
514
|
+
executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]);
|
515
|
+
}
|
516
|
+
|
517
|
+
// first pass: clean and copy data
|
518
|
+
for (i = 0; i < series.length; ++i) {
|
519
|
+
s = series[i];
|
520
|
+
|
521
|
+
var data = s.data, format = s.datapoints.format;
|
522
|
+
|
523
|
+
if (!format) {
|
524
|
+
format = [];
|
525
|
+
// find out how to copy
|
526
|
+
format.push({ x: true, number: true, required: true });
|
527
|
+
format.push({ y: true, number: true, required: true });
|
528
|
+
|
529
|
+
if (s.bars.show || (s.lines.show && s.lines.fill)) {
|
530
|
+
format.push({ y: true, number: true, required: false, defaultValue: 0 });
|
531
|
+
if (s.bars.horizontal) {
|
532
|
+
delete format[format.length - 1].y;
|
533
|
+
format[format.length - 1].x = true;
|
534
|
+
}
|
535
|
+
}
|
536
|
+
|
537
|
+
s.datapoints.format = format;
|
538
|
+
}
|
539
|
+
|
540
|
+
if (s.datapoints.pointsize != null)
|
541
|
+
continue; // already filled in
|
542
|
+
|
543
|
+
s.datapoints.pointsize = format.length;
|
544
|
+
|
545
|
+
ps = s.datapoints.pointsize;
|
546
|
+
points = s.datapoints.points;
|
547
|
+
|
548
|
+
insertSteps = s.lines.show && s.lines.steps;
|
549
|
+
s.xaxis.used = s.yaxis.used = true;
|
550
|
+
|
551
|
+
for (j = k = 0; j < data.length; ++j, k += ps) {
|
552
|
+
p = data[j];
|
553
|
+
|
554
|
+
var nullify = p == null;
|
555
|
+
if (!nullify) {
|
556
|
+
for (m = 0; m < ps; ++m) {
|
557
|
+
val = p[m];
|
558
|
+
f = format[m];
|
559
|
+
|
560
|
+
if (f) {
|
561
|
+
if (f.number && val != null) {
|
562
|
+
val = +val; // convert to number
|
563
|
+
if (isNaN(val))
|
564
|
+
val = null;
|
565
|
+
else if (val == Infinity)
|
566
|
+
val = fakeInfinity;
|
567
|
+
else if (val == -Infinity)
|
568
|
+
val = -fakeInfinity;
|
569
|
+
}
|
570
|
+
|
571
|
+
if (val == null) {
|
572
|
+
if (f.required)
|
573
|
+
nullify = true;
|
574
|
+
|
575
|
+
if (f.defaultValue != null)
|
576
|
+
val = f.defaultValue;
|
577
|
+
}
|
578
|
+
}
|
579
|
+
|
580
|
+
points[k + m] = val;
|
581
|
+
}
|
582
|
+
}
|
583
|
+
|
584
|
+
if (nullify) {
|
585
|
+
for (m = 0; m < ps; ++m) {
|
586
|
+
val = points[k + m];
|
587
|
+
if (val != null) {
|
588
|
+
f = format[m];
|
589
|
+
// extract min/max info
|
590
|
+
if (f.x)
|
591
|
+
updateAxis(s.xaxis, val, val);
|
592
|
+
if (f.y)
|
593
|
+
updateAxis(s.yaxis, val, val);
|
594
|
+
}
|
595
|
+
points[k + m] = null;
|
596
|
+
}
|
597
|
+
}
|
598
|
+
else {
|
599
|
+
// a little bit of line specific stuff that
|
600
|
+
// perhaps shouldn't be here, but lacking
|
601
|
+
// better means...
|
602
|
+
if (insertSteps && k > 0
|
603
|
+
&& points[k - ps] != null
|
604
|
+
&& points[k - ps] != points[k]
|
605
|
+
&& points[k - ps + 1] != points[k + 1]) {
|
606
|
+
// copy the point to make room for a middle point
|
607
|
+
for (m = 0; m < ps; ++m)
|
608
|
+
points[k + ps + m] = points[k + m];
|
609
|
+
|
610
|
+
// middle point has same y
|
611
|
+
points[k + 1] = points[k - ps + 1];
|
612
|
+
|
613
|
+
// we've added a point, better reflect that
|
614
|
+
k += ps;
|
615
|
+
}
|
616
|
+
}
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
// give the hooks a chance to run
|
621
|
+
for (i = 0; i < series.length; ++i) {
|
622
|
+
s = series[i];
|
623
|
+
|
624
|
+
executeHooks(hooks.processDatapoints, [ s, s.datapoints]);
|
625
|
+
}
|
626
|
+
|
627
|
+
// second pass: find datamax/datamin for auto-scaling
|
628
|
+
for (i = 0; i < series.length; ++i) {
|
629
|
+
s = series[i];
|
630
|
+
points = s.datapoints.points,
|
631
|
+
ps = s.datapoints.pointsize;
|
632
|
+
|
633
|
+
var xmin = topSentry, ymin = topSentry,
|
634
|
+
xmax = bottomSentry, ymax = bottomSentry;
|
635
|
+
|
636
|
+
for (j = 0; j < points.length; j += ps) {
|
637
|
+
if (points[j] == null)
|
638
|
+
continue;
|
639
|
+
|
640
|
+
for (m = 0; m < ps; ++m) {
|
641
|
+
val = points[j + m];
|
642
|
+
f = format[m];
|
643
|
+
if (!f || val == fakeInfinity || val == -fakeInfinity)
|
644
|
+
continue;
|
645
|
+
|
646
|
+
if (f.x) {
|
647
|
+
if (val < xmin)
|
648
|
+
xmin = val;
|
649
|
+
if (val > xmax)
|
650
|
+
xmax = val;
|
651
|
+
}
|
652
|
+
if (f.y) {
|
653
|
+
if (val < ymin)
|
654
|
+
ymin = val;
|
655
|
+
if (val > ymax)
|
656
|
+
ymax = val;
|
657
|
+
}
|
658
|
+
}
|
659
|
+
}
|
660
|
+
|
661
|
+
if (s.bars.show) {
|
662
|
+
// make sure we got room for the bar on the dancing floor
|
663
|
+
var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2;
|
664
|
+
if (s.bars.horizontal) {
|
665
|
+
ymin += delta;
|
666
|
+
ymax += delta + s.bars.barWidth;
|
667
|
+
}
|
668
|
+
else {
|
669
|
+
xmin += delta;
|
670
|
+
xmax += delta + s.bars.barWidth;
|
671
|
+
}
|
672
|
+
}
|
673
|
+
|
674
|
+
updateAxis(s.xaxis, xmin, xmax);
|
675
|
+
updateAxis(s.yaxis, ymin, ymax);
|
676
|
+
}
|
677
|
+
|
678
|
+
$.each(allAxes(), function (_, axis) {
|
679
|
+
if (axis.datamin == topSentry)
|
680
|
+
axis.datamin = null;
|
681
|
+
if (axis.datamax == bottomSentry)
|
682
|
+
axis.datamax = null;
|
683
|
+
});
|
684
|
+
}
|
685
|
+
|
686
|
+
function makeCanvas(skipPositioning, cls) {
|
687
|
+
var c = document.createElement('canvas');
|
688
|
+
c.className = cls;
|
689
|
+
c.width = canvasWidth;
|
690
|
+
c.height = canvasHeight;
|
691
|
+
|
692
|
+
if (!skipPositioning)
|
693
|
+
$(c).css({ position: 'absolute', left: 0, top: 0 });
|
694
|
+
|
695
|
+
$(c).appendTo(placeholder);
|
696
|
+
|
697
|
+
if (!c.getContext) // excanvas hack
|
698
|
+
c = window.G_vmlCanvasManager.initElement(c);
|
699
|
+
|
700
|
+
// used for resetting in case we get replotted
|
701
|
+
c.getContext("2d").save();
|
702
|
+
|
703
|
+
return c;
|
704
|
+
}
|
705
|
+
|
706
|
+
function getCanvasDimensions() {
|
707
|
+
canvasWidth = placeholder.width();
|
708
|
+
canvasHeight = placeholder.height();
|
709
|
+
|
710
|
+
if (canvasWidth <= 0 || canvasHeight <= 0)
|
711
|
+
throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight;
|
712
|
+
}
|
713
|
+
|
714
|
+
function resizeCanvas(c) {
|
715
|
+
// resizing should reset the state (excanvas seems to be
|
716
|
+
// buggy though)
|
717
|
+
if (c.width != canvasWidth)
|
718
|
+
c.width = canvasWidth;
|
719
|
+
|
720
|
+
if (c.height != canvasHeight)
|
721
|
+
c.height = canvasHeight;
|
722
|
+
|
723
|
+
// so try to get back to the initial state (even if it's
|
724
|
+
// gone now, this should be safe according to the spec)
|
725
|
+
var cctx = c.getContext("2d");
|
726
|
+
cctx.restore();
|
727
|
+
|
728
|
+
// and save again
|
729
|
+
cctx.save();
|
730
|
+
}
|
731
|
+
|
732
|
+
function setupCanvases() {
|
733
|
+
var reused,
|
734
|
+
existingCanvas = placeholder.children("canvas.base"),
|
735
|
+
existingOverlay = placeholder.children("canvas.overlay");
|
736
|
+
|
737
|
+
if (existingCanvas.length == 0 || existingOverlay == 0) {
|
738
|
+
// init everything
|
739
|
+
|
740
|
+
placeholder.html(""); // make sure placeholder is clear
|
741
|
+
|
742
|
+
placeholder.css({ padding: 0 }); // padding messes up the positioning
|
743
|
+
|
744
|
+
if (placeholder.css("position") == 'static')
|
745
|
+
placeholder.css("position", "relative"); // for positioning labels and overlay
|
746
|
+
|
747
|
+
getCanvasDimensions();
|
748
|
+
|
749
|
+
canvas = makeCanvas(true, "base");
|
750
|
+
overlay = makeCanvas(false, "overlay"); // overlay canvas for interactive features
|
751
|
+
|
752
|
+
reused = false;
|
753
|
+
}
|
754
|
+
else {
|
755
|
+
// reuse existing elements
|
756
|
+
|
757
|
+
canvas = existingCanvas.get(0);
|
758
|
+
overlay = existingOverlay.get(0);
|
759
|
+
|
760
|
+
reused = true;
|
761
|
+
}
|
762
|
+
|
763
|
+
ctx = canvas.getContext("2d");
|
764
|
+
octx = overlay.getContext("2d");
|
765
|
+
|
766
|
+
// we include the canvas in the event holder too, because IE 7
|
767
|
+
// sometimes has trouble with the stacking order
|
768
|
+
eventHolder = $([overlay, canvas]);
|
769
|
+
|
770
|
+
if (reused) {
|
771
|
+
// run shutdown in the old plot object
|
772
|
+
placeholder.data("plot").shutdown();
|
773
|
+
|
774
|
+
// reset reused canvases
|
775
|
+
plot.resize();
|
776
|
+
|
777
|
+
// make sure overlay pixels are cleared (canvas is cleared when we redraw)
|
778
|
+
octx.clearRect(0, 0, canvasWidth, canvasHeight);
|
779
|
+
|
780
|
+
// then whack any remaining obvious garbage left
|
781
|
+
eventHolder.unbind();
|
782
|
+
placeholder.children().not([canvas, overlay]).remove();
|
783
|
+
}
|
784
|
+
|
785
|
+
// save in case we get replotted
|
786
|
+
placeholder.data("plot", plot);
|
787
|
+
}
|
788
|
+
|
789
|
+
function bindEvents() {
|
790
|
+
// bind events
|
791
|
+
if (options.grid.hoverable) {
|
792
|
+
eventHolder.mousemove(onMouseMove);
|
793
|
+
eventHolder.mouseleave(onMouseLeave);
|
794
|
+
}
|
795
|
+
|
796
|
+
if (options.grid.clickable)
|
797
|
+
eventHolder.click(onClick);
|
798
|
+
|
799
|
+
executeHooks(hooks.bindEvents, [eventHolder]);
|
800
|
+
}
|
801
|
+
|
802
|
+
function shutdown() {
|
803
|
+
if (redrawTimeout)
|
804
|
+
clearTimeout(redrawTimeout);
|
805
|
+
|
806
|
+
eventHolder.unbind("mousemove", onMouseMove);
|
807
|
+
eventHolder.unbind("mouseleave", onMouseLeave);
|
808
|
+
eventHolder.unbind("click", onClick);
|
809
|
+
|
810
|
+
executeHooks(hooks.shutdown, [eventHolder]);
|
811
|
+
}
|
812
|
+
|
813
|
+
function setTransformationHelpers(axis) {
|
814
|
+
// set helper functions on the axis, assumes plot area
|
815
|
+
// has been computed already
|
816
|
+
|
817
|
+
function identity(x) { return x; }
|
818
|
+
|
819
|
+
var s, m, t = axis.options.transform || identity,
|
820
|
+
it = axis.options.inverseTransform;
|
821
|
+
|
822
|
+
// precompute how much the axis is scaling a point
|
823
|
+
// in canvas space
|
824
|
+
if (axis.direction == "x") {
|
825
|
+
s = axis.scale = plotWidth / Math.abs(t(axis.max) - t(axis.min));
|
826
|
+
m = Math.min(t(axis.max), t(axis.min));
|
827
|
+
}
|
828
|
+
else {
|
829
|
+
s = axis.scale = plotHeight / Math.abs(t(axis.max) - t(axis.min));
|
830
|
+
s = -s;
|
831
|
+
m = Math.max(t(axis.max), t(axis.min));
|
832
|
+
}
|
833
|
+
|
834
|
+
// data point to canvas coordinate
|
835
|
+
if (t == identity) // slight optimization
|
836
|
+
axis.p2c = function (p) { return (p - m) * s; };
|
837
|
+
else
|
838
|
+
axis.p2c = function (p) { return (t(p) - m) * s; };
|
839
|
+
// canvas coordinate to data point
|
840
|
+
if (!it)
|
841
|
+
axis.c2p = function (c) { return m + c / s; };
|
842
|
+
else
|
843
|
+
axis.c2p = function (c) { return it(m + c / s); };
|
844
|
+
}
|
845
|
+
|
846
|
+
function measureTickLabels(axis) {
|
847
|
+
var opts = axis.options, i, ticks = axis.ticks || [], labels = [],
|
848
|
+
l, w = opts.labelWidth, h = opts.labelHeight, dummyDiv;
|
849
|
+
|
850
|
+
function makeDummyDiv(labels, width) {
|
851
|
+
return $('<div style="position:absolute;top:-10000px;' + width + 'font-size:smaller">' +
|
852
|
+
'<div class="' + axis.direction + 'Axis ' + axis.direction + axis.n + 'Axis">'
|
853
|
+
+ labels.join("") + '</div></div>')
|
854
|
+
.appendTo(placeholder);
|
855
|
+
}
|
856
|
+
|
857
|
+
if (axis.direction == "x") {
|
858
|
+
// to avoid measuring the widths of the labels (it's slow), we
|
859
|
+
// construct fixed-size boxes and put the labels inside
|
860
|
+
// them, we don't need the exact figures and the
|
861
|
+
// fixed-size box content is easy to center
|
862
|
+
if (w == null)
|
863
|
+
w = Math.floor(canvasWidth / (ticks.length > 0 ? ticks.length : 1));
|
864
|
+
|
865
|
+
// measure x label heights
|
866
|
+
if (h == null) {
|
867
|
+
labels = [];
|
868
|
+
for (i = 0; i < ticks.length; ++i) {
|
869
|
+
l = ticks[i].label;
|
870
|
+
if (l)
|
871
|
+
labels.push('<div class="tickLabel" style="float:left;width:' + w + 'px">' + l + '</div>');
|
872
|
+
}
|
873
|
+
|
874
|
+
if (labels.length > 0) {
|
875
|
+
// stick them all in the same div and measure
|
876
|
+
// collective height
|
877
|
+
labels.push('<div style="clear:left"></div>');
|
878
|
+
dummyDiv = makeDummyDiv(labels, "width:10000px;");
|
879
|
+
h = dummyDiv.height();
|
880
|
+
dummyDiv.remove();
|
881
|
+
}
|
882
|
+
}
|
883
|
+
}
|
884
|
+
else if (w == null || h == null) {
|
885
|
+
// calculate y label dimensions
|
886
|
+
for (i = 0; i < ticks.length; ++i) {
|
887
|
+
l = ticks[i].label;
|
888
|
+
if (l)
|
889
|
+
labels.push('<div class="tickLabel">' + l + '</div>');
|
890
|
+
}
|
891
|
+
|
892
|
+
if (labels.length > 0) {
|
893
|
+
dummyDiv = makeDummyDiv(labels, "");
|
894
|
+
if (w == null)
|
895
|
+
w = dummyDiv.children().width();
|
896
|
+
if (h == null)
|
897
|
+
h = dummyDiv.find("div.tickLabel").height();
|
898
|
+
dummyDiv.remove();
|
899
|
+
}
|
900
|
+
}
|
901
|
+
|
902
|
+
if (w == null)
|
903
|
+
w = 0;
|
904
|
+
if (h == null)
|
905
|
+
h = 0;
|
906
|
+
|
907
|
+
axis.labelWidth = w;
|
908
|
+
axis.labelHeight = h;
|
909
|
+
}
|
910
|
+
|
911
|
+
function allocateAxisBoxFirstPhase(axis) {
|
912
|
+
// find the bounding box of the axis by looking at label
|
913
|
+
// widths/heights and ticks, make room by diminishing the
|
914
|
+
// plotOffset
|
915
|
+
|
916
|
+
var lw = axis.labelWidth,
|
917
|
+
lh = axis.labelHeight,
|
918
|
+
pos = axis.options.position,
|
919
|
+
tickLength = axis.options.tickLength,
|
920
|
+
axismargin = options.grid.axisMargin,
|
921
|
+
padding = options.grid.labelMargin,
|
922
|
+
all = axis.direction == "x" ? xaxes : yaxes,
|
923
|
+
index;
|
924
|
+
|
925
|
+
// determine axis margin
|
926
|
+
var samePosition = $.grep(all, function (a) {
|
927
|
+
return a && a.options.position == pos && a.reserveSpace;
|
928
|
+
});
|
929
|
+
if ($.inArray(axis, samePosition) == samePosition.length - 1)
|
930
|
+
axismargin = 0; // outermost
|
931
|
+
|
932
|
+
// determine tick length - if we're innermost, we can use "full"
|
933
|
+
if (tickLength == null)
|
934
|
+
tickLength = "full";
|
935
|
+
|
936
|
+
var sameDirection = $.grep(all, function (a) {
|
937
|
+
return a && a.reserveSpace;
|
938
|
+
});
|
939
|
+
|
940
|
+
var innermost = $.inArray(axis, sameDirection) == 0;
|
941
|
+
if (!innermost && tickLength == "full")
|
942
|
+
tickLength = 5;
|
943
|
+
|
944
|
+
if (!isNaN(+tickLength))
|
945
|
+
padding += +tickLength;
|
946
|
+
|
947
|
+
// compute box
|
948
|
+
if (axis.direction == "x") {
|
949
|
+
lh += padding;
|
950
|
+
|
951
|
+
if (pos == "bottom") {
|
952
|
+
plotOffset.bottom += lh + axismargin;
|
953
|
+
axis.box = { top: canvasHeight - plotOffset.bottom, height: lh };
|
954
|
+
}
|
955
|
+
else {
|
956
|
+
axis.box = { top: plotOffset.top + axismargin, height: lh };
|
957
|
+
plotOffset.top += lh + axismargin;
|
958
|
+
}
|
959
|
+
}
|
960
|
+
else {
|
961
|
+
lw += padding;
|
962
|
+
|
963
|
+
if (pos == "left") {
|
964
|
+
axis.box = { left: plotOffset.left + axismargin, width: lw };
|
965
|
+
plotOffset.left += lw + axismargin;
|
966
|
+
}
|
967
|
+
else {
|
968
|
+
plotOffset.right += lw + axismargin;
|
969
|
+
axis.box = { left: canvasWidth - plotOffset.right, width: lw };
|
970
|
+
}
|
971
|
+
}
|
972
|
+
|
973
|
+
// save for future reference
|
974
|
+
axis.position = pos;
|
975
|
+
axis.tickLength = tickLength;
|
976
|
+
axis.box.padding = padding;
|
977
|
+
axis.innermost = innermost;
|
978
|
+
}
|
979
|
+
|
980
|
+
function allocateAxisBoxSecondPhase(axis) {
|
981
|
+
// set remaining bounding box coordinates
|
982
|
+
if (axis.direction == "x") {
|
983
|
+
axis.box.left = plotOffset.left;
|
984
|
+
axis.box.width = plotWidth;
|
985
|
+
}
|
986
|
+
else {
|
987
|
+
axis.box.top = plotOffset.top;
|
988
|
+
axis.box.height = plotHeight;
|
989
|
+
}
|
990
|
+
}
|
991
|
+
|
992
|
+
function setupGrid() {
|
993
|
+
var i, axes = allAxes();
|
994
|
+
|
995
|
+
// first calculate the plot and axis box dimensions
|
996
|
+
|
997
|
+
$.each(axes, function (_, axis) {
|
998
|
+
axis.show = axis.options.show;
|
999
|
+
if (axis.show == null)
|
1000
|
+
axis.show = axis.used; // by default an axis is visible if it's got data
|
1001
|
+
|
1002
|
+
axis.reserveSpace = axis.show || axis.options.reserveSpace;
|
1003
|
+
|
1004
|
+
setRange(axis);
|
1005
|
+
});
|
1006
|
+
|
1007
|
+
allocatedAxes = $.grep(axes, function (axis) { return axis.reserveSpace; });
|
1008
|
+
|
1009
|
+
plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = 0;
|
1010
|
+
if (options.grid.show) {
|
1011
|
+
$.each(allocatedAxes, function (_, axis) {
|
1012
|
+
// make the ticks
|
1013
|
+
setupTickGeneration(axis);
|
1014
|
+
setTicks(axis);
|
1015
|
+
snapRangeToTicks(axis, axis.ticks);
|
1016
|
+
|
1017
|
+
// find labelWidth/Height for axis
|
1018
|
+
measureTickLabels(axis);
|
1019
|
+
});
|
1020
|
+
|
1021
|
+
// with all dimensions in house, we can compute the
|
1022
|
+
// axis boxes, start from the outside (reverse order)
|
1023
|
+
for (i = allocatedAxes.length - 1; i >= 0; --i)
|
1024
|
+
allocateAxisBoxFirstPhase(allocatedAxes[i]);
|
1025
|
+
|
1026
|
+
// make sure we've got enough space for things that
|
1027
|
+
// might stick out
|
1028
|
+
var minMargin = options.grid.minBorderMargin;
|
1029
|
+
if (minMargin == null) {
|
1030
|
+
minMargin = 0;
|
1031
|
+
for (i = 0; i < series.length; ++i)
|
1032
|
+
minMargin = Math.max(minMargin, series[i].points.radius + series[i].points.lineWidth/2);
|
1033
|
+
}
|
1034
|
+
|
1035
|
+
for (var a in plotOffset) {
|
1036
|
+
plotOffset[a] += options.grid.borderWidth;
|
1037
|
+
plotOffset[a] = Math.max(minMargin, plotOffset[a]);
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
plotWidth = canvasWidth - plotOffset.left - plotOffset.right;
|
1042
|
+
plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top;
|
1043
|
+
|
1044
|
+
// now we got the proper plotWidth/Height, we can compute the scaling
|
1045
|
+
$.each(axes, function (_, axis) {
|
1046
|
+
setTransformationHelpers(axis);
|
1047
|
+
});
|
1048
|
+
|
1049
|
+
if (options.grid.show) {
|
1050
|
+
$.each(allocatedAxes, function (_, axis) {
|
1051
|
+
allocateAxisBoxSecondPhase(axis);
|
1052
|
+
});
|
1053
|
+
|
1054
|
+
insertAxisLabels();
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
insertLegend();
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
function setRange(axis) {
|
1061
|
+
var opts = axis.options,
|
1062
|
+
min = +(opts.min != null ? opts.min : axis.datamin),
|
1063
|
+
max = +(opts.max != null ? opts.max : axis.datamax),
|
1064
|
+
delta = max - min;
|
1065
|
+
|
1066
|
+
if (delta == 0.0) {
|
1067
|
+
// degenerate case
|
1068
|
+
var widen = max == 0 ? 1 : 0.01;
|
1069
|
+
|
1070
|
+
if (opts.min == null)
|
1071
|
+
min -= widen;
|
1072
|
+
// always widen max if we couldn't widen min to ensure we
|
1073
|
+
// don't fall into min == max which doesn't work
|
1074
|
+
if (opts.max == null || opts.min != null)
|
1075
|
+
max += widen;
|
1076
|
+
}
|
1077
|
+
else {
|
1078
|
+
// consider autoscaling
|
1079
|
+
var margin = opts.autoscaleMargin;
|
1080
|
+
if (margin != null) {
|
1081
|
+
if (opts.min == null) {
|
1082
|
+
min -= delta * margin;
|
1083
|
+
// make sure we don't go below zero if all values
|
1084
|
+
// are positive
|
1085
|
+
if (min < 0 && axis.datamin != null && axis.datamin >= 0)
|
1086
|
+
min = 0;
|
1087
|
+
}
|
1088
|
+
if (opts.max == null) {
|
1089
|
+
max += delta * margin;
|
1090
|
+
if (max > 0 && axis.datamax != null && axis.datamax <= 0)
|
1091
|
+
max = 0;
|
1092
|
+
}
|
1093
|
+
}
|
1094
|
+
}
|
1095
|
+
axis.min = min;
|
1096
|
+
axis.max = max;
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
function setupTickGeneration(axis) {
|
1100
|
+
var opts = axis.options;
|
1101
|
+
|
1102
|
+
// estimate number of ticks
|
1103
|
+
var noTicks;
|
1104
|
+
if (typeof opts.ticks == "number" && opts.ticks > 0)
|
1105
|
+
noTicks = opts.ticks;
|
1106
|
+
else
|
1107
|
+
// heuristic based on the model a*sqrt(x) fitted to
|
1108
|
+
// some data points that seemed reasonable
|
1109
|
+
noTicks = 0.3 * Math.sqrt(axis.direction == "x" ? canvasWidth : canvasHeight);
|
1110
|
+
|
1111
|
+
var delta = (axis.max - axis.min) / noTicks,
|
1112
|
+
size, generator, unit, formatter, i, magn, norm;
|
1113
|
+
|
1114
|
+
if (opts.mode == "time") {
|
1115
|
+
// pretty handling of time
|
1116
|
+
|
1117
|
+
// map of app. size of time units in milliseconds
|
1118
|
+
var timeUnitSize = {
|
1119
|
+
"second": 1000,
|
1120
|
+
"minute": 60 * 1000,
|
1121
|
+
"hour": 60 * 60 * 1000,
|
1122
|
+
"day": 24 * 60 * 60 * 1000,
|
1123
|
+
"month": 30 * 24 * 60 * 60 * 1000,
|
1124
|
+
"year": 365.2425 * 24 * 60 * 60 * 1000
|
1125
|
+
};
|
1126
|
+
|
1127
|
+
|
1128
|
+
// the allowed tick sizes, after 1 year we use
|
1129
|
+
// an integer algorithm
|
1130
|
+
var spec = [
|
1131
|
+
[1, "second"], [2, "second"], [5, "second"], [10, "second"],
|
1132
|
+
[30, "second"],
|
1133
|
+
[1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"],
|
1134
|
+
[30, "minute"],
|
1135
|
+
[1, "hour"], [2, "hour"], [4, "hour"],
|
1136
|
+
[8, "hour"], [12, "hour"],
|
1137
|
+
[1, "day"], [2, "day"], [3, "day"],
|
1138
|
+
[0.25, "month"], [0.5, "month"], [1, "month"],
|
1139
|
+
[2, "month"], [3, "month"], [6, "month"],
|
1140
|
+
[1, "year"]
|
1141
|
+
];
|
1142
|
+
|
1143
|
+
var minSize = 0;
|
1144
|
+
if (opts.minTickSize != null) {
|
1145
|
+
if (typeof opts.tickSize == "number")
|
1146
|
+
minSize = opts.tickSize;
|
1147
|
+
else
|
1148
|
+
minSize = opts.minTickSize[0] * timeUnitSize[opts.minTickSize[1]];
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
for (var i = 0; i < spec.length - 1; ++i)
|
1152
|
+
if (delta < (spec[i][0] * timeUnitSize[spec[i][1]]
|
1153
|
+
+ spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2
|
1154
|
+
&& spec[i][0] * timeUnitSize[spec[i][1]] >= minSize)
|
1155
|
+
break;
|
1156
|
+
size = spec[i][0];
|
1157
|
+
unit = spec[i][1];
|
1158
|
+
|
1159
|
+
// special-case the possibility of several years
|
1160
|
+
if (unit == "year") {
|
1161
|
+
magn = Math.pow(10, Math.floor(Math.log(delta / timeUnitSize.year) / Math.LN10));
|
1162
|
+
norm = (delta / timeUnitSize.year) / magn;
|
1163
|
+
if (norm < 1.5)
|
1164
|
+
size = 1;
|
1165
|
+
else if (norm < 3)
|
1166
|
+
size = 2;
|
1167
|
+
else if (norm < 7.5)
|
1168
|
+
size = 5;
|
1169
|
+
else
|
1170
|
+
size = 10;
|
1171
|
+
|
1172
|
+
size *= magn;
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
axis.tickSize = opts.tickSize || [size, unit];
|
1176
|
+
|
1177
|
+
generator = function(axis) {
|
1178
|
+
var ticks = [],
|
1179
|
+
tickSize = axis.tickSize[0], unit = axis.tickSize[1],
|
1180
|
+
d = new Date(axis.min);
|
1181
|
+
|
1182
|
+
var step = tickSize * timeUnitSize[unit];
|
1183
|
+
|
1184
|
+
if (unit == "second")
|
1185
|
+
d.setUTCSeconds(floorInBase(d.getUTCSeconds(), tickSize));
|
1186
|
+
if (unit == "minute")
|
1187
|
+
d.setUTCMinutes(floorInBase(d.getUTCMinutes(), tickSize));
|
1188
|
+
if (unit == "hour")
|
1189
|
+
d.setUTCHours(floorInBase(d.getUTCHours(), tickSize));
|
1190
|
+
if (unit == "month")
|
1191
|
+
d.setUTCMonth(floorInBase(d.getUTCMonth(), tickSize));
|
1192
|
+
if (unit == "year")
|
1193
|
+
d.setUTCFullYear(floorInBase(d.getUTCFullYear(), tickSize));
|
1194
|
+
|
1195
|
+
// reset smaller components
|
1196
|
+
d.setUTCMilliseconds(0);
|
1197
|
+
if (step >= timeUnitSize.minute)
|
1198
|
+
d.setUTCSeconds(0);
|
1199
|
+
if (step >= timeUnitSize.hour)
|
1200
|
+
d.setUTCMinutes(0);
|
1201
|
+
if (step >= timeUnitSize.day)
|
1202
|
+
d.setUTCHours(0);
|
1203
|
+
if (step >= timeUnitSize.day * 4)
|
1204
|
+
d.setUTCDate(1);
|
1205
|
+
if (step >= timeUnitSize.year)
|
1206
|
+
d.setUTCMonth(0);
|
1207
|
+
|
1208
|
+
|
1209
|
+
var carry = 0, v = Number.NaN, prev;
|
1210
|
+
do {
|
1211
|
+
prev = v;
|
1212
|
+
v = d.getTime();
|
1213
|
+
ticks.push(v);
|
1214
|
+
if (unit == "month") {
|
1215
|
+
if (tickSize < 1) {
|
1216
|
+
// a bit complicated - we'll divide the month
|
1217
|
+
// up but we need to take care of fractions
|
1218
|
+
// so we don't end up in the middle of a day
|
1219
|
+
d.setUTCDate(1);
|
1220
|
+
var start = d.getTime();
|
1221
|
+
d.setUTCMonth(d.getUTCMonth() + 1);
|
1222
|
+
var end = d.getTime();
|
1223
|
+
d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
|
1224
|
+
carry = d.getUTCHours();
|
1225
|
+
d.setUTCHours(0);
|
1226
|
+
}
|
1227
|
+
else
|
1228
|
+
d.setUTCMonth(d.getUTCMonth() + tickSize);
|
1229
|
+
}
|
1230
|
+
else if (unit == "year") {
|
1231
|
+
d.setUTCFullYear(d.getUTCFullYear() + tickSize);
|
1232
|
+
}
|
1233
|
+
else
|
1234
|
+
d.setTime(v + step);
|
1235
|
+
} while (v < axis.max && v != prev);
|
1236
|
+
|
1237
|
+
return ticks;
|
1238
|
+
};
|
1239
|
+
|
1240
|
+
formatter = function (v, axis) {
|
1241
|
+
var d = new Date(v);
|
1242
|
+
|
1243
|
+
// first check global format
|
1244
|
+
if (opts.timeformat != null)
|
1245
|
+
return $.plot.formatDate(d, opts.timeformat, opts.monthNames);
|
1246
|
+
|
1247
|
+
var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
|
1248
|
+
var span = axis.max - axis.min;
|
1249
|
+
var suffix = (opts.twelveHourClock) ? " %p" : "";
|
1250
|
+
|
1251
|
+
if (t < timeUnitSize.minute)
|
1252
|
+
fmt = "%h:%M:%S" + suffix;
|
1253
|
+
else if (t < timeUnitSize.day) {
|
1254
|
+
if (span < 2 * timeUnitSize.day)
|
1255
|
+
fmt = "%h:%M" + suffix;
|
1256
|
+
else
|
1257
|
+
fmt = "%b %d %h:%M" + suffix;
|
1258
|
+
}
|
1259
|
+
else if (t < timeUnitSize.month)
|
1260
|
+
fmt = "%b %d";
|
1261
|
+
else if (t < timeUnitSize.year) {
|
1262
|
+
if (span < timeUnitSize.year)
|
1263
|
+
fmt = "%b";
|
1264
|
+
else
|
1265
|
+
fmt = "%b %y";
|
1266
|
+
}
|
1267
|
+
else
|
1268
|
+
fmt = "%y";
|
1269
|
+
|
1270
|
+
return $.plot.formatDate(d, fmt, opts.monthNames);
|
1271
|
+
};
|
1272
|
+
}
|
1273
|
+
else {
|
1274
|
+
// pretty rounding of base-10 numbers
|
1275
|
+
var maxDec = opts.tickDecimals;
|
1276
|
+
var dec = -Math.floor(Math.log(delta) / Math.LN10);
|
1277
|
+
if (maxDec != null && dec > maxDec)
|
1278
|
+
dec = maxDec;
|
1279
|
+
|
1280
|
+
magn = Math.pow(10, -dec);
|
1281
|
+
norm = delta / magn; // norm is between 1.0 and 10.0
|
1282
|
+
|
1283
|
+
if (norm < 1.5)
|
1284
|
+
size = 1;
|
1285
|
+
else if (norm < 3) {
|
1286
|
+
size = 2;
|
1287
|
+
// special case for 2.5, requires an extra decimal
|
1288
|
+
if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) {
|
1289
|
+
size = 2.5;
|
1290
|
+
++dec;
|
1291
|
+
}
|
1292
|
+
}
|
1293
|
+
else if (norm < 7.5)
|
1294
|
+
size = 5;
|
1295
|
+
else
|
1296
|
+
size = 10;
|
1297
|
+
|
1298
|
+
size *= magn;
|
1299
|
+
|
1300
|
+
if (opts.minTickSize != null && size < opts.minTickSize)
|
1301
|
+
size = opts.minTickSize;
|
1302
|
+
|
1303
|
+
axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec);
|
1304
|
+
axis.tickSize = opts.tickSize || size;
|
1305
|
+
|
1306
|
+
generator = function (axis) {
|
1307
|
+
var ticks = [];
|
1308
|
+
|
1309
|
+
// spew out all possible ticks
|
1310
|
+
var start = floorInBase(axis.min, axis.tickSize),
|
1311
|
+
i = 0, v = Number.NaN, prev;
|
1312
|
+
do {
|
1313
|
+
prev = v;
|
1314
|
+
v = start + i * axis.tickSize;
|
1315
|
+
ticks.push(v);
|
1316
|
+
++i;
|
1317
|
+
} while (v < axis.max && v != prev);
|
1318
|
+
return ticks;
|
1319
|
+
};
|
1320
|
+
|
1321
|
+
formatter = function (v, axis) {
|
1322
|
+
return v.toFixed(axis.tickDecimals);
|
1323
|
+
};
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
if (opts.alignTicksWithAxis != null) {
|
1327
|
+
var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1];
|
1328
|
+
if (otherAxis && otherAxis.used && otherAxis != axis) {
|
1329
|
+
// consider snapping min/max to outermost nice ticks
|
1330
|
+
var niceTicks = generator(axis);
|
1331
|
+
if (niceTicks.length > 0) {
|
1332
|
+
if (opts.min == null)
|
1333
|
+
axis.min = Math.min(axis.min, niceTicks[0]);
|
1334
|
+
if (opts.max == null && niceTicks.length > 1)
|
1335
|
+
axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]);
|
1336
|
+
}
|
1337
|
+
|
1338
|
+
generator = function (axis) {
|
1339
|
+
// copy ticks, scaled to this axis
|
1340
|
+
var ticks = [], v, i;
|
1341
|
+
for (i = 0; i < otherAxis.ticks.length; ++i) {
|
1342
|
+
v = (otherAxis.ticks[i].v - otherAxis.min) / (otherAxis.max - otherAxis.min);
|
1343
|
+
v = axis.min + v * (axis.max - axis.min);
|
1344
|
+
ticks.push(v);
|
1345
|
+
}
|
1346
|
+
return ticks;
|
1347
|
+
};
|
1348
|
+
|
1349
|
+
// we might need an extra decimal since forced
|
1350
|
+
// ticks don't necessarily fit naturally
|
1351
|
+
if (axis.mode != "time" && opts.tickDecimals == null) {
|
1352
|
+
var extraDec = Math.max(0, -Math.floor(Math.log(delta) / Math.LN10) + 1),
|
1353
|
+
ts = generator(axis);
|
1354
|
+
|
1355
|
+
// only proceed if the tick interval rounded
|
1356
|
+
// with an extra decimal doesn't give us a
|
1357
|
+
// zero at end
|
1358
|
+
if (!(ts.length > 1 && /\..*0$/.test((ts[1] - ts[0]).toFixed(extraDec))))
|
1359
|
+
axis.tickDecimals = extraDec;
|
1360
|
+
}
|
1361
|
+
}
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
axis.tickGenerator = generator;
|
1365
|
+
if ($.isFunction(opts.tickFormatter))
|
1366
|
+
axis.tickFormatter = function (v, axis) { return "" + opts.tickFormatter(v, axis); };
|
1367
|
+
else
|
1368
|
+
axis.tickFormatter = formatter;
|
1369
|
+
}
|
1370
|
+
|
1371
|
+
function setTicks(axis) {
|
1372
|
+
var oticks = axis.options.ticks, ticks = [];
|
1373
|
+
if (oticks == null || (typeof oticks == "number" && oticks > 0))
|
1374
|
+
ticks = axis.tickGenerator(axis);
|
1375
|
+
else if (oticks) {
|
1376
|
+
if ($.isFunction(oticks))
|
1377
|
+
// generate the ticks
|
1378
|
+
ticks = oticks({ min: axis.min, max: axis.max });
|
1379
|
+
else
|
1380
|
+
ticks = oticks;
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
// clean up/labelify the supplied ticks, copy them over
|
1384
|
+
var i, v;
|
1385
|
+
axis.ticks = [];
|
1386
|
+
for (i = 0; i < ticks.length; ++i) {
|
1387
|
+
var label = null;
|
1388
|
+
var t = ticks[i];
|
1389
|
+
if (typeof t == "object") {
|
1390
|
+
v = +t[0];
|
1391
|
+
if (t.length > 1)
|
1392
|
+
label = t[1];
|
1393
|
+
}
|
1394
|
+
else
|
1395
|
+
v = +t;
|
1396
|
+
if (label == null)
|
1397
|
+
label = axis.tickFormatter(v, axis);
|
1398
|
+
if (!isNaN(v))
|
1399
|
+
axis.ticks.push({ v: v, label: label });
|
1400
|
+
}
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
function snapRangeToTicks(axis, ticks) {
|
1404
|
+
if (axis.options.autoscaleMargin && ticks.length > 0) {
|
1405
|
+
// snap to ticks
|
1406
|
+
if (axis.options.min == null)
|
1407
|
+
axis.min = Math.min(axis.min, ticks[0].v);
|
1408
|
+
if (axis.options.max == null && ticks.length > 1)
|
1409
|
+
axis.max = Math.max(axis.max, ticks[ticks.length - 1].v);
|
1410
|
+
}
|
1411
|
+
}
|
1412
|
+
|
1413
|
+
function draw() {
|
1414
|
+
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
|
1415
|
+
|
1416
|
+
var grid = options.grid;
|
1417
|
+
|
1418
|
+
// draw background, if any
|
1419
|
+
if (grid.show && grid.backgroundColor)
|
1420
|
+
drawBackground();
|
1421
|
+
|
1422
|
+
if (grid.show && !grid.aboveData)
|
1423
|
+
drawGrid();
|
1424
|
+
|
1425
|
+
for (var i = 0; i < series.length; ++i) {
|
1426
|
+
executeHooks(hooks.drawSeries, [ctx, series[i]]);
|
1427
|
+
drawSeries(series[i]);
|
1428
|
+
}
|
1429
|
+
|
1430
|
+
executeHooks(hooks.draw, [ctx]);
|
1431
|
+
|
1432
|
+
if (grid.show && grid.aboveData)
|
1433
|
+
drawGrid();
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
function extractRange(ranges, coord) {
|
1437
|
+
var axis, from, to, key, axes = allAxes();
|
1438
|
+
|
1439
|
+
for (i = 0; i < axes.length; ++i) {
|
1440
|
+
axis = axes[i];
|
1441
|
+
if (axis.direction == coord) {
|
1442
|
+
key = coord + axis.n + "axis";
|
1443
|
+
if (!ranges[key] && axis.n == 1)
|
1444
|
+
key = coord + "axis"; // support x1axis as xaxis
|
1445
|
+
if (ranges[key]) {
|
1446
|
+
from = ranges[key].from;
|
1447
|
+
to = ranges[key].to;
|
1448
|
+
break;
|
1449
|
+
}
|
1450
|
+
}
|
1451
|
+
}
|
1452
|
+
|
1453
|
+
// backwards-compat stuff - to be removed in future
|
1454
|
+
if (!ranges[key]) {
|
1455
|
+
axis = coord == "x" ? xaxes[0] : yaxes[0];
|
1456
|
+
from = ranges[coord + "1"];
|
1457
|
+
to = ranges[coord + "2"];
|
1458
|
+
}
|
1459
|
+
|
1460
|
+
// auto-reverse as an added bonus
|
1461
|
+
if (from != null && to != null && from > to) {
|
1462
|
+
var tmp = from;
|
1463
|
+
from = to;
|
1464
|
+
to = tmp;
|
1465
|
+
}
|
1466
|
+
|
1467
|
+
return { from: from, to: to, axis: axis };
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
function drawBackground() {
|
1471
|
+
ctx.save();
|
1472
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
1473
|
+
|
1474
|
+
ctx.fillStyle = getColorOrGradient(options.grid.backgroundColor, plotHeight, 0, "rgba(255, 255, 255, 0)");
|
1475
|
+
ctx.fillRect(0, 0, plotWidth, plotHeight);
|
1476
|
+
ctx.restore();
|
1477
|
+
}
|
1478
|
+
|
1479
|
+
function drawGrid() {
|
1480
|
+
var i;
|
1481
|
+
|
1482
|
+
ctx.save();
|
1483
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
1484
|
+
|
1485
|
+
// draw markings
|
1486
|
+
var markings = options.grid.markings;
|
1487
|
+
if (markings) {
|
1488
|
+
if ($.isFunction(markings)) {
|
1489
|
+
var axes = plot.getAxes();
|
1490
|
+
// xmin etc. is backwards compatibility, to be
|
1491
|
+
// removed in the future
|
1492
|
+
axes.xmin = axes.xaxis.min;
|
1493
|
+
axes.xmax = axes.xaxis.max;
|
1494
|
+
axes.ymin = axes.yaxis.min;
|
1495
|
+
axes.ymax = axes.yaxis.max;
|
1496
|
+
|
1497
|
+
markings = markings(axes);
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
for (i = 0; i < markings.length; ++i) {
|
1501
|
+
var m = markings[i],
|
1502
|
+
xrange = extractRange(m, "x"),
|
1503
|
+
yrange = extractRange(m, "y");
|
1504
|
+
|
1505
|
+
// fill in missing
|
1506
|
+
if (xrange.from == null)
|
1507
|
+
xrange.from = xrange.axis.min;
|
1508
|
+
if (xrange.to == null)
|
1509
|
+
xrange.to = xrange.axis.max;
|
1510
|
+
if (yrange.from == null)
|
1511
|
+
yrange.from = yrange.axis.min;
|
1512
|
+
if (yrange.to == null)
|
1513
|
+
yrange.to = yrange.axis.max;
|
1514
|
+
|
1515
|
+
// clip
|
1516
|
+
if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max ||
|
1517
|
+
yrange.to < yrange.axis.min || yrange.from > yrange.axis.max)
|
1518
|
+
continue;
|
1519
|
+
|
1520
|
+
xrange.from = Math.max(xrange.from, xrange.axis.min);
|
1521
|
+
xrange.to = Math.min(xrange.to, xrange.axis.max);
|
1522
|
+
yrange.from = Math.max(yrange.from, yrange.axis.min);
|
1523
|
+
yrange.to = Math.min(yrange.to, yrange.axis.max);
|
1524
|
+
|
1525
|
+
if (xrange.from == xrange.to && yrange.from == yrange.to)
|
1526
|
+
continue;
|
1527
|
+
|
1528
|
+
// then draw
|
1529
|
+
xrange.from = xrange.axis.p2c(xrange.from);
|
1530
|
+
xrange.to = xrange.axis.p2c(xrange.to);
|
1531
|
+
yrange.from = yrange.axis.p2c(yrange.from);
|
1532
|
+
yrange.to = yrange.axis.p2c(yrange.to);
|
1533
|
+
|
1534
|
+
if (xrange.from == xrange.to || yrange.from == yrange.to) {
|
1535
|
+
// draw line
|
1536
|
+
ctx.beginPath();
|
1537
|
+
ctx.strokeStyle = m.color || options.grid.markingsColor;
|
1538
|
+
ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth;
|
1539
|
+
ctx.moveTo(xrange.from, yrange.from);
|
1540
|
+
ctx.lineTo(xrange.to, yrange.to);
|
1541
|
+
ctx.stroke();
|
1542
|
+
}
|
1543
|
+
else {
|
1544
|
+
// fill area
|
1545
|
+
ctx.fillStyle = m.color || options.grid.markingsColor;
|
1546
|
+
ctx.fillRect(xrange.from, yrange.to,
|
1547
|
+
xrange.to - xrange.from,
|
1548
|
+
yrange.from - yrange.to);
|
1549
|
+
}
|
1550
|
+
}
|
1551
|
+
}
|
1552
|
+
|
1553
|
+
// draw the ticks
|
1554
|
+
var axes = allAxes(), bw = options.grid.borderWidth;
|
1555
|
+
|
1556
|
+
for (var j = 0; j < axes.length; ++j) {
|
1557
|
+
var axis = axes[j], box = axis.box,
|
1558
|
+
t = axis.tickLength, x, y, xoff, yoff;
|
1559
|
+
if (!axis.show || axis.ticks.length == 0)
|
1560
|
+
continue
|
1561
|
+
|
1562
|
+
ctx.strokeStyle = axis.options.tickColor || $.color.parse(axis.options.color).scale('a', 0.22).toString();
|
1563
|
+
ctx.lineWidth = 1;
|
1564
|
+
|
1565
|
+
// find the edges
|
1566
|
+
if (axis.direction == "x") {
|
1567
|
+
x = 0;
|
1568
|
+
if (t == "full")
|
1569
|
+
y = (axis.position == "top" ? 0 : plotHeight);
|
1570
|
+
else
|
1571
|
+
y = box.top - plotOffset.top + (axis.position == "top" ? box.height : 0);
|
1572
|
+
}
|
1573
|
+
else {
|
1574
|
+
y = 0;
|
1575
|
+
if (t == "full")
|
1576
|
+
x = (axis.position == "left" ? 0 : plotWidth);
|
1577
|
+
else
|
1578
|
+
x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0);
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
// draw tick bar
|
1582
|
+
if (!axis.innermost) {
|
1583
|
+
ctx.beginPath();
|
1584
|
+
xoff = yoff = 0;
|
1585
|
+
if (axis.direction == "x")
|
1586
|
+
xoff = plotWidth;
|
1587
|
+
else
|
1588
|
+
yoff = plotHeight;
|
1589
|
+
|
1590
|
+
if (ctx.lineWidth == 1) {
|
1591
|
+
x = Math.floor(x) + 0.5;
|
1592
|
+
y = Math.floor(y) + 0.5;
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
ctx.moveTo(x, y);
|
1596
|
+
ctx.lineTo(x + xoff, y + yoff);
|
1597
|
+
ctx.stroke();
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
// draw ticks
|
1601
|
+
ctx.beginPath();
|
1602
|
+
for (i = 0; i < axis.ticks.length; ++i) {
|
1603
|
+
var v = axis.ticks[i].v;
|
1604
|
+
|
1605
|
+
xoff = yoff = 0;
|
1606
|
+
|
1607
|
+
if (v < axis.min || v > axis.max
|
1608
|
+
// skip those lying on the axes if we got a border
|
1609
|
+
|| (t == "full" && bw > 0
|
1610
|
+
&& (v == axis.min || v == axis.max)))
|
1611
|
+
continue;
|
1612
|
+
|
1613
|
+
if (axis.direction == "x") {
|
1614
|
+
x = axis.p2c(v);
|
1615
|
+
yoff = t == "full" ? -plotHeight : t;
|
1616
|
+
|
1617
|
+
if (axis.position == "top")
|
1618
|
+
yoff = -yoff;
|
1619
|
+
}
|
1620
|
+
else {
|
1621
|
+
y = axis.p2c(v);
|
1622
|
+
xoff = t == "full" ? -plotWidth : t;
|
1623
|
+
|
1624
|
+
if (axis.position == "left")
|
1625
|
+
xoff = -xoff;
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
if (ctx.lineWidth == 1) {
|
1629
|
+
if (axis.direction == "x")
|
1630
|
+
x = Math.floor(x) + 0.5;
|
1631
|
+
else
|
1632
|
+
y = Math.floor(y) + 0.5;
|
1633
|
+
}
|
1634
|
+
|
1635
|
+
ctx.moveTo(x, y);
|
1636
|
+
ctx.lineTo(x + xoff, y + yoff);
|
1637
|
+
}
|
1638
|
+
|
1639
|
+
ctx.stroke();
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
|
1643
|
+
// draw border
|
1644
|
+
if (bw) {
|
1645
|
+
ctx.lineWidth = bw;
|
1646
|
+
ctx.strokeStyle = options.grid.borderColor;
|
1647
|
+
ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw);
|
1648
|
+
}
|
1649
|
+
|
1650
|
+
ctx.restore();
|
1651
|
+
}
|
1652
|
+
|
1653
|
+
function insertAxisLabels() {
|
1654
|
+
placeholder.find(".tickLabels").remove();
|
1655
|
+
|
1656
|
+
var html = ['<div class="tickLabels" style="font-size:smaller">'];
|
1657
|
+
|
1658
|
+
var axes = allAxes();
|
1659
|
+
for (var j = 0; j < axes.length; ++j) {
|
1660
|
+
var axis = axes[j], box = axis.box;
|
1661
|
+
if (!axis.show)
|
1662
|
+
continue;
|
1663
|
+
//debug: html.push('<div style="position:absolute;opacity:0.10;background-color:red;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>')
|
1664
|
+
html.push('<div class="' + axis.direction + 'Axis ' + axis.direction + axis.n + 'Axis" style="color:' + axis.options.color + '">');
|
1665
|
+
for (var i = 0; i < axis.ticks.length; ++i) {
|
1666
|
+
var tick = axis.ticks[i];
|
1667
|
+
if (!tick.label || tick.v < axis.min || tick.v > axis.max)
|
1668
|
+
continue;
|
1669
|
+
|
1670
|
+
var pos = {}, align;
|
1671
|
+
|
1672
|
+
if (axis.direction == "x") {
|
1673
|
+
align = "center";
|
1674
|
+
pos.left = Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2);
|
1675
|
+
if (axis.position == "bottom")
|
1676
|
+
pos.top = box.top + box.padding;
|
1677
|
+
else
|
1678
|
+
pos.bottom = canvasHeight - (box.top + box.height - box.padding);
|
1679
|
+
}
|
1680
|
+
else {
|
1681
|
+
pos.top = Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2);
|
1682
|
+
if (axis.position == "left") {
|
1683
|
+
pos.right = canvasWidth - (box.left + box.width - box.padding)
|
1684
|
+
align = "right";
|
1685
|
+
}
|
1686
|
+
else {
|
1687
|
+
pos.left = box.left + box.padding;
|
1688
|
+
align = "left";
|
1689
|
+
}
|
1690
|
+
}
|
1691
|
+
|
1692
|
+
pos.width = axis.labelWidth;
|
1693
|
+
|
1694
|
+
var style = ["position:absolute", "text-align:" + align ];
|
1695
|
+
for (var a in pos)
|
1696
|
+
style.push(a + ":" + pos[a] + "px")
|
1697
|
+
|
1698
|
+
html.push('<div class="tickLabel" style="' + style.join(';') + '">' + tick.label + '</div>');
|
1699
|
+
}
|
1700
|
+
html.push('</div>');
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
html.push('</div>');
|
1704
|
+
|
1705
|
+
placeholder.append(html.join(""));
|
1706
|
+
}
|
1707
|
+
|
1708
|
+
function drawSeries(series) {
|
1709
|
+
if (series.lines.show)
|
1710
|
+
drawSeriesLines(series);
|
1711
|
+
if (series.bars.show)
|
1712
|
+
drawSeriesBars(series);
|
1713
|
+
if (series.points.show)
|
1714
|
+
drawSeriesPoints(series);
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
function drawSeriesLines(series) {
|
1718
|
+
function plotLine(datapoints, xoffset, yoffset, axisx, axisy) {
|
1719
|
+
var points = datapoints.points,
|
1720
|
+
ps = datapoints.pointsize,
|
1721
|
+
prevx = null, prevy = null;
|
1722
|
+
|
1723
|
+
ctx.beginPath();
|
1724
|
+
for (var i = ps; i < points.length; i += ps) {
|
1725
|
+
var x1 = points[i - ps], y1 = points[i - ps + 1],
|
1726
|
+
x2 = points[i], y2 = points[i + 1];
|
1727
|
+
|
1728
|
+
if (x1 == null || x2 == null)
|
1729
|
+
continue;
|
1730
|
+
|
1731
|
+
// clip with ymin
|
1732
|
+
if (y1 <= y2 && y1 < axisy.min) {
|
1733
|
+
if (y2 < axisy.min)
|
1734
|
+
continue; // line segment is outside
|
1735
|
+
// compute new intersection point
|
1736
|
+
x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1737
|
+
y1 = axisy.min;
|
1738
|
+
}
|
1739
|
+
else if (y2 <= y1 && y2 < axisy.min) {
|
1740
|
+
if (y1 < axisy.min)
|
1741
|
+
continue;
|
1742
|
+
x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1743
|
+
y2 = axisy.min;
|
1744
|
+
}
|
1745
|
+
|
1746
|
+
// clip with ymax
|
1747
|
+
if (y1 >= y2 && y1 > axisy.max) {
|
1748
|
+
if (y2 > axisy.max)
|
1749
|
+
continue;
|
1750
|
+
x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1751
|
+
y1 = axisy.max;
|
1752
|
+
}
|
1753
|
+
else if (y2 >= y1 && y2 > axisy.max) {
|
1754
|
+
if (y1 > axisy.max)
|
1755
|
+
continue;
|
1756
|
+
x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1757
|
+
y2 = axisy.max;
|
1758
|
+
}
|
1759
|
+
|
1760
|
+
// clip with xmin
|
1761
|
+
if (x1 <= x2 && x1 < axisx.min) {
|
1762
|
+
if (x2 < axisx.min)
|
1763
|
+
continue;
|
1764
|
+
y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1765
|
+
x1 = axisx.min;
|
1766
|
+
}
|
1767
|
+
else if (x2 <= x1 && x2 < axisx.min) {
|
1768
|
+
if (x1 < axisx.min)
|
1769
|
+
continue;
|
1770
|
+
y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1771
|
+
x2 = axisx.min;
|
1772
|
+
}
|
1773
|
+
|
1774
|
+
// clip with xmax
|
1775
|
+
if (x1 >= x2 && x1 > axisx.max) {
|
1776
|
+
if (x2 > axisx.max)
|
1777
|
+
continue;
|
1778
|
+
y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1779
|
+
x1 = axisx.max;
|
1780
|
+
}
|
1781
|
+
else if (x2 >= x1 && x2 > axisx.max) {
|
1782
|
+
if (x1 > axisx.max)
|
1783
|
+
continue;
|
1784
|
+
y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1785
|
+
x2 = axisx.max;
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
if (x1 != prevx || y1 != prevy)
|
1789
|
+
ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset);
|
1790
|
+
|
1791
|
+
prevx = x2;
|
1792
|
+
prevy = y2;
|
1793
|
+
ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset);
|
1794
|
+
}
|
1795
|
+
ctx.stroke();
|
1796
|
+
}
|
1797
|
+
|
1798
|
+
function plotLineArea(datapoints, axisx, axisy) {
|
1799
|
+
var points = datapoints.points,
|
1800
|
+
ps = datapoints.pointsize,
|
1801
|
+
bottom = Math.min(Math.max(0, axisy.min), axisy.max),
|
1802
|
+
i = 0, top, areaOpen = false,
|
1803
|
+
ypos = 1, segmentStart = 0, segmentEnd = 0;
|
1804
|
+
|
1805
|
+
// we process each segment in two turns, first forward
|
1806
|
+
// direction to sketch out top, then once we hit the
|
1807
|
+
// end we go backwards to sketch the bottom
|
1808
|
+
while (true) {
|
1809
|
+
if (ps > 0 && i > points.length + ps)
|
1810
|
+
break;
|
1811
|
+
|
1812
|
+
i += ps; // ps is negative if going backwards
|
1813
|
+
|
1814
|
+
var x1 = points[i - ps],
|
1815
|
+
y1 = points[i - ps + ypos],
|
1816
|
+
x2 = points[i], y2 = points[i + ypos];
|
1817
|
+
|
1818
|
+
if (areaOpen) {
|
1819
|
+
if (ps > 0 && x1 != null && x2 == null) {
|
1820
|
+
// at turning point
|
1821
|
+
segmentEnd = i;
|
1822
|
+
ps = -ps;
|
1823
|
+
ypos = 2;
|
1824
|
+
continue;
|
1825
|
+
}
|
1826
|
+
|
1827
|
+
if (ps < 0 && i == segmentStart + ps) {
|
1828
|
+
// done with the reverse sweep
|
1829
|
+
ctx.fill();
|
1830
|
+
areaOpen = false;
|
1831
|
+
ps = -ps;
|
1832
|
+
ypos = 1;
|
1833
|
+
i = segmentStart = segmentEnd + ps;
|
1834
|
+
continue;
|
1835
|
+
}
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
if (x1 == null || x2 == null)
|
1839
|
+
continue;
|
1840
|
+
|
1841
|
+
// clip x values
|
1842
|
+
|
1843
|
+
// clip with xmin
|
1844
|
+
if (x1 <= x2 && x1 < axisx.min) {
|
1845
|
+
if (x2 < axisx.min)
|
1846
|
+
continue;
|
1847
|
+
y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1848
|
+
x1 = axisx.min;
|
1849
|
+
}
|
1850
|
+
else if (x2 <= x1 && x2 < axisx.min) {
|
1851
|
+
if (x1 < axisx.min)
|
1852
|
+
continue;
|
1853
|
+
y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1854
|
+
x2 = axisx.min;
|
1855
|
+
}
|
1856
|
+
|
1857
|
+
// clip with xmax
|
1858
|
+
if (x1 >= x2 && x1 > axisx.max) {
|
1859
|
+
if (x2 > axisx.max)
|
1860
|
+
continue;
|
1861
|
+
y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1862
|
+
x1 = axisx.max;
|
1863
|
+
}
|
1864
|
+
else if (x2 >= x1 && x2 > axisx.max) {
|
1865
|
+
if (x1 > axisx.max)
|
1866
|
+
continue;
|
1867
|
+
y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
|
1868
|
+
x2 = axisx.max;
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
if (!areaOpen) {
|
1872
|
+
// open area
|
1873
|
+
ctx.beginPath();
|
1874
|
+
ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom));
|
1875
|
+
areaOpen = true;
|
1876
|
+
}
|
1877
|
+
|
1878
|
+
// now first check the case where both is outside
|
1879
|
+
if (y1 >= axisy.max && y2 >= axisy.max) {
|
1880
|
+
ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max));
|
1881
|
+
ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max));
|
1882
|
+
continue;
|
1883
|
+
}
|
1884
|
+
else if (y1 <= axisy.min && y2 <= axisy.min) {
|
1885
|
+
ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min));
|
1886
|
+
ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min));
|
1887
|
+
continue;
|
1888
|
+
}
|
1889
|
+
|
1890
|
+
// else it's a bit more complicated, there might
|
1891
|
+
// be a flat maxed out rectangle first, then a
|
1892
|
+
// triangular cutout or reverse; to find these
|
1893
|
+
// keep track of the current x values
|
1894
|
+
var x1old = x1, x2old = x2;
|
1895
|
+
|
1896
|
+
// clip the y values, without shortcutting, we
|
1897
|
+
// go through all cases in turn
|
1898
|
+
|
1899
|
+
// clip with ymin
|
1900
|
+
if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) {
|
1901
|
+
x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1902
|
+
y1 = axisy.min;
|
1903
|
+
}
|
1904
|
+
else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) {
|
1905
|
+
x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1906
|
+
y2 = axisy.min;
|
1907
|
+
}
|
1908
|
+
|
1909
|
+
// clip with ymax
|
1910
|
+
if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) {
|
1911
|
+
x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1912
|
+
y1 = axisy.max;
|
1913
|
+
}
|
1914
|
+
else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) {
|
1915
|
+
x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
|
1916
|
+
y2 = axisy.max;
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
// if the x value was changed we got a rectangle
|
1920
|
+
// to fill
|
1921
|
+
if (x1 != x1old) {
|
1922
|
+
ctx.lineTo(axisx.p2c(x1old), axisy.p2c(y1));
|
1923
|
+
// it goes to (x1, y1), but we fill that below
|
1924
|
+
}
|
1925
|
+
|
1926
|
+
// fill triangular section, this sometimes result
|
1927
|
+
// in redundant points if (x1, y1) hasn't changed
|
1928
|
+
// from previous line to, but we just ignore that
|
1929
|
+
ctx.lineTo(axisx.p2c(x1), axisy.p2c(y1));
|
1930
|
+
ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2));
|
1931
|
+
|
1932
|
+
// fill the other rectangle if it's there
|
1933
|
+
if (x2 != x2old) {
|
1934
|
+
ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2));
|
1935
|
+
ctx.lineTo(axisx.p2c(x2old), axisy.p2c(y2));
|
1936
|
+
}
|
1937
|
+
}
|
1938
|
+
}
|
1939
|
+
|
1940
|
+
ctx.save();
|
1941
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
1942
|
+
ctx.lineJoin = "round";
|
1943
|
+
|
1944
|
+
var lw = series.lines.lineWidth,
|
1945
|
+
sw = series.shadowSize;
|
1946
|
+
// FIXME: consider another form of shadow when filling is turned on
|
1947
|
+
if (lw > 0 && sw > 0) {
|
1948
|
+
// draw shadow as a thick and thin line with transparency
|
1949
|
+
ctx.lineWidth = sw;
|
1950
|
+
ctx.strokeStyle = "rgba(0,0,0,0.1)";
|
1951
|
+
// position shadow at angle from the mid of line
|
1952
|
+
var angle = Math.PI/18;
|
1953
|
+
plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis);
|
1954
|
+
ctx.lineWidth = sw/2;
|
1955
|
+
plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis);
|
1956
|
+
}
|
1957
|
+
|
1958
|
+
ctx.lineWidth = lw;
|
1959
|
+
ctx.strokeStyle = series.color;
|
1960
|
+
var fillStyle = getFillStyle(series.lines, series.color, 0, plotHeight);
|
1961
|
+
if (fillStyle) {
|
1962
|
+
ctx.fillStyle = fillStyle;
|
1963
|
+
plotLineArea(series.datapoints, series.xaxis, series.yaxis);
|
1964
|
+
}
|
1965
|
+
|
1966
|
+
if (lw > 0)
|
1967
|
+
plotLine(series.datapoints, 0, 0, series.xaxis, series.yaxis);
|
1968
|
+
ctx.restore();
|
1969
|
+
}
|
1970
|
+
|
1971
|
+
function drawSeriesPoints(series) {
|
1972
|
+
function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol) {
|
1973
|
+
var points = datapoints.points, ps = datapoints.pointsize;
|
1974
|
+
|
1975
|
+
for (var i = 0; i < points.length; i += ps) {
|
1976
|
+
var x = points[i], y = points[i + 1];
|
1977
|
+
if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
|
1978
|
+
continue;
|
1979
|
+
|
1980
|
+
ctx.beginPath();
|
1981
|
+
x = axisx.p2c(x);
|
1982
|
+
y = axisy.p2c(y) + offset;
|
1983
|
+
if (symbol == "circle")
|
1984
|
+
ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false);
|
1985
|
+
else
|
1986
|
+
symbol(ctx, x, y, radius, shadow);
|
1987
|
+
ctx.closePath();
|
1988
|
+
|
1989
|
+
if (fillStyle) {
|
1990
|
+
ctx.fillStyle = fillStyle;
|
1991
|
+
ctx.fill();
|
1992
|
+
}
|
1993
|
+
ctx.stroke();
|
1994
|
+
}
|
1995
|
+
}
|
1996
|
+
|
1997
|
+
ctx.save();
|
1998
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
1999
|
+
|
2000
|
+
var lw = series.points.lineWidth,
|
2001
|
+
sw = series.shadowSize,
|
2002
|
+
radius = series.points.radius,
|
2003
|
+
symbol = series.points.symbol;
|
2004
|
+
if (lw > 0 && sw > 0) {
|
2005
|
+
// draw shadow in two steps
|
2006
|
+
var w = sw / 2;
|
2007
|
+
ctx.lineWidth = w;
|
2008
|
+
ctx.strokeStyle = "rgba(0,0,0,0.1)";
|
2009
|
+
plotPoints(series.datapoints, radius, null, w + w/2, true,
|
2010
|
+
series.xaxis, series.yaxis, symbol);
|
2011
|
+
|
2012
|
+
ctx.strokeStyle = "rgba(0,0,0,0.2)";
|
2013
|
+
plotPoints(series.datapoints, radius, null, w/2, true,
|
2014
|
+
series.xaxis, series.yaxis, symbol);
|
2015
|
+
}
|
2016
|
+
|
2017
|
+
ctx.lineWidth = lw;
|
2018
|
+
ctx.strokeStyle = series.color;
|
2019
|
+
plotPoints(series.datapoints, radius,
|
2020
|
+
getFillStyle(series.points, series.color), 0, false,
|
2021
|
+
series.xaxis, series.yaxis, symbol);
|
2022
|
+
ctx.restore();
|
2023
|
+
}
|
2024
|
+
|
2025
|
+
function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
|
2026
|
+
var left, right, bottom, top,
|
2027
|
+
drawLeft, drawRight, drawTop, drawBottom,
|
2028
|
+
tmp;
|
2029
|
+
|
2030
|
+
// in horizontal mode, we start the bar from the left
|
2031
|
+
// instead of from the bottom so it appears to be
|
2032
|
+
// horizontal rather than vertical
|
2033
|
+
if (horizontal) {
|
2034
|
+
drawBottom = drawRight = drawTop = true;
|
2035
|
+
drawLeft = false;
|
2036
|
+
left = b;
|
2037
|
+
right = x;
|
2038
|
+
top = y + barLeft;
|
2039
|
+
bottom = y + barRight;
|
2040
|
+
|
2041
|
+
// account for negative bars
|
2042
|
+
if (right < left) {
|
2043
|
+
tmp = right;
|
2044
|
+
right = left;
|
2045
|
+
left = tmp;
|
2046
|
+
drawLeft = true;
|
2047
|
+
drawRight = false;
|
2048
|
+
}
|
2049
|
+
}
|
2050
|
+
else {
|
2051
|
+
drawLeft = drawRight = drawTop = true;
|
2052
|
+
drawBottom = false;
|
2053
|
+
left = x + barLeft;
|
2054
|
+
right = x + barRight;
|
2055
|
+
bottom = b;
|
2056
|
+
top = y;
|
2057
|
+
|
2058
|
+
// account for negative bars
|
2059
|
+
if (top < bottom) {
|
2060
|
+
tmp = top;
|
2061
|
+
top = bottom;
|
2062
|
+
bottom = tmp;
|
2063
|
+
drawBottom = true;
|
2064
|
+
drawTop = false;
|
2065
|
+
}
|
2066
|
+
}
|
2067
|
+
|
2068
|
+
// clip
|
2069
|
+
if (right < axisx.min || left > axisx.max ||
|
2070
|
+
top < axisy.min || bottom > axisy.max)
|
2071
|
+
return;
|
2072
|
+
|
2073
|
+
if (left < axisx.min) {
|
2074
|
+
left = axisx.min;
|
2075
|
+
drawLeft = false;
|
2076
|
+
}
|
2077
|
+
|
2078
|
+
if (right > axisx.max) {
|
2079
|
+
right = axisx.max;
|
2080
|
+
drawRight = false;
|
2081
|
+
}
|
2082
|
+
|
2083
|
+
if (bottom < axisy.min) {
|
2084
|
+
bottom = axisy.min;
|
2085
|
+
drawBottom = false;
|
2086
|
+
}
|
2087
|
+
|
2088
|
+
if (top > axisy.max) {
|
2089
|
+
top = axisy.max;
|
2090
|
+
drawTop = false;
|
2091
|
+
}
|
2092
|
+
|
2093
|
+
left = axisx.p2c(left);
|
2094
|
+
bottom = axisy.p2c(bottom);
|
2095
|
+
right = axisx.p2c(right);
|
2096
|
+
top = axisy.p2c(top);
|
2097
|
+
|
2098
|
+
// fill the bar
|
2099
|
+
if (fillStyleCallback) {
|
2100
|
+
c.beginPath();
|
2101
|
+
c.moveTo(left, bottom);
|
2102
|
+
c.lineTo(left, top);
|
2103
|
+
c.lineTo(right, top);
|
2104
|
+
c.lineTo(right, bottom);
|
2105
|
+
c.fillStyle = fillStyleCallback(bottom, top);
|
2106
|
+
c.fill();
|
2107
|
+
}
|
2108
|
+
|
2109
|
+
// draw outline
|
2110
|
+
if (lineWidth > 0 && (drawLeft || drawRight || drawTop || drawBottom)) {
|
2111
|
+
c.beginPath();
|
2112
|
+
|
2113
|
+
// FIXME: inline moveTo is buggy with excanvas
|
2114
|
+
c.moveTo(left, bottom + offset);
|
2115
|
+
if (drawLeft)
|
2116
|
+
c.lineTo(left, top + offset);
|
2117
|
+
else
|
2118
|
+
c.moveTo(left, top + offset);
|
2119
|
+
if (drawTop)
|
2120
|
+
c.lineTo(right, top + offset);
|
2121
|
+
else
|
2122
|
+
c.moveTo(right, top + offset);
|
2123
|
+
if (drawRight)
|
2124
|
+
c.lineTo(right, bottom + offset);
|
2125
|
+
else
|
2126
|
+
c.moveTo(right, bottom + offset);
|
2127
|
+
if (drawBottom)
|
2128
|
+
c.lineTo(left, bottom + offset);
|
2129
|
+
else
|
2130
|
+
c.moveTo(left, bottom + offset);
|
2131
|
+
c.stroke();
|
2132
|
+
}
|
2133
|
+
}
|
2134
|
+
|
2135
|
+
function drawSeriesBars(series) {
|
2136
|
+
function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) {
|
2137
|
+
var points = datapoints.points, ps = datapoints.pointsize;
|
2138
|
+
|
2139
|
+
for (var i = 0; i < points.length; i += ps) {
|
2140
|
+
if (points[i] == null)
|
2141
|
+
continue;
|
2142
|
+
drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth);
|
2143
|
+
}
|
2144
|
+
}
|
2145
|
+
|
2146
|
+
ctx.save();
|
2147
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
2148
|
+
|
2149
|
+
// FIXME: figure out a way to add shadows (for instance along the right edge)
|
2150
|
+
ctx.lineWidth = series.bars.lineWidth;
|
2151
|
+
ctx.strokeStyle = series.color;
|
2152
|
+
var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
|
2153
|
+
var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null;
|
2154
|
+
plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis);
|
2155
|
+
ctx.restore();
|
2156
|
+
}
|
2157
|
+
|
2158
|
+
function getFillStyle(filloptions, seriesColor, bottom, top) {
|
2159
|
+
var fill = filloptions.fill;
|
2160
|
+
if (!fill)
|
2161
|
+
return null;
|
2162
|
+
|
2163
|
+
if (filloptions.fillColor)
|
2164
|
+
return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor);
|
2165
|
+
|
2166
|
+
var c = $.color.parse(seriesColor);
|
2167
|
+
c.a = typeof fill == "number" ? fill : 0.4;
|
2168
|
+
c.normalize();
|
2169
|
+
return c.toString();
|
2170
|
+
}
|
2171
|
+
|
2172
|
+
function insertLegend() {
|
2173
|
+
placeholder.find(".legend").remove();
|
2174
|
+
|
2175
|
+
if (!options.legend.show)
|
2176
|
+
return;
|
2177
|
+
|
2178
|
+
var fragments = [], rowStarted = false,
|
2179
|
+
lf = options.legend.labelFormatter, s, label;
|
2180
|
+
for (var i = 0; i < series.length; ++i) {
|
2181
|
+
s = series[i];
|
2182
|
+
label = s.label;
|
2183
|
+
if (!label)
|
2184
|
+
continue;
|
2185
|
+
|
2186
|
+
if (i % options.legend.noColumns == 0) {
|
2187
|
+
if (rowStarted)
|
2188
|
+
fragments.push('</tr>');
|
2189
|
+
fragments.push('<tr>');
|
2190
|
+
rowStarted = true;
|
2191
|
+
}
|
2192
|
+
|
2193
|
+
if (lf)
|
2194
|
+
label = lf(label, s);
|
2195
|
+
|
2196
|
+
fragments.push(
|
2197
|
+
'<td class="legendColorBox"><div style="border:1px solid ' + options.legend.labelBoxBorderColor + ';padding:1px"><div style="width:4px;height:0;border:5px solid ' + s.color + ';overflow:hidden"></div></div></td>' +
|
2198
|
+
'<td class="legendLabel">' + label + '</td>');
|
2199
|
+
}
|
2200
|
+
if (rowStarted)
|
2201
|
+
fragments.push('</tr>');
|
2202
|
+
|
2203
|
+
if (fragments.length == 0)
|
2204
|
+
return;
|
2205
|
+
|
2206
|
+
var table = '<table style="font-size:smaller;color:' + options.grid.color + '">' + fragments.join("") + '</table>';
|
2207
|
+
if (options.legend.container != null)
|
2208
|
+
$(options.legend.container).html(table);
|
2209
|
+
else {
|
2210
|
+
var pos = "",
|
2211
|
+
p = options.legend.position,
|
2212
|
+
m = options.legend.margin;
|
2213
|
+
if (m[0] == null)
|
2214
|
+
m = [m, m];
|
2215
|
+
if (p.charAt(0) == "n")
|
2216
|
+
pos += 'top:' + (m[1] + plotOffset.top) + 'px;';
|
2217
|
+
else if (p.charAt(0) == "s")
|
2218
|
+
pos += 'bottom:' + (m[1] + plotOffset.bottom) + 'px;';
|
2219
|
+
if (p.charAt(1) == "e")
|
2220
|
+
pos += 'right:' + (m[0] + plotOffset.right) + 'px;';
|
2221
|
+
else if (p.charAt(1) == "w")
|
2222
|
+
pos += 'left:' + (m[0] + plotOffset.left) + 'px;';
|
2223
|
+
var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(placeholder);
|
2224
|
+
if (options.legend.backgroundOpacity != 0.0) {
|
2225
|
+
// put in the transparent background
|
2226
|
+
// separately to avoid blended labels and
|
2227
|
+
// label boxes
|
2228
|
+
var c = options.legend.backgroundColor;
|
2229
|
+
if (c == null) {
|
2230
|
+
c = options.grid.backgroundColor;
|
2231
|
+
if (c && typeof c == "string")
|
2232
|
+
c = $.color.parse(c);
|
2233
|
+
else
|
2234
|
+
c = $.color.extract(legend, 'background-color');
|
2235
|
+
c.a = 1;
|
2236
|
+
c = c.toString();
|
2237
|
+
}
|
2238
|
+
var div = legend.children();
|
2239
|
+
$('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity);
|
2240
|
+
}
|
2241
|
+
}
|
2242
|
+
}
|
2243
|
+
|
2244
|
+
|
2245
|
+
// interactive features
|
2246
|
+
|
2247
|
+
var highlights = [],
|
2248
|
+
redrawTimeout = null;
|
2249
|
+
|
2250
|
+
// returns the data item the mouse is over, or null if none is found
|
2251
|
+
function findNearbyItem(mouseX, mouseY, seriesFilter) {
|
2252
|
+
var maxDistance = options.grid.mouseActiveRadius,
|
2253
|
+
smallestDistance = maxDistance * maxDistance + 1,
|
2254
|
+
item = null, foundPoint = false, i, j;
|
2255
|
+
|
2256
|
+
for (i = series.length - 1; i >= 0; --i) {
|
2257
|
+
if (!seriesFilter(series[i]))
|
2258
|
+
continue;
|
2259
|
+
|
2260
|
+
var s = series[i],
|
2261
|
+
axisx = s.xaxis,
|
2262
|
+
axisy = s.yaxis,
|
2263
|
+
points = s.datapoints.points,
|
2264
|
+
ps = s.datapoints.pointsize,
|
2265
|
+
mx = axisx.c2p(mouseX), // precompute some stuff to make the loop faster
|
2266
|
+
my = axisy.c2p(mouseY),
|
2267
|
+
maxx = maxDistance / axisx.scale,
|
2268
|
+
maxy = maxDistance / axisy.scale;
|
2269
|
+
|
2270
|
+
// with inverse transforms, we can't use the maxx/maxy
|
2271
|
+
// optimization, sadly
|
2272
|
+
if (axisx.options.inverseTransform)
|
2273
|
+
maxx = Number.MAX_VALUE;
|
2274
|
+
if (axisy.options.inverseTransform)
|
2275
|
+
maxy = Number.MAX_VALUE;
|
2276
|
+
|
2277
|
+
if (s.lines.show || s.points.show) {
|
2278
|
+
for (j = 0; j < points.length; j += ps) {
|
2279
|
+
var x = points[j], y = points[j + 1];
|
2280
|
+
if (x == null)
|
2281
|
+
continue;
|
2282
|
+
|
2283
|
+
// For points and lines, the cursor must be within a
|
2284
|
+
// certain distance to the data point
|
2285
|
+
if (x - mx > maxx || x - mx < -maxx ||
|
2286
|
+
y - my > maxy || y - my < -maxy)
|
2287
|
+
continue;
|
2288
|
+
|
2289
|
+
// We have to calculate distances in pixels, not in
|
2290
|
+
// data units, because the scales of the axes may be different
|
2291
|
+
var dx = Math.abs(axisx.p2c(x) - mouseX),
|
2292
|
+
dy = Math.abs(axisy.p2c(y) - mouseY),
|
2293
|
+
dist = dx * dx + dy * dy; // we save the sqrt
|
2294
|
+
|
2295
|
+
// use <= to ensure last point takes precedence
|
2296
|
+
// (last generally means on top of)
|
2297
|
+
if (dist < smallestDistance) {
|
2298
|
+
smallestDistance = dist;
|
2299
|
+
item = [i, j / ps];
|
2300
|
+
}
|
2301
|
+
}
|
2302
|
+
}
|
2303
|
+
|
2304
|
+
if (s.bars.show && !item) { // no other point can be nearby
|
2305
|
+
var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2,
|
2306
|
+
barRight = barLeft + s.bars.barWidth;
|
2307
|
+
|
2308
|
+
for (j = 0; j < points.length; j += ps) {
|
2309
|
+
var x = points[j], y = points[j + 1], b = points[j + 2];
|
2310
|
+
if (x == null)
|
2311
|
+
continue;
|
2312
|
+
|
2313
|
+
// for a bar graph, the cursor must be inside the bar
|
2314
|
+
if (series[i].bars.horizontal ?
|
2315
|
+
(mx <= Math.max(b, x) && mx >= Math.min(b, x) &&
|
2316
|
+
my >= y + barLeft && my <= y + barRight) :
|
2317
|
+
(mx >= x + barLeft && mx <= x + barRight &&
|
2318
|
+
my >= Math.min(b, y) && my <= Math.max(b, y)))
|
2319
|
+
item = [i, j / ps];
|
2320
|
+
}
|
2321
|
+
}
|
2322
|
+
}
|
2323
|
+
|
2324
|
+
if (item) {
|
2325
|
+
i = item[0];
|
2326
|
+
j = item[1];
|
2327
|
+
ps = series[i].datapoints.pointsize;
|
2328
|
+
|
2329
|
+
return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps),
|
2330
|
+
dataIndex: j,
|
2331
|
+
series: series[i],
|
2332
|
+
seriesIndex: i };
|
2333
|
+
}
|
2334
|
+
|
2335
|
+
return null;
|
2336
|
+
}
|
2337
|
+
|
2338
|
+
function onMouseMove(e) {
|
2339
|
+
if (options.grid.hoverable)
|
2340
|
+
triggerClickHoverEvent("plothover", e,
|
2341
|
+
function (s) { return s["hoverable"] != false; });
|
2342
|
+
}
|
2343
|
+
|
2344
|
+
function onMouseLeave(e) {
|
2345
|
+
if (options.grid.hoverable)
|
2346
|
+
triggerClickHoverEvent("plothover", e,
|
2347
|
+
function (s) { return false; });
|
2348
|
+
}
|
2349
|
+
|
2350
|
+
function onClick(e) {
|
2351
|
+
triggerClickHoverEvent("plotclick", e,
|
2352
|
+
function (s) { return s["clickable"] != false; });
|
2353
|
+
}
|
2354
|
+
|
2355
|
+
// trigger click or hover event (they send the same parameters
|
2356
|
+
// so we share their code)
|
2357
|
+
function triggerClickHoverEvent(eventname, event, seriesFilter) {
|
2358
|
+
var offset = eventHolder.offset(),
|
2359
|
+
canvasX = event.pageX - offset.left - plotOffset.left,
|
2360
|
+
canvasY = event.pageY - offset.top - plotOffset.top,
|
2361
|
+
pos = canvasToAxisCoords({ left: canvasX, top: canvasY });
|
2362
|
+
|
2363
|
+
pos.pageX = event.pageX;
|
2364
|
+
pos.pageY = event.pageY;
|
2365
|
+
|
2366
|
+
var item = findNearbyItem(canvasX, canvasY, seriesFilter);
|
2367
|
+
|
2368
|
+
if (item) {
|
2369
|
+
// fill in mouse pos for any listeners out there
|
2370
|
+
item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left + plotOffset.left);
|
2371
|
+
item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top + plotOffset.top);
|
2372
|
+
}
|
2373
|
+
|
2374
|
+
if (options.grid.autoHighlight) {
|
2375
|
+
// clear auto-highlights
|
2376
|
+
for (var i = 0; i < highlights.length; ++i) {
|
2377
|
+
var h = highlights[i];
|
2378
|
+
if (h.auto == eventname &&
|
2379
|
+
!(item && h.series == item.series &&
|
2380
|
+
h.point[0] == item.datapoint[0] &&
|
2381
|
+
h.point[1] == item.datapoint[1]))
|
2382
|
+
unhighlight(h.series, h.point);
|
2383
|
+
}
|
2384
|
+
|
2385
|
+
if (item)
|
2386
|
+
highlight(item.series, item.datapoint, eventname);
|
2387
|
+
}
|
2388
|
+
|
2389
|
+
placeholder.trigger(eventname, [ pos, item ]);
|
2390
|
+
}
|
2391
|
+
|
2392
|
+
function triggerRedrawOverlay() {
|
2393
|
+
if (!redrawTimeout)
|
2394
|
+
redrawTimeout = setTimeout(drawOverlay, 30);
|
2395
|
+
}
|
2396
|
+
|
2397
|
+
function drawOverlay() {
|
2398
|
+
redrawTimeout = null;
|
2399
|
+
|
2400
|
+
// draw highlights
|
2401
|
+
octx.save();
|
2402
|
+
octx.clearRect(0, 0, canvasWidth, canvasHeight);
|
2403
|
+
octx.translate(plotOffset.left, plotOffset.top);
|
2404
|
+
|
2405
|
+
var i, hi;
|
2406
|
+
for (i = 0; i < highlights.length; ++i) {
|
2407
|
+
hi = highlights[i];
|
2408
|
+
|
2409
|
+
if (hi.series.bars.show)
|
2410
|
+
drawBarHighlight(hi.series, hi.point);
|
2411
|
+
else
|
2412
|
+
drawPointHighlight(hi.series, hi.point);
|
2413
|
+
}
|
2414
|
+
octx.restore();
|
2415
|
+
|
2416
|
+
executeHooks(hooks.drawOverlay, [octx]);
|
2417
|
+
}
|
2418
|
+
|
2419
|
+
function highlight(s, point, auto) {
|
2420
|
+
if (typeof s == "number")
|
2421
|
+
s = series[s];
|
2422
|
+
|
2423
|
+
if (typeof point == "number") {
|
2424
|
+
var ps = s.datapoints.pointsize;
|
2425
|
+
point = s.datapoints.points.slice(ps * point, ps * (point + 1));
|
2426
|
+
}
|
2427
|
+
|
2428
|
+
var i = indexOfHighlight(s, point);
|
2429
|
+
if (i == -1) {
|
2430
|
+
highlights.push({ series: s, point: point, auto: auto });
|
2431
|
+
|
2432
|
+
triggerRedrawOverlay();
|
2433
|
+
}
|
2434
|
+
else if (!auto)
|
2435
|
+
highlights[i].auto = false;
|
2436
|
+
}
|
2437
|
+
|
2438
|
+
function unhighlight(s, point) {
|
2439
|
+
if (s == null && point == null) {
|
2440
|
+
highlights = [];
|
2441
|
+
triggerRedrawOverlay();
|
2442
|
+
}
|
2443
|
+
|
2444
|
+
if (typeof s == "number")
|
2445
|
+
s = series[s];
|
2446
|
+
|
2447
|
+
if (typeof point == "number")
|
2448
|
+
point = s.data[point];
|
2449
|
+
|
2450
|
+
var i = indexOfHighlight(s, point);
|
2451
|
+
if (i != -1) {
|
2452
|
+
highlights.splice(i, 1);
|
2453
|
+
|
2454
|
+
triggerRedrawOverlay();
|
2455
|
+
}
|
2456
|
+
}
|
2457
|
+
|
2458
|
+
function indexOfHighlight(s, p) {
|
2459
|
+
for (var i = 0; i < highlights.length; ++i) {
|
2460
|
+
var h = highlights[i];
|
2461
|
+
if (h.series == s && h.point[0] == p[0]
|
2462
|
+
&& h.point[1] == p[1])
|
2463
|
+
return i;
|
2464
|
+
}
|
2465
|
+
return -1;
|
2466
|
+
}
|
2467
|
+
|
2468
|
+
function drawPointHighlight(series, point) {
|
2469
|
+
var x = point[0], y = point[1],
|
2470
|
+
axisx = series.xaxis, axisy = series.yaxis;
|
2471
|
+
|
2472
|
+
if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
|
2473
|
+
return;
|
2474
|
+
|
2475
|
+
var pointRadius = series.points.radius + series.points.lineWidth / 2;
|
2476
|
+
octx.lineWidth = pointRadius;
|
2477
|
+
octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
|
2478
|
+
var radius = 1.5 * pointRadius,
|
2479
|
+
x = axisx.p2c(x),
|
2480
|
+
y = axisy.p2c(y);
|
2481
|
+
|
2482
|
+
octx.beginPath();
|
2483
|
+
if (series.points.symbol == "circle")
|
2484
|
+
octx.arc(x, y, radius, 0, 2 * Math.PI, false);
|
2485
|
+
else
|
2486
|
+
series.points.symbol(octx, x, y, radius, false);
|
2487
|
+
octx.closePath();
|
2488
|
+
octx.stroke();
|
2489
|
+
}
|
2490
|
+
|
2491
|
+
function drawBarHighlight(series, point) {
|
2492
|
+
octx.lineWidth = series.bars.lineWidth;
|
2493
|
+
octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString();
|
2494
|
+
var fillStyle = $.color.parse(series.color).scale('a', 0.5).toString();
|
2495
|
+
var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2;
|
2496
|
+
drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth,
|
2497
|
+
0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
|
2498
|
+
}
|
2499
|
+
|
2500
|
+
function getColorOrGradient(spec, bottom, top, defaultColor) {
|
2501
|
+
if (typeof spec == "string")
|
2502
|
+
return spec;
|
2503
|
+
else {
|
2504
|
+
// assume this is a gradient spec; IE currently only
|
2505
|
+
// supports a simple vertical gradient properly, so that's
|
2506
|
+
// what we support too
|
2507
|
+
var gradient = ctx.createLinearGradient(0, top, 0, bottom);
|
2508
|
+
|
2509
|
+
for (var i = 0, l = spec.colors.length; i < l; ++i) {
|
2510
|
+
var c = spec.colors[i];
|
2511
|
+
if (typeof c != "string") {
|
2512
|
+
var co = $.color.parse(defaultColor);
|
2513
|
+
if (c.brightness != null)
|
2514
|
+
co = co.scale('rgb', c.brightness)
|
2515
|
+
if (c.opacity != null)
|
2516
|
+
co.a *= c.opacity;
|
2517
|
+
c = co.toString();
|
2518
|
+
}
|
2519
|
+
gradient.addColorStop(i / (l - 1), c);
|
2520
|
+
}
|
2521
|
+
|
2522
|
+
return gradient;
|
2523
|
+
}
|
2524
|
+
}
|
2525
|
+
}
|
2526
|
+
|
2527
|
+
$.plot = function(placeholder, data, options) {
|
2528
|
+
//var t0 = new Date();
|
2529
|
+
var plot = new Plot($(placeholder), data, options, $.plot.plugins);
|
2530
|
+
//(window.console ? console.log : alert)("time used (msecs): " + ((new Date()).getTime() - t0.getTime()));
|
2531
|
+
return plot;
|
2532
|
+
};
|
2533
|
+
|
2534
|
+
$.plot.version = "0.7";
|
2535
|
+
|
2536
|
+
$.plot.plugins = [];
|
2537
|
+
|
2538
|
+
// returns a string with the date d formatted according to fmt
|
2539
|
+
$.plot.formatDate = function(d, fmt, monthNames) {
|
2540
|
+
var leftPad = function(n) {
|
2541
|
+
n = "" + n;
|
2542
|
+
return n.length == 1 ? "0" + n : n;
|
2543
|
+
};
|
2544
|
+
|
2545
|
+
var r = [];
|
2546
|
+
var escape = false, padNext = false;
|
2547
|
+
var hours = d.getUTCHours();
|
2548
|
+
var isAM = hours < 12;
|
2549
|
+
if (monthNames == null)
|
2550
|
+
monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
2551
|
+
|
2552
|
+
if (fmt.search(/%p|%P/) != -1) {
|
2553
|
+
if (hours > 12) {
|
2554
|
+
hours = hours - 12;
|
2555
|
+
} else if (hours == 0) {
|
2556
|
+
hours = 12;
|
2557
|
+
}
|
2558
|
+
}
|
2559
|
+
for (var i = 0; i < fmt.length; ++i) {
|
2560
|
+
var c = fmt.charAt(i);
|
2561
|
+
|
2562
|
+
if (escape) {
|
2563
|
+
switch (c) {
|
2564
|
+
case 'h': c = "" + hours; break;
|
2565
|
+
case 'H': c = leftPad(hours); break;
|
2566
|
+
case 'M': c = leftPad(d.getUTCMinutes()); break;
|
2567
|
+
case 'S': c = leftPad(d.getUTCSeconds()); break;
|
2568
|
+
case 'd': c = "" + d.getUTCDate(); break;
|
2569
|
+
case 'm': c = "" + (d.getUTCMonth() + 1); break;
|
2570
|
+
case 'y': c = "" + d.getUTCFullYear(); break;
|
2571
|
+
case 'b': c = "" + monthNames[d.getUTCMonth()]; break;
|
2572
|
+
case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
|
2573
|
+
case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
|
2574
|
+
case '0': c = ""; padNext = true; break;
|
2575
|
+
}
|
2576
|
+
if (c && padNext) {
|
2577
|
+
c = leftPad(c);
|
2578
|
+
padNext = false;
|
2579
|
+
}
|
2580
|
+
r.push(c);
|
2581
|
+
if (!padNext)
|
2582
|
+
escape = false;
|
2583
|
+
}
|
2584
|
+
else {
|
2585
|
+
if (c == "%")
|
2586
|
+
escape = true;
|
2587
|
+
else
|
2588
|
+
r.push(c);
|
2589
|
+
}
|
2590
|
+
}
|
2591
|
+
return r.join("");
|
2592
|
+
};
|
2593
|
+
|
2594
|
+
// round to nearby lower multiple of base
|
2595
|
+
function floorInBase(n, base) {
|
2596
|
+
return base * Math.floor(n / base);
|
2597
|
+
}
|
2598
|
+
|
2599
|
+
})(jQuery);
|