Exemple #1
0
!function(a,b,c){"use strict";if("function"==typeof define&&define.amd)define(function(){return c()});else if("undefined"!=typeof module&&module.exports)module.exports=c();else for(var d=b.split("."),e=a||this,f=0;f<d.length;f++){var g=d[f],h=e[g];e=e[g]=f===d.length-1?c():h||{}}}(this,"backchart.base.logger",function(){if(!window.console){var a=function(a){window.alert(a)};window.console={log:a,info:a,warn:a,debug:a,error:a}}return window.console}),function(a,b,c){"use strict";if("function"==typeof define&&define.amd)define(function(){return c()});else if("undefined"!=typeof module&&module.exports)module.exports=c();else for(var d=b.split("."),e=a||this,f=0;f<d.length;f++){var g=d[f],h=e[g];e=e[g]=f===d.length-1?c():h||{}}}(this,"backchart.base.loader",function(){var a=this,b=function(b,c){var d=[];if("function"==typeof define&&define.amd)require(b instanceof Array?b:[b],c);else if("undefined"!=typeof module&&module.exports)if(b instanceof Array){for(var e=0;e<b.length;e++)d.push(require(b[e]));c.apply(this,d)}else c.call(this,require(b));else{("string"==typeof b||b instanceof String)&&(b=[b]);for(var f=0;f<b.length;f++){var g=b[f],h=a;g=g.replace("/",".").split(".");for(var i=0;i<g.length;i++){var j=g[i],k=h[j];if(!k){d.push(null);break}i===g.length-1&&d.push(k),h=k}}c.apply(this,d)}};return b}),function(a,b,c){"use strict";if("function"==typeof define&&define.amd)define(["jquery","backbone"],function(a,b){return c(a,b)});else if("undefined"!=typeof module&&module.exports){var d=require("jquery"),e=require("backbone");module.exports=c(d,e)}else for(var f=b.split("."),g=a||this,h=0;h<f.length;h++){var i=f[h],j=g[i];g=g[i]=h===f.length-1?c(a.jQuery||window.jQuery,a.Backbone||window.Backbone):j||{}}}(this,"backchart.base.model",function(a,b){var c=b.Model.extend({});return c}),function(a,b,c){"use strict";if("function"==typeof define&&define.amd)define(["jquery","underscore","backbone","backchart.base/loader","backchart.base/logger"],function(a,b,d,e){return c(a,b,d,e)});else if("undefined"!=typeof module&&module.exports){var d=require("jquery"),e=require("backbone"),f=require("underscore");require("backchart.base/logger");var g=require("backchart.base/loader");module.exports=c(d,f,e,g)}else for(var h=b.split("."),i=a||this,j=0;j<h.length;j++){var k=h[j],l=i[k];i=i[k]=j===h.length-1?c(a.jQuery||window.jQuery,a._||window._,a.Backbone||window.Backbone,a.backchart.base.loader):l||{}}}(this,"backchart.base.collection",function(a,b,c,d){var e=this,f=c.Collection.extend({_backchart:!0,constructor:function(){var b=this;this.fileType=null,this.parseOptions=a.extend({sheetIndex:0},b.parseOptions);var f=c.ajax;this._BackboneAjax=function(g){if("POST"!==g.type&&"GET"!==g.type)return f.apply(c.$,arguments);var h=b.fileType;if(!h&&g.url){var i=g.url.split("."),j=i.length>0?i.pop():"";switch(j.toLowerCase()){case"csv":h="csv";break;case"tsv":h="tsv";break;case"xls":h="xls";break;case"xlsx":h="xlsx"}}"json"!==h&&"undefined"!=typeof g.dataType&&(g.dataType="text");var k=g.success;return g.success=function(c,f,g){if(!h){var i=g.getResponseHeader("content-type")||"";"text/csv"===i?h="csv":/\/tsv/.test(i)?h="tsv":/vnd\.ms\-excel/.test(i)?h="xls":/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet/.test(i)&&(h="xlsx")}return h?void d(["backchart.utils/jszip/jszip","backchart.utils/codepage/cptable"],function(a){e.JSZip=a,d("backchart.utils/parser",function(a){switch(h){case"csv":c=a.parseCSV(c);break;case"tsv":c=a.parseTSV(c);break;case"xls":c=a.parseXLS(c,b.parseOptions);break;case"xlsx":c=a.parseXLSX(c,b.parseOptions)}return k.call(b,c,f,g)})}):(c="string"==typeof c?a.parseJSON(c):c,k.call(b,c,f,g))},f.call(c.$,g)},c.Collection.apply(this,arguments)},sync:function(){var a=c.ajax;c.ajax=this._BackboneAjax;var b=c.sync.apply(this,arguments);return c.ajax=a,b},initialize:function(){return this._silence=!1,this._modelOptions={},c.Collection.prototype.initialize.apply(this,arguments)},setSilence:function(a){this._silence=a},set:function(b,d){var e=a.extend({silent:!0},d);if(this._silence===!0)return c.Collection.prototype.set.apply(this,[b,e]);this.setSilence(!0);var f=c.Collection.prototype.set.apply(this,[b,e]);return this.setSilence(!1),this.trigger("seted",this.models,this,d),f},remove:function(b,d){var e=a.extend({silent:!0},d);if(this._silence===!0)return c.Collection.prototype.remove.apply(this,[b,e]);this.setSilence(!0);var f=c.Collection.prototype.remove.apply(this,[b,e]);this.setSilence(!1);for(var g=b.length;g>=0;g--){var h=b[g];this._modelOptions[h]&&delete this._modelOptions[h]}return this.trigger("removed",this.models,this,d),f},reset:function(a,b){if(this._silence===!0)return c.Collection.prototype.reset.apply(this,arguments);this.setSilence(!0);var d=c.Collection.prototype.reset.apply(this,arguments);return this.setSilence(!1),this.trigger("reseted",this,b),d},getOptions:function(a){var b=this;if((a instanceof String||"string"==typeof a)&&(a=b.get(a)),a instanceof c.Model)for(var d=b.models.length-1;d>=0;d--){var e=b.models[d];if(e.cid===a.cid)return b._modelOptions[e.cid]||(b._modelOptions[e.cid]={}),b._modelOptions[e.cid]}return null},_setOptions:function(b,c){var d=this;return d._modelOptions[b.cid]?d._modelOptions[b.cid]=a.extend(d._modelOptions[b.cid],c):d._modelOptions[b.cid]=a.extend({},c),d._modelOptions[b.cid]},setOptions:function(a,b){var d=this;if((a instanceof String||"string"==typeof a)&&(a=d.get(a)),a instanceof c.Model)for(var e=d.models.length-1;e>=0;e--){var f=d.models[e];f.cid===a.cid&&d._setOptions(a,b)}return null},_setVisible:function(a,b){var d=this;if((a instanceof String||"string"==typeof a)&&(a=d.get(a)),a instanceof c.Model)for(var e=d.models.length-1;e>=0;e--){var f=d.models[e];if(f.cid===a.cid)return d._setoptions(a,{visible:b}),d.trigger("change:visible",b),a}return null},hide:function(a){return this._setVisible(a,!1)},show:function(a){return this._setVisible(a,!0)},isVisibled:function(a){var b=this.getOptions(a);return b&&b.visible===!1?!1:!0}});return f}),function(a,b,c){"use strict";if("function"==typeof define&&define.amd)define(["jquery","backbone","underscore"],function(a,b,d){return c(a,b,d)});else if("undefined"!=typeof module&&module.exports){var d=require("jquery"),e=require("underscore"),f=require("backbone");module.exports=c(d,f,e)}else for(var g=b.split("."),h=a||this,i=0;i<g.length;i++){var j=g[i],k=h[j];h=h[j]=i===g.length-1?c(a.jQuery||window.jQuery,a.Backbone||window.Backbone,a._||window._):k||{}}}(this,"backchart.base.view",function(a,b,c){var d=b.View.extend({tagName:"div",className:"backchart",_collectionPrefix:"_bcname",_viewPrefix:"_bcview",container:null,eventCallback:{"default":"render"},_getEventCallback:function(a){var b=this.eventCallback[a]||this.eventCallback["default"];return b?this[b]:this.render},setSilence:function(a){this._silence=a},_setVisible:function(a,c){var d=this;if("string"==typeof a||a instanceof String){var e=d._collectionOptions[a];e&&(e.visible=c)}else a instanceof b.Collection&&d.eachCollection(function(b,d,e,f){d===a&&(f.visible=c)});return d.trigger("change:visible",c),d.render(!0),d},hide:function(a){return this._setVisible(a,!1)},show:function(a){return this._setVisible(a,!0)},isVisibled:function(a){var c=this;if("string"==typeof a||a instanceof String){var d=c._collectionOptions[a];return d?d.visible:!1}if(a instanceof b.Collection){var e=!0;return c.eachCollection(function(b,c,d,f){c===a&&(e=f?f.visible:!1)}),e}},initialize:function(){var a=this;a._silence=!1,b.View.prototype.initialize.apply(this,arguments),a.collections={},a._collectionOptions={},a._collectionRenderOptions={},this.on("collection.on",function(b,c,d,e){e.renderAfterOn===!0&&a.render(!0)}),this.on("collection.off",function(){a.render(!0)})},__bce:function(a,b,d){var e=this;c.each(b,function(a){e.listenTo(d,a,e._getEventCallback(a))})},__ubce:function(a,b,d){var e=this;c.each(b,function(a){d.off(a,e._getEventCallback(a))})},_getBindEvents:function(a){var b=["set","add","change","destroy","reset","sort"];return"undefined"!=typeof a._backchart&&(b=["seted","removed","change","destroy","reseted","sort","change:visible"]),b},_bindCollectionEvent:function(a,b,c){c.silence!==!0&&this.__bce(a,this._getBindEvents(b),b)},_unbindColletionEvent:function(a,b){this.__ubce(a,this._getBindEvents(b),b)},_collectionHasBind:function(a){for(var b in this.collections)if(this.collections[b]===a)return!0;return!1},onCollection:function(a,d,e){d=d||{},e=e||{};var f=this,g=e.bid||c.uniqueId(f._collectionPrefix);if(!a instanceof b.Collection)return g;f._collectionHasBind(a)&&f.unCollection(a),f._bindCollectionEvent(g,a,e),f.trigger("collection.bindEvent",a),f.collections[g]=a;var h=c.clone(d);return f._collectionOptions[g]=e,f._collectionRenderOptions[g]=h,f.trigger("collection.on",g,a,h,e),g},onCollections:function(a,b,d){var e=this;!a instanceof Array&&(a=[a]);var f={};return c.each(a,function(a){f[a]=e.onCollection(a,b,d)}),f},unCollection:function(a){var d=this,e=null;if("string"==typeof a||a instanceof String){if(e=d.collections[a]){delete d.collections[a];var f=d._collectionRenderOptions[a],g=d._collectionOptions[a];delete d._collectionRenderOptions[a],delete d._collectionOptions[a],d._collectionHasBind(e)&&(d._unbindColletionEvent(a,e),d.trigger("collection.unbindEvent",e)),d.trigger("collection.off",a,e,f,g)}return e}if(a instanceof b.Collection){var h=[];e=a;for(var i in d.collections)d.collections[i]===e&&h.push(i);return c.each(h,function(a){d.unCollection(a)}),e}},clearCollection:function(){var a=this,b=c.keys(this.collections);return c.each(b,function(b){a.unCollection(b)}),this},eachCollection:function(a){var b=this;for(var c in b.collections)a.call(b.collections[c],c,b.collections[c],b._collectionRenderOptions[c],b._collectionOptions[c])},getCollection:function(a){var d=this;if("boolean"==typeof a&&a===!1)return c.uniq(c.values(d.collections));if("string"==typeof a||a instanceof String)return d.collections[a];if(a instanceof b.Collection){var e=[];return d.eachCollection(function(b){this===a&&e.push(b)}),e}var f={};return d.eachCollection(function(a){"undefined"==typeof f[this]&&(f[this]=[]),f[this].push(a)}),f},getOptions:function(a){var c=this,d=null;return"string"==typeof a||a instanceof String?c._collectionOptions[a]:a instanceof b.Collection?(d=[],c.eachCollection(function(b,c,e,f){c===a&&d.push(f)}),d):(d={},c.eachCollection(function(a,b,c,e){"undefined"==typeof d[this]&&(d[this]=[]),d[this].push(e)}),d)},getRenderOptions:function(a){var c=this,d=[];return"string"==typeof a||a instanceof String?c._collectionRenderOptions[a]:a instanceof b.Collection?(d=[],c.eachCollection(function(b,c,e){c===a&&d.push(e)}),d):(d={},c.eachCollection(function(a,b,c){"undefined"==typeof d[this]&&(d[this]=[]),d[this].push(c)}),d)},renderBefore:function(){var b=this;if(b.container)return b.$container=a(b.container),b.$container.is(":hidden")?!1:b._silence===!0?!1:!0},renderAfter:function(){return this.trigger.apply(this,["rendered"].concat(Array.prototype.slice.call(arguments,0))),a(this.container).trigger("backchart.rendered",arguments),this},elFillParents:function(){this.$el.css({width:this.width?this.width+"px":"100%",height:this.height?this.height+"px":"100%"})},getChartOptions:function(){return null}});return d});
(function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/model",["jquery","backbone"],function(e,t){return n(e,t)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("backbone");module.exports=n(r,i)}else{var s=t.split("."),o=e||this;for(var u=0;u<s.length;u++){var a=s[u],f=o[a];o=o[a]=u===s.length-1?n(e.jQuery||window.jQuery,e.Backbone||window.Backbone):f||{}}}})(this,"backchart.base.model",function(e,t){var n=t.Model.extend({});return n}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.echarts/model",["jquery","../backchart.base/model"],function(e,t){return n(e,t)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("../backchart.base/model");module.exports=n(r,i)}else{var s=t.split("."),o=e||this;for(var u=0;u<s.length;u++){var a=s[u],f=o[a];o=o[a]=u===s.length-1?n(e.jQuery||window.jQuery,e.backchart.base.model):f||{}}}}(this,"backchart.echarts.model",function(e,t){var n=t.extend({categoryField:null,valueField:null});return n}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/loader",[],function(){return n()});else if(typeof module!="undefined"&&module.exports)module.exports=n();else{var r=t.split("."),i=e||this;for(var s=0;s<r.length;s++){var o=r[s],u=i[o];i=i[o]=s===r.length-1?n():u||{}}}}(this,"backchart.base.loader",function(){var e=this,t=function(t,n){var r=[];if(typeof define=="function"&&define.amd)require(t instanceof Array?t:[t],n);else if(typeof module!="undefined"&&module.exports)if(t instanceof Array){for(var i=0;i<t.length;i++)r.push(require(t[i]));n.apply(this,r)}else n.call(this,require(t));else{if(typeof t=="string"||t instanceof String)t=[t];for(var s=0;s<t.length;s++){var o=t[s],u=e;o=o.replace("/",".").split(".");for(var a=0;a<o.length;a++){var f=o[a],l=u[f];if(!l){r.push(null);break}a===o.length-1&&r.push(l),u=l}}n.apply(this,r)}};return t}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/logger",[],function(){return n()});else if(typeof module!="undefined"&&module.exports)module.exports=n();else{var r=t.split("."),i=e||this;for(var s=0;s<r.length;s++){var o=r[s],u=i[o];i=i[o]=s===r.length-1?n():u||{}}}}(this,"backchart.base.logger",function(){if(!window.console){var e=function(e){window.alert(e)};window.console={log:e,info:e,warn:e,debug:e,error:e}}return window.console}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/collection",["jquery","underscore","backbone","backchart.base/loader","backchart.base/logger"],function(e,t,r,i){return n(e,t,r,i)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("backbone"),s=require("underscore");require("backchart.base/logger");var o=require("backchart.base/loader");module.exports=n(r,s,i,o)}else{var u=t.split("."),a=e||this;for(var f=0;f<u.length;f++){var l=u[f],c=a[l];a=a[l]=f===u.length-1?n(e.jQuery||window.jQuery,e._||window._,e.Backbone||window.Backbone,e.backchart.base.loader):c||{}}}}(this,"backchart.base.collection",function(e,t,n,r){var i=this,s=n.Collection.extend({_backchart:!0,constructor:function(){var t=this;this.fileType=null,this.parseOptions=e.extend({sheetIndex:0},t.parseOptions);var s=n.ajax;this._BackboneAjax=function(o){if(o.type!=="POST"&&o.type!=="GET")return s.apply(n.$,arguments);var u=t.fileType;if(!u&&o.url){var a=o.url.split("."),f=a.length>0?a.pop():"";switch(f.toLowerCase()){case"csv":u="csv";break;case"tsv":u="tsv";break;case"xls":u="xls";break;case"xlsx":u="xlsx"}}u!=="json"&&typeof o.dataType!="undefined"&&(o.dataType="text");var l=o.success;return o.success=function(n,s,o){if(!u){var a=o.getResponseHeader("content-type")||"";a==="text/csv"?u="csv":/\/tsv/.test(a)?u="tsv":/vnd\.ms\-excel/.test(a)?u="xls":/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet/.test(a)&&(u="xlsx")}if(!u)return n=typeof n=="string"?e.parseJSON(n):n,l.call(t,n,s,o);r(["backchart.utils/jszip/jszip","backchart.utils/codepage/cptable"],function(e){i.JSZip=e,r("backchart.utils/parser",function(e){switch(u){case"csv":n=e.parseCSV(n);break;case"tsv":n=e.parseTSV(n);break;case"xls":n=e.parseXLS(n,t.parseOptions);break;case"xlsx":n=e.parseXLSX(n,t.parseOptions)}return l.call(t,n,s,o)})})},s.call(n.$,o)},n.Collection.apply(this,arguments)},sync:function(){var e=n.ajax;n.ajax=this._BackboneAjax;var t=n.sync.apply(this,arguments);return n.ajax=e,t},initialize:function(){return this._silence=!1,this._modelOptions={},n.Collection.prototype.initialize.apply(this,arguments)},setSilence:function(e){this._silence=e},set:function(t,r){var i=e.extend({silent:!0},r);if(this._silence===!0)return n.Collection.prototype.set.apply(this,[t,i]);this.setSilence(!0);var s=n.Collection.prototype.set.apply(this,[t,i]);return this.setSilence(!1),this.trigger("seted",this.models,this,r),s},remove:function(t,r){var i=e.extend({silent:!0},r);if(this._silence===!0)return n.Collection.prototype.remove.apply(this,[t,i]);this.setSilence(!0);var s=n.Collection.prototype.remove.apply(this,[t,i]);this.setSilence(!1);for(var o=t.length;o>=0;o--){var u=t[o];this._modelOptions[u]&&delete this._modelOptions[u]}return this.trigger("removed",this.models,this,r),s},reset:function(e,t){if(this._silence===!0)return n.Collection.prototype.reset.apply(this,arguments);this.setSilence(!0);var r=n.Collection.prototype.reset.apply(this,arguments);return this.setSilence(!1),this.trigger("reseted",this,t),r},getOptions:function(e){var t=this;if(e instanceof String||typeof e=="string")e=t.get(e);if(e instanceof n.Model)for(var r=t.models.length-1;r>=0;r--){var i=t.models[r];if(i.cid===e.cid)return t._modelOptions[i.cid]||(t._modelOptions[i.cid]={}),t._modelOptions[i.cid]}return null},_setOptions:function(t,n){var r=this;return r._modelOptions[t.cid]?r._modelOptions[t.cid]=e.extend(r._modelOptions[t.cid],n):r._modelOptions[t.cid]=e.extend({},n),r._modelOptions[t.cid]},setOptions:function(e,t){var r=this;if(e instanceof String||typeof e=="string")e=r.get(e);if(e instanceof n.Model)for(var i=r.models.length-1;i>=0;i--){var s=r.models[i];s.cid===e.cid&&r._setOptions(e,t)}return null},_setVisible:function(e,t){var r=this;if(e instanceof String||typeof e=="string")e=r.get(e);if(e instanceof n.Model)for(var i=r.models.length-1;i>=0;i--){var s=r.models[i];if(s.cid===e.cid)return r._setoptions(e,{visible:t}),r.trigger("change:visible",t),e}return null},hide:function(e){return this._setVisible(e,!1)},show:function(e){return this._setVisible(e,!0)},isVisibled:function(e){var t=this.getOptions(e);return t?t.visible===!1?!1:!0:!0}});return s}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.echarts/collection",["jquery","../backchart.base/collection"],function(e,t){return n(e,t)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("../backchart.base/collection");module.exports=n(r,i)}else{var s=t.split("."),o=e||this;for(var u=0;u<s.length;u++){var a=s[u],f=o[a];o=o[a]=u===s.length-1?n(e.jQuery||window.jQuery,e.backchart.base.collection):f||{}}}}(this,"backchart.echarts.collection",function(e,t){var n=t.extend({constructor:function(n){this._options=e.extend(!0,{},n),t.apply(this,arguments)}});return n}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/view",["jquery","backbone","underscore"],function(e,t,r){return n(e,t,r)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("underscore"),s=require("backbone");module.exports=n(r,s,i)}else{var o=t.split("."),u=e||this;for(var a=0;a<o.length;a++){var f=o[a],l=u[f];u=u[f]=a===o.length-1?n(e.jQuery||window.jQuery,e.Backbone||window.Backbone,e._||window._):l||{}}}}(this,"backchart.base.view",function(e,t,n){var r=t.View.extend({tagName:"div",className:"backchart",_collectionPrefix:"_bcname",_viewPrefix:"_bcview",container:null,eventCallback:{"default":"render"},_getEventCallback:function(e){var t=this.eventCallback[e]||this.eventCallback["default"];return t?this[t]:this.render},setSilence:function(e){this._silence=e},_setVisible:function(e,n){var r=this;if(typeof e=="string"||e instanceof String){var i=r._collectionOptions[e];i&&(i.visible=n)}else e instanceof t.Collection&&r.eachCollection(function(t,r,i,s){r===e&&(s.visible=n)});return r.trigger("change:visible",n),r.render(!0),r},hide:function(e){return this._setVisible(e,!1)},show:function(e){return this._setVisible(e,!0)},isVisibled:function(e){var n=this;if(typeof e=="string"||e instanceof String){var r=n._collectionOptions[e];return r?r.visible:!1}if(e instanceof t.Collection){var i=!0;return n.eachCollection(function(t,n,r,s){n===e&&(i=s?s.visible:!1)}),i}},initialize:function(){var e=this;e._silence=!1,t.View.prototype.initialize.apply(this,arguments),e.collections={},e._collectionOptions={},e._collectionRenderOptions={},this.on("collection.on",function(t,n,r,i){i.renderAfterOn===!0&&e.render(!0)}),this.on("collection.off",function(){e.render(!0)})},__bce:function(e,t,r){var i=this;n.each(t,function(e){i.listenTo(r,e,i._getEventCallback(e))})},__ubce:function(e,t,r){var i=this;n.each(t,function(e){r.off(e,i._getEventCallback(e))})},_getBindEvents:function(e){var t=["set","add","change","destroy","reset","sort"];return typeof e._backchart!="undefined"&&(t=["seted","removed","change","destroy","reseted","sort","change:visible"]),t},_bindCollectionEvent:function(e,t,n){if(n.silence===!0)return;this.__bce(e,this._getBindEvents(t),t)},_unbindColletionEvent:function(e,t){this.__ubce(e,this._getBindEvents(t),t)},_collectionHasBind:function(e){for(var t in this.collections)if(this.collections[t]===e)return!0;return!1},onCollection:function(e,r,i){r=r||{},i=i||{};var s=this,o=i.bid||n.uniqueId(s._collectionPrefix);if(!e instanceof t.Collection)return o;s._collectionHasBind(e)&&s.unCollection(e),s._bindCollectionEvent(o,e,i),s.trigger("collection.bindEvent",e),s.collections[o]=e;var u=n.clone(r);return s._collectionOptions[o]=i,s._collectionRenderOptions[o]=u,s.trigger("collection.on",o,e,u,i),o},onCollections:function(e,t,r){var i=this;!e instanceof Array&&(e=[e]);var s={};return n.each(e,function(e){s[e]=i.onCollection(e,t,r)}),s},unCollection:function(e){var r=this,i=null;if(typeof e=="string"||e instanceof String){i=r.collections[e];if(i){delete r.collections[e];var s=r._collectionRenderOptions[e],o=r._collectionOptions[e];delete r._collectionRenderOptions[e],delete r._collectionOptions[e],r._collectionHasBind(i)&&(r._unbindColletionEvent(e,i),r.trigger("collection.unbindEvent",i)),r.trigger("collection.off",e,i,s,o)}return i}if(e instanceof t.Collection){var u=[];i=e;for(var a in r.collections)r.collections[a]===i&&u.push(a);return n.each(u,function(e){r.unCollection(e)}),i}},clearCollection:function(){var e=this,t=n.keys(this.collections);return n.each(t,function(t){e.unCollection(t)}),this},eachCollection:function(e){var t=this;for(var n in t.collections)e.call(t.collections[n],n,t.collections[n],t._collectionRenderOptions[n],t._collectionOptions[n])},getCollection:function(e){var r=this;if(typeof e=="boolean"&&e===!1)return n.uniq(n.values(r.collections));if(typeof e=="string"||e instanceof String)return r.collections[e];if(e instanceof t.Collection){var i=[];return r.eachCollection(function(t){this===e&&i.push(t)}),i}var s={};return r.eachCollection(function(e){typeof s[this]=="undefined"&&(s[this]=[]),s[this].push(e)}),s},getOptions:function(e){var n=this,r=null;return typeof e=="string"||e instanceof String?n._collectionOptions[e]:e instanceof t.Collection?(r=[],n.eachCollection(function(t,n,i,s){n===e&&r.push(s)}),r):(r={},n.eachCollection(function(e,t,n,i){typeof r[this]=="undefined"&&(r[this]=[]),r[this].push(i)}),r)},getRenderOptions:function(e){var n=this,r=[];return typeof e=="string"||e instanceof String?n._collectionRenderOptions[e]:e instanceof t.Collection?(r=[],n.eachCollection(function(t,n,i){n===e&&r.push(i)}),r):(r={},n.eachCollection(function(e,t,n){typeof r[this]=="undefined"&&(r[this]=[]),r[this].push(n)}),r)},renderBefore:function(){var t=this;if(!t.container)return;return t.$container=e(t.container),t.$container.is(":hidden")?!1:t._silence===!0?!1:!0},renderAfter:function(){return this.trigger.apply(this,["rendered"].concat(Array.prototype.slice.call(arguments,0))),e(this.container).trigger("backchart.rendered",arguments),this},elFillParents:function(){this.$el.css({width:this.width?this.width+"px":"100%",height:this.height?this.height+"px":"100%"})},getChartOptions:function(){return null}});return r}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.echarts/view",["jquery","backbone","underscore","../backchart.base/view","echarts","../backchart.base/logger"],function(e,t,r,i,s,o){return s=s||window.echarts,n(e,t,r,i,s,o)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("../backchart.base/view"),s=require("backbone"),o=require("underscore"),u=require("echarts")||window.echarts,a=require("../backchart.base/logger");module.exports=n(r,s,o,i,u,a)}else{var f=t.split("."),l=e||this;for(var c=0;c<f.length;c++){var h=f[c],p=l[h];l=l[h]=c===f.length-1?n(e.jQuery||window.jQuery,e.Backbone||window.Backbone,e._||window._,e.backchart.base.view,e.echarts||window.echarts):p||{}}}}(this,"backchart.echarts.view",function(e,t,n,r,i){var s=r.extend({multiValueAxes:!1,autoSymbol:!0,seriesNamePrefix:"Data Source",constructor:function(){this.defaultOptions={calculable:!1,animation:!1,tooltip:{trigger:"axis"},title:{x:"center"},legend:{y:"bottom"}},this.defaultRenderOptions={symbol:"emptyCircle",smooth:!0},this.defaultxAxis={type:"category"},this.defaultyAxis={type:"value"},this.__render=!1,r.apply(this,arguments)},initialize:function(t,n){return r.prototype.initialize.apply(this,arguments),this.defaultOptions=e.extend(!0,{},this.defaultOptions,t),this.defaultRenderOptions=e.extend(!0,{},this.defaultRenderOptions,n),this},_transformOneCollection:function(t,n,r,i,s){var o=this,u=r.categoryField||n.categoryField||n.model.prototype.categoryField,a=r.valueField||n.valueField||n.model.prototype.valueField,f=r.type||"line",l=r,c,h,p,d;i.legend||(i.legend={}),c=l.data=[],i.legend||(i.legend={}),i.legend.data?h=i.legend.data:h=i.legend.data=[],s&&(p=s.data=s.data?s.data:[]),l.name=l.name?l.name:o.seriesNamePrefix+t;var v={};switch(f){case"bar":case"line":d=function(e){var t=e.get(a),n=e.get(u);t=t?t:0,c.push(t),p&&p.push(n)},h.push(l.name);break;case"scatter":d=function(e){var t=e.get(a),n=e.get(u);t=t?t:[0],t instanceof Array?c.push(t):c.push([n,t])},h.push(l.name);break;case"k":break;case"pie":d=function(e){var t=e.get(a),n=e.get(u);t instanceof Object?(c.push(t),h.push(t.name)):(c.push({name:n,value:t}),h.push(n))};break;case"map":d=function(e){var t=e.get(a),n=e.get(u);t instanceof Object?c.push(t):c.push({name:n,value:t})},h.push(l.name);break;case"radar":i.polar||(i.polar=[]),i.polar.length===0&&i.polar.push({indicator:[]}),d=function(t){var n=t.get(a),r=t.get(u);if(n instanceof Array)e.each(n,function(e,n){var r=t.get(n);r=r?r:0,c.push(r);if(!v[n]||v[n]<r)v[n]=r});else for(var i in t.attributes){if(i===r)continue;var s=t.attributes[i];s=s?s:0,c.push(s);if(!v[i]||v[i]<s)v[i]=s}};break;default:}n.each(function(e){n.isVisibled(e)&&d&&d(e)});if(l.type==="radar"){var m=i.polar[0].indicator,g=o.nameMap||r.nameMap;for(var y in v){var b=g?g[y]?g[y]:y:y,w=v[y],E=!1;for(var S=m.length-1;S>=0;S--){var x=m[S];if(x.text===b){E=!0,x.max<w&&(x.max=w);break}}E||m.push({text:b,max:w})}}if(o.autoSymbol){var T=typeof o.autoSymbol=="number"?T:30;l.data.length>T&&(l.symbolSize=0)}return l},transformOptions:function(t,n){var r=this;t.series||(t.series=[]);var i=0;return r.eachCollection(function(s,o,u,a){if(o._silence||a.visible===!1)return;if(o.length===0)return;var f,l,c,h,p=e.extend(!0,{},n,u);if(!r.multiValueAxes){if(p.type!=="pie"){if(!t.xAxis||t.xAxis.length===0)c=e.extend(!0,{},r.defaultxAxis,n.xAxis),t.xAxis=[c];if(!t.yAxis||t.yAxis.length===0)h=e.extend(!0,{},r.defaultyAxis,n.yAxis),t.yAxis=[h]}}else t.xAxis||(t.xAxis=[]),t.yAxis||(t.yAxis=[]),c=e.extend(!0,{},r.defaultxAxis,n.xAxis),f=t.xAxis.push(c),h=e.extend(!0,{},r.defaultyAxis,n.yAxis),l=t.yAxis.push(h);var d=r._transformOneCollection(i,o,p,t,c,h);f&&(d.xAxisIndex=f-1),l&&(d.yAxisIndex=l-1);if(p.type==="radar"){var v;!t.series||t.series.length===0?(v={type:"radar",data:[]},t.series.push(v)):v=t.series[0],d.data.length>0&&(v.name=(v.name?v.name+" - ":"")+d.name,v.data.push({name:d.name,value:d.data}),t.legend.data.push(d.name))}else t.series.push(d);i++}),t},render:function(){var t=this,s=r.prototype.renderBefore.apply(t,arguments);if(!s)return!1;t.el.id||(t.el.id=n.uniqueId(t._viewPrefix||"_bcname"));var o=e.extend(!0,{},t.defaultOptions),u=t.transformOptions(o,t.defaultRenderOptions);return this.__cOptions=u,t.__render||(t.$container.empty().append(t.$el.empty()),t.elFillParents()),t.trigger("beforeRender",t,t.el.id,u),t.Chart=i.init(t.el).setOption(u),t.__render=!0,r.prototype.renderAfter.apply(t,[t,t.el,t.Chart,u])},getChartOption:function(){return this.__cOptions}});return s}),define("backchart.echarts/main",["./model","./collection","./view"],function(e,t,n){return{model:e,collection:t,view:n,run:function(r){return r(e,t,n)}}}),define("backchart.echarts",["backchart.echarts/main"],function(e){return e});
Exemple #3
0
(function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/model",["jquery","backbone"],function(e,t){return n(e,t)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("backbone");module.exports=n(r,i)}else{var s=t.split("."),o=e||this;for(var u=0;u<s.length;u++){var a=s[u],f=o[a];o=o[a]=u===s.length-1?n(e.jQuery||window.jQuery,e.Backbone||window.Backbone):f||{}}}})(this,"backchart.base.model",function(e,t){var n=t.Model.extend({});return n}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/loader",[],function(){return n()});else if(typeof module!="undefined"&&module.exports)module.exports=n();else{var r=t.split("."),i=e||this;for(var s=0;s<r.length;s++){var o=r[s],u=i[o];i=i[o]=s===r.length-1?n():u||{}}}}(this,"backchart.base.loader",function(){var e=this,t=function(t,n){var r=[];if(typeof define=="function"&&define.amd)require(t instanceof Array?t:[t],n);else if(typeof module!="undefined"&&module.exports)if(t instanceof Array){for(var i=0;i<t.length;i++)r.push(require(t[i]));n.apply(this,r)}else n.call(this,require(t));else{if(typeof t=="string"||t instanceof String)t=[t];for(var s=0;s<t.length;s++){var o=t[s],u=e;o=o.replace("/",".").split(".");for(var a=0;a<o.length;a++){var f=o[a],l=u[f];if(!l){r.push(null);break}a===o.length-1&&r.push(l),u=l}}n.apply(this,r)}};return t}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/logger",[],function(){return n()});else if(typeof module!="undefined"&&module.exports)module.exports=n();else{var r=t.split("."),i=e||this;for(var s=0;s<r.length;s++){var o=r[s],u=i[o];i=i[o]=s===r.length-1?n():u||{}}}}(this,"backchart.base.logger",function(){if(!window.console){var e=function(e){window.alert(e)};window.console={log:e,info:e,warn:e,debug:e,error:e}}return window.console}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/collection",["jquery","underscore","backbone","backchart.base/loader","backchart.base/logger"],function(e,t,r,i){return n(e,t,r,i)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("backbone"),s=require("underscore");require("backchart.base/logger");var o=require("backchart.base/loader");module.exports=n(r,s,i,o)}else{var u=t.split("."),a=e||this;for(var f=0;f<u.length;f++){var l=u[f],c=a[l];a=a[l]=f===u.length-1?n(e.jQuery||window.jQuery,e._||window._,e.Backbone||window.Backbone,e.backchart.base.loader):c||{}}}}(this,"backchart.base.collection",function(e,t,n,r){var i=this,s=n.Collection.extend({_backchart:!0,constructor:function(){var t=this;this.fileType=null,this.parseOptions=e.extend({sheetIndex:0},t.parseOptions);var s=n.ajax;this._BackboneAjax=function(o){if(o.type!=="POST"&&o.type!=="GET")return s.apply(n.$,arguments);var u=t.fileType;if(!u&&o.url){var a=o.url.split("."),f=a.length>0?a.pop():"";switch(f.toLowerCase()){case"csv":u="csv";break;case"tsv":u="tsv";break;case"xls":u="xls";break;case"xlsx":u="xlsx"}}u!=="json"&&typeof o.dataType!="undefined"&&(o.dataType="text");var l=o.success;return o.success=function(n,s,o){if(!u){var a=o.getResponseHeader("content-type")||"";a==="text/csv"?u="csv":/\/tsv/.test(a)?u="tsv":/vnd\.ms\-excel/.test(a)?u="xls":/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet/.test(a)&&(u="xlsx")}if(!u)return n=typeof n=="string"?e.parseJSON(n):n,l.call(t,n,s,o);r(["backchart.utils/jszip/jszip","backchart.utils/codepage/cptable"],function(e){i.JSZip=e,r("backchart.utils/parser",function(e){switch(u){case"csv":n=e.parseCSV(n);break;case"tsv":n=e.parseTSV(n);break;case"xls":n=e.parseXLS(n,t.parseOptions);break;case"xlsx":n=e.parseXLSX(n,t.parseOptions)}return l.call(t,n,s,o)})})},s.call(n.$,o)},n.Collection.apply(this,arguments)},sync:function(){var e=n.ajax;n.ajax=this._BackboneAjax;var t=n.sync.apply(this,arguments);return n.ajax=e,t},initialize:function(){return this._silence=!1,this._modelOptions={},n.Collection.prototype.initialize.apply(this,arguments)},setSilence:function(e){this._silence=e},set:function(t,r){var i=e.extend({silent:!0},r);if(this._silence===!0)return n.Collection.prototype.set.apply(this,[t,i]);this.setSilence(!0);var s=n.Collection.prototype.set.apply(this,[t,i]);return this.setSilence(!1),this.trigger("seted",this.models,this,r),s},remove:function(t,r){var i=e.extend({silent:!0},r);if(this._silence===!0)return n.Collection.prototype.remove.apply(this,[t,i]);this.setSilence(!0);var s=n.Collection.prototype.remove.apply(this,[t,i]);this.setSilence(!1);for(var o=t.length;o>=0;o--){var u=t[o];this._modelOptions[u]&&delete this._modelOptions[u]}return this.trigger("removed",this.models,this,r),s},reset:function(e,t){if(this._silence===!0)return n.Collection.prototype.reset.apply(this,arguments);this.setSilence(!0);var r=n.Collection.prototype.reset.apply(this,arguments);return this.setSilence(!1),this.trigger("reseted",this,t),r},getOptions:function(e){var t=this;if(e instanceof String||typeof e=="string")e=t.get(e);if(e instanceof n.Model)for(var r=t.models.length-1;r>=0;r--){var i=t.models[r];if(i.cid===e.cid)return t._modelOptions[i.cid]||(t._modelOptions[i.cid]={}),t._modelOptions[i.cid]}return null},_setOptions:function(t,n){var r=this;return r._modelOptions[t.cid]?r._modelOptions[t.cid]=e.extend(r._modelOptions[t.cid],n):r._modelOptions[t.cid]=e.extend({},n),r._modelOptions[t.cid]},setOptions:function(e,t){var r=this;if(e instanceof String||typeof e=="string")e=r.get(e);if(e instanceof n.Model)for(var i=r.models.length-1;i>=0;i--){var s=r.models[i];s.cid===e.cid&&r._setOptions(e,t)}return null},_setVisible:function(e,t){var r=this;if(e instanceof String||typeof e=="string")e=r.get(e);if(e instanceof n.Model)for(var i=r.models.length-1;i>=0;i--){var s=r.models[i];if(s.cid===e.cid)return r._setoptions(e,{visible:t}),r.trigger("change:visible",t),e}return null},hide:function(e){return this._setVisible(e,!1)},show:function(e){return this._setVisible(e,!0)},isVisibled:function(e){var t=this.getOptions(e);return t?t.visible===!1?!1:!0:!0}});return s}),function(e,t,n){"use strict";if(typeof define=="function"&&define.amd)define("backchart.base/view",["jquery","backbone","underscore"],function(e,t,r){return n(e,t,r)});else if(typeof module!="undefined"&&module.exports){var r=require("jquery"),i=require("underscore"),s=require("backbone");module.exports=n(r,s,i)}else{var o=t.split("."),u=e||this;for(var a=0;a<o.length;a++){var f=o[a],l=u[f];u=u[f]=a===o.length-1?n(e.jQuery||window.jQuery,e.Backbone||window.Backbone,e._||window._):l||{}}}}(this,"backchart.base.view",function(e,t,n){var r=t.View.extend({tagName:"div",className:"backchart",_collectionPrefix:"_bcname",_viewPrefix:"_bcview",container:null,eventCallback:{"default":"render"},_getEventCallback:function(e){var t=this.eventCallback[e]||this.eventCallback["default"];return t?this[t]:this.render},setSilence:function(e){this._silence=e},_setVisible:function(e,n){var r=this;if(typeof e=="string"||e instanceof String){var i=r._collectionOptions[e];i&&(i.visible=n)}else e instanceof t.Collection&&r.eachCollection(function(t,r,i,s){r===e&&(s.visible=n)});return r.trigger("change:visible",n),r.render(!0),r},hide:function(e){return this._setVisible(e,!1)},show:function(e){return this._setVisible(e,!0)},isVisibled:function(e){var n=this;if(typeof e=="string"||e instanceof String){var r=n._collectionOptions[e];return r?r.visible:!1}if(e instanceof t.Collection){var i=!0;return n.eachCollection(function(t,n,r,s){n===e&&(i=s?s.visible:!1)}),i}},initialize:function(){var e=this;e._silence=!1,t.View.prototype.initialize.apply(this,arguments),e.collections={},e._collectionOptions={},e._collectionRenderOptions={},this.on("collection.on",function(t,n,r,i){i.renderAfterOn===!0&&e.render(!0)}),this.on("collection.off",function(){e.render(!0)})},__bce:function(e,t,r){var i=this;n.each(t,function(e){i.listenTo(r,e,i._getEventCallback(e))})},__ubce:function(e,t,r){var i=this;n.each(t,function(e){r.off(e,i._getEventCallback(e))})},_getBindEvents:function(e){var t=["set","add","change","destroy","reset","sort"];return typeof e._backchart!="undefined"&&(t=["seted","removed","change","destroy","reseted","sort","change:visible"]),t},_bindCollectionEvent:function(e,t,n){if(n.silence===!0)return;this.__bce(e,this._getBindEvents(t),t)},_unbindColletionEvent:function(e,t){this.__ubce(e,this._getBindEvents(t),t)},_collectionHasBind:function(e){for(var t in this.collections)if(this.collections[t]===e)return!0;return!1},onCollection:function(e,r,i){r=r||{},i=i||{};var s=this,o=i.bid||n.uniqueId(s._collectionPrefix);if(!e instanceof t.Collection)return o;s._collectionHasBind(e)&&s.unCollection(e),s._bindCollectionEvent(o,e,i),s.trigger("collection.bindEvent",e),s.collections[o]=e;var u=n.clone(r);return s._collectionOptions[o]=i,s._collectionRenderOptions[o]=u,s.trigger("collection.on",o,e,u,i),o},onCollections:function(e,t,r){var i=this;!e instanceof Array&&(e=[e]);var s={};return n.each(e,function(e){s[e]=i.onCollection(e,t,r)}),s},unCollection:function(e){var r=this,i=null;if(typeof e=="string"||e instanceof String){i=r.collections[e];if(i){delete r.collections[e];var s=r._collectionRenderOptions[e],o=r._collectionOptions[e];delete r._collectionRenderOptions[e],delete r._collectionOptions[e],r._collectionHasBind(i)&&(r._unbindColletionEvent(e,i),r.trigger("collection.unbindEvent",i)),r.trigger("collection.off",e,i,s,o)}return i}if(e instanceof t.Collection){var u=[];i=e;for(var a in r.collections)r.collections[a]===i&&u.push(a);return n.each(u,function(e){r.unCollection(e)}),i}},clearCollection:function(){var e=this,t=n.keys(this.collections);return n.each(t,function(t){e.unCollection(t)}),this},eachCollection:function(e){var t=this;for(var n in t.collections)e.call(t.collections[n],n,t.collections[n],t._collectionRenderOptions[n],t._collectionOptions[n])},getCollection:function(e){var r=this;if(typeof e=="boolean"&&e===!1)return n.uniq(n.values(r.collections));if(typeof e=="string"||e instanceof String)return r.collections[e];if(e instanceof t.Collection){var i=[];return r.eachCollection(function(t){this===e&&i.push(t)}),i}var s={};return r.eachCollection(function(e){typeof s[this]=="undefined"&&(s[this]=[]),s[this].push(e)}),s},getOptions:function(e){var n=this,r=null;return typeof e=="string"||e instanceof String?n._collectionOptions[e]:e instanceof t.Collection?(r=[],n.eachCollection(function(t,n,i,s){n===e&&r.push(s)}),r):(r={},n.eachCollection(function(e,t,n,i){typeof r[this]=="undefined"&&(r[this]=[]),r[this].push(i)}),r)},getRenderOptions:function(e){var n=this,r=[];return typeof e=="string"||e instanceof String?n._collectionRenderOptions[e]:e instanceof t.Collection?(r=[],n.eachCollection(function(t,n,i){n===e&&r.push(i)}),r):(r={},n.eachCollection(function(e,t,n){typeof r[this]=="undefined"&&(r[this]=[]),r[this].push(n)}),r)},renderBefore:function(){var t=this;if(!t.container)return;return t.$container=e(t.container),t.$container.is(":hidden")?!1:t._silence===!0?!1:!0},renderAfter:function(){return this.trigger.apply(this,["rendered"].concat(Array.prototype.slice.call(arguments,0))),e(this.container).trigger("backchart.rendered",arguments),this},elFillParents:function(){this.$el.css({width:this.width?this.width+"px":"100%",height:this.height?this.height+"px":"100%"})},getChartOptions:function(){return null}});return r}),define("backchart.base/main",["./model","./collection","./view","./loader","./logger"],function(e,t,n,r){return{loader:r,model:e,collection:t,view:n,run:function(r){return r(e,t,n)}}}),define("backchart.base",["backchart.base/main"],function(e){return e});