/** * esl (enterprise standard loader) * copyright 2013 baidu inc. all rights reserved. * * @file browser端标准加载器,符合amd规范 * @author errorrik(errorrik@gmail.com) * firede(firede@firede.us) */ /* jshint ignore:start */ var define; var require; var esl; /* jshint ignore:end */ /* eslint-disable guard-for-in */ /* eslint-env amd:false */ (function (global) { // "mod"开头的变量或函数为内部模块管理函数 // 为提高压缩率,不使用function或object包装 /** * 模块容器 * * @inner * @type {object} */ var modmodules = {}; // 模块状态枚举量 var module_pre_defined = 1; var module_analyzed = 2; var module_prepared = 3; var module_defined = 4; /** * 自动定义的模块表 * * 模块define factory是用到时才执行,但是以下几种情况需要自动马上执行: * 1. require([moduleid], callback) * 2. plugin module and plugin resource: require('plugin!resource') * 3. shim module * * @inner * @type {object} */ var modautodefinemodules = {}; /** * 标记模块自动进行定义 * * @inner * @param {string} id 模块id */ function modflagautodefine(id) { if (!modis(id, module_defined)) { modautodefinemodules[id] = 1; } } /** * 内建module名称集合 * * @inner * @type {object} */ var buildin_module = { require: globalrequire, exports: 1, module: 1 }; /** * 全局require函数 * * @inner * @type {function} */ var actualglobalrequire = createlocalrequire(); // #begin-ignore /** * 超时提醒定时器 * * @inner * @type {number} */ var waittimeout; // #end-ignore /* eslint-disable fecs-key-spacing */ /* eslint-disable key-spacing */ /** * require配置 * * @inner * @type {object} */ var requireconf = { baseurl : './', paths : {}, config : {}, map : {}, packages : [], shim : {}, // #begin-ignore waitseconds: 0, // #end-ignore bundles : {}, urlargs : {} }; /* eslint-enable key-spacing */ /** * 加载模块 * * @param {string|array} requireid 模块id或模块id数组, * @param {function=} callback 加载完成的回调函数 * @return {*} requireid为string时返回模块暴露对象 */ function globalrequire(requireid, callback) { // #begin-ignore // #begin assertnotcontainrelativeid // 确定require的模块id不包含相对id。用于global require,提前预防难以跟踪的错误出现 var invalidids = []; /** * 监测模块id是否relative id * * @inner * @param {string} id 模块id */ function monitor(id) { if (id.indexof('.') === 0) { invalidids.push(id); } } if (typeof requireid === 'string') { monitor(requireid); } else { each( requireid, function (id) { monitor(id); } ); } // 包含相对id时,直接抛出错误 if (invalidids.length > 0) { throw new error( '[require_fatal]relative id is not allowed in global require: ' + invalidids.join(', ') ); } // #end assertnotcontainrelativeid // 超时提醒 var timeout = requireconf.waitseconds; if (timeout && (requireid instanceof array)) { if (waittimeout) { cleartimeout(waittimeout); } waittimeout = settimeout(waittimeoutnotice, timeout * 1000); } // #end-ignore return actualglobalrequire(requireid, callback); } /** * 版本号 * * @type {string} */ globalrequire.version = '2.0.2'; /** * loader名称 * * @type {string} */ globalrequire.loader = 'esl'; /** * 将模块标识转换成相对的url * * @param {string} id 模块标识 * @return {string} */ globalrequire.tourl = actualglobalrequire.tourl; // #begin-ignore /** * 超时提醒函数 * * @inner */ function waittimeoutnotice() { var hangmodules = []; var missmodules = []; var hangmodulesmap = {}; var missmodulesmap = {}; var visited = {}; /** * 检查模块的加载错误 * * @inner * @param {string} id 模块id * @param {boolean} hard 是否装载时依赖 */ function checkerror(id, hard) { if (visited[id] || modis(id, module_defined)) { return; } visited[id] = 1; if (!modis(id, module_prepared)) { // hack: 为gzip后体积优化,不做抽取 if (!hangmodulesmap[id]) { hangmodulesmap[id] = 1; hangmodules.push(id); } } var mod = modmodules[id]; if (!mod) { if (!missmodulesmap[id]) { missmodulesmap[id] = 1; missmodules.push(id); } } else if (hard) { if (!hangmodulesmap[id]) { hangmodulesmap[id] = 1; hangmodules.push(id); } each( mod.depms, function (dep) { checkerror(dep.absid, dep.hard); } ); } } for (var id in modautodefinemodules) { checkerror(id, 1); } if (hangmodules.length || missmodules.length) { throw new error( '[module_timeout]hang( ' + (hangmodules.join(', ') || 'none') + ' ) miss( ' + (missmodules.join(', ') || 'none') + ' )' ); } } // #end-ignore /** * 未预定义的模块集合 * 主要存储匿名方式define的模块 * * @inner * @type {array} */ var wait4predefine = []; /** * 完成模块预定义,此时处理的模块是匿名define的模块 * * @inner * @param {string} currentid 匿名define的模块的id */ function modcompletepredefine(currentid) { // hack: 这里在ie下有个性能陷阱,不能使用任何变量。 // 否则貌似会形成变量引用和修改的读写锁,导致wait4predefine释放困难 each(wait4predefine, function (mod) { modpredefine( currentid, mod.deps, mod.factory ); }); wait4predefine.length = 0; } /** * 定义模块 * * @param {string=} id 模块标识 * @param {array=} dependencies 依赖模块列表 * @param {function=} factory 创建模块的工厂方法 */ function globaldefine(id, dependencies, factory) { // define(factory) // define(dependencies, factory) // define(id, factory) // define(id, dependencies, factory) if (factory == null) { if (dependencies == null) { factory = id; id = null; } else { factory = dependencies; dependencies = null; if (id instanceof array) { dependencies = id; id = null; } } } if (factory == null) { return; } var opera = window.opera; // ie下通过current script的data-require-id获取当前id if ( !id && document.attachevent && (!(opera && opera.tostring() === '[object opera]')) ) { var currentscript = getcurrentscript(); id = currentscript && currentscript.getattribute('data-require-id'); } if (id) { modpredefine(id, dependencies, factory); } else { // 纪录到共享变量中,在load或readystatechange中处理 // 标准浏览器下,使用匿名define时,将进入这个分支 wait4predefine[0] = { deps: dependencies, factory: factory }; } } globaldefine.amd = {}; /** * 模块配置获取函数 * * @inner * @return {object} 模块配置对象 */ function moduleconfiggetter() { var conf = requireconf.config[this.id]; if (conf && typeof conf === 'object') { return conf; } return {}; } /** * 预定义模块 * * @inner * @param {string} id 模块标识 * @param {array.} dependencies 显式声明的依赖模块列表 * @param {*} factory 模块定义函数或模块对象 */ function modpredefine(id, dependencies, factory) { // 将模块存入容器 // // 模块内部信息包括 // ----------------------------------- // id: module id // depsdec: 模块定义时声明的依赖 // deps: 模块依赖,默认为['require', 'exports', 'module'] // factory: 初始化函数或对象 // factorydeps: 初始化函数的参数依赖 // exports: 模块的实际暴露对象(amd定义) // config: 用于获取模块配置信息的函数(amd定义) // state: 模块当前状态 // require: local require函数 // depms: 实际依赖的模块集合,数组形式 // depmkv: 实际依赖的模块集合,表形式,便于查找 // deprs: 实际依赖的资源集合 // ------------------------------------ if (!modmodules[id]) { /* eslint-disable key-spacing */ modmodules[id] = { id : id, depsdec : dependencies, deps : dependencies || ['require', 'exports', 'module'], factorydeps : [], factory : factory, exports : {}, config : moduleconfiggetter, state : module_pre_defined, require : createlocalrequire(id), depms : [], depmkv : {}, deprs : [] }; /* eslint-enable key-spacing */ } } /** * 开始执行模块定义前的准备工作 * * 首先,完成对factory中声明依赖的分析提取 * 然后,尝试加载"资源加载所需模块" * * 需要先加载模块的原因是:如果模块不存在,无法进行resourceid normalize化 * * @inner * @param {string} id 模块id */ function modprepare(id) { var mod = modmodules[id]; if (!mod || modis(id, module_analyzed)) { return; } var deps = mod.deps; var factory = mod.factory; var harddependscount = 0; // 分析function body中的require // 如果包含显式依赖声明,根据amd规定和性能考虑,可以不分析factorybody if (typeof factory === 'function') { harddependscount = math.min(factory.length, deps.length); // if the dependencies argument is present, the module loader // should not scan for dependencies within the factory function. !mod.depsdec && factory.tostring() .replace(/(\/\*([\s\s]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, '') .replace(/require\(\s*(['"'])([^'"]+)\1\s*\)/g, function ($0, $1, depid) { deps.push(depid); } ); } var requiremodules = []; var depresources = []; each(deps, function (depid, index) { var idinfo = parseid(depid); var absid = normalize(idinfo.mod, id); var moduleinfo; var resinfo; if (absid && !buildin_module[absid]) { // 如果依赖是一个资源,将其信息添加到module.deprs // // module.deprs中的项有可能是重复的。 // 在这个阶段,加载resource的module可能还未defined, // 导致此时resource id无法被normalize。 // // 比如对a/b/c而言,下面几个resource可能指的是同一个资源: // - js!../name.js // - js!a/name.js // - ../../js!../name.js // // 所以加载资源的module ready时,需要遍历module.deprs进行处理 if (idinfo.res) { resinfo = { id: depid, mod: absid, res: idinfo.res }; depresources.push(depid); mod.deprs.push(resinfo); } // 对依赖模块的id normalize能保证正确性,在此处进行去重 moduleinfo = mod.depmkv[absid]; if (!moduleinfo) { moduleinfo = { id: idinfo.mod, absid: absid, hard: index < harddependscount }; mod.depms.push(moduleinfo); mod.depmkv[absid] = moduleinfo; requiremodules.push(absid); } } else { moduleinfo = {absid: absid}; } // 如果当前正在分析的依赖项是define中声明的, // 则记录到module.factorydeps中 // 在factory invoke前将用于生成invoke arguments if (index < harddependscount) { mod.factorydeps.push(resinfo || moduleinfo); } }); mod.state = module_analyzed; modinitfactoryinvoker(id); nativeasyncrequire(requiremodules); depresources.length && mod.require( depresources, function () { each(mod.deprs, function (res) { if (!res.absid) { res.absid = normalize(res.id, id); } }); modautodefine(); } ); } /** * 对一些需要自动定义的模块进行自动定义 * * @inner */ function modautodefine() { for (var id in modautodefinemodules) { modprepare(id); modupdatepreparedstate(id); modtryinvokefactory(id); } } /** * 更新模块的准备状态 * * @inner * @param {string} id 模块id */ function modupdatepreparedstate(id) { var visited = {}; update(id); function update(id) { modprepare(id); if (!modis(id, module_analyzed)) { return false; } if (modis(id, module_prepared) || visited[id]) { return true; } visited[id] = 1; var mod = modmodules[id]; var prepared = true; each( mod.depms, function (dep) { return (prepared = update(dep.absid)); } ); // 判断resource是否加载完成。如果resource未加载完成,则认为未准备好 /* jshint ignore:start */ prepared && each( mod.deprs, function (dep) { prepared = !!dep.absid; return prepared; } ); /* jshint ignore:end */ if (prepared) { mod.state = module_prepared; } return prepared; } } /** * 初始化模块定义时所需的factory执行器 * * @inner * @param {string} id 模块id */ function modinitfactoryinvoker(id) { var mod = modmodules[id]; var invoking; mod.invokefactory = invokefactory; /** * 初始化模块 * * @inner */ function invokefactory() { if (invoking || mod.state !== module_prepared) { return; } invoking = 1; // 拼接factory invoke所需的arguments var factoryready = 1; each( mod.factorydeps, function (dep) { var depid = dep.absid; if (!buildin_module[depid]) { modtryinvokefactory(depid); return (factoryready = modis(depid, module_defined)); } } ); if (factoryready) { try { // 调用factory函数初始化module var factory = mod.factory; var exports = typeof factory === 'function' ? factory.apply(global, modgetmodulesexports( mod.factorydeps, { require: mod.require, exports: mod.exports, module: mod } )) : factory; if (exports != null) { mod.exports = exports; } mod.invokefactory = null; } catch (ex) { if (/^\[module_miss\]"([^"]+)/.test(ex.message)) { // 出错,则说明在factory的运行中,该require的模块是需要的 // 所以把它加入强依赖中 var hardcirclurdep = mod.depmkv[regexp.$1]; hardcirclurdep && (hardcirclurdep.hard = 1); // 如果是模块本身有问题导致的运行错误 // 就不要把invoking置回去了,避免影响autoinvoke其他模块的初始化 invoking = 0; return; } throw ex; } // 完成define // 不放在try里,避免后续的运行错误被这里吞掉 moddefined(id); } } } /** * 判断模块是否完成相应的状态 * * @inner * @param {string} id 模块标识 * @param {number} state 状态码,使用时传入相应的枚举变量,比如`module_defined` * @return {boolean} 是否完成相应的状态 */ function modis(id, state) { return modmodules[id] && modmodules[id].state >= state; } /** * 尝试执行模块factory函数,进行模块初始化 * * @inner * @param {string} id 模块id */ function modtryinvokefactory(id) { var mod = modmodules[id]; if (mod && mod.invokefactory) { mod.invokefactory(); } } /** * 根据模块id数组,获取其的exports数组 * 用于模块初始化的factory参数或require的callback参数生成 * * @inner * @param {array} modules 模块id数组 * @param {object} buildinmodules 内建模块对象 * @return {array} 模块exports数组 */ function modgetmodulesexports(modules, buildinmodules) { var args = []; each( modules, function (id, index) { if (typeof id === 'object') { id = id.absid; } args[index] = buildinmodules[id] || modmodules[id].exports; } ); return args; } /** * 模块定义完成事件监听器容器 * * @inner * @type {object} */ var moddefinedlisteners = {}; /** * 添加模块定义完成时间的监听器 * * @inner * @param {string} id 模块标识 * @param {function} listener 监听函数 */ function modadddefinedlistener(id, listener) { if (modis(id, module_defined)) { listener(); return; } var listeners = moddefinedlisteners[id]; if (!listeners) { listeners = moddefinedlisteners[id] = []; } listeners.push(listener); } /** * 模块状态切换为定义完成 * 因为需要触发事件,module_defined状态切换通过该函数 * * @inner * @param {string} id 模块标识 */ function moddefined(id) { var mod = modmodules[id]; mod.state = module_defined; delete modautodefinemodules[id]; var listeners = moddefinedlisteners[id] || []; var len = listeners.length; while (len--) { // 这里不做function类型的检测 // 因为listener都是通过modon传入的,modon为内部调用 listeners[len](); } // 清理listeners listeners.length = 0; moddefinedlisteners[id] = null; } /** * 异步加载模块 * 内部使用,模块id必须是经过normalize的top-level id * * @inner * @param {array} ids 模块名称或模块名称列表 * @param {function=} callback 获取模块完成时的回调函数 * @param {string} baseid 基础id,用于当ids是relative id时的normalize */ function nativeasyncrequire(ids, callback, baseid) { var iscallbackcalled = 0; each(ids, function (id) { if (!(buildin_module[id] || modis(id, module_defined))) { modadddefinedlistener(id, tryfinishrequire); (id.indexof('!') > 0 ? loadresource : loadmodule )(id, baseid); } }); tryfinishrequire(); /** * 尝试完成require,调用callback * 在模块与其依赖模块都加载完时调用 * * @inner */ function tryfinishrequire() { if (typeof callback === 'function' && !iscallbackcalled) { var isallcompleted = 1; each(ids, function (id) { if (!buildin_module[id]) { return (isallcompleted = !!modis(id, module_defined)); } }); // 检测并调用callback if (isallcompleted) { iscallbackcalled = 1; callback.apply( global, modgetmodulesexports(ids, buildin_module) ); } } } } /** * 正在加载的模块列表 * * @inner * @type {object} */ var loadingmodules = {}; /** * 加载模块 * * @inner * @param {string} moduleid 模块标识 */ function loadmodule(moduleid) { // 加载过的模块,就不要再继续了 if (loadingmodules[moduleid] || modmodules[moduleid]) { return; } loadingmodules[moduleid] = 1; // 初始化相关 shim 的配置 var shimconf = requireconf.shim[moduleid]; if (shimconf instanceof array) { requireconf.shim[moduleid] = shimconf = { deps: shimconf }; } // shim依赖的模块需要自动标识为shim // 无论是纯正的shim模块还是hybird模块 var shimdeps = shimconf && (shimconf.deps || []); if (shimdeps) { each(shimdeps, function (dep) { if (!requireconf.shim[dep]) { requireconf.shim[dep] = {}; } }); actualglobalrequire(shimdeps, load); } else { load(); } /** * 发送请求去加载模块 * * @inner */ function load() { /* eslint-disable no-use-before-define */ var bundlemoduleid = bundlesindex[moduleid]; createscript(bundlemoduleid || moduleid, loaded); /* eslint-enable no-use-before-define */ } /** * script标签加载完成的事件处理函数 * * @inner */ function loaded() { if (shimconf) { var exports; if (typeof shimconf.init === 'function') { exports = shimconf.init.apply( global, modgetmodulesexports(shimdeps, buildin_module) ); } if (exports == null && shimconf.exports) { exports = global; each( shimconf.exports.split('.'), function (prop) { exports = exports[prop]; return !!exports; } ); } globaldefine(moduleid, shimdeps, exports || {}); } else { modcompletepredefine(moduleid); } modautodefine(); } } /** * 加载资源 * * @inner * @param {string} pluginandresource 插件与资源标识 * @param {string} baseid 当前环境的模块标识 */ function loadresource(pluginandresource, baseid) { if (modmodules[pluginandresource]) { return; } /* eslint-disable no-use-before-define */ var bundlemoduleid = bundlesindex[pluginandresource]; if (bundlemoduleid) { loadmodule(bundlemoduleid); return; } /* eslint-enable no-use-before-define */ var idinfo = parseid(pluginandresource); var resource = { id: pluginandresource, state: module_analyzed }; modmodules[pluginandresource] = resource; /** * plugin加载完成的回调函数 * * @inner * @param {*} value resource的值 */ function pluginonload(value) { resource.exports = value || true; moddefined(pluginandresource); } /* jshint ignore:start */ /** * 该方法允许plugin使用加载的资源声明模块 * * @param {string} id 模块id * @param {string} text 模块声明字符串 */ pluginonload.fromtext = function (id, text) { new function(text)(); modcompletepredefine(id); }; /* jshint ignore:end */ /** * 加载资源 * * @inner * @param {object} plugin 用于加载资源的插件模块 */ function load(plugin) { var pluginrequire = baseid ? modmodules[baseid].require : actualglobalrequire; plugin.load( idinfo.res, pluginrequire, pluginonload, moduleconfiggetter.call({id: pluginandresource}) ); } load(actualglobalrequire(idinfo.mod)); } /** * 配置require * * @param {object} conf 配置对象 */ globalrequire.config = function (conf) { if (conf) { for (var key in requireconf) { var newvalue = conf[key]; var oldvalue = requireconf[key]; if (!newvalue) { continue; } if (key === 'urlargs' && typeof newvalue === 'string') { requireconf.urlargs['*'] = newvalue; } else { // 简单的多处配置还是需要支持,所以配置实现为支持二级mix if (oldvalue instanceof array) { oldvalue.push.apply(oldvalue, newvalue); } else if (typeof oldvalue === 'object') { for (var k in newvalue) { oldvalue[k] = newvalue[k]; } } else { requireconf[key] = newvalue; } } } createconfindex(); } }; // 初始化时需要创建配置索引 createconfindex(); /** * paths内部索引 * * @inner * @type {array} */ var pathsindex; /** * packages内部索引 * * @inner * @type {array} */ var packagesindex; /** * mapping内部索引 * * @inner * @type {array} */ var mappingidindex; /** * bundles内部索引 * * @inner * @type {object} */ var bundlesindex; /** * urlargs内部索引 * * @inner * @type {array} */ var urlargsindex; /** * 将key为module id prefix的object,生成数组形式的索引,并按照长度和字面排序 * * @inner * @param {object} value 源值 * @param {boolean} allowasterisk 是否允许*号表示匹配所有 * @return {array} 索引对象 */ function createkvsortedindex(value, allowasterisk) { var index = kv2list(value, 1, allowasterisk); index.sort(descsorterbykorname); return index; } /** * 创建配置信息内部索引 * * @inner */ function createconfindex() { requireconf.baseurl = requireconf.baseurl.replace(/\/$/, '') + '/'; // create paths index pathsindex = createkvsortedindex(requireconf.paths); // create mappingid index mappingidindex = createkvsortedindex(requireconf.map, 1); each( mappingidindex, function (item) { item.v = createkvsortedindex(item.v); } ); // create packages index packagesindex = []; each( requireconf.packages, function (packageconf) { var pkg = packageconf; if (typeof packageconf === 'string') { pkg = { name: packageconf.split('/')[0], location: packageconf, main: 'main' }; } pkg.location = pkg.location || pkg.name; pkg.main = (pkg.main || 'main').replace(/\.js$/i, ''); pkg.reg = createprefixregexp(pkg.name); packagesindex.push(pkg); } ); packagesindex.sort(descsorterbykorname); // create urlargs index urlargsindex = createkvsortedindex(requireconf.urlargs, 1); // create bundles index bundlesindex = {}; /* eslint-disable no-use-before-define */ function bundlesiterator(id) { bundlesindex[id] = key; } /* eslint-enable no-use-before-define */ for (var key in requireconf.bundles) { each(requireconf.bundles[key], bundlesiterator); } } /** * 对配置信息的索引进行检索 * * @inner * @param {string} value 要检索的值 * @param {array} index 索引对象 * @param {function} hitbehavior 索引命中的行为函数 */ function indexretrieve(value, index, hitbehavior) { each(index, function (item) { if (item.reg.test(value)) { hitbehavior(item.v, item.k, item); return false; } }); } /** * 将`模块标识+'.extension'`形式的字符串转换成相对的url * * @inner * @param {string} source 源字符串 * @return {string} url */ function tourl(source) { // 分离 模块标识 和 .extension var extreg = /(\.[a-z0-9]+)$/i; var queryreg = /(\?[^#]*)$/; var extname = ''; var id = source; var query = ''; if (queryreg.test(source)) { query = regexp.$1; source = source.replace(queryreg, ''); } if (extreg.test(source)) { extname = regexp.$1; id = source.replace(extreg, ''); } var url = id; // paths处理和匹配 var ispathmap; indexretrieve(id, pathsindex, function (value, key) { url = url.replace(key, value); ispathmap = 1; }); // packages处理和匹配 if (!ispathmap) { indexretrieve(id, packagesindex, function (value, key, item) { url = url.replace(item.name, item.location); }); } // 相对路径时,附加baseurl if (!/^([a-z]{2,10}:\/)?\//i.test(url)) { url = requireconf.baseurl + url; } // 附加 .extension 和 query url += extname + query; // urlargs处理和匹配 indexretrieve(id, urlargsindex, function (value) { url += (url.indexof('?') > 0 ? '&' : '?') + value; }); return url; } /** * 创建local require函数 * * @inner * @param {number} baseid 当前module id * @return {function} local require函数 */ function createlocalrequire(baseid) { var requiredcache = {}; function req(requireid, callback) { if (typeof requireid === 'string') { if (!requiredcache[requireid]) { var toplevelid = normalize(requireid, baseid); // 根据 https://github.com/amdjs/amdjs-api/wiki/require // it must throw an error if the module has not // already been loaded and evaluated. modtryinvokefactory(toplevelid); if (!modis(toplevelid, module_defined)) { throw new error('[module_miss]"' + toplevelid + '" is not exists!'); } requiredcache[requireid] = modmodules[toplevelid].exports; } return requiredcache[requireid]; } else if (requireid instanceof array) { // 分析是否有resource,取出pluginmodule先 var puremodules = []; var normalizedids = []; each( requireid, function (id, i) { var idinfo = parseid(id); var absid = normalize(idinfo.mod, baseid); var resid = idinfo.res; var normalizedid = absid; if (resid) { var trueresid = absid + '!' + resid; if (resid.indexof('.') !== 0 && bundlesindex[trueresid]) { absid = normalizedid = trueresid; } else { normalizedid = null; } } normalizedids[i] = normalizedid; modflagautodefine(absid); puremodules.push(absid); } ); // 加载模块 nativeasyncrequire( puremodules, function () { /* jshint ignore:start */ each(normalizedids, function (id, i) { if (id == null) { id = normalizedids[i] = normalize(requireid[i], baseid); modflagautodefine(id); } }); /* jshint ignore:end */ // modautodefine中,factory invoke可能发生错误 // 从而导致nativeasyncrequire没有被调用,callback没挂上 // 所以nativeasyncrequire要先运行 nativeasyncrequire(normalizedids, callback, baseid); modautodefine(); }, baseid ); modautodefine(); } } /** * 将[module id] + '.extension'格式的字符串转换成url * * @inner * @param {string} id 符合描述格式的源字符串 * @return {string} url */ req.tourl = function (id) { return tourl(normalize(id, baseid)); }; return req; } /** * id normalize化 * * @inner * @param {string} id 需要normalize的模块标识 * @param {string} baseid 当前环境的模块标识 * @return {string} normalize结果 */ function normalize(id, baseid) { if (!id) { return ''; } baseid = baseid || ''; var idinfo = parseid(id); if (!idinfo) { return id; } var resourceid = idinfo.res; var moduleid = relative2absolute(idinfo.mod, baseid); each( packagesindex, function (packageconf) { var name = packageconf.name; if (name === moduleid) { moduleid = name + '/' + packageconf.main; return false; } } ); // 根据config中的map配置进行module id mapping indexretrieve( baseid, mappingidindex, function (value) { indexretrieve( moduleid, value, function (mdvalue, mdkey) { moduleid = moduleid.replace(mdkey, mdvalue); } ); } ); if (resourceid) { var mod = modis(moduleid, module_defined) && actualglobalrequire(moduleid); resourceid = mod && mod.normalize ? mod.normalize( resourceid, function (resid) { return normalize(resid, baseid); } ) : normalize(resourceid, baseid); moduleid += '!' + resourceid; } return moduleid; } /** * 相对id转换成绝对id * * @inner * @param {string} id 要转换的相对id * @param {string} baseid 当前所在环境id * @return {string} 绝对id */ function relative2absolute(id, baseid) { if (id.indexof('.') === 0) { var basepath = baseid.split('/'); var namepath = id.split('/'); var baselen = basepath.length - 1; var namelen = namepath.length; var cutbaseterms = 0; var cutnameterms = 0; /* eslint-disable block-scoped-var */ pathloop: for (var i = 0; i < namelen; i++) { switch (namepath[i]) { case '..': if (cutbaseterms < baselen) { cutbaseterms++; cutnameterms++; } else { break pathloop; } break; case '.': cutnameterms++; break; default: break pathloop; } } /* eslint-enable block-scoped-var */ basepath.length = baselen - cutbaseterms; namepath = namepath.slice(cutnameterms); return basepath.concat(namepath).join('/'); } return id; } /** * 解析id,返回带有module和resource属性的object * * @inner * @param {string} id 标识 * @return {object} id解析结果对象 */ function parseid(id) { var segs = id.split('!'); if (segs[0]) { return { mod: segs[0], res: segs[1] }; } } /** * 将对象数据转换成数组,数组每项是带有k和v的object * * @inner * @param {object} source 对象数据 * @param {boolean} keymatchable key是否允许被前缀匹配 * @param {boolean} allowasterisk 是否支持*匹配所有 * @return {array.} 对象转换数组 */ function kv2list(source, keymatchable, allowasterisk) { var list = []; for (var key in source) { if (source.hasownproperty(key)) { var item = { k: key, v: source[key] }; list.push(item); if (keymatchable) { item.reg = key === '*' && allowasterisk ? /^/ : createprefixregexp(key); } } } return list; } // 感谢requirejs,通过currentlyaddingscript兼容老旧ie // // for some cache cases in ie 6-8, the script executes before the end // of the appendchild execution, so to tie an anonymous define // call to the module name (which is stored on the node), hold on // to a reference to this node, but clear after the dom insertion. var currentlyaddingscript; var interactivescript; /** * 获取当前script标签 * 用于ie下define未指定module id时获取id * * @inner * @return {htmlscriptelement} 当前script标签 */ function getcurrentscript() { if (currentlyaddingscript) { return currentlyaddingscript; } else if ( interactivescript && interactivescript.readystate === 'interactive' ) { return interactivescript; } var scripts = document.getelementsbytagname('script'); var scriptlen = scripts.length; while (scriptlen--) { var script = scripts[scriptlen]; if (script.readystate === 'interactive') { interactivescript = script; return script; } } } var headelement = document.getelementsbytagname('head')[0]; var baseelement = document.getelementsbytagname('base')[0]; if (baseelement) { headelement = baseelement.parentnode; } function createscript(moduleid, onload) { // 创建script标签 // // 这里不挂接onerror的错误处理 // 因为高级浏览器在devtool的console面板会报错 // 再throw一个error多此一举了 var script = document.createelement('script'); script.setattribute('data-require-id', moduleid); script.src = tourl(moduleid + '.js'); script.async = true; if (script.readystate) { script.onreadystatechange = inneronload; } else { script.onload = inneronload; } function inneronload() { var readystate = script.readystate; if ( typeof readystate === 'undefined' || /^(loaded|complete)$/.test(readystate) ) { script.onload = script.onreadystatechange = null; script = null; onload(); } } currentlyaddingscript = script; // if base tag is in play, using appendchild is a problem for ie6. // see: http://dev.jquery.com/ticket/2709 baseelement ? headelement.insertbefore(script, baseelement) : headelement.appendchild(script); currentlyaddingscript = null; } /** * 创建id前缀匹配的正则对象 * * @inner * @param {string} prefix id前缀 * @return {regexp} 前缀匹配的正则对象 */ function createprefixregexp(prefix) { return new regexp('^' + prefix + '(/|$)'); } /** * 循环遍历数组集合 * * @inner * @param {array} source 数组源 * @param {function(array,number):boolean} iterator 遍历函数 */ function each(source, iterator) { if (source instanceof array) { for (var i = 0, len = source.length; i < len; i++) { if (iterator(source[i], i) === false) { break; } } } } /** * 根据元素的k或name项进行数组字符数逆序的排序函数 * * @inner * @param {object} a 要比较的对象a * @param {object} b 要比较的对象b * @return {number} 比较结果 */ function descsorterbykorname(a, b) { var avalue = a.k || a.name; var bvalue = b.k || b.name; if (bvalue === '*') { return -1; } if (avalue === '*') { return 1; } return bvalue.length - avalue.length; } // 暴露全局对象 if (!define) { define = globaldefine; // 可能碰到其他形式的loader,所以,不要覆盖人家 if (!require) { require = globalrequire; } // 如果存在其他版本的esl,在define那里就判断过了,不会进入这个分支 // 所以这里就不判断了,直接写 esl = globalrequire; } })(this); define('echarts', ['echarts/echarts'], function (main) {return main;}); define('echarts/echarts', [ 'require', './config', 'zrender/tool/util', 'zrender/tool/event', 'zrender/tool/env', 'zrender', 'zrender/config', './chart/island', './component/toolbox', './component', './component/title', './component/tooltip', './component/legend', './util/ecdata', './chart', 'zrender/tool/color', './component/timeline', 'zrender/shape/image', 'zrender/loadingeffect/bar', 'zrender/loadingeffect/bubble', 'zrender/loadingeffect/dynamicline', 'zrender/loadingeffect/ring', 'zrender/loadingeffect/spin', 'zrender/loadingeffect/whirling', './theme/macarons', './theme/infographic' ], function (require) { var ecconfig = require('./config'); var zrutil = require('zrender/tool/util'); var zrevent = require('zrender/tool/event'); var self = {}; var _canvassupported = require('zrender/tool/env').canvassupported; var _idbase = new date() - 0; var _instances = {}; var dom_attribute_key = '_echarts_instance_'; self.version = '2.2.7'; self.dependencies = { zrender: '2.1.1' }; self.init = function (dom, theme) { var zrender = require('zrender'); if (zrender.version.replace('.', '') - 0 < self.dependencies.zrender.replace('.', '') - 0) { console.error('zrender ' + zrender.version + ' is too old for echarts ' + self.version + '. current version need zrender ' + self.dependencies.zrender + '+'); } dom = dom instanceof array ? dom[0] : dom; var key = dom.getattribute(dom_attribute_key); if (!key) { key = _idbase++; dom.setattribute(dom_attribute_key, key); } if (_instances[key]) { _instances[key].dispose(); } _instances[key] = new echarts(dom); _instances[key].id = key; _instances[key].canvassupported = _canvassupported; _instances[key].settheme(theme); return _instances[key]; }; self.getinstancebyid = function (key) { return _instances[key]; }; function messagecenter() { zrevent.dispatcher.call(this); } zrutil.merge(messagecenter.prototype, zrevent.dispatcher.prototype, true); function echarts(dom) { dom.innerhtml = ''; this._themeconfig = {}; this.dom = dom; this._connected = false; this._status = { dragin: false, dragout: false, needrefresh: false }; this._cureventtype = false; this._chartlist = []; this._messagecenter = new messagecenter(); this._messagecenteroutside = new messagecenter(); this.resize = this.resize(); this._init(); } var zr_event = require('zrender/config').event; var zr_event_listens = [ 'click', 'dblclick', 'mouseover', 'mouseout', 'dragstart', 'dragend', 'dragenter', 'dragover', 'dragleave', 'drop' ]; function callchartlistmethodreverse(ecinstance, methodname, arg0, arg1, arg2) { var chartlist = ecinstance._chartlist; var len = chartlist.length; while (len--) { var chart = chartlist[len]; if (typeof chart[methodname] === 'function') { chart[methodname](arg0, arg1, arg2); } } } echarts.prototype = { _init: function () { var self = this; var _zr = require('zrender').init(this.dom); this._zr = _zr; this._messagecenter.dispatch = function (type, event, eventpackage, that) { eventpackage = eventpackage || {}; eventpackage.type = type; eventpackage.event = event; self._messagecenter.dispatchwithcontext(type, eventpackage, that); self._messagecenteroutside.dispatchwithcontext(type, eventpackage, that); }; this._onevent = function (param) { return self.__onevent(param); }; for (var e in ecconfig.event) { if (e != 'click' && e != 'dblclick' && e != 'hover' && e != 'mouseout' && e != 'map_roam') { this._messagecenter.bind(ecconfig.event[e], this._onevent, this); } } var eventbehaviors = {}; this._onzrevent = function (param) { return self[eventbehaviors[param.type]](param); }; for (var i = 0, len = zr_event_listens.length; i < len; i++) { var eventname = zr_event_listens[i]; var eventvalue = zr_event[eventname]; eventbehaviors[eventvalue] = '_on' + eventname.tolowercase(); _zr.on(eventvalue, this._onzrevent); } this.chart = {}; this.component = {}; var island = require('./chart/island'); this._island = new island(this._themeconfig, this._messagecenter, _zr, {}, this); this.chart.island = this._island; var toolbox = require('./component/toolbox'); this._toolbox = new toolbox(this._themeconfig, this._messagecenter, _zr, {}, this); this.component.toolbox = this._toolbox; var componentlibrary = require('./component'); componentlibrary.define('title', require('./component/title')); componentlibrary.define('tooltip', require('./component/tooltip')); componentlibrary.define('legend', require('./component/legend')); if (_zr.getwidth() === 0 || _zr.getheight() === 0) { console.error('dom’s width & height should be ready before init.'); } }, __onevent: function (param) { param.__echartsid = param.__echartsid || this.id; var frommyself = param.__echartsid === this.id; if (!this._cureventtype) { this._cureventtype = param.type; } switch (param.type) { case ecconfig.event.legend_selected: this._onlegendselected(param); break; case ecconfig.event.data_zoom: if (!frommyself) { var dz = this.component.datazoom; if (dz) { dz.silence(true); dz.absolutezoom(param.zoom); dz.silence(false); } } this._ondatazoom(param); break; case ecconfig.event.data_range: frommyself && this._ondatarange(param); break; case ecconfig.event.magic_type_changed: if (!frommyself) { var tb = this.component.toolbox; if (tb) { tb.silence(true); tb.setmagictype(param.magictype); tb.silence(false); } } this._onmagictypechanged(param); break; case ecconfig.event.data_view_changed: frommyself && this._ondataviewchanged(param); break; case ecconfig.event.tooltip_hover: frommyself && this._tooltiphover(param); break; case ecconfig.event.restore: this._onrestore(); break; case ecconfig.event.refresh: frommyself && this._onrefresh(param); break; case ecconfig.event.tooltip_in_grid: case ecconfig.event.tooltip_out_grid: if (!frommyself) { var grid = this.component.grid; if (grid) { this._zr.trigger('mousemove', { connecttrigger: true, zrenderx: grid.getx() + param.x * grid.getwidth(), zrendery: grid.gety() + param.y * grid.getheight() }); } } else if (this._connected) { var grid = this.component.grid; if (grid) { param.x = (param.event.zrenderx - grid.getx()) / grid.getwidth(); param.y = (param.event.zrendery - grid.gety()) / grid.getheight(); } } break; } if (this._connected && frommyself && this._cureventtype === param.type) { for (var c in this._connected) { this._connected[c].connectedeventhandler(param); } this._cureventtype = null; } if (!frommyself || !this._connected && frommyself) { this._cureventtype = null; } }, _onclick: function (param) { callchartlistmethodreverse(this, 'onclick', param); if (param.target) { var ecdata = this._eventpackage(param.target); if (ecdata && ecdata.seriesindex != null) { this._messagecenter.dispatch(ecconfig.event.click, param.event, ecdata, this); } } }, _ondblclick: function (param) { callchartlistmethodreverse(this, 'ondblclick', param); if (param.target) { var ecdata = this._eventpackage(param.target); if (ecdata && ecdata.seriesindex != null) { this._messagecenter.dispatch(ecconfig.event.dblclick, param.event, ecdata, this); } } }, _onmouseover: function (param) { if (param.target) { var ecdata = this._eventpackage(param.target); if (ecdata && ecdata.seriesindex != null) { this._messagecenter.dispatch(ecconfig.event.hover, param.event, ecdata, this); } } }, _onmouseout: function (param) { if (param.target) { var ecdata = this._eventpackage(param.target); if (ecdata && ecdata.seriesindex != null) { this._messagecenter.dispatch(ecconfig.event.mouseout, param.event, ecdata, this); } } }, _ondragstart: function (param) { this._status = { dragin: false, dragout: false, needrefresh: false }; callchartlistmethodreverse(this, 'ondragstart', param); }, _ondragenter: function (param) { callchartlistmethodreverse(this, 'ondragenter', param); }, _ondragover: function (param) { callchartlistmethodreverse(this, 'ondragover', param); }, _ondragleave: function (param) { callchartlistmethodreverse(this, 'ondragleave', param); }, _ondrop: function (param) { callchartlistmethodreverse(this, 'ondrop', param, this._status); this._island.ondrop(param, this._status); }, _ondragend: function (param) { callchartlistmethodreverse(this, 'ondragend', param, this._status); this._timeline && this._timeline.ondragend(param, this._status); this._island.ondragend(param, this._status); if (this._status.needrefresh) { this._syncbackupdata(this._option); var messagecenter = this._messagecenter; messagecenter.dispatch(ecconfig.event.data_changed, param.event, this._eventpackage(param.target), this); messagecenter.dispatch(ecconfig.event.refresh, null, null, this); } }, _onlegendselected: function (param) { this._status.needrefresh = false; callchartlistmethodreverse(this, 'onlegendselected', param, this._status); if (this._status.needrefresh) { this._messagecenter.dispatch(ecconfig.event.refresh, null, null, this); } }, _ondatazoom: function (param) { this._status.needrefresh = false; callchartlistmethodreverse(this, 'ondatazoom', param, this._status); if (this._status.needrefresh) { this._messagecenter.dispatch(ecconfig.event.refresh, null, null, this); } }, _ondatarange: function (param) { this._cleareffect(); this._status.needrefresh = false; callchartlistmethodreverse(this, 'ondatarange', param, this._status); if (this._status.needrefresh) { this._zr.refreshnextframe(); } }, _onmagictypechanged: function () { this._cleareffect(); this._render(this._toolbox.getmagicoption()); }, _ondataviewchanged: function (param) { this._syncbackupdata(param.option); this._messagecenter.dispatch(ecconfig.event.data_changed, null, param, this); this._messagecenter.dispatch(ecconfig.event.refresh, null, null, this); }, _tooltiphover: function (param) { var tipshape = []; callchartlistmethodreverse(this, 'ontooltiphover', param, tipshape); }, _onrestore: function () { this.restore(); }, _onrefresh: function (param) { this._refreshinside = true; this.refresh(param); this._refreshinside = false; }, _syncbackupdata: function (curoption) { this.component.datazoom && this.component.datazoom.syncbackupdata(curoption); }, _eventpackage: function (target) { if (target) { var ecdata = require('./util/ecdata'); var seriesindex = ecdata.get(target, 'seriesindex'); var dataindex = ecdata.get(target, 'dataindex'); dataindex = seriesindex != -1 && this.component.datazoom ? this.component.datazoom.getrealdataindex(seriesindex, dataindex) : dataindex; return { seriesindex: seriesindex, seriesname: (ecdata.get(target, 'series') || {}).name, dataindex: dataindex, data: ecdata.get(target, 'data'), name: ecdata.get(target, 'name'), value: ecdata.get(target, 'value'), special: ecdata.get(target, 'special') }; } return; }, _nodatacheck: function (magicoption) { var series = magicoption.series; for (var i = 0, l = series.length; i < l; i++) { if (series[i].type == ecconfig.chart_type_map || series[i].data && series[i].data.length > 0 || series[i].markpoint && series[i].markpoint.data && series[i].markpoint.data.length > 0 || series[i].markline && series[i].markline.data && series[i].markline.data.length > 0 || series[i].nodes && series[i].nodes.length > 0 || series[i].links && series[i].links.length > 0 || series[i].matrix && series[i].matrix.length > 0 || series[i].eventlist && series[i].eventlist.length > 0) { return false; } } var loadoption = this._option && this._option.nodataloadingoption || this._themeconfig.nodataloadingoption || ecconfig.nodataloadingoption || { text: this._option && this._option.nodatatext || this._themeconfig.nodatatext || ecconfig.nodatatext, effect: this._option && this._option.nodataeffect || this._themeconfig.nodataeffect || ecconfig.nodataeffect }; this.clear(); this.showloading(loadoption); return true; }, _render: function (magicoption) { this._mergeglobalconifg(magicoption); if (this._nodatacheck(magicoption)) { return; } var bgcolor = magicoption.backgroundcolor; if (bgcolor) { if (!_canvassupported && bgcolor.indexof('rgba') != -1) { var clist = bgcolor.split(','); this.dom.style.filter = 'alpha(opacity=' + clist[3].substring(0, clist[3].lastindexof(')')) * 100 + ')'; clist.length = 3; clist[0] = clist[0].replace('a', ''); this.dom.style.backgroundcolor = clist.join(',') + ')'; } else { this.dom.style.backgroundcolor = bgcolor; } } this._zr.clearanimation(); this._chartlist = []; var chartlibrary = require('./chart'); var componentlibrary = require('./component'); if (magicoption.xaxis || magicoption.yaxis) { magicoption.grid = magicoption.grid || {}; magicoption.datazoom = magicoption.datazoom || {}; } var componentlist = [ 'title', 'legend', 'tooltip', 'datarange', 'roamcontroller', 'grid', 'datazoom', 'xaxis', 'yaxis', 'polar' ]; var componentclass; var componenttype; var component; for (var i = 0, l = componentlist.length; i < l; i++) { componenttype = componentlist[i]; component = this.component[componenttype]; if (magicoption[componenttype]) { if (component) { component.refresh && component.refresh(magicoption); } else { componentclass = componentlibrary.get(/^[xy]axis$/.test(componenttype) ? 'axis' : componenttype); component = new componentclass(this._themeconfig, this._messagecenter, this._zr, magicoption, this, componenttype); this.component[componenttype] = component; } this._chartlist.push(component); } else if (component) { component.dispose(); this.component[componenttype] = null; delete this.component[componenttype]; } } var chartclass; var charttype; var chart; var chartmap = {}; for (var i = 0, l = magicoption.series.length; i < l; i++) { charttype = magicoption.series[i].type; if (!charttype) { console.error('series[' + i + '] chart type has not been defined.'); continue; } if (!chartmap[charttype]) { chartmap[charttype] = true; chartclass = chartlibrary.get(charttype); if (chartclass) { if (this.chart[charttype]) { chart = this.chart[charttype]; chart.refresh(magicoption); } else { chart = new chartclass(this._themeconfig, this._messagecenter, this._zr, magicoption, this); } this._chartlist.push(chart); this.chart[charttype] = chart; } else { console.error(charttype + ' has not been required.'); } } } for (charttype in this.chart) { if (charttype != ecconfig.chart_type_island && !chartmap[charttype]) { this.chart[charttype].dispose(); this.chart[charttype] = null; delete this.chart[charttype]; } } this.component.grid && this.component.grid.refixaxisshape(this.component); this._island.refresh(magicoption); this._toolbox.refresh(magicoption); magicoption.animation && !magicoption.renderasimage ? this._zr.refresh() : this._zr.render(); var imgid = 'img' + this.id; var img = document.getelementbyid(imgid); if (magicoption.renderasimage && _canvassupported) { if (img) { img.src = this.getdataurl(magicoption.renderasimage); } else { img = this.getimage(magicoption.renderasimage); img.id = imgid; img.style.position = 'absolute'; img.style.left = 0; img.style.top = 0; this.dom.firstchild.appendchild(img); } this.un(); this._zr.un(); this._disposechartlist(); this._zr.clear(); } else if (img) { img.parentnode.removechild(img); } img = null; this._option = magicoption; }, restore: function () { this._cleareffect(); this._option = zrutil.clone(this._optionrestore); this._disposechartlist(); this._island.clear(); this._toolbox.reset(this._option, true); this._render(this._option); }, refresh: function (param) { this._cleareffect(); param = param || {}; var magicoption = param.option; if (!this._refreshinside && magicoption) { magicoption = this.getoption(); zrutil.merge(magicoption, param.option, true); zrutil.merge(this._optionrestore, param.option, true); this._toolbox.reset(magicoption); } this._island.refresh(magicoption); this._toolbox.refresh(magicoption); this._zr.clearanimation(); for (var i = 0, l = this._chartlist.length; i < l; i++) { this._chartlist[i].refresh && this._chartlist[i].refresh(magicoption); } this.component.grid && this.component.grid.refixaxisshape(this.component); this._zr.refresh(); }, _disposechartlist: function () { this._cleareffect(); this._zr.clearanimation(); var len = this._chartlist.length; while (len--) { var chart = this._chartlist[len]; if (chart) { var charttype = chart.type; this.chart[charttype] && delete this.chart[charttype]; this.component[charttype] && delete this.component[charttype]; chart.dispose && chart.dispose(); } } this._chartlist = []; }, _mergeglobalconifg: function (magicoption) { var mergelist = [ 'backgroundcolor', 'calculable', 'calculablecolor', 'calculableholdercolor', 'nameconnector', 'valueconnector', 'animation', 'animationthreshold', 'animationduration', 'animationdurationupdate', 'animationeasing', 'adddataanimation', 'symbollist', 'drag_enable_time' ]; var len = mergelist.length; while (len--) { var mergeitem = mergelist[len]; if (magicoption[mergeitem] == null) { magicoption[mergeitem] = this._themeconfig[mergeitem] != null ? this._themeconfig[mergeitem] : ecconfig[mergeitem]; } } var themecolor = magicoption.color; if (!(themecolor && themecolor.length)) { themecolor = this._themeconfig.color || ecconfig.color; } this._zr.getcolor = function (idx) { var zrcolor = require('zrender/tool/color'); return zrcolor.getcolor(idx, themecolor); }; if (!_canvassupported) { magicoption.animation = false; magicoption.adddataanimation = false; } }, setoption: function (option, notmerge) { if (!option.timeline) { return this._setoption(option, notmerge); } else { return this._settimelineoption(option); } }, _setoption: function (option, notmerge, keeptimeline) { if (!notmerge && this._option) { this._option = zrutil.merge(this.getoption(), zrutil.clone(option), true); } else { this._option = zrutil.clone(option); !keeptimeline && this._timeline && this._timeline.dispose(); } this._optionrestore = zrutil.clone(this._option); if (!this._option.series || this._option.series.length === 0) { this._zr.clear(); return; } if (this.component.datazoom && (this._option.datazoom || this._option.toolbox && this._option.toolbox.feature && this._option.toolbox.feature.datazoom && this._option.toolbox.feature.datazoom.show)) { this.component.datazoom.syncoption(this._option); } this._toolbox.reset(this._option); this._render(this._option); return this; }, getoption: function () { var magicoption = zrutil.clone(this._option); var self = this; function restoreoption(prop) { var restoresource = self._optionrestore[prop]; if (restoresource) { if (restoresource instanceof array) { var len = restoresource.length; while (len--) { magicoption[prop][len].data = zrutil.clone(restoresource[len].data); } } else { magicoption[prop].data = zrutil.clone(restoresource.data); } } } restoreoption('xaxis'); restoreoption('yaxis'); restoreoption('series'); return magicoption; }, setseries: function (series, notmerge) { if (!notmerge) { this.setoption({ series: series }); } else { this._option.series = series; this.setoption(this._option, notmerge); } return this; }, getseries: function () { return this.getoption().series; }, _settimelineoption: function (option) { this._timeline && this._timeline.dispose(); var timeline = require('./component/timeline'); var timeline = new timeline(this._themeconfig, this._messagecenter, this._zr, option, this); this._timeline = timeline; this.component.timeline = this._timeline; return this; }, adddata: function (seriesidx, data, ishead, datagrow, additiondata) { var params = seriesidx instanceof array ? seriesidx : [[ seriesidx, data, ishead, datagrow, additiondata ]]; var magicoption = this.getoption(); var optionrestore = this._optionrestore; var self = this; for (var i = 0, l = params.length; i < l; i++) { seriesidx = params[i][0]; data = params[i][1]; ishead = params[i][2]; datagrow = params[i][3]; additiondata = params[i][4]; var seriesitem = optionrestore.series[seriesidx]; var inmethod = ishead ? 'unshift' : 'push'; var outmethod = ishead ? 'pop' : 'shift'; if (seriesitem) { var seriesitemdata = seriesitem.data; var mseriesitemdata = magicoption.series[seriesidx].data; seriesitemdata[inmethod](data); mseriesitemdata[inmethod](data); if (!datagrow) { seriesitemdata[outmethod](); data = mseriesitemdata[outmethod](); } if (additiondata != null) { var legend; var legenddata; if (seriesitem.type === ecconfig.chart_type_pie && (legend = optionrestore.legend) && (legenddata = legend.data)) { var mlegenddata = magicoption.legend.data; legenddata[inmethod](additiondata); mlegenddata[inmethod](additiondata); if (!datagrow) { var legenddataidx = zrutil.indexof(legenddata, data.name); legenddataidx != -1 && legenddata.splice(legenddataidx, 1); legenddataidx = zrutil.indexof(mlegenddata, data.name); legenddataidx != -1 && mlegenddata.splice(legenddataidx, 1); } } else if (optionrestore.xaxis != null && optionrestore.yaxis != null) { var axisdata; var maxisdata; var axisidx = seriesitem.xaxisindex || 0; if (optionrestore.xaxis[axisidx].type == null || optionrestore.xaxis[axisidx].type === 'category') { axisdata = optionrestore.xaxis[axisidx].data; maxisdata = magicoption.xaxis[axisidx].data; axisdata[inmethod](additiondata); maxisdata[inmethod](additiondata); if (!datagrow) { axisdata[outmethod](); maxisdata[outmethod](); } } axisidx = seriesitem.yaxisindex || 0; if (optionrestore.yaxis[axisidx].type === 'category') { axisdata = optionrestore.yaxis[axisidx].data; maxisdata = magicoption.yaxis[axisidx].data; axisdata[inmethod](additiondata); maxisdata[inmethod](additiondata); if (!datagrow) { axisdata[outmethod](); maxisdata[outmethod](); } } } } this._option.series[seriesidx].data = magicoption.series[seriesidx].data; } } this._zr.clearanimation(); var chartlist = this._chartlist; var chartanimationcount = 0; var chartanimationdone = function () { chartanimationcount--; if (chartanimationcount === 0) { animationdone(); } }; for (var i = 0, l = chartlist.length; i < l; i++) { if (magicoption.adddataanimation && chartlist[i].adddataanimation) { chartanimationcount++; chartlist[i].adddataanimation(params, chartanimationdone); } } this.component.datazoom && this.component.datazoom.syncoption(magicoption); this._option = magicoption; function animationdone() { if (!self._zr) { return; } self._zr.clearanimation(); for (var i = 0, l = chartlist.length; i < l; i++) { chartlist[i].motionlessonce = magicoption.adddataanimation && chartlist[i].adddataanimation; } self._messagecenter.dispatch(ecconfig.event.refresh, null, { option: magicoption }, self); } if (!magicoption.adddataanimation) { settimeout(animationdone, 0); } return this; }, addmarkpoint: function (seriesidx, markdata) { return this._addmark(seriesidx, markdata, 'markpoint'); }, addmarkline: function (seriesidx, markdata) { return this._addmark(seriesidx, markdata, 'markline'); }, _addmark: function (seriesidx, markdata, marktype) { var series = this._option.series; var seriesitem; if (series && (seriesitem = series[seriesidx])) { var seriesr = this._optionrestore.series; var seriesritem = seriesr[seriesidx]; var markopt = seriesitem[marktype]; var markoptr = seriesritem[marktype]; markopt = seriesitem[marktype] = markopt || { data: [] }; markoptr = seriesritem[marktype] = markoptr || { data: [] }; for (var key in markdata) { if (key === 'data') { markopt.data = markopt.data.concat(markdata.data); markoptr.data = markoptr.data.concat(markdata.data); } else if (typeof markdata[key] != 'object' || markopt[key] == null) { markopt[key] = markoptr[key] = markdata[key]; } else { zrutil.merge(markopt[key], markdata[key], true); zrutil.merge(markoptr[key], markdata[key], true); } } var chart = this.chart[seriesitem.type]; chart && chart.addmark(seriesidx, markdata, marktype); } return this; }, delmarkpoint: function (seriesidx, markname) { return this._delmark(seriesidx, markname, 'markpoint'); }, delmarkline: function (seriesidx, markname) { return this._delmark(seriesidx, markname, 'markline'); }, _delmark: function (seriesidx, markname, marktype) { var series = this._option.series; var seriesitem; var mark; var dataarray; if (!(series && (seriesitem = series[seriesidx]) && (mark = seriesitem[marktype]) && (dataarray = mark.data))) { return this; } markname = markname.split(' > '); var targetindex = -1; for (var i = 0, l = dataarray.length; i < l; i++) { var dataitem = dataarray[i]; if (dataitem instanceof array) { if (dataitem[0].name === markname[0] && dataitem[1].name === markname[1]) { targetindex = i; break; } } else if (dataitem.name === markname[0]) { targetindex = i; break; } } if (targetindex > -1) { dataarray.splice(targetindex, 1); this._optionrestore.series[seriesidx][marktype].data.splice(targetindex, 1); var chart = this.chart[seriesitem.type]; chart && chart.delmark(seriesidx, markname.join(' > '), marktype); } return this; }, getdom: function () { return this.dom; }, getzrender: function () { return this._zr; }, getdataurl: function (imgtype) { if (!_canvassupported) { return ''; } if (this._chartlist.length === 0) { var imgid = 'img' + this.id; var img = document.getelementbyid(imgid); if (img) { return img.src; } } var tooltip = this.component.tooltip; tooltip && tooltip.hidetip(); switch (imgtype) { case 'jpeg': break; default: imgtype = 'png'; } var bgcolor = this._option.backgroundcolor; if (bgcolor && bgcolor.replace(' ', '') === 'rgba(0,0,0,0)') { bgcolor = '#fff'; } return this._zr.todataurl('image/' + imgtype, bgcolor); }, getimage: function (imgtype) { var title = this._optionrestore.title; var imgdom = document.createelement('img'); imgdom.src = this.getdataurl(imgtype); imgdom.title = title && title.text || 'echarts'; return imgdom; }, getconnecteddataurl: function (imgtype) { if (!this.isconnected()) { return this.getdataurl(imgtype); } var tempdom = this.dom; var imglist = { 'self': { img: this.getdataurl(imgtype), left: tempdom.offsetleft, top: tempdom.offsettop, right: tempdom.offsetleft + tempdom.offsetwidth, bottom: tempdom.offsettop + tempdom.offsetheight } }; var minleft = imglist.self.left; var mintop = imglist.self.top; var maxright = imglist.self.right; var maxbottom = imglist.self.bottom; for (var c in this._connected) { tempdom = this._connected[c].getdom(); imglist[c] = { img: this._connected[c].getdataurl(imgtype), left: tempdom.offsetleft, top: tempdom.offsettop, right: tempdom.offsetleft + tempdom.offsetwidth, bottom: tempdom.offsettop + tempdom.offsetheight }; minleft = math.min(minleft, imglist[c].left); mintop = math.min(mintop, imglist[c].top); maxright = math.max(maxright, imglist[c].right); maxbottom = math.max(maxbottom, imglist[c].bottom); } var zrdom = document.createelement('div'); zrdom.style.position = 'absolute'; zrdom.style.left = '-4000px'; zrdom.style.width = maxright - minleft + 'px'; zrdom.style.height = maxbottom - mintop + 'px'; document.body.appendchild(zrdom); var zrimg = require('zrender').init(zrdom); var imageshape = require('zrender/shape/image'); for (var c in imglist) { zrimg.addshape(new imageshape({ style: { x: imglist[c].left - minleft, y: imglist[c].top - mintop, image: imglist[c].img } })); } zrimg.render(); var bgcolor = this._option.backgroundcolor; if (bgcolor && bgcolor.replace(/ /g, '') === 'rgba(0,0,0,0)') { bgcolor = '#fff'; } var image = zrimg.todataurl('image/png', bgcolor); settimeout(function () { zrimg.dispose(); zrdom.parentnode.removechild(zrdom); zrdom = null; }, 100); return image; }, getconnectedimage: function (imgtype) { var title = this._optionrestore.title; var imgdom = document.createelement('img'); imgdom.src = this.getconnecteddataurl(imgtype); imgdom.title = title && title.text || 'echarts'; return imgdom; }, on: function (eventname, eventlistener) { this._messagecenteroutside.bind(eventname, eventlistener, this); return this; }, un: function (eventname, eventlistener) { this._messagecenteroutside.unbind(eventname, eventlistener); return this; }, connect: function (connecttarget) { if (!connecttarget) { return this; } if (!this._connected) { this._connected = {}; } if (connecttarget instanceof array) { for (var i = 0, l = connecttarget.length; i < l; i++) { this._connected[connecttarget[i].id] = connecttarget[i]; } } else { this._connected[connecttarget.id] = connecttarget; } return this; }, disconnect: function (connecttarget) { if (!connecttarget || !this._connected) { return this; } if (connecttarget instanceof array) { for (var i = 0, l = connecttarget.length; i < l; i++) { delete this._connected[connecttarget[i].id]; } } else { delete this._connected[connecttarget.id]; } for (var k in this._connected) { return k, this; } this._connected = false; return this; }, connectedeventhandler: function (param) { if (param.__echartsid != this.id) { this._onevent(param); } }, isconnected: function () { return !!this._connected; }, showloading: function (loadingoption) { var effectlist = { bar: require('zrender/loadingeffect/bar'), bubble: require('zrender/loadingeffect/bubble'), dynamicline: require('zrender/loadingeffect/dynamicline'), ring: require('zrender/loadingeffect/ring'), spin: require('zrender/loadingeffect/spin'), whirling: require('zrender/loadingeffect/whirling') }; this._toolbox.hidedataview(); loadingoption = loadingoption || {}; var textstyle = loadingoption.textstyle || {}; loadingoption.textstyle = textstyle; var finaltextstyle = zrutil.merge(zrutil.merge(zrutil.clone(textstyle), this._themeconfig.textstyle), ecconfig.textstyle); textstyle.textfont = finaltextstyle.fontstyle + ' ' + finaltextstyle.fontweight + ' ' + finaltextstyle.fontsize + 'px ' + finaltextstyle.fontfamily; textstyle.text = loadingoption.text || this._option && this._option.loadingtext || this._themeconfig.loadingtext || ecconfig.loadingtext; if (loadingoption.x != null) { textstyle.x = loadingoption.x; } if (loadingoption.y != null) { textstyle.y = loadingoption.y; } loadingoption.effectoption = loadingoption.effectoption || {}; loadingoption.effectoption.textstyle = textstyle; var effect = loadingoption.effect; if (typeof effect === 'string' || effect == null) { effect = effectlist[loadingoption.effect || this._option && this._option.loadingeffect || this._themeconfig.loadingeffect || ecconfig.loadingeffect] || effectlist.spin; } this._zr.showloading(new effect(loadingoption.effectoption)); return this; }, hideloading: function () { this._zr.hideloading(); return this; }, settheme: function (theme) { if (theme) { if (typeof theme === 'string') { switch (theme) { case 'macarons': theme = require('./theme/macarons'); break; case 'infographic': theme = require('./theme/infographic'); break; default: theme = {}; } } else { theme = theme || {}; } this._themeconfig = theme; } if (!_canvassupported) { var textstyle = this._themeconfig.textstyle; textstyle && textstyle.fontfamily && textstyle.fontfamily2 && (textstyle.fontfamily = textstyle.fontfamily2); textstyle = ecconfig.textstyle; textstyle.fontfamily = textstyle.fontfamily2; } this._timeline && this._timeline.settheme(true); this._optionrestore && this.restore(); }, resize: function () { var self = this; return function () { self._cleareffect(); self._zr.resize(); if (self._option && self._option.renderasimage && _canvassupported) { self._render(self._option); return self; } self._zr.clearanimation(); self._island.resize(); self._toolbox.resize(); self._timeline && self._timeline.resize(); for (var i = 0, l = self._chartlist.length; i < l; i++) { self._chartlist[i].resize && self._chartlist[i].resize(); } self.component.grid && self.component.grid.refixaxisshape(self.component); self._zr.refresh(); self._messagecenter.dispatch(ecconfig.event.resize, null, null, self); return self; }; }, _cleareffect: function () { this._zr.modlayer(ecconfig.effect_zlevel, { motionblur: false }); this._zr.painter.clearlayer(ecconfig.effect_zlevel); }, clear: function () { this._disposechartlist(); this._zr.clear(); this._option = {}; this._optionrestore = {}; this.dom.style.backgroundcolor = null; return this; }, dispose: function () { var key = this.dom.getattribute(dom_attribute_key); key && delete _instances[key]; this._island.dispose(); this._toolbox.dispose(); this._timeline && this._timeline.dispose(); this._messagecenter.unbind(); this.clear(); this._zr.dispose(); this._zr = null; } }; return self; });define('echarts/config', [], function () { var config = { chart_type_line: 'line', chart_type_bar: 'bar', chart_type_scatter: 'scatter', chart_type_pie: 'pie', chart_type_radar: 'radar', chart_type_venn: 'venn', chart_type_treemap: 'treemap', chart_type_tree: 'tree', chart_type_map: 'map', chart_type_k: 'k', chart_type_island: 'island', chart_type_force: 'force', chart_type_chord: 'chord', chart_type_gauge: 'gauge', chart_type_funnel: 'funnel', chart_type_eventriver: 'eventriver', chart_type_wordcloud: 'wordcloud', chart_type_heatmap: 'heatmap', component_type_title: 'title', component_type_legend: 'legend', component_type_datarange: 'datarange', component_type_dataview: 'dataview', component_type_datazoom: 'datazoom', component_type_toolbox: 'toolbox', component_type_tooltip: 'tooltip', component_type_grid: 'grid', component_type_axis: 'axis', component_type_polar: 'polar', component_type_x_axis: 'xaxis', component_type_y_axis: 'yaxis', component_type_axis_category: 'categoryaxis', component_type_axis_value: 'valueaxis', component_type_timeline: 'timeline', component_type_roamcontroller: 'roamcontroller', backgroundcolor: 'rgba(0,0,0,0)', color: [ '#ff7f50', '#87cefa', '#da70d6', '#32cd32', '#6495ed', '#ff69b4', '#ba55d3', '#cd5c5c', '#ffa500', '#40e0d0', '#1e90ff', '#ff6347', '#7b68ee', '#00fa9a', '#ffd700', '#6699ff', '#ff6666', '#3cb371', '#b8860b', '#30e0e0' ], markpoint: { clickable: true, symbol: 'pin', symbolsize: 10, large: false, effect: { show: false, loop: true, period: 15, type: 'scale', scalesize: 2, bouncedistance: 10 }, itemstyle: { normal: { borderwidth: 2, label: { show: true, position: 'inside' } }, emphasis: { label: { show: true } } } }, markline: { clickable: true, symbol: [ 'circle', 'arrow' ], symbolsize: [ 2, 4 ], smoothness: 0.2, precision: 2, effect: { show: false, loop: true, period: 15, scalesize: 2 }, bundling: { enable: false, maxturningangle: 45 }, itemstyle: { normal: { borderwidth: 1.5, label: { show: true, position: 'end' }, linestyle: { type: 'dashed' } }, emphasis: { label: { show: false }, linestyle: {} } } }, textstyle: { decoration: 'none', fontfamily: 'arial, verdana, sans-serif', fontfamily2: '微软雅黑', fontsize: 12, fontstyle: 'normal', fontweight: 'normal' }, event: { refresh: 'refresh', restore: 'restore', resize: 'resize', click: 'click', dblclick: 'dblclick', hover: 'hover', mouseout: 'mouseout', data_changed: 'datachanged', data_zoom: 'datazoom', data_range: 'datarange', data_range_selected: 'datarangeselected', data_range_hoverlink: 'datarangehoverlink', legend_selected: 'legendselected', legend_hoverlink: 'legendhoverlink', map_selected: 'mapselected', pie_selected: 'pieselected', magic_type_changed: 'magictypechanged', data_view_changed: 'dataviewchanged', timeline_changed: 'timelinechanged', map_roam: 'maproam', force_layout_end: 'forcelayoutend', tooltip_hover: 'tooltiphover', tooltip_in_grid: 'tooltipingrid', tooltip_out_grid: 'tooltipoutgrid', roamcontroller: 'roamcontroller' }, drag_enable_time: 120, effect_zlevel: 10, effectblendalpha: 0.95, symbollist: [ 'circle', 'rectangle', 'triangle', 'diamond', 'emptycircle', 'emptyrectangle', 'emptytriangle', 'emptydiamond' ], loadingeffect: 'spin', loadingtext: '数据读取中...', nodataeffect: 'bubble', nodatatext: '暂无数据', calculable: false, calculablecolor: 'rgba(255,165,0,0.6)', calculableholdercolor: '#ccc', nameconnector: ' & ', valueconnector: ': ', animation: true, adddataanimation: true, animationthreshold: 2000, animationduration: 2000, animationdurationupdate: 500, animationeasing: 'exponentialout' }; return config; });define('zrender/tool/util', [ 'require', '../dep/excanvas' ], function (require) { var arrayproto = array.prototype; var nativeforeach = arrayproto.foreach; var nativemap = arrayproto.map; var nativefilter = arrayproto.filter; var builtin_object = { '[object function]': 1, '[object regexp]': 1, '[object date]': 1, '[object error]': 1, '[object canvasgradient]': 1 }; var objtostring = object.prototype.tostring; function isdom(obj) { return obj && obj.nodetype === 1 && typeof obj.nodename == 'string'; } function clone(source) { if (typeof source == 'object' && source !== null) { var result = source; if (source instanceof array) { result = []; for (var i = 0, len = source.length; i < len; i++) { result[i] = clone(source[i]); } } else if (!builtin_object[objtostring.call(source)] && !isdom(source)) { result = {}; for (var key in source) { if (source.hasownproperty(key)) { result[key] = clone(source[key]); } } } return result; } return source; } function mergeitem(target, source, key, overwrite) { if (source.hasownproperty(key)) { var targetprop = target[key]; if (typeof targetprop == 'object' && !builtin_object[objtostring.call(targetprop)] && !isdom(targetprop)) { merge(target[key], source[key], overwrite); } else if (overwrite || !(key in target)) { target[key] = source[key]; } } } function merge(target, source, overwrite) { for (var i in source) { mergeitem(target, source, i, overwrite); } return target; } var _ctx; function getcontext() { if (!_ctx) { require('../dep/excanvas'); if (window['g_vmlcanvasmanager']) { var _div = document.createelement('div'); _div.style.position = 'absolute'; _div.style.top = '-1000px'; document.body.appendchild(_div); _ctx = g_vmlcanvasmanager.initelement(_div).getcontext('2d'); } else { _ctx = document.createelement('canvas').getcontext('2d'); } } return _ctx; } function indexof(array, value) { if (array.indexof) { return array.indexof(value); } for (var i = 0, len = array.length; i < len; i++) { if (array[i] === value) { return i; } } return -1; } function inherits(clazz, baseclazz) { var clazzprototype = clazz.prototype; function f() { } f.prototype = baseclazz.prototype; clazz.prototype = new f(); for (var prop in clazzprototype) { clazz.prototype[prop] = clazzprototype[prop]; } clazz.constructor = clazz; } function each(obj, cb, context) { if (!(obj && cb)) { return; } if (obj.foreach && obj.foreach === nativeforeach) { obj.foreach(cb, context); } else if (obj.length === +obj.length) { for (var i = 0, len = obj.length; i < len; i++) { cb.call(context, obj[i], i, obj); } } else { for (var key in obj) { if (obj.hasownproperty(key)) { cb.call(context, obj[key], key, obj); } } } } function map(obj, cb, context) { if (!(obj && cb)) { return; } if (obj.map && obj.map === nativemap) { return obj.map(cb, context); } else { var result = []; for (var i = 0, len = obj.length; i < len; i++) { result.push(cb.call(context, obj[i], i, obj)); } return result; } } function filter(obj, cb, context) { if (!(obj && cb)) { return; } if (obj.filter && obj.filter === nativefilter) { return obj.filter(cb, context); } else { var result = []; for (var i = 0, len = obj.length; i < len; i++) { if (cb.call(context, obj[i], i, obj)) { result.push(obj[i]); } } return result; } } function bind(func, context) { return function () { func.apply(context, arguments); }; } return { inherits: inherits, clone: clone, merge: merge, getcontext: getcontext, indexof: indexof, each: each, map: map, filter: filter, bind: bind }; });define('zrender/tool/event', [ 'require', '../mixin/eventful' ], function (require) { 'use strict'; var eventful = require('../mixin/eventful'); function getx(e) { return typeof e.zrenderx != 'undefined' && e.zrenderx || typeof e.offsetx != 'undefined' && e.offsetx || typeof e.layerx != 'undefined' && e.layerx || typeof e.clientx != 'undefined' && e.clientx; } function gety(e) { return typeof e.zrendery != 'undefined' && e.zrendery || typeof e.offsety != 'undefined' && e.offsety || typeof e.layery != 'undefined' && e.layery || typeof e.clienty != 'undefined' && e.clienty; } function getdelta(e) { return typeof e.zrenderdelta != 'undefined' && e.zrenderdelta || typeof e.wheeldelta != 'undefined' && e.wheeldelta || typeof e.detail != 'undefined' && -e.detail; } var stop = typeof window.addeventlistener === 'function' ? function (e) { e.preventdefault(); e.stoppropagation(); e.cancelbubble = true; } : function (e) { e.returnvalue = false; e.cancelbubble = true; }; return { getx: getx, gety: gety, getdelta: getdelta, stop: stop, dispatcher: eventful }; });define('zrender/tool/env', [], function () { function detect(ua) { var os = this.os = {}; var browser = this.browser = {}; var webkit = ua.match(/web[kk]it[\/]{0,1}([\d.]+)/); var android = ua.match(/(android);?[\s\/]+([\d.]+)?/); var ipad = ua.match(/(ipad).*os\s([\d_]+)/); var ipod = ua.match(/(ipod)(.*os\s([\d_]+))?/); var iphone = !ipad && ua.match(/(iphone\sos)\s([\d_]+)/); var webos = ua.match(/(webos|hpwos)[\s\/]([\d.]+)/); var touchpad = webos && ua.match(/touchpad/); var kindle = ua.match(/kindle\/([\d.]+)/); var silk = ua.match(/silk\/([\d._]+)/); var blackberry = ua.match(/(blackberry).*version\/([\d.]+)/); var bb10 = ua.match(/(bb10).*version\/([\d.]+)/); var rimtabletos = ua.match(/(rim\stablet\sos)\s([\d.]+)/); var playbook = ua.match(/playbook/); var chrome = ua.match(/chrome\/([\d.]+)/) || ua.match(/crios\/([\d.]+)/); var firefox = ua.match(/firefox\/([\d.]+)/); var ie = ua.match(/msie ([\d.]+)/); var safari = webkit && ua.match(/mobile\//) && !chrome; var webview = ua.match(/(iphone|ipod|ipad).*applewebkit(?!.*safari)/) && !chrome; var ie = ua.match(/msie\s([\d.]+)/); if (browser.webkit = !!webkit) browser.version = webkit[1]; if (android) os.android = true, os.version = android[2]; if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.'); if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.'); if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null; if (webos) os.webos = true, os.version = webos[2]; if (touchpad) os.touchpad = true; if (blackberry) os.blackberry = true, os.version = blackberry[2]; if (bb10) os.bb10 = true, os.version = bb10[2]; if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2]; if (playbook) browser.playbook = true; if (kindle) os.kindle = true, os.version = kindle[1]; if (silk) browser.silk = true, browser.version = silk[1]; if (!silk && os.android && ua.match(/kindle fire/)) browser.silk = true; if (chrome) browser.chrome = true, browser.version = chrome[1]; if (firefox) browser.firefox = true, browser.version = firefox[1]; if (ie) browser.ie = true, browser.version = ie[1]; if (safari && (ua.match(/safari/) || !!os.ios)) browser.safari = true; if (webview) browser.webview = true; if (ie) browser.ie = true, browser.version = ie[1]; os.tablet = !!(ipad || playbook || android && !ua.match(/mobile/) || firefox && ua.match(/tablet/) || ie && !ua.match(/phone/) && ua.match(/touch/)); os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos || blackberry || bb10 || chrome && ua.match(/android/) || chrome && ua.match(/crios\/([\d.]+)/) || firefox && ua.match(/mobile/) || ie && ua.match(/touch/))); return { browser: browser, os: os, canvassupported: document.createelement('canvas').getcontext ? true : false }; } return detect(navigator.useragent); });define('zrender', ['zrender/zrender'], function (main) {return main;}); define('zrender/zrender', [ 'require', './dep/excanvas', './tool/util', './tool/log', './tool/guid', './handler', './painter', './storage', './animation/animation', './tool/env' ], function (require) { require('./dep/excanvas'); var util = require('./tool/util'); var log = require('./tool/log'); var guid = require('./tool/guid'); var handler = require('./handler'); var painter = require('./painter'); var storage = require('./storage'); var animation = require('./animation/animation'); var _instances = {}; var zrender = {}; zrender.version = '2.1.1'; zrender.init = function (dom) { var zr = new zrender(guid(), dom); _instances[zr.id] = zr; return zr; }; zrender.dispose = function (zr) { if (zr) { zr.dispose(); } else { for (var key in _instances) { _instances[key].dispose(); } _instances = {}; } return zrender; }; zrender.getinstance = function (id) { return _instances[id]; }; zrender.delinstance = function (id) { delete _instances[id]; return zrender; }; function getframecallback(zrinstance) { return function () { if (zrinstance._needsrefreshnextframe) { zrinstance.refresh(); } }; } var zrender = function (id, dom) { this.id = id; this.env = require('./tool/env'); this.storage = new storage(); this.painter = new painter(dom, this.storage); this.handler = new handler(dom, this.storage, this.painter); this.animation = new animation({ stage: { update: getframecallback(this) } }); this.animation.start(); var self = this; this.painter.refreshnextframe = function () { self.refreshnextframe(); }; this._needsrefreshnextframe = false; var self = this; var storage = this.storage; var olddelfrommap = storage.delfrommap; storage.delfrommap = function (elid) { var el = storage.get(elid); self.stopanimation(el); olddelfrommap.call(storage, elid); }; }; zrender.prototype.getid = function () { return this.id; }; zrender.prototype.addshape = function (shape) { this.addelement(shape); return this; }; zrender.prototype.addgroup = function (group) { this.addelement(group); return this; }; zrender.prototype.delshape = function (shapeid) { this.delelement(shapeid); return this; }; zrender.prototype.delgroup = function (groupid) { this.delelement(groupid); return this; }; zrender.prototype.modshape = function (shapeid, shape) { this.modelement(shapeid, shape); return this; }; zrender.prototype.modgroup = function (groupid, group) { this.modelement(groupid, group); return this; }; zrender.prototype.addelement = function (el) { this.storage.addroot(el); this._needsrefreshnextframe = true; return this; }; zrender.prototype.delelement = function (el) { this.storage.delroot(el); this._needsrefreshnextframe = true; return this; }; zrender.prototype.modelement = function (el, params) { this.storage.mod(el, params); this._needsrefreshnextframe = true; return this; }; zrender.prototype.modlayer = function (zlevel, config) { this.painter.modlayer(zlevel, config); this._needsrefreshnextframe = true; return this; }; zrender.prototype.addhovershape = function (shape) { this.storage.addhover(shape); return this; }; zrender.prototype.render = function (callback) { this.painter.render(callback); this._needsrefreshnextframe = false; return this; }; zrender.prototype.refresh = function (callback) { this.painter.refresh(callback); this._needsrefreshnextframe = false; return this; }; zrender.prototype.refreshnextframe = function () { this._needsrefreshnextframe = true; return this; }; zrender.prototype.refreshhover = function (callback) { this.painter.refreshhover(callback); return this; }; zrender.prototype.refreshshapes = function (shapelist, callback) { this.painter.refreshshapes(shapelist, callback); return this; }; zrender.prototype.resize = function () { this.painter.resize(); return this; }; zrender.prototype.animate = function (el, path, loop) { var self = this; if (typeof el === 'string') { el = this.storage.get(el); } if (el) { var target; if (path) { var pathsplitted = path.split('.'); var prop = el; for (var i = 0, l = pathsplitted.length; i < l; i++) { if (!prop) { continue; } prop = prop[pathsplitted[i]]; } if (prop) { target = prop; } } else { target = el; } if (!target) { log('property "' + path + '" is not existed in element ' + el.id); return; } if (el.__animators == null) { el.__animators = []; } var animators = el.__animators; var animator = this.animation.animate(target, { loop: loop }).during(function () { self.modshape(el); }).done(function () { var idx = util.indexof(el.__animators, animator); if (idx >= 0) { animators.splice(idx, 1); } }); animators.push(animator); return animator; } else { log('element not existed'); } }; zrender.prototype.stopanimation = function (el) { if (el.__animators) { var animators = el.__animators; var len = animators.length; for (var i = 0; i < len; i++) { animators[i].stop(); } animators.length = 0; } return this; }; zrender.prototype.clearanimation = function () { this.animation.clear(); return this; }; zrender.prototype.showloading = function (loadingeffect) { this.painter.showloading(loadingeffect); return this; }; zrender.prototype.hideloading = function () { this.painter.hideloading(); return this; }; zrender.prototype.getwidth = function () { return this.painter.getwidth(); }; zrender.prototype.getheight = function () { return this.painter.getheight(); }; zrender.prototype.todataurl = function (type, backgroundcolor, args) { return this.painter.todataurl(type, backgroundcolor, args); }; zrender.prototype.shapetoimage = function (e, width, height) { var id = guid(); return this.painter.shapetoimage(id, e, width, height); }; zrender.prototype.on = function (eventname, eventhandler, context) { this.handler.on(eventname, eventhandler, context); return this; }; zrender.prototype.un = function (eventname, eventhandler) { this.handler.un(eventname, eventhandler); return this; }; zrender.prototype.trigger = function (eventname, event) { this.handler.trigger(eventname, event); return this; }; zrender.prototype.clear = function () { this.storage.delroot(); this.painter.clear(); return this; }; zrender.prototype.dispose = function () { this.animation.stop(); this.clear(); this.storage.dispose(); this.painter.dispose(); this.handler.dispose(); this.animation = this.storage = this.painter = this.handler = null; zrender.delinstance(this.id); }; return zrender; });define('zrender/config', [], function () { var config = { event: { resize: 'resize', click: 'click', dblclick: 'dblclick', mousewheel: 'mousewheel', mousemove: 'mousemove', mouseover: 'mouseover', mouseout: 'mouseout', mousedown: 'mousedown', mouseup: 'mouseup', globalout: 'globalout', dragstart: 'dragstart', dragend: 'dragend', dragenter: 'dragenter', dragover: 'dragover', dragleave: 'dragleave', drop: 'drop', touchclickdelay: 300 }, elementclassname: 'zr-element', catchbrushexception: false, debugmode: 0, devicepixelratio: math.max(window.devicepixelratio || 1, 1) }; return config; });define('echarts/chart/island', [ 'require', './base', 'zrender/shape/circle', '../config', '../util/ecdata', 'zrender/tool/util', 'zrender/tool/event', 'zrender/tool/color', '../util/accmath', '../chart' ], function (require) { var chartbase = require('./base'); var circleshape = require('zrender/shape/circle'); var ecconfig = require('../config'); ecconfig.island = { zlevel: 0, z: 5, r: 15, calculatestep: 0.1 }; var ecdata = require('../util/ecdata'); var zrutil = require('zrender/tool/util'); var zrevent = require('zrender/tool/event'); function island(ectheme, messagecenter, zr, option, mychart) { chartbase.call(this, ectheme, messagecenter, zr, option, mychart); this._nameconnector; this._valueconnector; this._zrheight = this.zr.getheight(); this._zrwidth = this.zr.getwidth(); var self = this; self.shapehandler.onmousewheel = function (param) { var shape = param.target; var event = param.event; var delta = zrevent.getdelta(event); delta = delta > 0 ? -1 : 1; shape.style.r -= delta; shape.style.r = shape.style.r < 5 ? 5 : shape.style.r; var value = ecdata.get(shape, 'value'); var dvalue = value * self.option.island.calculatestep; value = dvalue > 1 ? math.round(value - dvalue * delta) : +(value - dvalue * delta).tofixed(2); var name = ecdata.get(shape, 'name'); shape.style.text = name + ':' + value; ecdata.set(shape, 'value', value); ecdata.set(shape, 'name', name); self.zr.modshape(shape.id); self.zr.refreshnextframe(); zrevent.stop(event); }; } island.prototype = { type: ecconfig.chart_type_island, _combine: function (tarshape, srcshape) { var zrcolor = require('zrender/tool/color'); var accmath = require('../util/accmath'); var value = accmath.accadd(ecdata.get(tarshape, 'value'), ecdata.get(srcshape, 'value')); var name = ecdata.get(tarshape, 'name') + this._nameconnector + ecdata.get(srcshape, 'name'); tarshape.style.text = name + this._valueconnector + value; ecdata.set(tarshape, 'value', value); ecdata.set(tarshape, 'name', name); tarshape.style.r = this.option.island.r; tarshape.style.color = zrcolor.mix(tarshape.style.color, srcshape.style.color); }, refresh: function (newoption) { if (newoption) { newoption.island = this.reformoption(newoption.island); this.option = newoption; this._nameconnector = this.option.nameconnector; this._valueconnector = this.option.valueconnector; } }, getoption: function () { return this.option; }, resize: function () { var newwidth = this.zr.getwidth(); var newhieght = this.zr.getheight(); var xscale = newwidth / (this._zrwidth || newwidth); var yscale = newhieght / (this._zrheight || newhieght); if (xscale === 1 && yscale === 1) { return; } this._zrwidth = newwidth; this._zrheight = newhieght; for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.modshape(this.shapelist[i].id, { style: { x: math.round(this.shapelist[i].style.x * xscale), y: math.round(this.shapelist[i].style.y * yscale) } }); } }, add: function (shape) { var name = ecdata.get(shape, 'name'); var value = ecdata.get(shape, 'value'); var seriesname = ecdata.get(shape, 'series') != null ? ecdata.get(shape, 'series').name : ''; var font = this.getfont(this.option.island.textstyle); var islandoption = this.option.island; var islandshape = { zlevel: islandoption.zlevel, z: islandoption.z, style: { x: shape.style.x, y: shape.style.y, r: this.option.island.r, color: shape.style.color || shape.style.strokecolor, text: name + this._valueconnector + value, textfont: font }, draggable: true, hoverable: true, onmousewheel: this.shapehandler.onmousewheel, _type: 'island' }; if (islandshape.style.color === '#fff') { islandshape.style.color = shape.style.strokecolor; } this.setcalculable(islandshape); islandshape.dragenabletime = 0; ecdata.pack(islandshape, { name: seriesname }, -1, value, -1, name); islandshape = new circleshape(islandshape); this.shapelist.push(islandshape); this.zr.addshape(islandshape); }, del: function (shape) { this.zr.delshape(shape.id); var newshapelist = []; for (var i = 0, l = this.shapelist.length; i < l; i++) { if (this.shapelist[i].id != shape.id) { newshapelist.push(this.shapelist[i]); } } this.shapelist = newshapelist; }, ondrop: function (param, status) { if (!this.isdrop || !param.target) { return; } var target = param.target; var dragged = param.dragged; this._combine(target, dragged); this.zr.modshape(target.id); status.dragin = true; this.isdrop = false; return; }, ondragend: function (param, status) { var target = param.target; if (!this.isdragend) { if (!status.dragin) { target.style.x = zrevent.getx(param.event); target.style.y = zrevent.gety(param.event); this.add(target); status.needrefresh = true; } } else { if (status.dragin) { this.del(target); status.needrefresh = true; } } this.isdragend = false; return; } }; zrutil.inherits(island, chartbase); require('../chart').define('island', island); return island; });define('echarts/component/toolbox', [ 'require', './base', 'zrender/shape/line', 'zrender/shape/image', 'zrender/shape/rectangle', '../util/shape/icon', '../config', 'zrender/tool/util', 'zrender/config', 'zrender/tool/event', './dataview', '../component' ], function (require) { var base = require('./base'); var lineshape = require('zrender/shape/line'); var imageshape = require('zrender/shape/image'); var rectangleshape = require('zrender/shape/rectangle'); var iconshape = require('../util/shape/icon'); var ecconfig = require('../config'); ecconfig.toolbox = { zlevel: 0, z: 6, show: false, orient: 'horizontal', x: 'right', y: 'top', color: [ '#1e90ff', '#22bb22', '#4b0082', '#d2691e' ], disablecolor: '#ddd', effectivecolor: 'red', backgroundcolor: 'rgba(0,0,0,0)', bordercolor: '#ccc', borderwidth: 0, padding: 5, itemgap: 10, itemsize: 16, showtitle: true, feature: { mark: { show: false, title: { mark: '辅助线开关', markundo: '删除辅助线', markclear: '清空辅助线' }, linestyle: { width: 1, color: '#1e90ff', type: 'dashed' } }, datazoom: { show: false, title: { datazoom: '区域缩放', datazoomreset: '区域缩放后退' } }, dataview: { show: false, title: '数据视图', readonly: false, lang: [ '数据视图', '关闭', '刷新' ] }, magictype: { show: false, title: { line: '折线图切换', bar: '柱形图切换', stack: '堆积', tiled: '平铺', force: '力导向布局图切换', chord: '和弦图切换', pie: '饼图切换', funnel: '漏斗图切换' }, type: [] }, restore: { show: false, title: '还原' }, saveasimage: { show: false, title: '保存为图片', type: 'png', lang: ['点击保存'] } } }; var zrutil = require('zrender/tool/util'); var zrconfig = require('zrender/config'); var zrevent = require('zrender/tool/event'); var _magictype_stack = 'stack'; var _magictype_tiled = 'tiled'; function toolbox(ectheme, messagecenter, zr, option, mychart) { base.call(this, ectheme, messagecenter, zr, option, mychart); this.dom = mychart.dom; this._magictype = {}; this._magicmap = {}; this._issilence = false; this._iconlist; this._iconshapemap = {}; this._featuretitle = {}; this._featureicon = {}; this._featurecolor = {}; this._featureoption = {}; this._enablecolor = 'red'; this._disablecolor = '#ccc'; this._markshapelist = []; var self = this; self._onmark = function (param) { self.__onmark(param); }; self._onmarkundo = function (param) { self.__onmarkundo(param); }; self._onmarkclear = function (param) { self.__onmarkclear(param); }; self._ondatazoom = function (param) { self.__ondatazoom(param); }; self._ondatazoomreset = function (param) { self.__ondatazoomreset(param); }; self._ondataview = function (param) { self.__ondataview(param); }; self._onrestore = function (param) { self.__onrestore(param); }; self._onsaveasimage = function (param) { self.__onsaveasimage(param); }; self._onmagictype = function (param) { self.__onmagictype(param); }; self._oncustomhandler = function (param) { self.__oncustomhandler(param); }; self._onmousemove = function (param) { return self.__onmousemove(param); }; self._onmousedown = function (param) { return self.__onmousedown(param); }; self._onmouseup = function (param) { return self.__onmouseup(param); }; self._onclick = function (param) { return self.__onclick(param); }; } toolbox.prototype = { type: ecconfig.component_type_toolbox, _buildshape: function () { this._iconlist = []; var toolboxoption = this.option.toolbox; this._enablecolor = toolboxoption.effectivecolor; this._disablecolor = toolboxoption.disablecolor; var feature = toolboxoption.feature; var iconname = []; for (var key in feature) { if (feature[key].show) { switch (key) { case 'mark': iconname.push({ key: key, name: 'mark' }); iconname.push({ key: key, name: 'markundo' }); iconname.push({ key: key, name: 'markclear' }); break; case 'magictype': for (var i = 0, l = feature[key].type.length; i < l; i++) { feature[key].title[feature[key].type[i] + 'chart'] = feature[key].title[feature[key].type[i]]; if (feature[key].option) { feature[key].option[feature[key].type[i] + 'chart'] = feature[key].option[feature[key].type[i]]; } iconname.push({ key: key, name: feature[key].type[i] + 'chart' }); } break; case 'datazoom': iconname.push({ key: key, name: 'datazoom' }); iconname.push({ key: key, name: 'datazoomreset' }); break; case 'saveasimage': if (this.canvassupported) { iconname.push({ key: key, name: 'saveasimage' }); } break; default: iconname.push({ key: key, name: key }); break; } } } if (iconname.length > 0) { var name; var key; for (var i = 0, l = iconname.length; i < l; i++) { name = iconname[i].name; key = iconname[i].key; this._iconlist.push(name); this._featuretitle[name] = feature[key].title[name] || feature[key].title; if (feature[key].icon) { this._featureicon[name] = feature[key].icon[name] || feature[key].icon; } if (feature[key].color) { this._featurecolor[name] = feature[key].color[name] || feature[key].color; } if (feature[key].option) { this._featureoption[name] = feature[key].option[name] || feature[key].option; } } this._itemgrouplocation = this._getitemgrouplocation(); this._buildbackground(); this._builditem(); for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } if (this._iconshapemap['mark']) { this._icondisable(this._iconshapemap['markundo']); this._icondisable(this._iconshapemap['markclear']); } if (this._iconshapemap['datazoomreset'] && this._zoomqueue.length === 0) { this._icondisable(this._iconshapemap['datazoomreset']); } } }, _builditem: function () { var toolboxoption = this.option.toolbox; var iconlength = this._iconlist.length; var lastx = this._itemgrouplocation.x; var lasty = this._itemgrouplocation.y; var itemsize = toolboxoption.itemsize; var itemgap = toolboxoption.itemgap; var itemshape; var color = toolboxoption.color instanceof array ? toolboxoption.color : [toolboxoption.color]; var textfont = this.getfont(toolboxoption.textstyle); var textposition; var textalign; var textbaseline; if (toolboxoption.orient === 'horizontal') { textposition = this._itemgrouplocation.y / this.zr.getheight() < 0.5 ? 'bottom' : 'top'; textalign = this._itemgrouplocation.x / this.zr.getwidth() < 0.5 ? 'left' : 'right'; textbaseline = this._itemgrouplocation.y / this.zr.getheight() < 0.5 ? 'top' : 'bottom'; } else { textposition = this._itemgrouplocation.x / this.zr.getwidth() < 0.5 ? 'right' : 'left'; } this._iconshapemap = {}; var self = this; for (var i = 0; i < iconlength; i++) { itemshape = { type: 'icon', zlevel: this.getzlevelbase(), z: this.getzbase(), style: { x: lastx, y: lasty, width: itemsize, height: itemsize, icontype: this._iconlist[i], linewidth: 1, strokecolor: this._featurecolor[this._iconlist[i]] || color[i % color.length], brushtype: 'stroke' }, highlightstyle: { linewidth: 1, text: toolboxoption.showtitle ? this._featuretitle[this._iconlist[i]] : undefined, textfont: textfont, textposition: textposition, strokecolor: this._featurecolor[this._iconlist[i]] || color[i % color.length] }, hoverable: true, clickable: true }; if (this._featureicon[this._iconlist[i]]) { itemshape.style.image = this._featureicon[this._iconlist[i]].replace(new regexp('^image:\\/\\/'), ''); itemshape.style.opacity = 0.8; itemshape.highlightstyle.opacity = 1; itemshape.type = 'image'; } if (toolboxoption.orient === 'horizontal') { if (i === 0 && textalign === 'left') { itemshape.highlightstyle.textposition = 'specific'; itemshape.highlightstyle.textalign = textalign; itemshape.highlightstyle.textbaseline = textbaseline; itemshape.highlightstyle.textx = lastx; itemshape.highlightstyle.texty = textbaseline === 'top' ? lasty + itemsize + 10 : lasty - 10; } if (i === iconlength - 1 && textalign === 'right') { itemshape.highlightstyle.textposition = 'specific'; itemshape.highlightstyle.textalign = textalign; itemshape.highlightstyle.textbaseline = textbaseline; itemshape.highlightstyle.textx = lastx + itemsize; itemshape.highlightstyle.texty = textbaseline === 'top' ? lasty + itemsize + 10 : lasty - 10; } } switch (this._iconlist[i]) { case 'mark': itemshape.onclick = self._onmark; break; case 'markundo': itemshape.onclick = self._onmarkundo; break; case 'markclear': itemshape.onclick = self._onmarkclear; break; case 'datazoom': itemshape.onclick = self._ondatazoom; break; case 'datazoomreset': itemshape.onclick = self._ondatazoomreset; break; case 'dataview': if (!this._dataview) { var dataview = require('./dataview'); this._dataview = new dataview(this.ectheme, this.messagecenter, this.zr, this.option, this.mychart); } itemshape.onclick = self._ondataview; break; case 'restore': itemshape.onclick = self._onrestore; break; case 'saveasimage': itemshape.onclick = self._onsaveasimage; break; default: if (this._iconlist[i].match('chart')) { itemshape._name = this._iconlist[i].replace('chart', ''); itemshape.onclick = self._onmagictype; } else { itemshape.onclick = self._oncustomhandler; } break; } if (itemshape.type === 'icon') { itemshape = new iconshape(itemshape); } else if (itemshape.type === 'image') { itemshape = new imageshape(itemshape); } this.shapelist.push(itemshape); this._iconshapemap[this._iconlist[i]] = itemshape; if (toolboxoption.orient === 'horizontal') { lastx += itemsize + itemgap; } else { lasty += itemsize + itemgap; } } }, _buildbackground: function () { var toolboxoption = this.option.toolbox; var padding = this.reformcssarray(this.option.toolbox.padding); this.shapelist.push(new rectangleshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this._itemgrouplocation.x - padding[3], y: this._itemgrouplocation.y - padding[0], width: this._itemgrouplocation.width + padding[3] + padding[1], height: this._itemgrouplocation.height + padding[0] + padding[2], brushtype: toolboxoption.borderwidth === 0 ? 'fill' : 'both', color: toolboxoption.backgroundcolor, strokecolor: toolboxoption.bordercolor, linewidth: toolboxoption.borderwidth } })); }, _getitemgrouplocation: function () { var toolboxoption = this.option.toolbox; var padding = this.reformcssarray(this.option.toolbox.padding); var iconlength = this._iconlist.length; var itemgap = toolboxoption.itemgap; var itemsize = toolboxoption.itemsize; var totalwidth = 0; var totalheight = 0; if (toolboxoption.orient === 'horizontal') { totalwidth = (itemsize + itemgap) * iconlength - itemgap; totalheight = itemsize; } else { totalheight = (itemsize + itemgap) * iconlength - itemgap; totalwidth = itemsize; } var x; var zrwidth = this.zr.getwidth(); switch (toolboxoption.x) { case 'center': x = math.floor((zrwidth - totalwidth) / 2); break; case 'left': x = padding[3] + toolboxoption.borderwidth; break; case 'right': x = zrwidth - totalwidth - padding[1] - toolboxoption.borderwidth; break; default: x = toolboxoption.x - 0; x = isnan(x) ? 0 : x; break; } var y; var zrheight = this.zr.getheight(); switch (toolboxoption.y) { case 'top': y = padding[0] + toolboxoption.borderwidth; break; case 'bottom': y = zrheight - totalheight - padding[2] - toolboxoption.borderwidth; break; case 'center': y = math.floor((zrheight - totalheight) / 2); break; default: y = toolboxoption.y - 0; y = isnan(y) ? 0 : y; break; } return { x: x, y: y, width: totalwidth, height: totalheight }; }, __onmousemove: function (param) { if (this._marking) { this._markshape.style.xend = zrevent.getx(param.event); this._markshape.style.yend = zrevent.gety(param.event); this.zr.addhovershape(this._markshape); } if (this._zooming) { this._zoomshape.style.width = zrevent.getx(param.event) - this._zoomshape.style.x; this._zoomshape.style.height = zrevent.gety(param.event) - this._zoomshape.style.y; this.zr.addhovershape(this._zoomshape); this.dom.style.cursor = 'crosshair'; zrevent.stop(param.event); } if (this._zoomstart && (this.dom.style.cursor != 'pointer' && this.dom.style.cursor != 'move')) { this.dom.style.cursor = 'crosshair'; } }, __onmousedown: function (param) { if (param.target) { return; } this._zooming = true; var x = zrevent.getx(param.event); var y = zrevent.gety(param.event); var zoomoption = this.option.datazoom || {}; this._zoomshape = new rectangleshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), style: { x: x, y: y, width: 1, height: 1, brushtype: 'both' }, highlightstyle: { linewidth: 2, color: zoomoption.fillercolor || ecconfig.datazoom.fillercolor, strokecolor: zoomoption.handlecolor || ecconfig.datazoom.handlecolor, brushtype: 'both' } }); this.zr.addhovershape(this._zoomshape); return true; }, __onmouseup: function () { if (!this._zoomshape || math.abs(this._zoomshape.style.width) < 10 || math.abs(this._zoomshape.style.height) < 10) { this._zooming = false; return true; } if (this._zooming && this.component.datazoom) { this._zooming = false; var zoom = this.component.datazoom.rectzoom(this._zoomshape.style); if (zoom) { this._zoomqueue.push({ start: zoom.start, end: zoom.end, start2: zoom.start2, end2: zoom.end2 }); this._iconenable(this._iconshapemap['datazoomreset']); this.zr.refreshnextframe(); } } return true; }, __onclick: function (param) { if (param.target) { return; } if (this._marking) { this._marking = false; this._markshapelist.push(this._markshape); this._iconenable(this._iconshapemap['markundo']); this._iconenable(this._iconshapemap['markclear']); this.zr.addshape(this._markshape); this.zr.refreshnextframe(); } else if (this._markstart) { this._marking = true; var x = zrevent.getx(param.event); var y = zrevent.gety(param.event); this._markshape = new lineshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), style: { xstart: x, ystart: y, xend: x, yend: y, linewidth: this.query(this.option, 'toolbox.feature.mark.linestyle.width'), strokecolor: this.query(this.option, 'toolbox.feature.mark.linestyle.color'), linetype: this.query(this.option, 'toolbox.feature.mark.linestyle.type') } }); this.zr.addhovershape(this._markshape); } }, __onmark: function (param) { var target = param.target; if (this._marking || this._markstart) { this._resetmark(); this.zr.refreshnextframe(); } else { this._resetzoom(); this.zr.modshape(target.id, { style: { strokecolor: this._enablecolor } }); this.zr.refreshnextframe(); this._markstart = true; var self = this; settimeout(function () { self.zr && self.zr.on(zrconfig.event.click, self._onclick) && self.zr.on(zrconfig.event.mousemove, self._onmousemove); }, 10); } return true; }, __onmarkundo: function () { if (this._marking) { this._marking = false; } else { var len = this._markshapelist.length; if (len >= 1) { var target = this._markshapelist[len - 1]; this.zr.delshape(target.id); this.zr.refreshnextframe(); this._markshapelist.pop(); if (len === 1) { this._icondisable(this._iconshapemap['markundo']); this._icondisable(this._iconshapemap['markclear']); } } } return true; }, __onmarkclear: function () { if (this._marking) { this._marking = false; } var len = this._markshapelist.length; if (len > 0) { while (len--) { this.zr.delshape(this._markshapelist.pop().id); } this._icondisable(this._iconshapemap['markundo']); this._icondisable(this._iconshapemap['markclear']); this.zr.refreshnextframe(); } return true; }, __ondatazoom: function (param) { var target = param.target; if (this._zooming || this._zoomstart) { this._resetzoom(); this.zr.refreshnextframe(); this.dom.style.cursor = 'default'; } else { this._resetmark(); this.zr.modshape(target.id, { style: { strokecolor: this._enablecolor } }); this.zr.refreshnextframe(); this._zoomstart = true; var self = this; settimeout(function () { self.zr && self.zr.on(zrconfig.event.mousedown, self._onmousedown) && self.zr.on(zrconfig.event.mouseup, self._onmouseup) && self.zr.on(zrconfig.event.mousemove, self._onmousemove); }, 10); this.dom.style.cursor = 'crosshair'; } return true; }, __ondatazoomreset: function () { if (this._zooming) { this._zooming = false; } this._zoomqueue.pop(); if (this._zoomqueue.length > 0) { this.component.datazoom.absolutezoom(this._zoomqueue[this._zoomqueue.length - 1]); } else { this.component.datazoom.rectzoom(); this._icondisable(this._iconshapemap['datazoomreset']); this.zr.refreshnextframe(); } return true; }, _resetmark: function () { this._marking = false; if (this._markstart) { this._markstart = false; if (this._iconshapemap['mark']) { this.zr.modshape(this._iconshapemap['mark'].id, { style: { strokecolor: this._iconshapemap['mark'].highlightstyle.strokecolor } }); } this.zr.un(zrconfig.event.click, this._onclick); this.zr.un(zrconfig.event.mousemove, this._onmousemove); } }, _resetzoom: function () { this._zooming = false; if (this._zoomstart) { this._zoomstart = false; if (this._iconshapemap['datazoom']) { this.zr.modshape(this._iconshapemap['datazoom'].id, { style: { strokecolor: this._iconshapemap['datazoom'].highlightstyle.strokecolor } }); } this.zr.un(zrconfig.event.mousedown, this._onmousedown); this.zr.un(zrconfig.event.mouseup, this._onmouseup); this.zr.un(zrconfig.event.mousemove, this._onmousemove); } }, _icondisable: function (target) { if (target.type != 'image') { this.zr.modshape(target.id, { hoverable: false, clickable: false, style: { strokecolor: this._disablecolor } }); } else { this.zr.modshape(target.id, { hoverable: false, clickable: false, style: { opacity: 0.3 } }); } }, _iconenable: function (target) { if (target.type != 'image') { this.zr.modshape(target.id, { hoverable: true, clickable: true, style: { strokecolor: target.highlightstyle.strokecolor } }); } else { this.zr.modshape(target.id, { hoverable: true, clickable: true, style: { opacity: 0.8 } }); } }, __ondataview: function () { this._dataview.show(this.option); return true; }, __onrestore: function () { this._resetmark(); this._resetzoom(); this.messagecenter.dispatch(ecconfig.event.restore, null, null, this.mychart); return true; }, __onsaveasimage: function () { var saveoption = this.option.toolbox.feature.saveasimage; var imgtype = saveoption.type || 'png'; if (imgtype != 'png' && imgtype != 'jpeg') { imgtype = 'png'; } var image; if (!this.mychart.isconnected()) { image = this.zr.todataurl('image/' + imgtype, this.option.backgroundcolor && this.option.backgroundcolor.replace(' ', '') === 'rgba(0,0,0,0)' ? '#fff' : this.option.backgroundcolor); } else { image = this.mychart.getconnecteddataurl(imgtype); } var downloaddiv = document.createelement('div'); downloaddiv.id = '__echarts_download_wrap__'; downloaddiv.style.csstext = 'position:fixed;' + 'z-index:99999;' + 'display:block;' + 'top:0;left:0;' + 'background-color:rgba(33,33,33,0.5);' + 'text-align:center;' + 'width:100%;' + 'height:100%;' + 'line-height:' + document.documentelement.clientheight + 'px;'; var downloadlink = document.createelement('a'); downloadlink.href = image; downloadlink.setattribute('download', (saveoption.name ? saveoption.name : this.option.title && (this.option.title.text || this.option.title.subtext) ? this.option.title.text || this.option.title.subtext : 'echarts') + '.' + imgtype); downloadlink.innerhtml = ''; downloaddiv.appendchild(downloadlink); document.body.appendchild(downloaddiv); downloadlink = null; downloaddiv = null; settimeout(function () { var _d = document.getelementbyid('__echarts_download_wrap__'); if (_d) { _d.onclick = function () { var d = document.getelementbyid('__echarts_download_wrap__'); d.onclick = null; d.innerhtml = ''; document.body.removechild(d); d = null; }; _d = null; } }, 500); return; }, __onmagictype: function (param) { this._resetmark(); var itemname = param.target._name; if (!this._magictype[itemname]) { this._magictype[itemname] = true; if (itemname === ecconfig.chart_type_line) { this._magictype[ecconfig.chart_type_bar] = false; } else if (itemname === ecconfig.chart_type_bar) { this._magictype[ecconfig.chart_type_line] = false; } if (itemname === ecconfig.chart_type_pie) { this._magictype[ecconfig.chart_type_funnel] = false; } else if (itemname === ecconfig.chart_type_funnel) { this._magictype[ecconfig.chart_type_pie] = false; } if (itemname === ecconfig.chart_type_force) { this._magictype[ecconfig.chart_type_chord] = false; } else if (itemname === ecconfig.chart_type_chord) { this._magictype[ecconfig.chart_type_force] = false; } if (itemname === _magictype_stack) { this._magictype[_magictype_tiled] = false; } else if (itemname === _magictype_tiled) { this._magictype[_magictype_stack] = false; } this.messagecenter.dispatch(ecconfig.event.magic_type_changed, param.event, { magictype: this._magictype }, this.mychart); } return true; }, setmagictype: function (magictype) { this._resetmark(); this._magictype = magictype; !this._issilence && this.messagecenter.dispatch(ecconfig.event.magic_type_changed, null, { magictype: this._magictype }, this.mychart); }, __oncustomhandler: function (param) { var target = param.target.style.icontype; var featurehandler = this.option.toolbox.feature[target].onclick; if (typeof featurehandler === 'function') { featurehandler.call(this, this.option); } }, reset: function (newoption, isrestore) { isrestore && this.clear(); if (this.query(newoption, 'toolbox.show') && this.query(newoption, 'toolbox.feature.magictype.show')) { var magictype = newoption.toolbox.feature.magictype.type; var len = magictype.length; this._magicmap = {}; while (len--) { this._magicmap[magictype[len]] = true; } len = newoption.series.length; var oritype; var axis; while (len--) { oritype = newoption.series[len].type; if (this._magicmap[oritype]) { axis = newoption.xaxis instanceof array ? newoption.xaxis[newoption.series[len].xaxisindex || 0] : newoption.xaxis; if (axis && (axis.type || 'category') === 'category') { axis.__boundarygap = axis.boundarygap != null ? axis.boundarygap : true; } axis = newoption.yaxis instanceof array ? newoption.yaxis[newoption.series[len].yaxisindex || 0] : newoption.yaxis; if (axis && axis.type === 'category') { axis.__boundarygap = axis.boundarygap != null ? axis.boundarygap : true; } newoption.series[len].__type = oritype; newoption.series[len].__itemstyle = zrutil.clone(newoption.series[len].itemstyle || {}); } if (this._magicmap[_magictype_stack] || this._magicmap[_magictype_tiled]) { newoption.series[len].__stack = newoption.series[len].stack; } } } this._magictype = isrestore ? {} : this._magictype || {}; for (var itemname in this._magictype) { if (this._magictype[itemname]) { this.option = newoption; this.getmagicoption(); break; } } var zoomoption = newoption.datazoom; if (zoomoption && zoomoption.show) { var start = zoomoption.start != null && zoomoption.start >= 0 && zoomoption.start <= 100 ? zoomoption.start : 0; var end = zoomoption.end != null && zoomoption.end >= 0 && zoomoption.end <= 100 ? zoomoption.end : 100; if (start > end) { start = start + end; end = start - end; start = start - end; } this._zoomqueue = [{ start: start, end: end, start2: 0, end2: 100 }]; } else { this._zoomqueue = []; } }, getmagicoption: function () { var axis; var charttype; if (this._magictype[ecconfig.chart_type_line] || this._magictype[ecconfig.chart_type_bar]) { var boundarygap = this._magictype[ecconfig.chart_type_line] ? false : true; for (var i = 0, l = this.option.series.length; i < l; i++) { charttype = this.option.series[i].type; if (charttype == ecconfig.chart_type_line || charttype == ecconfig.chart_type_bar) { axis = this.option.xaxis instanceof array ? this.option.xaxis[this.option.series[i].xaxisindex || 0] : this.option.xaxis; if (axis && (axis.type || 'category') === 'category') { axis.boundarygap = boundarygap ? true : axis.__boundarygap; } axis = this.option.yaxis instanceof array ? this.option.yaxis[this.option.series[i].yaxisindex || 0] : this.option.yaxis; if (axis && axis.type === 'category') { axis.boundarygap = boundarygap ? true : axis.__boundarygap; } } } this._defaultmagic(ecconfig.chart_type_line, ecconfig.chart_type_bar); } this._defaultmagic(ecconfig.chart_type_chord, ecconfig.chart_type_force); this._defaultmagic(ecconfig.chart_type_pie, ecconfig.chart_type_funnel); if (this._magictype[_magictype_stack] || this._magictype[_magictype_tiled]) { for (var i = 0, l = this.option.series.length; i < l; i++) { if (this._magictype[_magictype_stack]) { this.option.series[i].stack = '_echarts_stack_kener_2014_'; charttype = _magictype_stack; } else if (this._magictype[_magictype_tiled]) { this.option.series[i].stack = null; charttype = _magictype_tiled; } if (this._featureoption[charttype + 'chart']) { zrutil.merge(this.option.series[i], this._featureoption[charttype + 'chart'] || {}, true); } } } return this.option; }, _defaultmagic: function (ctype1, ctype2) { if (this._magictype[ctype1] || this._magictype[ctype2]) { for (var i = 0, l = this.option.series.length; i < l; i++) { var charttype = this.option.series[i].type; if (charttype == ctype1 || charttype == ctype2) { this.option.series[i].type = this._magictype[ctype1] ? ctype1 : ctype2; this.option.series[i].itemstyle = zrutil.clone(this.option.series[i].__itemstyle); charttype = this.option.series[i].type; if (this._featureoption[charttype + 'chart']) { zrutil.merge(this.option.series[i], this._featureoption[charttype + 'chart'] || {}, true); } } } } }, silence: function (s) { this._issilence = s; }, resize: function () { this._resetmark(); this.clear(); if (this.option && this.option.toolbox && this.option.toolbox.show) { this._buildshape(); } if (this._dataview) { this._dataview.resize(); } }, hidedataview: function () { if (this._dataview) { this._dataview.hide(); } }, clear: function (notmark) { if (this.zr) { this.zr.delshape(this.shapelist); this.shapelist = []; if (!notmark) { this.zr.delshape(this._markshapelist); this._markshapelist = []; } } }, onbefordispose: function () { if (this._dataview) { this._dataview.dispose(); this._dataview = null; } this._markshapelist = null; }, refresh: function (newoption) { if (newoption) { this._resetmark(); this._resetzoom(); newoption.toolbox = this.reformoption(newoption.toolbox); this.option = newoption; this.clear(true); if (newoption.toolbox.show) { this._buildshape(); } this.hidedataview(); } } }; zrutil.inherits(toolbox, base); require('../component').define('toolbox', toolbox); return toolbox; });define('echarts/component', [], function () { var self = {}; var _componentlibrary = {}; self.define = function (name, clazz) { _componentlibrary[name] = clazz; return self; }; self.get = function (name) { return _componentlibrary[name]; }; return self; });define('echarts/component/title', [ 'require', './base', 'zrender/shape/text', 'zrender/shape/rectangle', '../config', 'zrender/tool/util', 'zrender/tool/area', 'zrender/tool/color', '../component' ], function (require) { var base = require('./base'); var textshape = require('zrender/shape/text'); var rectangleshape = require('zrender/shape/rectangle'); var ecconfig = require('../config'); ecconfig.title = { zlevel: 0, z: 6, show: true, text: '', subtext: '', x: 'left', y: 'top', backgroundcolor: 'rgba(0,0,0,0)', bordercolor: '#ccc', borderwidth: 0, padding: 5, itemgap: 5, textstyle: { fontsize: 18, fontweight: 'bolder', color: '#333' }, subtextstyle: { color: '#aaa' } }; var zrutil = require('zrender/tool/util'); var zrarea = require('zrender/tool/area'); var zrcolor = require('zrender/tool/color'); function title(ectheme, messagecenter, zr, option, mychart) { base.call(this, ectheme, messagecenter, zr, option, mychart); this.refresh(option); } title.prototype = { type: ecconfig.component_type_title, _buildshape: function () { if (!this.titleoption.show) { return; } this._itemgrouplocation = this._getitemgrouplocation(); this._buildbackground(); this._builditem(); for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } }, _builditem: function () { var text = this.titleoption.text; var link = this.titleoption.link; var target = this.titleoption.target; var subtext = this.titleoption.subtext; var sublink = this.titleoption.sublink; var subtarget = this.titleoption.subtarget; var font = this.getfont(this.titleoption.textstyle); var subfont = this.getfont(this.titleoption.subtextstyle); var x = this._itemgrouplocation.x; var y = this._itemgrouplocation.y; var width = this._itemgrouplocation.width; var height = this._itemgrouplocation.height; var textshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), style: { y: y, color: this.titleoption.textstyle.color, text: text, textfont: font, textbaseline: 'top' }, highlightstyle: { color: zrcolor.lift(this.titleoption.textstyle.color, 1), brushtype: 'fill' }, hoverable: false }; if (link) { textshape.hoverable = true; textshape.clickable = true; textshape.onclick = function () { if (!target || target != 'self') { window.open(link); } else { window.location = link; } }; } var subtextshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), style: { y: y + height, color: this.titleoption.subtextstyle.color, text: subtext, textfont: subfont, textbaseline: 'bottom' }, highlightstyle: { color: zrcolor.lift(this.titleoption.subtextstyle.color, 1), brushtype: 'fill' }, hoverable: false }; if (sublink) { subtextshape.hoverable = true; subtextshape.clickable = true; subtextshape.onclick = function () { if (!subtarget || subtarget != 'self') { window.open(sublink); } else { window.location = sublink; } }; } switch (this.titleoption.x) { case 'center': textshape.style.x = subtextshape.style.x = x + width / 2; textshape.style.textalign = subtextshape.style.textalign = 'center'; break; case 'left': textshape.style.x = subtextshape.style.x = x; textshape.style.textalign = subtextshape.style.textalign = 'left'; break; case 'right': textshape.style.x = subtextshape.style.x = x + width; textshape.style.textalign = subtextshape.style.textalign = 'right'; break; default: x = this.titleoption.x - 0; x = isnan(x) ? 0 : x; textshape.style.x = subtextshape.style.x = x; break; } if (this.titleoption.textalign) { textshape.style.textalign = subtextshape.style.textalign = this.titleoption.textalign; } this.shapelist.push(new textshape(textshape)); subtext !== '' && this.shapelist.push(new textshape(subtextshape)); }, _buildbackground: function () { var padding = this.reformcssarray(this.titleoption.padding); this.shapelist.push(new rectangleshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this._itemgrouplocation.x - padding[3], y: this._itemgrouplocation.y - padding[0], width: this._itemgrouplocation.width + padding[3] + padding[1], height: this._itemgrouplocation.height + padding[0] + padding[2], brushtype: this.titleoption.borderwidth === 0 ? 'fill' : 'both', color: this.titleoption.backgroundcolor, strokecolor: this.titleoption.bordercolor, linewidth: this.titleoption.borderwidth } })); }, _getitemgrouplocation: function () { var padding = this.reformcssarray(this.titleoption.padding); var text = this.titleoption.text; var subtext = this.titleoption.subtext; var font = this.getfont(this.titleoption.textstyle); var subfont = this.getfont(this.titleoption.subtextstyle); var totalwidth = math.max(zrarea.gettextwidth(text, font), zrarea.gettextwidth(subtext, subfont)); var totalheight = zrarea.gettextheight(text, font) + (subtext === '' ? 0 : this.titleoption.itemgap + zrarea.gettextheight(subtext, subfont)); var x; var zrwidth = this.zr.getwidth(); switch (this.titleoption.x) { case 'center': x = math.floor((zrwidth - totalwidth) / 2); break; case 'left': x = padding[3] + this.titleoption.borderwidth; break; case 'right': x = zrwidth - totalwidth - padding[1] - this.titleoption.borderwidth; break; default: x = this.titleoption.x - 0; x = isnan(x) ? 0 : x; break; } var y; var zrheight = this.zr.getheight(); switch (this.titleoption.y) { case 'top': y = padding[0] + this.titleoption.borderwidth; break; case 'bottom': y = zrheight - totalheight - padding[2] - this.titleoption.borderwidth; break; case 'center': y = math.floor((zrheight - totalheight) / 2); break; default: y = this.titleoption.y - 0; y = isnan(y) ? 0 : y; break; } return { x: x, y: y, width: totalwidth, height: totalheight }; }, refresh: function (newoption) { if (newoption) { this.option = newoption; this.option.title = this.reformoption(this.option.title); this.titleoption = this.option.title; this.titleoption.textstyle = this.gettextstyle(this.titleoption.textstyle); this.titleoption.subtextstyle = this.gettextstyle(this.titleoption.subtextstyle); } this.clear(); this._buildshape(); } }; zrutil.inherits(title, base); require('../component').define('title', title); return title; });define('echarts/component/tooltip', [ 'require', './base', '../util/shape/cross', 'zrender/shape/line', 'zrender/shape/rectangle', '../config', '../util/ecdata', 'zrender/config', 'zrender/tool/event', 'zrender/tool/area', 'zrender/tool/color', 'zrender/tool/util', 'zrender/shape/base', '../component' ], function (require) { var base = require('./base'); var crossshape = require('../util/shape/cross'); var lineshape = require('zrender/shape/line'); var rectangleshape = require('zrender/shape/rectangle'); var rectangleinstance = new rectangleshape({}); var ecconfig = require('../config'); ecconfig.tooltip = { zlevel: 1, z: 8, show: true, showcontent: true, trigger: 'item', islandformatter: '{a}
{b} : {c}', showdelay: 20, hidedelay: 100, transitionduration: 0.4, enterable: false, backgroundcolor: 'rgba(0,0,0,0.7)', bordercolor: '#333', borderradius: 4, borderwidth: 0, padding: 5, axispointer: { type: 'line', linestyle: { color: '#48b', width: 2, type: 'solid' }, crossstyle: { color: '#1e90ff', width: 1, type: 'dashed' }, shadowstyle: { color: 'rgba(150,150,150,0.3)', width: 'auto', type: 'default' } }, textstyle: { color: '#fff' } }; var ecdata = require('../util/ecdata'); var zrconfig = require('zrender/config'); var zrevent = require('zrender/tool/event'); var zrarea = require('zrender/tool/area'); var zrcolor = require('zrender/tool/color'); var zrutil = require('zrender/tool/util'); var zrshapebase = require('zrender/shape/base'); function tooltip(ectheme, messagecenter, zr, option, mychart) { base.call(this, ectheme, messagecenter, zr, option, mychart); this.dom = mychart.dom; var self = this; self._onmousemove = function (param) { return self.__onmousemove(param); }; self._onglobalout = function (param) { return self.__onglobalout(param); }; this.zr.on(zrconfig.event.mousemove, self._onmousemove); this.zr.on(zrconfig.event.globalout, self._onglobalout); self._hide = function (param) { return self.__hide(param); }; self._tryshow = function (param) { return self.__tryshow(param); }; self._refixed = function (param) { return self.__refixed(param); }; self._setcontent = function (ticket, res) { return self.__setcontent(ticket, res); }; this._tdom = this._tdom || document.createelement('div'); this._tdom.onselectstart = function () { return false; }; this._tdom.onmouseover = function () { self._mousein = true; }; this._tdom.onmouseout = function () { self._mousein = false; }; this._tdom.classname = 'echarts-tooltip'; this._tdom.style.position = 'absolute'; this.hasappend = false; this._axislineshape && this.zr.delshape(this._axislineshape.id); this._axislineshape = new lineshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), invisible: true, hoverable: false }); this.shapelist.push(this._axislineshape); this.zr.addshape(this._axislineshape); this._axisshadowshape && this.zr.delshape(this._axisshadowshape.id); this._axisshadowshape = new lineshape({ zlevel: this.getzlevelbase(), z: 1, invisible: true, hoverable: false }); this.shapelist.push(this._axisshadowshape); this.zr.addshape(this._axisshadowshape); this._axiscrossshape && this.zr.delshape(this._axiscrossshape.id); this._axiscrossshape = new crossshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), invisible: true, hoverable: false }); this.shapelist.push(this._axiscrossshape); this.zr.addshape(this._axiscrossshape); this.showing = false; this.refresh(option); } tooltip.prototype = { type: ecconfig.component_type_tooltip, _gcsstext: 'position:absolute;display:block;border-style:solid;white-space:nowrap;', _style: function (opt) { if (!opt) { return ''; } var csstext = []; if (opt.transitionduration) { var transitiontext = 'left ' + opt.transitionduration + 's,' + 'top ' + opt.transitionduration + 's'; csstext.push('transition:' + transitiontext); csstext.push('-moz-transition:' + transitiontext); csstext.push('-webkit-transition:' + transitiontext); csstext.push('-o-transition:' + transitiontext); } if (opt.backgroundcolor) { csstext.push('background-color:' + zrcolor.tohex(opt.backgroundcolor)); csstext.push('filter:alpha(opacity=70)'); csstext.push('background-color:' + opt.backgroundcolor); } if (opt.borderwidth != null) { csstext.push('border-width:' + opt.borderwidth + 'px'); } if (opt.bordercolor != null) { csstext.push('border-color:' + opt.bordercolor); } if (opt.borderradius != null) { csstext.push('border-radius:' + opt.borderradius + 'px'); csstext.push('-moz-border-radius:' + opt.borderradius + 'px'); csstext.push('-webkit-border-radius:' + opt.borderradius + 'px'); csstext.push('-o-border-radius:' + opt.borderradius + 'px'); } var textstyle = opt.textstyle; if (textstyle) { textstyle.color && csstext.push('color:' + textstyle.color); textstyle.decoration && csstext.push('text-decoration:' + textstyle.decoration); textstyle.align && csstext.push('text-align:' + textstyle.align); textstyle.fontfamily && csstext.push('font-family:' + textstyle.fontfamily); textstyle.fontsize && csstext.push('font-size:' + textstyle.fontsize + 'px'); textstyle.fontsize && csstext.push('line-height:' + math.round(textstyle.fontsize * 3 / 2) + 'px'); textstyle.fontstyle && csstext.push('font-style:' + textstyle.fontstyle); textstyle.fontweight && csstext.push('font-weight:' + textstyle.fontweight); } var padding = opt.padding; if (padding != null) { padding = this.reformcssarray(padding); csstext.push('padding:' + padding[0] + 'px ' + padding[1] + 'px ' + padding[2] + 'px ' + padding[3] + 'px'); } csstext = csstext.join(';') + ';'; return csstext; }, __hide: function () { this._lastdataindex = -1; this._lastseriesindex = -1; this._lastitemtriggerid = -1; if (this._tdom) { this._tdom.style.display = 'none'; } var needrefresh = false; if (!this._axislineshape.invisible) { this._axislineshape.invisible = true; this.zr.modshape(this._axislineshape.id); needrefresh = true; } if (!this._axisshadowshape.invisible) { this._axisshadowshape.invisible = true; this.zr.modshape(this._axisshadowshape.id); needrefresh = true; } if (!this._axiscrossshape.invisible) { this._axiscrossshape.invisible = true; this.zr.modshape(this._axiscrossshape.id); needrefresh = true; } if (this._lasttipshape && this._lasttipshape.tipshape.length > 0) { this.zr.delshape(this._lasttipshape.tipshape); this._lasttipshape = false; this.shapelist.length = 2; } needrefresh && this.zr.refreshnextframe(); this.showing = false; }, _show: function (position, x, y, specialcsstext) { var domheight = this._tdom.offsetheight; var domwidth = this._tdom.offsetwidth; if (position) { if (typeof position === 'function') { position = position([ x, y ]); } if (position instanceof array) { x = position[0]; y = position[1]; } } if (x + domwidth > this._zrwidth) { x -= domwidth + 40; } if (y + domheight > this._zrheight) { y -= domheight - 20; } if (y < 20) { y = 0; } this._tdom.style.csstext = this._gcsstext + this._defaultcsstext + (specialcsstext ? specialcsstext : '') + 'left:' + x + 'px;top:' + y + 'px;'; if (domheight < 10 || domwidth < 10) { settimeout(this._refixed, 20); } this.showing = true; }, __refixed: function () { if (this._tdom) { var csstext = ''; var domheight = this._tdom.offsetheight; var domwidth = this._tdom.offsetwidth; if (this._tdom.offsetleft + domwidth > this._zrwidth) { csstext += 'left:' + (this._zrwidth - domwidth - 20) + 'px;'; } if (this._tdom.offsettop + domheight > this._zrheight) { csstext += 'top:' + (this._zrheight - domheight - 10) + 'px;'; } if (csstext !== '') { this._tdom.style.csstext += csstext; } } }, __tryshow: function () { var needshow; var trigger; if (!this._curtarget) { this._findpolartrigger() || this._findaxistrigger(); } else { if (this._curtarget._type === 'island' && this.option.tooltip.show) { this._showitemtrigger(); return; } var serie = ecdata.get(this._curtarget, 'series'); var data = ecdata.get(this._curtarget, 'data'); needshow = this.deepquery([ data, serie, this.option ], 'tooltip.show'); if (serie == null || data == null || !needshow) { cleartimeout(this._hidingticket); cleartimeout(this._showingticket); this._hidingticket = settimeout(this._hide, this._hidedelay); } else { trigger = this.deepquery([ data, serie, this.option ], 'tooltip.trigger'); trigger === 'axis' ? this._showaxistrigger(serie.xaxisindex, serie.yaxisindex, ecdata.get(this._curtarget, 'dataindex')) : this._showitemtrigger(); } } }, _findaxistrigger: function () { if (!this.component.xaxis || !this.component.yaxis) { this._hidingticket = settimeout(this._hide, this._hidedelay); return; } var series = this.option.series; var xaxisindex; var yaxisindex; for (var i = 0, l = series.length; i < l; i++) { if (this.deepquery([ series[i], this.option ], 'tooltip.trigger') === 'axis') { xaxisindex = series[i].xaxisindex || 0; yaxisindex = series[i].yaxisindex || 0; if (this.component.xaxis.getaxis(xaxisindex) && this.component.xaxis.getaxis(xaxisindex).type === ecconfig.component_type_axis_category) { this._showaxistrigger(xaxisindex, yaxisindex, this._getnearestdataindex('x', this.component.xaxis.getaxis(xaxisindex))); return; } else if (this.component.yaxis.getaxis(yaxisindex) && this.component.yaxis.getaxis(yaxisindex).type === ecconfig.component_type_axis_category) { this._showaxistrigger(xaxisindex, yaxisindex, this._getnearestdataindex('y', this.component.yaxis.getaxis(yaxisindex))); return; } else { this._showaxistrigger(xaxisindex, yaxisindex, -1); return; } } } if (this.option.tooltip.axispointer.type === 'cross') { this._showaxistrigger(-1, -1, -1); } }, _findpolartrigger: function () { if (!this.component.polar) { return false; } var x = zrevent.getx(this._event); var y = zrevent.gety(this._event); var polarindex = this.component.polar.getnearestindex([ x, y ]); var valueindex; if (polarindex) { valueindex = polarindex.valueindex; polarindex = polarindex.polarindex; } else { polarindex = -1; } if (polarindex != -1) { return this._showpolartrigger(polarindex, valueindex); } return false; }, _getnearestdataindex: function (direction, categoryaxis) { var dataindex = -1; var x = zrevent.getx(this._event); var y = zrevent.gety(this._event); if (direction === 'x') { var left; var right; var xend = this.component.grid.getxend(); var curcoord = categoryaxis.getcoordbyindex(dataindex); while (curcoord < xend) { right = curcoord; if (curcoord <= x) { left = curcoord; } else { break; } curcoord = categoryaxis.getcoordbyindex(++dataindex); } if (dataindex <= 0) { dataindex = 0; } else if (x - left <= right - x) { dataindex -= 1; } else { if (categoryaxis.getnamebyindex(dataindex) == null) { dataindex -= 1; } } return dataindex; } else { var top; var bottom; var ystart = this.component.grid.gety(); var curcoord = categoryaxis.getcoordbyindex(dataindex); while (curcoord > ystart) { top = curcoord; if (curcoord >= y) { bottom = curcoord; } else { break; } curcoord = categoryaxis.getcoordbyindex(++dataindex); } if (dataindex <= 0) { dataindex = 0; } else if (y - top >= bottom - y) { dataindex -= 1; } else { if (categoryaxis.getnamebyindex(dataindex) == null) { dataindex -= 1; } } return dataindex; } return -1; }, _showaxistrigger: function (xaxisindex, yaxisindex, dataindex) { !this._event.connecttrigger && this.messagecenter.dispatch(ecconfig.event.tooltip_in_grid, this._event, null, this.mychart); if (this.component.xaxis == null || this.component.yaxis == null || xaxisindex == null || yaxisindex == null) { cleartimeout(this._hidingticket); cleartimeout(this._showingticket); this._hidingticket = settimeout(this._hide, this._hidedelay); return; } var series = this.option.series; var seriesarray = []; var seriesindex = []; var categoryaxis; var formatter; var position; var showcontent; var specialcsstext = ''; if (this.option.tooltip.trigger === 'axis') { if (!this.option.tooltip.show) { return; } formatter = this.option.tooltip.formatter; position = this.option.tooltip.position; } var axislayout = xaxisindex != -1 && this.component.xaxis.getaxis(xaxisindex).type === ecconfig.component_type_axis_category ? 'xaxis' : yaxisindex != -1 && this.component.yaxis.getaxis(yaxisindex).type === ecconfig.component_type_axis_category ? 'yaxis' : false; var x; var y; if (axislayout) { var axisindex = axislayout == 'xaxis' ? xaxisindex : yaxisindex; categoryaxis = this.component[axislayout].getaxis(axisindex); for (var i = 0, l = series.length; i < l; i++) { if (!this._isselected(series[i].name)) { continue; } if (series[i][axislayout + 'index'] === axisindex && this.deepquery([ series[i], this.option ], 'tooltip.trigger') === 'axis') { showcontent = this.query(series[i], 'tooltip.showcontent') || showcontent; formatter = this.query(series[i], 'tooltip.formatter') || formatter; position = this.query(series[i], 'tooltip.position') || position; specialcsstext += this._style(this.query(series[i], 'tooltip')); if (series[i].stack != null && axislayout == 'xaxis') { seriesarray.unshift(series[i]); seriesindex.unshift(i); } else { seriesarray.push(series[i]); seriesindex.push(i); } } } this.messagecenter.dispatch(ecconfig.event.tooltip_hover, this._event, { seriesindex: seriesindex, dataindex: dataindex }, this.mychart); var rect; if (axislayout == 'xaxis') { x = this.subpixeloptimize(categoryaxis.getcoordbyindex(dataindex), this._axislinewidth); y = zrevent.gety(this._event); rect = [ x, this.component.grid.gety(), x, this.component.grid.getyend() ]; } else { x = zrevent.getx(this._event); y = this.subpixeloptimize(categoryaxis.getcoordbyindex(dataindex), this._axislinewidth); rect = [ this.component.grid.getx(), y, this.component.grid.getxend(), y ]; } this._styleaxispointer(seriesarray, rect[0], rect[1], rect[2], rect[3], categoryaxis.getgap(), x, y); } else { x = zrevent.getx(this._event); y = zrevent.gety(this._event); this._styleaxispointer(series, this.component.grid.getx(), y, this.component.grid.getxend(), y, 0, x, y); if (dataindex >= 0) { this._showitemtrigger(true); } else { cleartimeout(this._hidingticket); cleartimeout(this._showingticket); this._tdom.style.display = 'none'; } } if (seriesarray.length > 0) { this._lastitemtriggerid = -1; if (this._lastdataindex != dataindex || this._lastseriesindex != seriesindex[0]) { this._lastdataindex = dataindex; this._lastseriesindex = seriesindex[0]; var data; var value; if (typeof formatter === 'function') { var params = []; for (var i = 0, l = seriesarray.length; i < l; i++) { data = seriesarray[i].data[dataindex]; value = this.getdatafromoption(data, '-'); params.push({ seriesindex: seriesindex[i], seriesname: seriesarray[i].name || '', series: seriesarray[i], dataindex: dataindex, data: data, name: categoryaxis.getnamebyindex(dataindex), value: value, 0: seriesarray[i].name || '', 1: categoryaxis.getnamebyindex(dataindex), 2: value, 3: data }); } this._curticket = 'axis:' + dataindex; this._tdom.innerhtml = formatter.call(this.mychart, params, this._curticket, this._setcontent); } else if (typeof formatter === 'string') { this._curticket = nan; formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}'); for (var i = 0, l = seriesarray.length; i < l; i++) { formatter = formatter.replace('{a' + i + '}', this._encodehtml(seriesarray[i].name || '')); formatter = formatter.replace('{b' + i + '}', this._encodehtml(categoryaxis.getnamebyindex(dataindex))); data = seriesarray[i].data[dataindex]; data = this.getdatafromoption(data, '-'); formatter = formatter.replace('{c' + i + '}', data instanceof array ? data : this.numaddcommas(data)); } this._tdom.innerhtml = formatter; } else { this._curticket = nan; formatter = this._encodehtml(categoryaxis.getnamebyindex(dataindex)); for (var i = 0, l = seriesarray.length; i < l; i++) { formatter += '
' + this._encodehtml(seriesarray[i].name || '') + ' : '; data = seriesarray[i].data[dataindex]; data = this.getdatafromoption(data, '-'); formatter += data instanceof array ? data : this.numaddcommas(data); } this._tdom.innerhtml = formatter; } } if (showcontent === false || !this.option.tooltip.showcontent) { return; } if (!this.hasappend) { this._tdom.style.left = this._zrwidth / 2 + 'px'; this._tdom.style.top = this._zrheight / 2 + 'px'; this.dom.firstchild.appendchild(this._tdom); this.hasappend = true; } this._show(position, x + 10, y + 10, specialcsstext); } }, _showpolartrigger: function (polarindex, dataindex) { if (this.component.polar == null || polarindex == null || dataindex == null || dataindex < 0) { return false; } var series = this.option.series; var seriesarray = []; var seriesindex = []; var formatter; var position; var showcontent; var specialcsstext = ''; if (this.option.tooltip.trigger === 'axis') { if (!this.option.tooltip.show) { return false; } formatter = this.option.tooltip.formatter; position = this.option.tooltip.position; } var indicatorname = this.option.polar[polarindex].indicator[dataindex].text; for (var i = 0, l = series.length; i < l; i++) { if (!this._isselected(series[i].name)) { continue; } if (series[i].polarindex === polarindex && this.deepquery([ series[i], this.option ], 'tooltip.trigger') === 'axis') { showcontent = this.query(series[i], 'tooltip.showcontent') || showcontent; formatter = this.query(series[i], 'tooltip.formatter') || formatter; position = this.query(series[i], 'tooltip.position') || position; specialcsstext += this._style(this.query(series[i], 'tooltip')); seriesarray.push(series[i]); seriesindex.push(i); } } if (seriesarray.length > 0) { var polardata; var data; var value; var params = []; for (var i = 0, l = seriesarray.length; i < l; i++) { polardata = seriesarray[i].data; for (var j = 0, k = polardata.length; j < k; j++) { data = polardata[j]; if (!this._isselected(data.name)) { continue; } data = data != null ? data : { name: '', value: { dataindex: '-' } }; value = this.getdatafromoption(data.value[dataindex]); params.push({ seriesindex: seriesindex[i], seriesname: seriesarray[i].name || '', series: seriesarray[i], dataindex: dataindex, data: data, name: data.name, indicator: indicatorname, value: value, 0: seriesarray[i].name || '', 1: data.name, 2: value, 3: indicatorname }); } } if (params.length <= 0) { return; } this._lastitemtriggerid = -1; if (this._lastdataindex != dataindex || this._lastseriesindex != seriesindex[0]) { this._lastdataindex = dataindex; this._lastseriesindex = seriesindex[0]; if (typeof formatter === 'function') { this._curticket = 'axis:' + dataindex; this._tdom.innerhtml = formatter.call(this.mychart, params, this._curticket, this._setcontent); } else if (typeof formatter === 'string') { formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}').replace('{d}', '{d0}'); for (var i = 0, l = params.length; i < l; i++) { formatter = formatter.replace('{a' + i + '}', this._encodehtml(params[i].seriesname)); formatter = formatter.replace('{b' + i + '}', this._encodehtml(params[i].name)); formatter = formatter.replace('{c' + i + '}', this.numaddcommas(params[i].value)); formatter = formatter.replace('{d' + i + '}', this._encodehtml(params[i].indicator)); } this._tdom.innerhtml = formatter; } else { formatter = this._encodehtml(params[0].name) + '
' + this._encodehtml(params[0].indicator) + ' : ' + this.numaddcommas(params[0].value); for (var i = 1, l = params.length; i < l; i++) { formatter += '
' + this._encodehtml(params[i].name) + '
'; formatter += this._encodehtml(params[i].indicator) + ' : ' + this.numaddcommas(params[i].value); } this._tdom.innerhtml = formatter; } } if (showcontent === false || !this.option.tooltip.showcontent) { return; } if (!this.hasappend) { this._tdom.style.left = this._zrwidth / 2 + 'px'; this._tdom.style.top = this._zrheight / 2 + 'px'; this.dom.firstchild.appendchild(this._tdom); this.hasappend = true; } this._show(position, zrevent.getx(this._event), zrevent.gety(this._event), specialcsstext); return true; } }, _showitemtrigger: function (axistrigger) { if (!this._curtarget) { return; } var serie = ecdata.get(this._curtarget, 'series'); var seriesindex = ecdata.get(this._curtarget, 'seriesindex'); var data = ecdata.get(this._curtarget, 'data'); var dataindex = ecdata.get(this._curtarget, 'dataindex'); var name = ecdata.get(this._curtarget, 'name'); var value = ecdata.get(this._curtarget, 'value'); var special = ecdata.get(this._curtarget, 'special'); var special2 = ecdata.get(this._curtarget, 'special2'); var querytarget = [ data, serie, this.option ]; var formatter; var position; var showcontent; var specialcsstext = ''; if (this._curtarget._type != 'island') { var trigger = axistrigger ? 'axis' : 'item'; if (this.option.tooltip.trigger === trigger) { formatter = this.option.tooltip.formatter; position = this.option.tooltip.position; } if (this.query(serie, 'tooltip.trigger') === trigger) { showcontent = this.query(serie, 'tooltip.showcontent') || showcontent; formatter = this.query(serie, 'tooltip.formatter') || formatter; position = this.query(serie, 'tooltip.position') || position; specialcsstext += this._style(this.query(serie, 'tooltip')); } showcontent = this.query(data, 'tooltip.showcontent') || showcontent; formatter = this.query(data, 'tooltip.formatter') || formatter; position = this.query(data, 'tooltip.position') || position; specialcsstext += this._style(this.query(data, 'tooltip')); } else { this._lastitemtriggerid = nan; showcontent = this.deepquery(querytarget, 'tooltip.showcontent'); formatter = this.deepquery(querytarget, 'tooltip.islandformatter'); position = this.deepquery(querytarget, 'tooltip.islandposition'); } this._lastdataindex = -1; this._lastseriesindex = -1; if (this._lastitemtriggerid !== this._curtarget.id) { this._lastitemtriggerid = this._curtarget.id; if (typeof formatter === 'function') { this._curticket = (serie.name || '') + ':' + dataindex; this._tdom.innerhtml = formatter.call(this.mychart, { seriesindex: seriesindex, seriesname: serie.name || '', series: serie, dataindex: dataindex, data: data, name: name, value: value, percent: special, indicator: special, value2: special2, indicator2: special2, 0: serie.name || '', 1: name, 2: value, 3: special, 4: special2, 5: data, 6: seriesindex, 7: dataindex }, this._curticket, this._setcontent); } else if (typeof formatter === 'string') { this._curticket = nan; formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}'); formatter = formatter.replace('{a0}', this._encodehtml(serie.name || '')).replace('{b0}', this._encodehtml(name)).replace('{c0}', value instanceof array ? value : this.numaddcommas(value)); formatter = formatter.replace('{d}', '{d0}').replace('{d0}', special || ''); formatter = formatter.replace('{e}', '{e0}').replace('{e0}', ecdata.get(this._curtarget, 'special2') || ''); this._tdom.innerhtml = formatter; } else { this._curticket = nan; if (serie.type === ecconfig.chart_type_radar && special) { this._tdom.innerhtml = this._itemformatter.radar.call(this, serie, name, value, special); } else if (serie.type === ecconfig.chart_type_eventriver) { this._tdom.innerhtml = this._itemformatter.eventriver.call(this, serie, name, value, data); } else { this._tdom.innerhtml = '' + (serie.name != null ? this._encodehtml(serie.name) + '
' : '') + (name === '' ? '' : this._encodehtml(name) + ' : ') + (value instanceof array ? value : this.numaddcommas(value)); } } } var x = zrevent.getx(this._event); var y = zrevent.gety(this._event); if (this.deepquery(querytarget, 'tooltip.axispointer.show') && this.component.grid) { this._styleaxispointer([serie], this.component.grid.getx(), y, this.component.grid.getxend(), y, 0, x, y); } else { this._hide(); } if (showcontent === false || !this.option.tooltip.showcontent) { return; } if (!this.hasappend) { this._tdom.style.left = this._zrwidth / 2 + 'px'; this._tdom.style.top = this._zrheight / 2 + 'px'; this.dom.firstchild.appendchild(this._tdom); this.hasappend = true; } this._show(position, x + 20, y - 20, specialcsstext); }, _itemformatter: { radar: function (serie, name, value, indicator) { var html = ''; html += this._encodehtml(name === '' ? serie.name || '' : name); html += html === '' ? '' : '
'; for (var i = 0; i < indicator.length; i++) { html += this._encodehtml(indicator[i].text) + ' : ' + this.numaddcommas(value[i]) + '
'; } return html; }, chord: function (serie, name, value, special, special2) { if (special2 == null) { return this._encodehtml(name) + ' (' + this.numaddcommas(value) + ')'; } else { var name1 = this._encodehtml(name); var name2 = this._encodehtml(special); return '' + (serie.name != null ? this._encodehtml(serie.name) + '
' : '') + name1 + ' -> ' + name2 + ' (' + this.numaddcommas(value) + ')' + '
' + name2 + ' -> ' + name1 + ' (' + this.numaddcommas(special2) + ')'; } }, eventriver: function (serie, name, value, data) { var html = ''; html += this._encodehtml(serie.name === '' ? '' : serie.name + ' : '); html += this._encodehtml(name); html += html === '' ? '' : '
'; data = data.evolution; for (var i = 0, l = data.length; i < l; i++) { html += '
'; if (!data[i].detail) { continue; } if (data[i].detail.img) { html += ''; } html += '
' + data[i].time + '
'; html += ''; html += data[i].detail.text + '
'; html += '
'; } return html; } }, _styleaxispointer: function (seriesarray, xstart, ystart, xend, yend, gap, x, y) { if (seriesarray.length > 0) { var querytarget; var curtype; var axispointer = this.option.tooltip.axispointer; var pointtype = axispointer.type; var style = { line: {}, cross: {}, shadow: {} }; for (var ptype in style) { style[ptype].color = axispointer[ptype + 'style'].color; style[ptype].width = axispointer[ptype + 'style'].width; style[ptype].type = axispointer[ptype + 'style'].type; } for (var i = 0, l = seriesarray.length; i < l; i++) { querytarget = seriesarray[i]; curtype = this.query(querytarget, 'tooltip.axispointer.type'); pointtype = curtype || pointtype; if (curtype) { style[curtype].color = this.query(querytarget, 'tooltip.axispointer.' + curtype + 'style.color') || style[curtype].color; style[curtype].width = this.query(querytarget, 'tooltip.axispointer.' + curtype + 'style.width') || style[curtype].width; style[curtype].type = this.query(querytarget, 'tooltip.axispointer.' + curtype + 'style.type') || style[curtype].type; } } if (pointtype === 'line') { var linewidth = style.line.width; var isvertical = xstart == xend; this._axislineshape.style = { xstart: isvertical ? this.subpixeloptimize(xstart, linewidth) : xstart, ystart: isvertical ? ystart : this.subpixeloptimize(ystart, linewidth), xend: isvertical ? this.subpixeloptimize(xend, linewidth) : xend, yend: isvertical ? yend : this.subpixeloptimize(yend, linewidth), strokecolor: style.line.color, linewidth: linewidth, linetype: style.line.type }; this._axislineshape.invisible = false; this.zr.modshape(this._axislineshape.id); } else if (pointtype === 'cross') { var crosswidth = style.cross.width; this._axiscrossshape.style = { brushtype: 'stroke', rect: this.component.grid.getarea(), x: this.subpixeloptimize(x, crosswidth), y: this.subpixeloptimize(y, crosswidth), text: ('( ' + this.component.xaxis.getaxis(0).getvaluefromcoord(x) + ' , ' + this.component.yaxis.getaxis(0).getvaluefromcoord(y) + ' )').replace(' , ', ' ').replace(' , ', ' '), textposition: 'specific', strokecolor: style.cross.color, linewidth: crosswidth, linetype: style.cross.type }; if (this.component.grid.getxend() - x > 100) { this._axiscrossshape.style.textalign = 'left'; this._axiscrossshape.style.textx = x + 10; } else { this._axiscrossshape.style.textalign = 'right'; this._axiscrossshape.style.textx = x - 10; } if (y - this.component.grid.gety() > 50) { this._axiscrossshape.style.textbaseline = 'bottom'; this._axiscrossshape.style.texty = y - 10; } else { this._axiscrossshape.style.textbaseline = 'top'; this._axiscrossshape.style.texty = y + 10; } this._axiscrossshape.invisible = false; this.zr.modshape(this._axiscrossshape.id); } else if (pointtype === 'shadow') { if (style.shadow.width == null || style.shadow.width === 'auto' || isnan(style.shadow.width)) { style.shadow.width = gap; } if (xstart === xend) { if (math.abs(this.component.grid.getx() - xstart) < 2) { style.shadow.width /= 2; xstart = xend = xend + style.shadow.width / 2; } else if (math.abs(this.component.grid.getxend() - xstart) < 2) { style.shadow.width /= 2; xstart = xend = xend - style.shadow.width / 2; } } else if (ystart === yend) { if (math.abs(this.component.grid.gety() - ystart) < 2) { style.shadow.width /= 2; ystart = yend = yend + style.shadow.width / 2; } else if (math.abs(this.component.grid.getyend() - ystart) < 2) { style.shadow.width /= 2; ystart = yend = yend - style.shadow.width / 2; } } this._axisshadowshape.style = { xstart: xstart, ystart: ystart, xend: xend, yend: yend, strokecolor: style.shadow.color, linewidth: style.shadow.width }; this._axisshadowshape.invisible = false; this.zr.modshape(this._axisshadowshape.id); } this.zr.refreshnextframe(); } }, __onmousemove: function (param) { cleartimeout(this._hidingticket); cleartimeout(this._showingticket); if (this._mousein && this._enterable) { return; } var target = param.target; var mx = zrevent.getx(param.event); var my = zrevent.gety(param.event); if (!target) { this._curtarget = false; this._event = param.event; this._event.zrenderx = mx; this._event.zrendery = my; if (this._needaxistrigger && this.component.grid && zrarea.isinside(rectangleinstance, this.component.grid.getarea(), mx, my)) { this._showingticket = settimeout(this._tryshow, this._showdelay); } else if (this._needaxistrigger && this.component.polar && this.component.polar.isinside([ mx, my ]) != -1) { this._showingticket = settimeout(this._tryshow, this._showdelay); } else { !this._event.connecttrigger && this.messagecenter.dispatch(ecconfig.event.tooltip_out_grid, this._event, null, this.mychart); this._hidingticket = settimeout(this._hide, this._hidedelay); } } else { this._curtarget = target; this._event = param.event; this._event.zrenderx = mx; this._event.zrendery = my; var polarindex; if (this._needaxistrigger && this.component.polar && (polarindex = this.component.polar.isinside([ mx, my ])) != -1) { var series = this.option.series; for (var i = 0, l = series.length; i < l; i++) { if (series[i].polarindex === polarindex && this.deepquery([ series[i], this.option ], 'tooltip.trigger') === 'axis') { this._curtarget = null; break; } } } this._showingticket = settimeout(this._tryshow, this._showdelay); } }, __onglobalout: function () { cleartimeout(this._hidingticket); cleartimeout(this._showingticket); this._hidingticket = settimeout(this._hide, this._hidedelay); }, __setcontent: function (ticket, content) { if (!this._tdom) { return; } if (ticket === this._curticket) { this._tdom.innerhtml = content; } settimeout(this._refixed, 20); }, ontooltiphover: function (param, tipshape) { if (!this._lasttipshape || this._lasttipshape && this._lasttipshape.dataindex != param.dataindex) { if (this._lasttipshape && this._lasttipshape.tipshape.length > 0) { this.zr.delshape(this._lasttipshape.tipshape); this.shapelist.length = 2; } for (var i = 0, l = tipshape.length; i < l; i++) { tipshape[i].zlevel = this.getzlevelbase(); tipshape[i].z = this.getzbase(); tipshape[i].style = zrshapebase.prototype.gethighlightstyle(tipshape[i].style, tipshape[i].highlightstyle); tipshape[i].draggable = false; tipshape[i].hoverable = false; tipshape[i].clickable = false; tipshape[i].ondragend = null; tipshape[i].ondragover = null; tipshape[i].ondrop = null; this.shapelist.push(tipshape[i]); this.zr.addshape(tipshape[i]); } this._lasttipshape = { dataindex: param.dataindex, tipshape: tipshape }; } }, ondragend: function () { this._hide(); }, onlegendselected: function (param) { this._selectedmap = param.selected; }, _setselectedmap: function () { if (this.component.legend) { this._selectedmap = zrutil.clone(this.component.legend.getselectedmap()); } else { this._selectedmap = {}; } }, _isselected: function (itemname) { if (this._selectedmap[itemname] != null) { return this._selectedmap[itemname]; } else { return true; } }, showtip: function (params) { if (!params) { return; } var seriesindex; var series = this.option.series; if (params.seriesindex != null) { seriesindex = params.seriesindex; } else { var seriesname = params.seriesname; for (var i = 0, l = series.length; i < l; i++) { if (series[i].name === seriesname) { seriesindex = i; break; } } } var serie = series[seriesindex]; if (serie == null) { return; } var chart = this.mychart.chart[serie.type]; var isaxistrigger = this.deepquery([ serie, this.option ], 'tooltip.trigger') === 'axis'; if (!chart) { return; } if (isaxistrigger) { var dataindex = params.dataindex; switch (chart.type) { case ecconfig.chart_type_line: case ecconfig.chart_type_bar: case ecconfig.chart_type_k: case ecconfig.chart_type_radar: if (this.component.polar == null || serie.data[0].value.length <= dataindex) { return; } var polarindex = serie.polarindex || 0; var vector = this.component.polar.getvector(polarindex, dataindex, 'max'); this._event = { zrenderx: vector[0], zrendery: vector[1] }; this._showpolartrigger(polarindex, dataindex); break; } } else { var shapelist = chart.shapelist; var x; var y; switch (chart.type) { case ecconfig.chart_type_line: case ecconfig.chart_type_bar: case ecconfig.chart_type_k: case ecconfig.chart_type_treemap: case ecconfig.chart_type_scatter: var dataindex = params.dataindex; for (var i = 0, l = shapelist.length; i < l; i++) { if (shapelist[i]._mark == null && ecdata.get(shapelist[i], 'seriesindex') == seriesindex && ecdata.get(shapelist[i], 'dataindex') == dataindex) { this._curtarget = shapelist[i]; x = shapelist[i].style.x; y = chart.type != ecconfig.chart_type_k ? shapelist[i].style.y : shapelist[i].style.y[0]; break; } } break; case ecconfig.chart_type_radar: var dataindex = params.dataindex; for (var i = 0, l = shapelist.length; i < l; i++) { if (shapelist[i].type === 'polygon' && ecdata.get(shapelist[i], 'seriesindex') == seriesindex && ecdata.get(shapelist[i], 'dataindex') == dataindex) { this._curtarget = shapelist[i]; var vector = this.component.polar.getcenter(serie.polarindex || 0); x = vector[0]; y = vector[1]; break; } } break; case ecconfig.chart_type_pie: var name = params.name; for (var i = 0, l = shapelist.length; i < l; i++) { if (shapelist[i].type === 'sector' && ecdata.get(shapelist[i], 'seriesindex') == seriesindex && ecdata.get(shapelist[i], 'name') == name) { this._curtarget = shapelist[i]; var style = this._curtarget.style; var midangle = (style.startangle + style.endangle) / 2 * math.pi / 180; x = this._curtarget.style.x + math.cos(midangle) * style.r / 1.5; y = this._curtarget.style.y - math.sin(midangle) * style.r / 1.5; break; } } break; case ecconfig.chart_type_map: var name = params.name; var maptype = serie.maptype; for (var i = 0, l = shapelist.length; i < l; i++) { if (shapelist[i].type === 'text' && shapelist[i]._maptype === maptype && shapelist[i].style._name === name) { this._curtarget = shapelist[i]; x = this._curtarget.style.x + this._curtarget.position[0]; y = this._curtarget.style.y + this._curtarget.position[1]; break; } } break; case ecconfig.chart_type_chord: var name = params.name; for (var i = 0, l = shapelist.length; i < l; i++) { if (shapelist[i].type === 'sector' && ecdata.get(shapelist[i], 'name') == name) { this._curtarget = shapelist[i]; var style = this._curtarget.style; var midangle = (style.startangle + style.endangle) / 2 * math.pi / 180; x = this._curtarget.style.x + math.cos(midangle) * (style.r - 2); y = this._curtarget.style.y - math.sin(midangle) * (style.r - 2); this.zr.trigger(zrconfig.event.mousemove, { zrenderx: x, zrendery: y }); return; } } break; case ecconfig.chart_type_force: var name = params.name; for (var i = 0, l = shapelist.length; i < l; i++) { if (shapelist[i].type === 'circle' && ecdata.get(shapelist[i], 'name') == name) { this._curtarget = shapelist[i]; x = this._curtarget.position[0]; y = this._curtarget.position[1]; break; } } break; } if (x != null && y != null) { this._event = { zrenderx: x, zrendery: y }; this.zr.addhovershape(this._curtarget); this.zr.refreshhover(); this._showitemtrigger(); } } }, hidetip: function () { this._hide(); }, refresh: function (newoption) { this._zrheight = this.zr.getheight(); this._zrwidth = this.zr.getwidth(); if (this._lasttipshape && this._lasttipshape.tipshape.length > 0) { this.zr.delshape(this._lasttipshape.tipshape); } this._lasttipshape = false; this.shapelist.length = 2; this._lastdataindex = -1; this._lastseriesindex = -1; this._lastitemtriggerid = -1; if (newoption) { this.option = newoption; this.option.tooltip = this.reformoption(this.option.tooltip); this.option.tooltip.textstyle = zrutil.merge(this.option.tooltip.textstyle, this.ectheme.textstyle); this._needaxistrigger = false; if (this.option.tooltip.trigger === 'axis') { this._needaxistrigger = true; } var series = this.option.series; for (var i = 0, l = series.length; i < l; i++) { if (this.query(series[i], 'tooltip.trigger') === 'axis') { this._needaxistrigger = true; break; } } this._showdelay = this.option.tooltip.showdelay; this._hidedelay = this.option.tooltip.hidedelay; this._defaultcsstext = this._style(this.option.tooltip); this._setselectedmap(); this._axislinewidth = this.option.tooltip.axispointer.linestyle.width; this._enterable = this.option.tooltip.enterable; if (!this._enterable && this._tdom.classname.indexof(zrconfig.elementclassname) < 0) { this._tdom.classname += ' ' + zrconfig.elementclassname; } } if (this.showing) { var self = this; settimeout(function () { self.zr.trigger(zrconfig.event.mousemove, self.zr.handler._event); }, 50); } }, onbefordispose: function () { if (this._lasttipshape && this._lasttipshape.tipshape.length > 0) { this.zr.delshape(this._lasttipshape.tipshape); } cleartimeout(this._hidingticket); cleartimeout(this._showingticket); this.zr.un(zrconfig.event.mousemove, this._onmousemove); this.zr.un(zrconfig.event.globalout, this._onglobalout); if (this.hasappend && !!this.dom.firstchild) { this.dom.firstchild.removechild(this._tdom); } this._tdom = null; }, _encodehtml: function (source) { return string(source).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); } }; zrutil.inherits(tooltip, base); require('../component').define('tooltip', tooltip); return tooltip; });define('echarts/component/legend', [ 'require', './base', 'zrender/shape/text', 'zrender/shape/rectangle', 'zrender/shape/sector', '../util/shape/icon', '../util/shape/candle', '../config', 'zrender/tool/util', 'zrender/tool/area', '../component' ], function (require) { var base = require('./base'); var textshape = require('zrender/shape/text'); var rectangleshape = require('zrender/shape/rectangle'); var sectorshape = require('zrender/shape/sector'); var iconshape = require('../util/shape/icon'); var candleshape = require('../util/shape/candle'); var ecconfig = require('../config'); ecconfig.legend = { zlevel: 0, z: 4, show: true, orient: 'horizontal', x: 'center', y: 'top', backgroundcolor: 'rgba(0,0,0,0)', bordercolor: '#ccc', borderwidth: 0, padding: 5, itemgap: 10, itemwidth: 20, itemheight: 14, textstyle: { color: '#333' }, selectedmode: true }; var zrutil = require('zrender/tool/util'); var zrarea = require('zrender/tool/area'); function legend(ectheme, messagecenter, zr, option, mychart) { if (!this.query(option, 'legend.data')) { console.error('option.legend.data has not been defined.'); return; } base.call(this, ectheme, messagecenter, zr, option, mychart); var self = this; self._legendselected = function (param) { self.__legendselected(param); }; self._dispatchhoverlink = function (param) { return self.__dispatchhoverlink(param); }; this._colorindex = 0; this._colormap = {}; this._selectedmap = {}; this._hasdatamap = {}; this.refresh(option); } legend.prototype = { type: ecconfig.component_type_legend, _buildshape: function () { if (!this.legendoption.show) { return; } this._itemgrouplocation = this._getitemgrouplocation(); this._buildbackground(); this._builditem(); for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } }, _builditem: function () { var data = this.legendoption.data; var datalength = data.length; var itemname; var itemtype; var itemshape; var textshape; var textstyle = this.legendoption.textstyle; var datatextstyle; var datafont; var formattedname; var zrwidth = this.zr.getwidth(); var zrheight = this.zr.getheight(); var lastx = this._itemgrouplocation.x; var lasty = this._itemgrouplocation.y; var itemwidth = this.legendoption.itemwidth; var itemheight = this.legendoption.itemheight; var itemgap = this.legendoption.itemgap; var color; if (this.legendoption.orient === 'vertical' && this.legendoption.x === 'right') { lastx = this._itemgrouplocation.x + this._itemgrouplocation.width - itemwidth; } for (var i = 0; i < datalength; i++) { datatextstyle = zrutil.merge(data[i].textstyle || {}, textstyle); datafont = this.getfont(datatextstyle); itemname = this._getname(data[i]); formattedname = this._getformattername(itemname); if (itemname === '') { if (this.legendoption.orient === 'horizontal') { lastx = this._itemgrouplocation.x; lasty += itemheight + itemgap; } else { this.legendoption.x === 'right' ? lastx -= this._itemgrouplocation.maxwidth + itemgap : lastx += this._itemgrouplocation.maxwidth + itemgap; lasty = this._itemgrouplocation.y; } continue; } itemtype = data[i].icon || this._getsomethingbyname(itemname).type; color = this.getcolor(itemname); if (this.legendoption.orient === 'horizontal') { if (zrwidth - lastx < 200 && itemwidth + 5 + zrarea.gettextwidth(formattedname, datafont) + (i === datalength - 1 || data[i + 1] === '' ? 0 : itemgap) >= zrwidth - lastx) { lastx = this._itemgrouplocation.x; lasty += itemheight + itemgap; } } else { if (zrheight - lasty < 200 && itemheight + (i === datalength - 1 || data[i + 1] === '' ? 0 : itemgap) >= zrheight - lasty) { this.legendoption.x === 'right' ? lastx -= this._itemgrouplocation.maxwidth + itemgap : lastx += this._itemgrouplocation.maxwidth + itemgap; lasty = this._itemgrouplocation.y; } } itemshape = this._getitemshapebytype(lastx, lasty, itemwidth, itemheight, this._selectedmap[itemname] && this._hasdatamap[itemname] ? color : '#ccc', itemtype, color); itemshape._name = itemname; itemshape = new iconshape(itemshape); textshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), style: { x: lastx + itemwidth + 5, y: lasty + itemheight / 2, color: this._selectedmap[itemname] ? datatextstyle.color === 'auto' ? color : datatextstyle.color : '#ccc', text: formattedname, textfont: datafont, textbaseline: 'middle' }, highlightstyle: { color: color, brushtype: 'fill' }, hoverable: !!this.legendoption.selectedmode, clickable: !!this.legendoption.selectedmode }; if (this.legendoption.orient === 'vertical' && this.legendoption.x === 'right') { textshape.style.x -= itemwidth + 10; textshape.style.textalign = 'right'; } textshape._name = itemname; textshape = new textshape(textshape); if (this.legendoption.selectedmode) { itemshape.onclick = textshape.onclick = this._legendselected; itemshape.onmouseover = textshape.onmouseover = this._dispatchhoverlink; itemshape.hoverconnect = textshape.id; textshape.hoverconnect = itemshape.id; } this.shapelist.push(itemshape); this.shapelist.push(textshape); if (this.legendoption.orient === 'horizontal') { lastx += itemwidth + 5 + zrarea.gettextwidth(formattedname, datafont) + itemgap; } else { lasty += itemheight + itemgap; } } if (this.legendoption.orient === 'horizontal' && this.legendoption.x === 'center' && lasty != this._itemgrouplocation.y) { this._mlineoptimize(); } }, _getname: function (data) { return typeof data.name != 'undefined' ? data.name : data; }, _getformattername: function (itemname) { var formatter = this.legendoption.formatter; var formattedname; if (typeof formatter === 'function') { formattedname = formatter.call(this.mychart, itemname); } else if (typeof formatter === 'string') { formattedname = formatter.replace('{name}', itemname); } else { formattedname = itemname; } return formattedname; }, _getformatternamefromdata: function (data) { var itemname = this._getname(data); return this._getformattername(itemname); }, _mlineoptimize: function () { var lineoffsetarray = []; var lastx = this._itemgrouplocation.x; for (var i = 2, l = this.shapelist.length; i < l; i++) { if (this.shapelist[i].style.x === lastx) { lineoffsetarray.push((this._itemgrouplocation.width - (this.shapelist[i - 1].style.x + zrarea.gettextwidth(this.shapelist[i - 1].style.text, this.shapelist[i - 1].style.textfont) - lastx)) / 2); } else if (i === l - 1) { lineoffsetarray.push((this._itemgrouplocation.width - (this.shapelist[i].style.x + zrarea.gettextwidth(this.shapelist[i].style.text, this.shapelist[i].style.textfont) - lastx)) / 2); } } var curlineindex = -1; for (var i = 1, l = this.shapelist.length; i < l; i++) { if (this.shapelist[i].style.x === lastx) { curlineindex++; } if (lineoffsetarray[curlineindex] === 0) { continue; } else { this.shapelist[i].style.x += lineoffsetarray[curlineindex]; } } }, _buildbackground: function () { var padding = this.reformcssarray(this.legendoption.padding); this.shapelist.push(new rectangleshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this._itemgrouplocation.x - padding[3], y: this._itemgrouplocation.y - padding[0], width: this._itemgrouplocation.width + padding[3] + padding[1], height: this._itemgrouplocation.height + padding[0] + padding[2], brushtype: this.legendoption.borderwidth === 0 ? 'fill' : 'both', color: this.legendoption.backgroundcolor, strokecolor: this.legendoption.bordercolor, linewidth: this.legendoption.borderwidth } })); }, _getitemgrouplocation: function () { var data = this.legendoption.data; var datalength = data.length; var itemgap = this.legendoption.itemgap; var itemwidth = this.legendoption.itemwidth + 5; var itemheight = this.legendoption.itemheight; var textstyle = this.legendoption.textstyle; var font = this.getfont(textstyle); var totalwidth = 0; var totalheight = 0; var padding = this.reformcssarray(this.legendoption.padding); var zrwidth = this.zr.getwidth() - padding[1] - padding[3]; var zrheight = this.zr.getheight() - padding[0] - padding[2]; var temp = 0; var maxwidth = 0; if (this.legendoption.orient === 'horizontal') { totalheight = itemheight; for (var i = 0; i < datalength; i++) { if (this._getname(data[i]) === '') { temp -= itemgap; totalwidth = math.max(totalwidth, temp); totalheight += itemheight + itemgap; temp = 0; continue; } var temptextwidth = zrarea.gettextwidth(this._getformatternamefromdata(data[i]), data[i].textstyle ? this.getfont(zrutil.merge(data[i].textstyle || {}, textstyle)) : font); if (temp + itemwidth + temptextwidth + itemgap > zrwidth) { temp -= itemgap; totalwidth = math.max(totalwidth, temp); totalheight += itemheight + itemgap; temp = 0; } else { temp += itemwidth + temptextwidth + itemgap; totalwidth = math.max(totalwidth, temp - itemgap); } } } else { for (var i = 0; i < datalength; i++) { maxwidth = math.max(maxwidth, zrarea.gettextwidth(this._getformatternamefromdata(data[i]), data[i].textstyle ? this.getfont(zrutil.merge(data[i].textstyle || {}, textstyle)) : font)); } maxwidth += itemwidth; totalwidth = maxwidth; for (var i = 0; i < datalength; i++) { if (this._getname(data[i]) === '') { totalwidth += maxwidth + itemgap; temp -= itemgap; totalheight = math.max(totalheight, temp); temp = 0; continue; } if (temp + itemheight + itemgap > zrheight) { totalwidth += maxwidth + itemgap; temp -= itemgap; totalheight = math.max(totalheight, temp); temp = 0; } else { temp += itemheight + itemgap; totalheight = math.max(totalheight, temp - itemgap); } } } zrwidth = this.zr.getwidth(); zrheight = this.zr.getheight(); var x; switch (this.legendoption.x) { case 'center': x = math.floor((zrwidth - totalwidth) / 2); break; case 'left': x = padding[3] + this.legendoption.borderwidth; break; case 'right': x = zrwidth - totalwidth - padding[1] - padding[3] - this.legendoption.borderwidth * 2; break; default: x = this.parsepercent(this.legendoption.x, zrwidth); break; } var y; switch (this.legendoption.y) { case 'top': y = padding[0] + this.legendoption.borderwidth; break; case 'bottom': y = zrheight - totalheight - padding[0] - padding[2] - this.legendoption.borderwidth * 2; break; case 'center': y = math.floor((zrheight - totalheight) / 2); break; default: y = this.parsepercent(this.legendoption.y, zrheight); break; } return { x: x, y: y, width: totalwidth, height: totalheight, maxwidth: maxwidth }; }, _getsomethingbyname: function (name) { var series = this.option.series; var data; for (var i = 0, l = series.length; i < l; i++) { if (series[i].name === name) { return { type: series[i].type, series: series[i], seriesindex: i, data: null, dataindex: -1 }; } if (series[i].type === ecconfig.chart_type_pie || series[i].type === ecconfig.chart_type_radar || series[i].type === ecconfig.chart_type_chord || series[i].type === ecconfig.chart_type_force || series[i].type === ecconfig.chart_type_funnel || series[i].type === ecconfig.chart_type_treemap) { data = series[i].categories || series[i].data || series[i].nodes; for (var j = 0, k = data.length; j < k; j++) { if (data[j].name === name) { return { type: series[i].type, series: series[i], seriesindex: i, data: data[j], dataindex: j }; } } } } return { type: 'bar', series: null, seriesindex: -1, data: null, dataindex: -1 }; }, _getitemshapebytype: function (x, y, width, height, color, itemtype, defaultcolor) { var highlightcolor = color === '#ccc' ? defaultcolor : color; var itemshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), style: { icontype: 'legendicon' + itemtype, x: x, y: y, width: width, height: height, color: color, strokecolor: color, linewidth: 2 }, highlightstyle: { color: highlightcolor, strokecolor: highlightcolor, linewidth: 1 }, hoverable: this.legendoption.selectedmode, clickable: this.legendoption.selectedmode }; var imagelocation; if (itemtype.match('image')) { var imagelocation = itemtype.replace(new regexp('^image:\\/\\/'), ''); itemtype = 'image'; } switch (itemtype) { case 'line': itemshape.style.brushtype = 'stroke'; itemshape.highlightstyle.linewidth = 3; break; case 'radar': case 'venn': case 'tree': case 'treemap': case 'scatter': itemshape.highlightstyle.linewidth = 3; break; case 'k': itemshape.style.brushtype = 'both'; itemshape.highlightstyle.linewidth = 3; itemshape.highlightstyle.color = itemshape.style.color = this.deepquery([ this.ectheme, ecconfig ], 'k.itemstyle.normal.color') || '#fff'; itemshape.style.strokecolor = color != '#ccc' ? this.deepquery([ this.ectheme, ecconfig ], 'k.itemstyle.normal.linestyle.color') || '#ff3200' : color; break; case 'image': itemshape.style.icontype = 'image'; itemshape.style.image = imagelocation; if (color === '#ccc') { itemshape.style.opacity = 0.5; } break; } return itemshape; }, __legendselected: function (param) { var itemname = param.target._name; if (this.legendoption.selectedmode === 'single') { for (var k in this._selectedmap) { this._selectedmap[k] = false; } } this._selectedmap[itemname] = !this._selectedmap[itemname]; this.messagecenter.dispatch(ecconfig.event.legend_selected, param.event, { selected: this._selectedmap, target: itemname }, this.mychart); }, __dispatchhoverlink: function (param) { this.messagecenter.dispatch(ecconfig.event.legend_hoverlink, param.event, { target: param.target._name }, this.mychart); return; }, refresh: function (newoption) { if (newoption) { this.option = newoption || this.option; this.option.legend = this.reformoption(this.option.legend); this.legendoption = this.option.legend; var data = this.legendoption.data || []; var itemname; var something; var color; var querytarget; if (this.legendoption.selected) { for (var k in this.legendoption.selected) { this._selectedmap[k] = typeof this._selectedmap[k] != 'undefined' ? this._selectedmap[k] : this.legendoption.selected[k]; } } for (var i = 0, datalength = data.length; i < datalength; i++) { itemname = this._getname(data[i]); if (itemname === '') { continue; } something = this._getsomethingbyname(itemname); if (!something.series) { this._hasdatamap[itemname] = false; } else { this._hasdatamap[itemname] = true; if (something.data && (something.type === ecconfig.chart_type_pie || something.type === ecconfig.chart_type_force || something.type === ecconfig.chart_type_funnel)) { querytarget = [ something.data, something.series ]; } else { querytarget = [something.series]; } color = this.getitemstylecolor(this.deepquery(querytarget, 'itemstyle.normal.color'), something.seriesindex, something.dataindex, something.data); if (color && something.type != ecconfig.chart_type_k) { this.setcolor(itemname, color); } this._selectedmap[itemname] = this._selectedmap[itemname] != null ? this._selectedmap[itemname] : true; } } } this.clear(); this._buildshape(); }, getrelatedamount: function (name) { var amount = 0; var series = this.option.series; var data; for (var i = 0, l = series.length; i < l; i++) { if (series[i].name === name) { amount++; } if (series[i].type === ecconfig.chart_type_pie || series[i].type === ecconfig.chart_type_radar || series[i].type === ecconfig.chart_type_chord || series[i].type === ecconfig.chart_type_force || series[i].type === ecconfig.chart_type_funnel) { data = series[i].type != ecconfig.chart_type_force ? series[i].data : series[i].categories; for (var j = 0, k = data.length; j < k; j++) { if (data[j].name === name && data[j].value != '-') { amount++; } } } } return amount; }, setcolor: function (legendname, color) { this._colormap[legendname] = color; }, getcolor: function (legendname) { if (!this._colormap[legendname]) { this._colormap[legendname] = this.zr.getcolor(this._colorindex++); } return this._colormap[legendname]; }, hascolor: function (legendname) { return this._colormap[legendname] ? this._colormap[legendname] : false; }, add: function (name, color) { var data = this.legendoption.data; for (var i = 0, datalength = data.length; i < datalength; i++) { if (this._getname(data[i]) === name) { return; } } this.legendoption.data.push(name); this.setcolor(name, color); this._selectedmap[name] = true; this._hasdatamap[name] = true; }, del: function (name) { var data = this.legendoption.data; for (var i = 0, datalength = data.length; i < datalength; i++) { if (this._getname(data[i]) === name) { return this.legendoption.data.splice(i, 1); } } }, getitemshape: function (name) { if (name == null) { return; } var shape; for (var i = 0, l = this.shapelist.length; i < l; i++) { shape = this.shapelist[i]; if (shape._name === name && shape.type != 'text') { return shape; } } }, setitemshape: function (name, itemshape) { var shape; for (var i = 0, l = this.shapelist.length; i < l; i++) { shape = this.shapelist[i]; if (shape._name === name && shape.type != 'text') { if (!this._selectedmap[name]) { itemshape.style.color = '#ccc'; itemshape.style.strokecolor = '#ccc'; } this.zr.modshape(shape.id, itemshape); } } }, isselected: function (itemname) { if (typeof this._selectedmap[itemname] != 'undefined') { return this._selectedmap[itemname]; } else { return true; } }, getselectedmap: function () { return this._selectedmap; }, setselected: function (itemname, selectstatus) { if (this.legendoption.selectedmode === 'single') { for (var k in this._selectedmap) { this._selectedmap[k] = false; } } this._selectedmap[itemname] = selectstatus; this.messagecenter.dispatch(ecconfig.event.legend_selected, null, { selected: this._selectedmap, target: itemname }, this.mychart); }, onlegendselected: function (param, status) { var legendselected = param.selected; for (var itemname in legendselected) { if (this._selectedmap[itemname] != legendselected[itemname]) { status.needrefresh = true; } this._selectedmap[itemname] = legendselected[itemname]; } return; } }; var legendicon = { line: function (ctx, style) { var dy = style.height / 2; ctx.moveto(style.x, style.y + dy); ctx.lineto(style.x + style.width, style.y + dy); }, pie: function (ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; sectorshape.prototype.buildpath(ctx, { x: x + width / 2, y: y + height + 2, r: height, r0: 6, startangle: 45, endangle: 135 }); }, eventriver: function (ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; ctx.moveto(x, y + height); ctx.beziercurveto(x + width, y + height, x, y + 4, x + width, y + 4); ctx.lineto(x + width, y); ctx.beziercurveto(x, y, x + width, y + height - 4, x, y + height - 4); ctx.lineto(x, y + height); }, k: function (ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; candleshape.prototype.buildpath(ctx, { x: x + width / 2, y: [ y + 1, y + 1, y + height - 6, y + height ], width: width - 6 }); }, bar: function (ctx, style) { var x = style.x; var y = style.y + 1; var width = style.width; var height = style.height - 2; var r = 3; ctx.moveto(x + r, y); ctx.lineto(x + width - r, y); ctx.quadraticcurveto(x + width, y, x + width, y + r); ctx.lineto(x + width, y + height - r); ctx.quadraticcurveto(x + width, y + height, x + width - r, y + height); ctx.lineto(x + r, y + height); ctx.quadraticcurveto(x, y + height, x, y + height - r); ctx.lineto(x, y + r); ctx.quadraticcurveto(x, y, x + r, y); }, force: function (ctx, style) { iconshape.prototype.iconlibrary.circle(ctx, style); }, radar: function (ctx, style) { var n = 6; var x = style.x + style.width / 2; var y = style.y + style.height / 2; var r = style.height / 2; var dstep = 2 * math.pi / n; var deg = -math.pi / 2; var xstart = x + r * math.cos(deg); var ystart = y + r * math.sin(deg); ctx.moveto(xstart, ystart); deg += dstep; for (var i = 0, end = n - 1; i < end; i++) { ctx.lineto(x + r * math.cos(deg), y + r * math.sin(deg)); deg += dstep; } ctx.lineto(xstart, ystart); } }; legendicon.chord = legendicon.pie; legendicon.map = legendicon.bar; for (var k in legendicon) { iconshape.prototype.iconlibrary['legendicon' + k] = legendicon[k]; } zrutil.inherits(legend, base); require('../component').define('legend', legend); return legend; });define('echarts/util/ecdata', [], function () { function pack(shape, series, seriesindex, data, dataindex, name, special, special2) { var value; if (typeof data != 'undefined') { value = data.value == null ? data : data.value; } shape._echartsdata = { '_series': series, '_seriesindex': seriesindex, '_data': data, '_dataindex': dataindex, '_name': name, '_value': value, '_special': special, '_special2': special2 }; return shape._echartsdata; } function get(shape, key) { var data = shape._echartsdata; if (!key) { return data; } switch (key) { case 'series': case 'seriesindex': case 'data': case 'dataindex': case 'name': case 'value': case 'special': case 'special2': return data && data['_' + key]; } return null; } function set(shape, key, value) { shape._echartsdata = shape._echartsdata || {}; switch (key) { case 'series': case 'seriesindex': case 'data': case 'dataindex': case 'name': case 'value': case 'special': case 'special2': shape._echartsdata['_' + key] = value; break; } } function clone(source, target) { target._echartsdata = { '_series': source._echartsdata._series, '_seriesindex': source._echartsdata._seriesindex, '_data': source._echartsdata._data, '_dataindex': source._echartsdata._dataindex, '_name': source._echartsdata._name, '_value': source._echartsdata._value, '_special': source._echartsdata._special, '_special2': source._echartsdata._special2 }; } return { pack: pack, set: set, get: get, clone: clone }; });define('echarts/chart', [], function () { var self = {}; var _chartlibrary = {}; self.define = function (name, clazz) { _chartlibrary[name] = clazz; return self; }; self.get = function (name) { return _chartlibrary[name]; }; return self; });define('zrender/tool/color', [ 'require', '../tool/util' ], function (require) { var util = require('../tool/util'); var _ctx; var palette = [ '#ff9277', ' #dddd00', ' #ffc877', ' #bbe3ff', ' #d5ffbb', '#bbbbff', ' #ddb000', ' #b0dd00', ' #e2bbff', ' #ffbbe3', '#ff7777', ' #ff9900', ' #83dd00', ' #77e3ff', ' #778fff', '#c877ff', ' #ff77ab', ' #ff6600', ' #aa8800', ' #77c7ff', '#ad77ff', ' #ff77ff', ' #dd0083', ' #777700', ' #00aa00', '#0088aa', ' #8400dd', ' #aa0088', ' #dd0000', ' #772e00' ]; var _palette = palette; var highlightcolor = 'rgba(255,255,0,0.5)'; var _highlightcolor = highlightcolor; var colorregexp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i; var _namecolors = { aliceblue: '#f0f8ff', antiquewhite: '#faebd7', aqua: '#0ff', aquamarine: '#7fffd4', azure: '#f0ffff', beige: '#f5f5dc', bisque: '#ffe4c4', black: '#000', blanchedalmond: '#ffebcd', blue: '#00f', blueviolet: '#8a2be2', brown: '#a52a2a', burlywood: '#deb887', cadetblue: '#5f9ea0', chartreuse: '#7fff00', chocolate: '#d2691e', coral: '#ff7f50', cornflowerblue: '#6495ed', cornsilk: '#fff8dc', crimson: '#dc143c', cyan: '#0ff', darkblue: '#00008b', darkcyan: '#008b8b', darkgoldenrod: '#b8860b', darkgray: '#a9a9a9', darkgrey: '#a9a9a9', darkgreen: '#006400', 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', fuchsia: '#f0f', gainsboro: '#dcdcdc', ghostwhite: '#f8f8ff', gold: '#ffd700', goldenrod: '#daa520', gray: '#808080', grey: '#808080', green: '#008000', 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', lightgray: '#d3d3d3', lightgrey: '#d3d3d3', lightgreen: '#90ee90', lightpink: '#ffb6c1', lightsalmon: '#ffa07a', lightseagreen: '#20b2aa', lightskyblue: '#87cefa', lightslategray: '#789', lightslategrey: '#789', lightsteelblue: '#b0c4de', lightyellow: '#ffffe0', lime: '#0f0', limegreen: '#32cd32', linen: '#faf0e6', magenta: '#f0f', maroon: '#800000', mediumaquamarine: '#66cdaa', mediumblue: '#0000cd', mediumorchid: '#ba55d3', mediumpurple: '#9370d8', mediumseagreen: '#3cb371', mediumslateblue: '#7b68ee', mediumspringgreen: '#00fa9a', mediumturquoise: '#48d1cc', mediumvioletred: '#c71585', midnightblue: '#191970', mintcream: '#f5fffa', mistyrose: '#ffe4e1', moccasin: '#ffe4b5', navajowhite: '#ffdead', navy: '#000080', oldlace: '#fdf5e6', olive: '#808000', olivedrab: '#6b8e23', orange: '#ffa500', orangered: '#ff4500', orchid: '#da70d6', palegoldenrod: '#eee8aa', palegreen: '#98fb98', paleturquoise: '#afeeee', palevioletred: '#d87093', papayawhip: '#ffefd5', peachpuff: '#ffdab9', peru: '#cd853f', pink: '#ffc0cb', plum: '#dda0dd', powderblue: '#b0e0e6', purple: '#800080', red: '#f00', rosybrown: '#bc8f8f', royalblue: '#4169e1', saddlebrown: '#8b4513', salmon: '#fa8072', sandybrown: '#f4a460', seagreen: '#2e8b57', seashell: '#fff5ee', sienna: '#a0522d', silver: '#c0c0c0', skyblue: '#87ceeb', slateblue: '#6a5acd', slategray: '#708090', slategrey: '#708090', snow: '#fffafa', springgreen: '#00ff7f', steelblue: '#4682b4', tan: '#d2b48c', teal: '#008080', thistle: '#d8bfd8', tomato: '#ff6347', turquoise: '#40e0d0', violet: '#ee82ee', wheat: '#f5deb3', white: '#fff', whitesmoke: '#f5f5f5', yellow: '#ff0', yellowgreen: '#9acd32' }; function custompalette(userpalete) { palette = userpalete; } function resetpalette() { palette = _palette; } function getcolor(idx, userpalete) { idx = idx | 0; userpalete = userpalete || palette; return userpalete[idx % userpalete.length]; } function customhighlight(userhighlightcolor) { highlightcolor = userhighlightcolor; } function resethighlight() { _highlightcolor = highlightcolor; } function gethighlightcolor() { return highlightcolor; } function getradialgradient(x0, y0, r0, x1, y1, r1, colorlist) { if (!_ctx) { _ctx = util.getcontext(); } var gradient = _ctx.createradialgradient(x0, y0, r0, x1, y1, r1); for (var i = 0, l = colorlist.length; i < l; i++) { gradient.addcolorstop(colorlist[i][0], colorlist[i][1]); } gradient.__nonrecursion = true; return gradient; } function getlineargradient(x0, y0, x1, y1, colorlist) { if (!_ctx) { _ctx = util.getcontext(); } var gradient = _ctx.createlineargradient(x0, y0, x1, y1); for (var i = 0, l = colorlist.length; i < l; i++) { gradient.addcolorstop(colorlist[i][0], colorlist[i][1]); } gradient.__nonrecursion = true; return gradient; } function getstepcolors(start, end, step) { start = torgba(start); end = torgba(end); start = getdata(start); end = getdata(end); var colors = []; var stepr = (end[0] - start[0]) / step; var stepg = (end[1] - start[1]) / step; var stepb = (end[2] - start[2]) / step; var stepa = (end[3] - start[3]) / step; for (var i = 0, r = start[0], g = start[1], b = start[2], a = start[3]; i < step; i++) { colors[i] = tocolor([ adjust(math.floor(r), [ 0, 255 ]), adjust(math.floor(g), [ 0, 255 ]), adjust(math.floor(b), [ 0, 255 ]), a.tofixed(4) - 0 ], 'rgba'); r += stepr; g += stepg; b += stepb; a += stepa; } r = end[0]; g = end[1]; b = end[2]; a = end[3]; colors[i] = tocolor([ r, g, b, a ], 'rgba'); return colors; } function getgradientcolors(colors, step) { var ret = []; var len = colors.length; if (step === undefined) { step = 20; } if (len === 1) { ret = getstepcolors(colors[0], colors[0], step); } else if (len > 1) { for (var i = 0, n = len - 1; i < n; i++) { var steps = getstepcolors(colors[i], colors[i + 1], step); if (i < n - 1) { steps.pop(); } ret = ret.concat(steps); } } return ret; } function tocolor(data, format) { format = format || 'rgb'; if (data && (data.length === 3 || data.length === 4)) { data = map(data, function (c) { return c > 1 ? math.ceil(c) : c; }); if (format.indexof('hex') > -1) { return '#' + ((1 << 24) + (data[0] << 16) + (data[1] << 8) + +data[2]).tostring(16).slice(1); } else if (format.indexof('hs') > -1) { var sx = map(data.slice(1, 3), function (c) { return c + '%'; }); data[1] = sx[0]; data[2] = sx[1]; } if (format.indexof('a') > -1) { if (data.length === 3) { data.push(1); } data[3] = adjust(data[3], [ 0, 1 ]); return format + '(' + data.slice(0, 4).join(',') + ')'; } return format + '(' + data.slice(0, 3).join(',') + ')'; } } function toarray(color) { color = trim(color); if (color.indexof('rgba') < 0) { color = torgba(color); } var data = []; var i = 0; color.replace(/[\d.]+/g, function (n) { if (i < 3) { n = n | 0; } else { n = +n; } data[i++] = n; }); return data; } function convert(color, format) { if (!iscalculablecolor(color)) { return color; } var data = getdata(color); var alpha = data[3]; if (typeof alpha === 'undefined') { alpha = 1; } if (color.indexof('hsb') > -1) { data = _hsv_2_rgb(data); } else if (color.indexof('hsl') > -1) { data = _hsl_2_rgb(data); } if (format.indexof('hsb') > -1 || format.indexof('hsv') > -1) { data = _rgb_2_hsb(data); } else if (format.indexof('hsl') > -1) { data = _rgb_2_hsl(data); } data[3] = alpha; return tocolor(data, format); } function torgba(color) { return convert(color, 'rgba'); } function torgb(color) { return convert(color, 'rgb'); } function tohex(color) { return convert(color, 'hex'); } function tohsva(color) { return convert(color, 'hsva'); } function tohsv(color) { return convert(color, 'hsv'); } function tohsba(color) { return convert(color, 'hsba'); } function tohsb(color) { return convert(color, 'hsb'); } function tohsla(color) { return convert(color, 'hsla'); } function tohsl(color) { return convert(color, 'hsl'); } function toname(color) { for (var key in _namecolors) { if (tohex(_namecolors[key]) === tohex(color)) { return key; } } return null; } function trim(color) { return string(color).replace(/\s+/g, ''); } function normalize(color) { if (_namecolors[color]) { color = _namecolors[color]; } color = trim(color); color = color.replace(/hsv/i, 'hsb'); if (/^#[\da-f]{3}$/i.test(color)) { color = parseint(color.slice(1), 16); var r = (color & 3840) << 8; var g = (color & 240) << 4; var b = color & 15; color = '#' + ((1 << 24) + (r << 4) + r + (g << 4) + g + (b << 4) + b).tostring(16).slice(1); } return color; } function lift(color, level) { if (!iscalculablecolor(color)) { return color; } var direct = level > 0 ? 1 : -1; if (typeof level === 'undefined') { level = 0; } level = math.abs(level) > 1 ? 1 : math.abs(level); color = torgb(color); var data = getdata(color); for (var i = 0; i < 3; i++) { if (direct === 1) { data[i] = data[i] * (1 - level) | 0; } else { data[i] = (255 - data[i]) * level + data[i] | 0; } } return 'rgb(' + data.join(',') + ')'; } function reverse(color) { if (!iscalculablecolor(color)) { return color; } var data = getdata(torgba(color)); data = map(data, function (c) { return 255 - c; }); return tocolor(data, 'rgb'); } function mix(color1, color2, weight) { if (!iscalculablecolor(color1) || !iscalculablecolor(color2)) { return color1; } if (typeof weight === 'undefined') { weight = 0.5; } weight = 1 - adjust(weight, [ 0, 1 ]); var w = weight * 2 - 1; var data1 = getdata(torgba(color1)); var data2 = getdata(torgba(color2)); var d = data1[3] - data2[3]; var weight1 = ((w * d === -1 ? w : (w + d) / (1 + w * d)) + 1) / 2; var weight2 = 1 - weight1; var data = []; for (var i = 0; i < 3; i++) { data[i] = data1[i] * weight1 + data2[i] * weight2; } var alpha = data1[3] * weight + data2[3] * (1 - weight); alpha = math.max(0, math.min(1, alpha)); if (data1[3] === 1 && data2[3] === 1) { return tocolor(data, 'rgb'); } data[3] = alpha; return tocolor(data, 'rgba'); } function random() { return '#' + (math.random().tostring(16) + '0000').slice(2, 8); } function getdata(color) { color = normalize(color); var r = color.match(colorregexp); if (r === null) { throw new error('the color format error'); } var d; var a; var data = []; var rgb; if (r[2]) { d = r[2].replace('#', '').split(''); rgb = [ d[0] + d[1], d[2] + d[3], d[4] + d[5] ]; data = map(rgb, function (c) { return adjust(parseint(c, 16), [ 0, 255 ]); }); } else if (r[4]) { var rgba = r[4].split(','); a = rgba[3]; rgb = rgba.slice(0, 3); data = map(rgb, function (c) { c = math.floor(c.indexof('%') > 0 ? parseint(c, 0) * 2.55 : c); return adjust(c, [ 0, 255 ]); }); if (typeof a !== 'undefined') { data.push(adjust(parsefloat(a), [ 0, 1 ])); } } else if (r[5] || r[6]) { var hsxa = (r[5] || r[6]).split(','); var h = parseint(hsxa[0], 0) / 360; var s = hsxa[1]; var x = hsxa[2]; a = hsxa[3]; data = map([ s, x ], function (c) { return adjust(parsefloat(c) / 100, [ 0, 1 ]); }); data.unshift(h); if (typeof a !== 'undefined') { data.push(adjust(parsefloat(a), [ 0, 1 ])); } } return data; } function alpha(color, a) { if (!iscalculablecolor(color)) { return color; } if (a === null) { a = 1; } var data = getdata(torgba(color)); data[3] = adjust(number(a).tofixed(4), [ 0, 1 ]); return tocolor(data, 'rgba'); } function map(array, fun) { if (typeof fun !== 'function') { throw new typeerror(); } var len = array ? array.length : 0; for (var i = 0; i < len; i++) { array[i] = fun(array[i]); } return array; } function adjust(value, region) { if (value <= region[0]) { value = region[0]; } else if (value >= region[1]) { value = region[1]; } return value; } function iscalculablecolor(color) { return color instanceof array || typeof color === 'string'; } function _hsv_2_rgb(data) { var h = data[0]; var s = data[1]; var v = data[2]; var r; var g; var b; if (s === 0) { r = v * 255; g = v * 255; b = v * 255; } else { var h = h * 6; if (h === 6) { h = 0; } var i = h | 0; var v1 = v * (1 - s); var v2 = v * (1 - s * (h - i)); var v3 = v * (1 - s * (1 - (h - i))); var r = 0; var g = 0; var b = 0; if (i === 0) { r = v; g = v3; b = v1; } else if (i === 1) { r = v2; g = v; b = v1; } else if (i === 2) { r = v1; g = v; b = v3; } else if (i === 3) { r = v1; g = v2; b = v; } else if (i === 4) { r = v3; g = v1; b = v; } else { r = v; g = v1; b = v2; } r = r * 255; g = g * 255; b = b * 255; } return [ r, g, b ]; } function _hsl_2_rgb(data) { var h = data[0]; var s = data[1]; var l = data[2]; var r; var g; var b; if (s === 0) { r = l * 255; g = l * 255; b = l * 255; } else { var v2; if (l < 0.5) { v2 = l * (1 + s); } else { v2 = l + s - s * l; } var v1 = 2 * l - v2; r = 255 * _hue_2_rgb(v1, v2, h + 1 / 3); g = 255 * _hue_2_rgb(v1, v2, h); b = 255 * _hue_2_rgb(v1, v2, h - 1 / 3); } return [ r, g, b ]; } function _hue_2_rgb(v1, v2, vh) { if (vh < 0) { vh += 1; } if (vh > 1) { vh -= 1; } if (6 * vh < 1) { return v1 + (v2 - v1) * 6 * vh; } if (2 * vh < 1) { return v2; } if (3 * vh < 2) { return v1 + (v2 - v1) * (2 / 3 - vh) * 6; } return v1; } function _rgb_2_hsb(data) { var r = data[0] / 255; var g = data[1] / 255; var b = data[2] / 255; var vmin = math.min(r, g, b); var vmax = math.max(r, g, b); var delta = vmax - vmin; var v = vmax; var h; var s; if (delta === 0) { h = 0; s = 0; } else { s = delta / vmax; var deltar = ((vmax - r) / 6 + delta / 2) / delta; var deltag = ((vmax - g) / 6 + delta / 2) / delta; var deltab = ((vmax - b) / 6 + delta / 2) / delta; if (r === vmax) { h = deltab - deltag; } else if (g === vmax) { h = 1 / 3 + deltar - deltab; } else if (b === vmax) { h = 2 / 3 + deltag - deltar; } if (h < 0) { h += 1; } if (h > 1) { h -= 1; } } h = h * 360; s = s * 100; v = v * 100; return [ h, s, v ]; } function _rgb_2_hsl(data) { var r = data[0] / 255; var g = data[1] / 255; var b = data[2] / 255; var vmin = math.min(r, g, b); var vmax = math.max(r, g, b); var delta = vmax - vmin; var l = (vmax + vmin) / 2; var h; var s; if (delta === 0) { h = 0; s = 0; } else { if (l < 0.5) { s = delta / (vmax + vmin); } else { s = delta / (2 - vmax - vmin); } var deltar = ((vmax - r) / 6 + delta / 2) / delta; var deltag = ((vmax - g) / 6 + delta / 2) / delta; var deltab = ((vmax - b) / 6 + delta / 2) / delta; if (r === vmax) { h = deltab - deltag; } else if (g === vmax) { h = 1 / 3 + deltar - deltab; } else if (b === vmax) { h = 2 / 3 + deltag - deltar; } if (h < 0) { h += 1; } if (h > 1) { h -= 1; } } h = h * 360; s = s * 100; l = l * 100; return [ h, s, l ]; } return { custompalette: custompalette, resetpalette: resetpalette, getcolor: getcolor, gethighlightcolor: gethighlightcolor, customhighlight: customhighlight, resethighlight: resethighlight, getradialgradient: getradialgradient, getlineargradient: getlineargradient, getgradientcolors: getgradientcolors, getstepcolors: getstepcolors, reverse: reverse, mix: mix, lift: lift, trim: trim, random: random, torgb: torgb, torgba: torgba, tohex: tohex, tohsl: tohsl, tohsla: tohsla, tohsb: tohsb, tohsba: tohsba, tohsv: tohsv, tohsva: tohsva, toname: toname, tocolor: tocolor, toarray: toarray, alpha: alpha, getdata: getdata }; });define('echarts/component/timeline', [ 'require', './base', 'zrender/shape/rectangle', '../util/shape/icon', '../util/shape/chain', '../config', 'zrender/tool/util', 'zrender/tool/area', 'zrender/tool/event', '../component' ], function (require) { var base = require('./base'); var rectangleshape = require('zrender/shape/rectangle'); var iconshape = require('../util/shape/icon'); var chainshape = require('../util/shape/chain'); var ecconfig = require('../config'); ecconfig.timeline = { zlevel: 0, z: 4, show: true, type: 'time', notmerge: false, realtime: true, x: 80, x2: 80, y2: 0, height: 50, backgroundcolor: 'rgba(0,0,0,0)', bordercolor: '#ccc', borderwidth: 0, padding: 5, controlposition: 'left', autoplay: false, loop: true, playinterval: 2000, linestyle: { width: 1, color: '#666', type: 'dashed' }, label: { show: true, interval: 'auto', rotate: 0, textstyle: { color: '#333' } }, checkpointstyle: { symbol: 'auto', symbolsize: 'auto', color: 'auto', bordercolor: 'auto', borderwidth: 'auto', label: { show: false, textstyle: { color: 'auto' } } }, controlstyle: { itemsize: 15, itemgap: 5, normal: { color: '#333' }, emphasis: { color: '#1e90ff' } }, symbol: 'emptydiamond', symbolsize: 4, currentindex: 0 }; var zrutil = require('zrender/tool/util'); var zrarea = require('zrender/tool/area'); var zrevent = require('zrender/tool/event'); function timeline(ectheme, messagecenter, zr, option, mychart) { base.call(this, ectheme, messagecenter, zr, option, mychart); var self = this; self._onclick = function (param) { return self.__onclick(param); }; self._ondrift = function (dx, dy) { return self.__ondrift(this, dx, dy); }; self._ondragend = function () { return self.__ondragend(); }; self._setcurrentoption = function () { var timelineoption = self.timelineoption; self.currentindex %= timelineoption.data.length; var curoption = self.options[self.currentindex] || {}; self.mychart._setoption(curoption, timelineoption.notmerge, true); self.messagecenter.dispatch(ecconfig.event.timeline_changed, null, { currentindex: self.currentindex, data: timelineoption.data[self.currentindex].name != null ? timelineoption.data[self.currentindex].name : timelineoption.data[self.currentindex] }, self.mychart); }; self._onframe = function () { self._setcurrentoption(); self._synchandleshape(); if (self.timelineoption.autoplay) { self.playticket = settimeout(function () { self.currentindex += 1; if (!self.timelineoption.loop && self.currentindex >= self.timelineoption.data.length) { self.currentindex = self.timelineoption.data.length - 1; self.stop(); return; } self._onframe(); }, self.timelineoption.playinterval); } }; this.settheme(false); this.options = this.option.options; this.currentindex = this.timelineoption.currentindex % this.timelineoption.data.length; if (!this.timelineoption.notmerge && this.currentindex !== 0) { this.options[this.currentindex] = zrutil.merge(this.options[this.currentindex], this.options[0]); } if (this.timelineoption.show) { this._buildshape(); this._synchandleshape(); } this._setcurrentoption(); if (this.timelineoption.autoplay) { var self = this; this.playticket = settimeout(function () { self.play(); }, this.ectheme.animationduration != null ? this.ectheme.animationduration : ecconfig.animationduration); } } timeline.prototype = { type: ecconfig.component_type_timeline, _buildshape: function () { this._location = this._getlocation(); this._buildbackground(); this._buildcontrol(); this._chainpoint = this._getchainpoint(); if (this.timelineoption.label.show) { var interval = this._getinterval(); for (var i = 0, len = this._chainpoint.length; i < len; i += interval) { this._chainpoint[i].showlabel = true; } } this._buildchain(); this._buildhandle(); for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } }, _getlocation: function () { var timelineoption = this.timelineoption; var padding = this.reformcssarray(this.timelineoption.padding); var zrwidth = this.zr.getwidth(); var x = this.parsepercent(timelineoption.x, zrwidth); var x2 = this.parsepercent(timelineoption.x2, zrwidth); var width; if (timelineoption.width == null) { width = zrwidth - x - x2; x2 = zrwidth - x2; } else { width = this.parsepercent(timelineoption.width, zrwidth); x2 = x + width; } var zrheight = this.zr.getheight(); var height = this.parsepercent(timelineoption.height, zrheight); var y; var y2; if (timelineoption.y != null) { y = this.parsepercent(timelineoption.y, zrheight); y2 = y + height; } else { y2 = zrheight - this.parsepercent(timelineoption.y2, zrheight); y = y2 - height; } return { x: x + padding[3], y: y + padding[0], x2: x2 - padding[1], y2: y2 - padding[2], width: width - padding[1] - padding[3], height: height - padding[0] - padding[2] }; }, _getreformedlabel: function (idx) { var timelineoption = this.timelineoption; var data = timelineoption.data[idx].name != null ? timelineoption.data[idx].name : timelineoption.data[idx]; var formatter = timelineoption.data[idx].formatter || timelineoption.label.formatter; if (formatter) { if (typeof formatter === 'function') { data = formatter.call(this.mychart, data); } else if (typeof formatter === 'string') { data = formatter.replace('{value}', data); } } return data; }, _getinterval: function () { var chainpoint = this._chainpoint; var timelineoption = this.timelineoption; var interval = timelineoption.label.interval; if (interval === 'auto') { var fontsize = timelineoption.label.textstyle.fontsize; var data = timelineoption.data; var datalength = timelineoption.data.length; if (datalength > 3) { var isenough = false; var labelspace; var labelsize; interval = 0; while (!isenough && interval < datalength) { interval++; isenough = true; for (var i = interval; i < datalength; i += interval) { labelspace = chainpoint[i].x - chainpoint[i - interval].x; if (timelineoption.label.rotate !== 0) { labelsize = fontsize; } else if (data[i].textstyle) { labelsize = zrarea.gettextwidth(chainpoint[i].name, chainpoint[i].textfont); } else { var label = chainpoint[i].name + ''; var wlen = (label.match(/\w/g) || '').length; var olen = label.length - wlen; labelsize = wlen * fontsize * 2 / 3 + olen * fontsize; } if (labelspace < labelsize) { isenough = false; break; } } } } else { interval = 1; } } else { interval = interval - 0 + 1; } return interval; }, _getchainpoint: function () { var timelineoption = this.timelineoption; var symbol = timelineoption.symbol.tolowercase(); var symbolsize = timelineoption.symbolsize; var rotate = timelineoption.label.rotate; var textstyle = timelineoption.label.textstyle; var textfont = this.getfont(textstyle); var datatextstyle; var data = timelineoption.data; var x = this._location.x; var y = this._location.y + this._location.height / 4 * 3; var width = this._location.x2 - this._location.x; var len = data.length; function _getname(i) { return data[i].name != null ? data[i].name : data[i] + ''; } var xlist = []; if (len > 1) { var boundarygap = width / len; boundarygap = boundarygap > 50 ? 50 : boundarygap < 20 ? 5 : boundarygap; width -= boundarygap * 2; if (timelineoption.type === 'number') { for (var i = 0; i < len; i++) { xlist.push(x + boundarygap + width / (len - 1) * i); } } else { xlist[0] = new date(_getname(0).replace(/-/g, '/')); xlist[len - 1] = new date(_getname(len - 1).replace(/-/g, '/')) - xlist[0]; for (var i = 1; i < len; i++) { xlist[i] = x + boundarygap + width * (new date(_getname(i).replace(/-/g, '/')) - xlist[0]) / xlist[len - 1]; } xlist[0] = x + boundarygap; } } else { xlist.push(x + width / 2); } var list = []; var cursymbol; var n; var isempty; var textalign; var rotation; for (var i = 0; i < len; i++) { x = xlist[i]; cursymbol = data[i].symbol && data[i].symbol.tolowercase() || symbol; if (cursymbol.match('empty')) { cursymbol = cursymbol.replace('empty', ''); isempty = true; } else { isempty = false; } if (cursymbol.match('star')) { n = cursymbol.replace('star', '') - 0 || 5; cursymbol = 'star'; } datatextstyle = data[i].textstyle ? zrutil.merge(data[i].textstyle || {}, textstyle) : textstyle; textalign = datatextstyle.align || 'center'; if (rotate) { textalign = rotate > 0 ? 'right' : 'left'; rotation = [ rotate * math.pi / 180, x, y - 5 ]; } else { rotation = false; } list.push({ x: x, n: n, isempty: isempty, symbol: cursymbol, symbolsize: data[i].symbolsize || symbolsize, color: data[i].color, bordercolor: data[i].bordercolor, borderwidth: data[i].borderwidth, name: this._getreformedlabel(i), textcolor: datatextstyle.color, textalign: textalign, textbaseline: datatextstyle.baseline || 'middle', textx: x, texty: y - (rotate ? 5 : 0), textfont: data[i].textstyle ? this.getfont(datatextstyle) : textfont, rotation: rotation, showlabel: false }); } return list; }, _buildbackground: function () { var timelineoption = this.timelineoption; var padding = this.reformcssarray(this.timelineoption.padding); var width = this._location.width; var height = this._location.height; if (timelineoption.borderwidth !== 0 || timelineoption.backgroundcolor.replace(/\s/g, '') != 'rgba(0,0,0,0)') { this.shapelist.push(new rectangleshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this._location.x - padding[3], y: this._location.y - padding[0], width: width + padding[1] + padding[3], height: height + padding[0] + padding[2], brushtype: timelineoption.borderwidth === 0 ? 'fill' : 'both', color: timelineoption.backgroundcolor, strokecolor: timelineoption.bordercolor, linewidth: timelineoption.borderwidth } })); } }, _buildcontrol: function () { var self = this; var timelineoption = this.timelineoption; var linestyle = timelineoption.linestyle; var controlstyle = timelineoption.controlstyle; if (timelineoption.controlposition === 'none') { return; } var iconsize = controlstyle.itemsize; var icongap = controlstyle.itemgap; var x; if (timelineoption.controlposition === 'left') { x = this._location.x; this._location.x += (iconsize + icongap) * 3; } else { x = this._location.x2 - ((iconsize + icongap) * 3 - icongap); this._location.x2 -= (iconsize + icongap) * 3; } var y = this._location.y; var iconstyle = { zlevel: this.getzlevelbase(), z: this.getzbase() + 1, style: { icontype: 'timelinecontrol', symbol: 'last', x: x, y: y, width: iconsize, height: iconsize, brushtype: 'stroke', color: controlstyle.normal.color, strokecolor: controlstyle.normal.color, linewidth: linestyle.width }, highlightstyle: { color: controlstyle.emphasis.color, strokecolor: controlstyle.emphasis.color, linewidth: linestyle.width + 1 }, clickable: true }; this._ctrlastshape = new iconshape(iconstyle); this._ctrlastshape.onclick = function () { self.last(); }; this.shapelist.push(this._ctrlastshape); x += iconsize + icongap; this._ctrplayshape = new iconshape(zrutil.clone(iconstyle)); this._ctrplayshape.style.brushtype = 'fill'; this._ctrplayshape.style.symbol = 'play'; this._ctrplayshape.style.status = this.timelineoption.autoplay ? 'playing' : 'stop'; this._ctrplayshape.style.x = x; this._ctrplayshape.onclick = function () { if (self._ctrplayshape.style.status === 'stop') { self.play(); } else { self.stop(); } }; this.shapelist.push(this._ctrplayshape); x += iconsize + icongap; this._ctrnextshape = new iconshape(zrutil.clone(iconstyle)); this._ctrnextshape.style.symbol = 'next'; this._ctrnextshape.style.x = x; this._ctrnextshape.onclick = function () { self.next(); }; this.shapelist.push(this._ctrnextshape); }, _buildchain: function () { var timelineoption = this.timelineoption; var linestyle = timelineoption.linestyle; this._timelineshae = { zlevel: this.getzlevelbase(), z: this.getzbase(), style: { x: this._location.x, y: this.subpixeloptimize(this._location.y, linestyle.width), width: this._location.x2 - this._location.x, height: this._location.height, chainpoint: this._chainpoint, brushtype: 'both', strokecolor: linestyle.color, linewidth: linestyle.width, linetype: linestyle.type }, hoverable: false, clickable: true, onclick: this._onclick }; this._timelineshae = new chainshape(this._timelineshae); this.shapelist.push(this._timelineshae); }, _buildhandle: function () { var curpoint = this._chainpoint[this.currentindex]; var symbolsize = curpoint.symbolsize + 1; symbolsize = symbolsize < 5 ? 5 : symbolsize; this._handleshape = { zlevel: this.getzlevelbase(), z: this.getzbase() + 1, hoverable: false, draggable: true, style: { icontype: 'diamond', n: curpoint.n, x: curpoint.x - symbolsize, y: this._location.y + this._location.height / 4 - symbolsize, width: symbolsize * 2, height: symbolsize * 2, brushtype: 'both', textposition: 'specific', textx: curpoint.x, texty: this._location.y - this._location.height / 4, textalign: 'center', textbaseline: 'middle' }, highlightstyle: {}, ondrift: this._ondrift, ondragend: this._ondragend }; this._handleshape = new iconshape(this._handleshape); this.shapelist.push(this._handleshape); }, _synchandleshape: function () { if (!this.timelineoption.show) { return; } var timelineoption = this.timelineoption; var cpstyle = timelineoption.checkpointstyle; var curpoint = this._chainpoint[this.currentindex]; this._handleshape.style.text = cpstyle.label.show ? curpoint.name : ''; this._handleshape.style.textfont = curpoint.textfont; this._handleshape.style.n = curpoint.n; if (cpstyle.symbol === 'auto') { this._handleshape.style.icontype = curpoint.symbol != 'none' ? curpoint.symbol : 'diamond'; } else { this._handleshape.style.icontype = cpstyle.symbol; if (cpstyle.symbol.match('star')) { this._handleshape.style.n = cpstyle.symbol.replace('star', '') - 0 || 5; this._handleshape.style.icontype = 'star'; } } var symbolsize; if (cpstyle.symbolsize === 'auto') { symbolsize = curpoint.symbolsize + 2; symbolsize = symbolsize < 5 ? 5 : symbolsize; } else { symbolsize = cpstyle.symbolsize - 0; } this._handleshape.style.color = cpstyle.color === 'auto' ? curpoint.color ? curpoint.color : timelineoption.controlstyle.emphasis.color : cpstyle.color; this._handleshape.style.textcolor = cpstyle.label.textstyle.color === 'auto' ? this._handleshape.style.color : cpstyle.label.textstyle.color; this._handleshape.highlightstyle.strokecolor = this._handleshape.style.strokecolor = cpstyle.bordercolor === 'auto' ? curpoint.bordercolor ? curpoint.bordercolor : '#fff' : cpstyle.bordercolor; this._handleshape.style.linewidth = cpstyle.borderwidth === 'auto' ? curpoint.borderwidth ? curpoint.borderwidth : 0 : cpstyle.borderwidth - 0; this._handleshape.highlightstyle.linewidth = this._handleshape.style.linewidth + 1; this.zr.animate(this._handleshape.id, 'style').when(500, { x: curpoint.x - symbolsize, textx: curpoint.x, y: this._location.y + this._location.height / 4 - symbolsize, width: symbolsize * 2, height: symbolsize * 2 }).start('exponentialout'); }, _findchainindex: function (x) { var chainpoint = this._chainpoint; var len = chainpoint.length; if (x <= chainpoint[0].x) { return 0; } else if (x >= chainpoint[len - 1].x) { return len - 1; } for (var i = 0; i < len - 1; i++) { if (x >= chainpoint[i].x && x <= chainpoint[i + 1].x) { return math.abs(x - chainpoint[i].x) < math.abs(x - chainpoint[i + 1].x) ? i : i + 1; } } }, __onclick: function (param) { var x = zrevent.getx(param.event); var newindex = this._findchainindex(x); if (newindex === this.currentindex) { return true; } this.currentindex = newindex; this.timelineoption.autoplay && this.stop(); cleartimeout(this.playticket); this._onframe(); }, __ondrift: function (shape, dx) { this.timelineoption.autoplay && this.stop(); var chainpoint = this._chainpoint; var len = chainpoint.length; var newindex; if (shape.style.x + dx <= chainpoint[0].x - chainpoint[0].symbolsize) { shape.style.x = chainpoint[0].x - chainpoint[0].symbolsize; newindex = 0; } else if (shape.style.x + dx >= chainpoint[len - 1].x - chainpoint[len - 1].symbolsize) { shape.style.x = chainpoint[len - 1].x - chainpoint[len - 1].symbolsize; newindex = len - 1; } else { shape.style.x += dx; newindex = this._findchainindex(shape.style.x); } var curpoint = chainpoint[newindex]; var symbolsize = curpoint.symbolsize + 2; shape.style.icontype = curpoint.symbol; shape.style.n = curpoint.n; shape.style.textx = shape.style.x + symbolsize / 2; shape.style.y = this._location.y + this._location.height / 4 - symbolsize; shape.style.width = symbolsize * 2; shape.style.height = symbolsize * 2; shape.style.text = curpoint.name; if (newindex === this.currentindex) { return true; } this.currentindex = newindex; if (this.timelineoption.realtime) { cleartimeout(this.playticket); var self = this; this.playticket = settimeout(function () { self._setcurrentoption(); }, 200); } return true; }, __ondragend: function () { this.isdragend = true; }, ondragend: function (param, status) { if (!this.isdragend || !param.target) { return; } !this.timelineoption.realtime && this._setcurrentoption(); status.dragout = true; status.dragin = true; status.needrefresh = false; this.isdragend = false; this._synchandleshape(); return; }, last: function () { this.timelineoption.autoplay && this.stop(); this.currentindex -= 1; if (this.currentindex < 0) { this.currentindex = this.timelineoption.data.length - 1; } this._onframe(); return this.currentindex; }, next: function () { this.timelineoption.autoplay && this.stop(); this.currentindex += 1; if (this.currentindex >= this.timelineoption.data.length) { this.currentindex = 0; } this._onframe(); return this.currentindex; }, play: function (targetindex, autoplay) { if (this._ctrplayshape && this._ctrplayshape.style.status != 'playing') { this._ctrplayshape.style.status = 'playing'; this.zr.modshape(this._ctrplayshape.id); this.zr.refreshnextframe(); } this.timelineoption.autoplay = autoplay != null ? autoplay : true; if (!this.timelineoption.autoplay) { cleartimeout(this.playticket); } this.currentindex = targetindex != null ? targetindex : this.currentindex + 1; if (this.currentindex >= this.timelineoption.data.length) { this.currentindex = 0; } this._onframe(); return this.currentindex; }, stop: function () { if (this._ctrplayshape && this._ctrplayshape.style.status != 'stop') { this._ctrplayshape.style.status = 'stop'; this.zr.modshape(this._ctrplayshape.id); this.zr.refreshnextframe(); } this.timelineoption.autoplay = false; cleartimeout(this.playticket); return this.currentindex; }, resize: function () { if (this.timelineoption.show) { this.clear(); this._buildshape(); this._synchandleshape(); } }, settheme: function (needrefresh) { this.timelineoption = this.reformoption(zrutil.clone(this.option.timeline)); this.timelineoption.label.textstyle = this.gettextstyle(this.timelineoption.label.textstyle); this.timelineoption.checkpointstyle.label.textstyle = this.gettextstyle(this.timelineoption.checkpointstyle.label.textstyle); if (!this.mychart.canvassupported) { this.timelineoption.realtime = false; } if (this.timelineoption.show && needrefresh) { this.clear(); this._buildshape(); this._synchandleshape(); } }, onbefordispose: function () { cleartimeout(this.playticket); } }; function timelinecontrol(ctx, style) { var linewidth = 2; var x = style.x + linewidth; var y = style.y + linewidth + 2; var width = style.width - linewidth; var height = style.height - linewidth; var symbol = style.symbol; if (symbol === 'last') { ctx.moveto(x + width - 2, y + height / 3); ctx.lineto(x + width - 2, y); ctx.lineto(x + 2, y + height / 2); ctx.lineto(x + width - 2, y + height); ctx.lineto(x + width - 2, y + height / 3 * 2); ctx.moveto(x, y); ctx.lineto(x, y); } else if (symbol === 'next') { ctx.moveto(x + 2, y + height / 3); ctx.lineto(x + 2, y); ctx.lineto(x + width - 2, y + height / 2); ctx.lineto(x + 2, y + height); ctx.lineto(x + 2, y + height / 3 * 2); ctx.moveto(x, y); ctx.lineto(x, y); } else if (symbol === 'play') { if (style.status === 'stop') { ctx.moveto(x + 2, y); ctx.lineto(x + width - 2, y + height / 2); ctx.lineto(x + 2, y + height); ctx.lineto(x + 2, y); } else { var delta = style.brushtype === 'both' ? 2 : 3; ctx.rect(x + 2, y, delta, height); ctx.rect(x + width - delta - 2, y, delta, height); } } else if (symbol.match('image')) { var imagelocation = ''; imagelocation = symbol.replace(new regexp('^image:\\/\\/'), ''); symbol = iconshape.prototype.iconlibrary.image; symbol(ctx, { x: x, y: y, width: width, height: height, image: imagelocation }); } } iconshape.prototype.iconlibrary['timelinecontrol'] = timelinecontrol; zrutil.inherits(timeline, base); require('../component').define('timeline', timeline); return timeline; });define('zrender/shape/image', [ 'require', './base', '../tool/util' ], function (require) { var base = require('./base'); var zimage = function (options) { base.call(this, options); }; zimage.prototype = { type: 'image', brush: function (ctx, ishighlight, refreshnextframe) { var style = this.style || {}; if (ishighlight) { style = this.gethighlightstyle(style, this.highlightstyle || {}); } var image = style.image; var self = this; if (!this._imagecache) { this._imagecache = {}; } if (typeof image === 'string') { var src = image; if (this._imagecache[src]) { image = this._imagecache[src]; } else { image = new image(); image.onload = function () { image.onload = null; self.modself(); refreshnextframe(); }; image.src = src; this._imagecache[src] = image; } } if (image) { if (image.nodename.touppercase() == 'img') { if (window.activexobject) { if (image.readystate != 'complete') { return; } } else { if (!image.complete) { return; } } } var width = style.width || image.width; var height = style.height || image.height; var x = style.x; var y = style.y; if (!image.width || !image.height) { return; } ctx.save(); this.doclip(ctx); this.setcontext(ctx, style); this.settransform(ctx); if (style.swidth && style.sheight) { var sx = style.sx || 0; var sy = style.sy || 0; ctx.drawimage(image, sx, sy, style.swidth, style.sheight, x, y, width, height); } else if (style.sx && style.sy) { var sx = style.sx; var sy = style.sy; var swidth = width - sx; var sheight = height - sy; ctx.drawimage(image, sx, sy, swidth, sheight, x, y, width, height); } else { ctx.drawimage(image, x, y, width, height); } if (!style.width) { style.width = width; } if (!style.height) { style.height = height; } if (!this.style.width) { this.style.width = width; } if (!this.style.height) { this.style.height = height; } this.drawtext(ctx, style, this.style); ctx.restore(); } }, getrect: function (style) { return { x: style.x, y: style.y, width: style.width, height: style.height }; }, clearcache: function () { this._imagecache = {}; } }; require('../tool/util').inherits(zimage, base); return zimage; });define('zrender/loadingeffect/bar', [ 'require', './base', '../tool/util', '../tool/color', '../shape/rectangle' ], function (require) { var base = require('./base'); var util = require('../tool/util'); var zrcolor = require('../tool/color'); var rectangleshape = require('../shape/rectangle'); function bar(options) { base.call(this, options); } util.inherits(bar, base); bar.prototype._start = function (addshapehandle, refreshhandle) { var options = util.merge(this.options, { textstyle: { color: '#888' }, backgroundcolor: 'rgba(250, 250, 250, 0.8)', effectoption: { x: 0, y: this.canvasheight / 2 - 30, width: this.canvaswidth, height: 5, brushtype: 'fill', timeinterval: 100 } }); var textshape = this.createtextshape(options.textstyle); var background = this.createbackgroundshape(options.backgroundcolor); var effectoption = options.effectoption; var barshape = new rectangleshape({ highlightstyle: util.clone(effectoption) }); barshape.highlightstyle.color = effectoption.color || zrcolor.getlineargradient(effectoption.x, effectoption.y, effectoption.x + effectoption.width, effectoption.y + effectoption.height, [ [ 0, '#ff6400' ], [ 0.5, '#ffe100' ], [ 1, '#b1ff00' ] ]); if (options.progress != null) { addshapehandle(background); barshape.highlightstyle.width = this.adjust(options.progress, [ 0, 1 ]) * options.effectoption.width; addshapehandle(barshape); addshapehandle(textshape); refreshhandle(); return; } else { barshape.highlightstyle.width = 0; return setinterval(function () { addshapehandle(background); if (barshape.highlightstyle.width < effectoption.width) { barshape.highlightstyle.width += 8; } else { barshape.highlightstyle.width = 0; } addshapehandle(barshape); addshapehandle(textshape); refreshhandle(); }, effectoption.timeinterval); } }; return bar; });define('zrender/loadingeffect/bubble', [ 'require', './base', '../tool/util', '../tool/color', '../shape/circle' ], function (require) { var base = require('./base'); var util = require('../tool/util'); var zrcolor = require('../tool/color'); var circleshape = require('../shape/circle'); function bubble(options) { base.call(this, options); } util.inherits(bubble, base); bubble.prototype._start = function (addshapehandle, refreshhandle) { var options = util.merge(this.options, { textstyle: { color: '#888' }, backgroundcolor: 'rgba(250, 250, 250, 0.8)', effect: { n: 50, linewidth: 2, brushtype: 'stroke', color: 'random', timeinterval: 100 } }); var textshape = this.createtextshape(options.textstyle); var background = this.createbackgroundshape(options.backgroundcolor); var effectoption = options.effect; var n = effectoption.n; var brushtype = effectoption.brushtype; var linewidth = effectoption.linewidth; var shapelist = []; var canvaswidth = this.canvaswidth; var canvasheight = this.canvasheight; for (var i = 0; i < n; i++) { var color = effectoption.color == 'random' ? zrcolor.alpha(zrcolor.random(), 0.3) : effectoption.color; shapelist[i] = new circleshape({ highlightstyle: { x: math.ceil(math.random() * canvaswidth), y: math.ceil(math.random() * canvasheight), r: math.ceil(math.random() * 40), brushtype: brushtype, color: color, strokecolor: color, linewidth: linewidth }, animationy: math.ceil(math.random() * 20) }); } return setinterval(function () { addshapehandle(background); for (var i = 0; i < n; i++) { var style = shapelist[i].highlightstyle; if (style.y - shapelist[i].animationy + style.r <= 0) { shapelist[i].highlightstyle.y = canvasheight + style.r; shapelist[i].highlightstyle.x = math.ceil(math.random() * canvaswidth); } shapelist[i].highlightstyle.y -= shapelist[i].animationy; addshapehandle(shapelist[i]); } addshapehandle(textshape); refreshhandle(); }, effectoption.timeinterval); }; return bubble; });define('zrender/loadingeffect/dynamicline', [ 'require', './base', '../tool/util', '../tool/color', '../shape/line' ], function (require) { var base = require('./base'); var util = require('../tool/util'); var zrcolor = require('../tool/color'); var lineshape = require('../shape/line'); function dynamicline(options) { base.call(this, options); } util.inherits(dynamicline, base); dynamicline.prototype._start = function (addshapehandle, refreshhandle) { var options = util.merge(this.options, { textstyle: { color: '#fff' }, backgroundcolor: 'rgba(0, 0, 0, 0.8)', effectoption: { n: 30, linewidth: 1, color: 'random', timeinterval: 100 } }); var textshape = this.createtextshape(options.textstyle); var background = this.createbackgroundshape(options.backgroundcolor); var effectoption = options.effectoption; var n = effectoption.n; var linewidth = effectoption.linewidth; var shapelist = []; var canvaswidth = this.canvaswidth; var canvasheight = this.canvasheight; for (var i = 0; i < n; i++) { var xstart = -math.ceil(math.random() * 1000); var len = math.ceil(math.random() * 400); var pos = math.ceil(math.random() * canvasheight); var color = effectoption.color == 'random' ? zrcolor.random() : effectoption.color; shapelist[i] = new lineshape({ highlightstyle: { xstart: xstart, ystart: pos, xend: xstart + len, yend: pos, strokecolor: color, linewidth: linewidth }, animationx: math.ceil(math.random() * 100), len: len }); } return setinterval(function () { addshapehandle(background); for (var i = 0; i < n; i++) { var style = shapelist[i].highlightstyle; if (style.xstart >= canvaswidth) { shapelist[i].len = math.ceil(math.random() * 400); style.xstart = -400; style.xend = -400 + shapelist[i].len; style.ystart = math.ceil(math.random() * canvasheight); style.yend = style.ystart; } style.xstart += shapelist[i].animationx; style.xend += shapelist[i].animationx; addshapehandle(shapelist[i]); } addshapehandle(textshape); refreshhandle(); }, effectoption.timeinterval); }; return dynamicline; });define('zrender/loadingeffect/ring', [ 'require', './base', '../tool/util', '../tool/color', '../shape/ring', '../shape/sector' ], function (require) { var base = require('./base'); var util = require('../tool/util'); var zrcolor = require('../tool/color'); var ringshape = require('../shape/ring'); var sectorshape = require('../shape/sector'); function ring(options) { base.call(this, options); } util.inherits(ring, base); ring.prototype._start = function (addshapehandle, refreshhandle) { var options = util.merge(this.options, { textstyle: { color: '#07a' }, backgroundcolor: 'rgba(250, 250, 250, 0.8)', effect: { x: this.canvaswidth / 2, y: this.canvasheight / 2, r0: 60, r: 100, color: '#bbdcff', brushtype: 'fill', textposition: 'inside', textfont: 'normal 30px verdana', textcolor: 'rgba(30, 144, 255, 0.6)', timeinterval: 100 } }); var effectoption = options.effect; var textstyle = options.textstyle; if (textstyle.x == null) { textstyle.x = effectoption.x; } if (textstyle.y == null) { textstyle.y = effectoption.y + (effectoption.r0 + effectoption.r) / 2 - 5; } var textshape = this.createtextshape(options.textstyle); var background = this.createbackgroundshape(options.backgroundcolor); var x = effectoption.x; var y = effectoption.y; var r0 = effectoption.r0 + 6; var r = effectoption.r - 6; var color = effectoption.color; var darkcolor = zrcolor.lift(color, 0.1); var shapering = new ringshape({ highlightstyle: util.clone(effectoption) }); var shapelist = []; var clolrlist = zrcolor.getgradientcolors([ '#ff6400', '#ffe100', '#97ff00' ], 25); var preangle = 15; var endangle = 240; for (var i = 0; i < 16; i++) { shapelist.push(new sectorshape({ highlightstyle: { x: x, y: y, r0: r0, r: r, startangle: endangle - preangle, endangle: endangle, brushtype: 'fill', color: darkcolor }, _color: zrcolor.getlineargradient(x + r0 * math.cos(endangle, true), y - r0 * math.sin(endangle, true), x + r0 * math.cos(endangle - preangle, true), y - r0 * math.sin(endangle - preangle, true), [ [ 0, clolrlist[i * 2] ], [ 1, clolrlist[i * 2 + 1] ] ]) })); endangle -= preangle; } endangle = 360; for (var i = 0; i < 4; i++) { shapelist.push(new sectorshape({ highlightstyle: { x: x, y: y, r0: r0, r: r, startangle: endangle - preangle, endangle: endangle, brushtype: 'fill', color: darkcolor }, _color: zrcolor.getlineargradient(x + r0 * math.cos(endangle, true), y - r0 * math.sin(endangle, true), x + r0 * math.cos(endangle - preangle, true), y - r0 * math.sin(endangle - preangle, true), [ [ 0, clolrlist[i * 2 + 32] ], [ 1, clolrlist[i * 2 + 33] ] ]) })); endangle -= preangle; } var n = 0; if (options.progress != null) { addshapehandle(background); n = this.adjust(options.progress, [ 0, 1 ]).tofixed(2) * 100 / 5; shapering.highlightstyle.text = n * 5 + '%'; addshapehandle(shapering); for (var i = 0; i < 20; i++) { shapelist[i].highlightstyle.color = i < n ? shapelist[i]._color : darkcolor; addshapehandle(shapelist[i]); } addshapehandle(textshape); refreshhandle(); return; } return setinterval(function () { addshapehandle(background); n += n >= 20 ? -20 : 1; addshapehandle(shapering); for (var i = 0; i < 20; i++) { shapelist[i].highlightstyle.color = i < n ? shapelist[i]._color : darkcolor; addshapehandle(shapelist[i]); } addshapehandle(textshape); refreshhandle(); }, effectoption.timeinterval); }; return ring; });define('zrender/loadingeffect/spin', [ 'require', './base', '../tool/util', '../tool/color', '../tool/area', '../shape/sector' ], function (require) { var base = require('./base'); var util = require('../tool/util'); var zrcolor = require('../tool/color'); var zrarea = require('../tool/area'); var sectorshape = require('../shape/sector'); function spin(options) { base.call(this, options); } util.inherits(spin, base); spin.prototype._start = function (addshapehandle, refreshhandle) { var options = util.merge(this.options, { textstyle: { color: '#fff', textalign: 'start' }, backgroundcolor: 'rgba(0, 0, 0, 0.8)' }); var textshape = this.createtextshape(options.textstyle); var textgap = 10; var textwidth = zrarea.gettextwidth(textshape.highlightstyle.text, textshape.highlightstyle.textfont); var textheight = zrarea.gettextheight(textshape.highlightstyle.text, textshape.highlightstyle.textfont); var effectoption = util.merge(this.options.effect || {}, { r0: 9, r: 15, n: 18, color: '#fff', timeinterval: 100 }); var location = this.getlocation(this.options.textstyle, textwidth + textgap + effectoption.r * 2, math.max(effectoption.r * 2, textheight)); effectoption.x = location.x + effectoption.r; effectoption.y = textshape.highlightstyle.y = location.y + location.height / 2; textshape.highlightstyle.x = effectoption.x + effectoption.r + textgap; var background = this.createbackgroundshape(options.backgroundcolor); var n = effectoption.n; var x = effectoption.x; var y = effectoption.y; var r0 = effectoption.r0; var r = effectoption.r; var color = effectoption.color; var shapelist = []; var preangle = math.round(180 / n); for (var i = 0; i < n; i++) { shapelist[i] = new sectorshape({ highlightstyle: { x: x, y: y, r0: r0, r: r, startangle: preangle * i * 2, endangle: preangle * i * 2 + preangle, color: zrcolor.alpha(color, (i + 1) / n), brushtype: 'fill' } }); } var pos = [ 0, x, y ]; return setinterval(function () { addshapehandle(background); pos[0] -= 0.3; for (var i = 0; i < n; i++) { shapelist[i].rotation = pos; addshapehandle(shapelist[i]); } addshapehandle(textshape); refreshhandle(); }, effectoption.timeinterval); }; return spin; });define('zrender/loadingeffect/whirling', [ 'require', './base', '../tool/util', '../tool/area', '../shape/ring', '../shape/droplet', '../shape/circle' ], function (require) { var base = require('./base'); var util = require('../tool/util'); var zrarea = require('../tool/area'); var ringshape = require('../shape/ring'); var dropletshape = require('../shape/droplet'); var circleshape = require('../shape/circle'); function whirling(options) { base.call(this, options); } util.inherits(whirling, base); whirling.prototype._start = function (addshapehandle, refreshhandle) { var options = util.merge(this.options, { textstyle: { color: '#888', textalign: 'start' }, backgroundcolor: 'rgba(250, 250, 250, 0.8)' }); var textshape = this.createtextshape(options.textstyle); var textgap = 10; var textwidth = zrarea.gettextwidth(textshape.highlightstyle.text, textshape.highlightstyle.textfont); var textheight = zrarea.gettextheight(textshape.highlightstyle.text, textshape.highlightstyle.textfont); var effectoption = util.merge(this.options.effect || {}, { r: 18, colorin: '#fff', colorout: '#555', colorwhirl: '#6cf', timeinterval: 50 }); var location = this.getlocation(this.options.textstyle, textwidth + textgap + effectoption.r * 2, math.max(effectoption.r * 2, textheight)); effectoption.x = location.x + effectoption.r; effectoption.y = textshape.highlightstyle.y = location.y + location.height / 2; textshape.highlightstyle.x = effectoption.x + effectoption.r + textgap; var background = this.createbackgroundshape(options.backgroundcolor); var droplet = new dropletshape({ highlightstyle: { a: math.round(effectoption.r / 2), b: math.round(effectoption.r - effectoption.r / 6), brushtype: 'fill', color: effectoption.colorwhirl } }); var circlein = new circleshape({ highlightstyle: { r: math.round(effectoption.r / 6), brushtype: 'fill', color: effectoption.colorin } }); var circleout = new ringshape({ highlightstyle: { r0: math.round(effectoption.r - effectoption.r / 3), r: effectoption.r, brushtype: 'fill', color: effectoption.colorout } }); var pos = [ 0, effectoption.x, effectoption.y ]; droplet.highlightstyle.x = circlein.highlightstyle.x = circleout.highlightstyle.x = pos[1]; droplet.highlightstyle.y = circlein.highlightstyle.y = circleout.highlightstyle.y = pos[2]; return setinterval(function () { addshapehandle(background); addshapehandle(circleout); pos[0] -= 0.3; droplet.rotation = pos; addshapehandle(droplet); addshapehandle(circlein); addshapehandle(textshape); refreshhandle(); }, effectoption.timeinterval); }; return whirling; });define('echarts/theme/macarons', [], function () { var theme = { color: [ '#2ec7c9', '#b6a2de', '#5ab1ef', '#ffb980', '#d87a80', '#8d98b3', '#e5cf0d', '#97b552', '#95706d', '#dc69aa', '#07a2a4', '#9a7fd1', '#588dd5', '#f5994e', '#c05050', '#59678c', '#c9ab00', '#7eb00a', '#6f5553', '#c14089' ], title: { textstyle: { fontweight: 'normal', color: '#008acd' } }, datarange: { itemwidth: 15, color: [ '#5ab1ef', '#e0ffff' ] }, toolbox: { color: [ '#1e90ff', '#1e90ff', '#1e90ff', '#1e90ff' ], effectivecolor: '#ff4500' }, tooltip: { backgroundcolor: 'rgba(50,50,50,0.5)', axispointer: { type: 'line', linestyle: { color: '#008acd' }, crossstyle: { color: '#008acd' }, shadowstyle: { color: 'rgba(200,200,200,0.2)' } } }, datazoom: { databackgroundcolor: '#efefff', fillercolor: 'rgba(182,162,222,0.2)', handlecolor: '#008acd' }, grid: { bordercolor: '#eee' }, categoryaxis: { axisline: { linestyle: { color: '#008acd' } }, splitline: { linestyle: { color: ['#eee'] } } }, valueaxis: { axisline: { linestyle: { color: '#008acd' } }, splitarea: { show: true, areastyle: { color: [ 'rgba(250,250,250,0.1)', 'rgba(200,200,200,0.1)' ] } }, splitline: { linestyle: { color: ['#eee'] } } }, polar: { axisline: { linestyle: { color: '#ddd' } }, splitarea: { show: true, areastyle: { color: [ 'rgba(250,250,250,0.2)', 'rgba(200,200,200,0.2)' ] } }, splitline: { linestyle: { color: '#ddd' } } }, timeline: { linestyle: { color: '#008acd' }, controlstyle: { normal: { color: '#008acd' }, emphasis: { color: '#008acd' } }, symbol: 'emptycircle', symbolsize: 3 }, bar: { itemstyle: { normal: { barborderradius: 5 }, emphasis: { barborderradius: 5 } } }, line: { smooth: true, symbol: 'emptycircle', symbolsize: 3 }, k: { itemstyle: { normal: { color: '#d87a80', color0: '#2ec7c9', linestyle: { color: '#d87a80', color0: '#2ec7c9' } } } }, scatter: { symbol: 'circle', symbolsize: 4 }, radar: { symbol: 'emptycircle', symbolsize: 3 }, map: { itemstyle: { normal: { areastyle: { color: '#ddd' }, label: { textstyle: { color: '#d87a80' } } }, emphasis: { areastyle: { color: '#fe994e' } } } }, force: { itemstyle: { normal: { linkstyle: { color: '#1e90ff' } } } }, chord: { itemstyle: { normal: { borderwidth: 1, bordercolor: 'rgba(128, 128, 128, 0.5)', chordstyle: { linestyle: { color: 'rgba(128, 128, 128, 0.5)' } } }, emphasis: { borderwidth: 1, bordercolor: 'rgba(128, 128, 128, 0.5)', chordstyle: { linestyle: { color: 'rgba(128, 128, 128, 0.5)' } } } } }, gauge: { axisline: { linestyle: { color: [ [ 0.2, '#2ec7c9' ], [ 0.8, '#5ab1ef' ], [ 1, '#d87a80' ] ], width: 10 } }, axistick: { splitnumber: 10, length: 15, linestyle: { color: 'auto' } }, splitline: { length: 22, linestyle: { color: 'auto' } }, pointer: { width: 5 } }, textstyle: { fontfamily: '微软雅黑, arial, verdana, sans-serif' } }; return theme; });define('echarts/theme/infographic', [], function () { var theme = { color: [ '#c1232b', '#b5c334', '#fcce10', '#e87c25', '#27727b', '#fe8463', '#9bca63', '#fad860', '#f3a43b', '#60c0dd', '#d7504b', '#c6e579', '#f4e001', '#f0805a', '#26c0c0' ], title: { textstyle: { fontweight: 'normal', color: '#27727b' } }, datarange: { x: 'right', y: 'center', itemwidth: 5, itemheight: 25, color: [ '#c1232b', '#fcce10' ] }, toolbox: { color: [ '#c1232b', '#b5c334', '#fcce10', '#e87c25', '#27727b', '#fe8463', '#9bca63', '#fad860', '#f3a43b', '#60c0dd' ], effectivecolor: '#ff4500' }, tooltip: { backgroundcolor: 'rgba(50,50,50,0.5)', axispointer: { type: 'line', linestyle: { color: '#27727b', type: 'dashed' }, crossstyle: { color: '#27727b' }, shadowstyle: { color: 'rgba(200,200,200,0.3)' } } }, datazoom: { databackgroundcolor: 'rgba(181,195,52,0.3)', fillercolor: 'rgba(181,195,52,0.2)', handlecolor: '#27727b' }, grid: { borderwidth: 0 }, categoryaxis: { axisline: { linestyle: { color: '#27727b' } }, splitline: { show: false } }, valueaxis: { axisline: { show: false }, splitarea: { show: false }, splitline: { linestyle: { color: ['#ccc'], type: 'dashed' } } }, polar: { axisline: { linestyle: { color: '#ddd' } }, splitarea: { show: true, areastyle: { color: [ 'rgba(250,250,250,0.2)', 'rgba(200,200,200,0.2)' ] } }, splitline: { linestyle: { color: '#ddd' } } }, timeline: { linestyle: { color: '#27727b' }, controlstyle: { normal: { color: '#27727b' }, emphasis: { color: '#27727b' } }, symbol: 'emptycircle', symbolsize: 3 }, line: { itemstyle: { normal: { borderwidth: 2, bordercolor: '#fff', linestyle: { width: 3 } }, emphasis: { borderwidth: 0 } }, symbol: 'circle', symbolsize: 3.5 }, k: { itemstyle: { normal: { color: '#c1232b', color0: '#b5c334', linestyle: { width: 1, color: '#c1232b', color0: '#b5c334' } } } }, scatter: { itemstyle: { normal: { borderwidth: 1, bordercolor: 'rgba(200,200,200,0.5)' }, emphasis: { borderwidth: 0 } }, symbol: 'star4', symbolsize: 4 }, radar: { symbol: 'emptycircle', symbolsize: 3 }, map: { itemstyle: { normal: { areastyle: { color: '#ddd' }, label: { textstyle: { color: '#c1232b' } } }, emphasis: { areastyle: { color: '#fe994e' }, label: { textstyle: { color: 'rgb(100,0,0)' } } } } }, force: { itemstyle: { normal: { linkstyle: { color: '#27727b' } } } }, chord: { itemstyle: { normal: { borderwidth: 1, bordercolor: 'rgba(128, 128, 128, 0.5)', chordstyle: { linestyle: { color: 'rgba(128, 128, 128, 0.5)' } } }, emphasis: { borderwidth: 1, bordercolor: 'rgba(128, 128, 128, 0.5)', chordstyle: { linestyle: { color: 'rgba(128, 128, 128, 0.5)' } } } } }, gauge: { center: [ '50%', '80%' ], radius: '100%', startangle: 180, endangle: 0, axisline: { show: true, linestyle: { color: [ [ 0.2, '#b5c334' ], [ 0.8, '#27727b' ], [ 1, '#c1232b' ] ], width: '40%' } }, axistick: { splitnumber: 2, length: 5, linestyle: { color: '#fff' } }, axislabel: { textstyle: { color: '#fff', fontweight: 'bolder' } }, splitline: { length: '5%', linestyle: { color: '#fff' } }, pointer: { width: '40%', length: '80%', color: '#fff' }, title: { offsetcenter: [ 0, -20 ], textstyle: { color: 'auto', fontsize: 20 } }, detail: { offsetcenter: [ 0, 0 ], textstyle: { color: 'auto', fontsize: 40 } } }, textstyle: { fontfamily: '微软雅黑, arial, verdana, sans-serif' } }; return theme; });define('zrender/dep/excanvas', ['require'], function (require) { if (!document.createelement('canvas').getcontext) { (function () { var m = math; var mr = m.round; var ms = m.sin; var mc = m.cos; var abs = m.abs; var sqrt = m.sqrt; var z = 10; var z2 = z / 2; var ie_version = +navigator.useragent.match(/msie ([\d.]+)?/)[1]; function getcontext() { return this.context_ || (this.context_ = new canvasrenderingcontext2d_(this)); } var slice = array.prototype.slice; function bind(f, obj, var_args) { var a = slice.call(arguments, 2); return function () { return f.apply(obj, a.concat(slice.call(arguments))); }; } function encodehtmlattribute(s) { return string(s).replace(/&/g, '&').replace(/"/g, '"'); } function addnamespace(doc, prefix, urn) { if (!doc.namespaces[prefix]) { doc.namespaces.add(prefix, urn, '#default#vml'); } } function addnamespacesandstylesheet(doc) { addnamespace(doc, 'g_vml_', 'urn:schemas-microsoft-com:vml'); addnamespace(doc, 'g_o_', 'urn:schemas-microsoft-com:office:office'); if (!doc.stylesheets['ex_canvas_']) { var ss = doc.createstylesheet(); ss.owningelement.id = 'ex_canvas_'; ss.csstext = 'canvas{display:inline-block;overflow:hidden;' + 'text-align:left;width:300px;height:150px}'; } } addnamespacesandstylesheet(document); var g_vmlcanvasmanager_ = { init: function (opt_doc) { var doc = opt_doc || document; doc.createelement('canvas'); doc.attachevent('onreadystatechange', bind(this.init_, this, doc)); }, init_: function (doc) { var els = doc.getelementsbytagname('canvas'); for (var i = 0; i < els.length; i++) { this.initelement(els[i]); } }, initelement: function (el) { if (!el.getcontext) { el.getcontext = getcontext; addnamespacesandstylesheet(el.ownerdocument); el.innerhtml = ''; el.attachevent('onpropertychange', onpropertychange); el.attachevent('onresize', onresize); var attrs = el.attributes; if (attrs.width && attrs.width.specified) { el.style.width = attrs.width.nodevalue + 'px'; } else { el.width = el.clientwidth; } if (attrs.height && attrs.height.specified) { el.style.height = attrs.height.nodevalue + 'px'; } else { el.height = el.clientheight; } } return el; } }; function onpropertychange(e) { var el = e.srcelement; switch (e.propertyname) { case 'width': el.getcontext().clearrect(); el.style.width = el.attributes.width.nodevalue + 'px'; el.firstchild.style.width = el.clientwidth + 'px'; break; case 'height': el.getcontext().clearrect(); el.style.height = el.attributes.height.nodevalue + 'px'; el.firstchild.style.height = el.clientheight + 'px'; break; } } function onresize(e) { var el = e.srcelement; if (el.firstchild) { el.firstchild.style.width = el.clientwidth + 'px'; el.firstchild.style.height = el.clientheight + 'px'; } } g_vmlcanvasmanager_.init(); var dectohex = []; for (var i = 0; i < 16; i++) { for (var j = 0; j < 16; j++) { dectohex[i * 16 + j] = i.tostring(16) + j.tostring(16); } } function creatematrixidentity() { return [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ 0, 0, 1 ] ]; } function matrixmultiply(m1, m2) { var result = creatematrixidentity(); for (var x = 0; x < 3; x++) { for (var y = 0; y < 3; y++) { var sum = 0; for (var z = 0; z < 3; z++) { sum += m1[x][z] * m2[z][y]; } result[x][y] = sum; } } return result; } function copystate(o1, o2) { o2.fillstyle = o1.fillstyle; o2.linecap = o1.linecap; o2.linejoin = o1.linejoin; o2.linewidth = o1.linewidth; o2.miterlimit = o1.miterlimit; o2.shadowblur = o1.shadowblur; o2.shadowcolor = o1.shadowcolor; o2.shadowoffsetx = o1.shadowoffsetx; o2.shadowoffsety = o1.shadowoffsety; o2.strokestyle = o1.strokestyle; o2.globalalpha = o1.globalalpha; o2.font = o1.font; o2.textalign = o1.textalign; o2.textbaseline = o1.textbaseline; o2.scalex_ = o1.scalex_; o2.scaley_ = o1.scaley_; o2.linescale_ = o1.linescale_; } var colordata = { 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 getrgbhslcontent(stylestring) { var start = stylestring.indexof('(', 3); var end = stylestring.indexof(')', start + 1); var parts = stylestring.substring(start + 1, end).split(','); if (parts.length != 4 || stylestring.charat(3) != 'a') { parts[3] = 1; } return parts; } function percent(s) { return parsefloat(s) / 100; } function clamp(v, min, max) { return math.min(max, math.max(min, v)); } function hsltorgb(parts) { var r, g, b, h, s, l; h = parsefloat(parts[0]) / 360 % 360; if (h < 0) h++; s = clamp(percent(parts[1]), 0, 1); l = clamp(percent(parts[2]), 0, 1); if (s == 0) { r = g = b = l; } else { var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; r = huetorgb(p, q, h + 1 / 3); g = huetorgb(p, q, h); b = huetorgb(p, q, h - 1 / 3); } return '#' + dectohex[math.floor(r * 255)] + dectohex[math.floor(g * 255)] + dectohex[math.floor(b * 255)]; } function huetorgb(m1, m2, h) { if (h < 0) h++; if (h > 1) h--; if (6 * h < 1) return m1 + (m2 - m1) * 6 * h; else if (2 * h < 1) return m2; else if (3 * h < 2) return m1 + (m2 - m1) * (2 / 3 - h) * 6; else return m1; } var processstylecache = {}; function processstyle(stylestring) { if (stylestring in processstylecache) { return processstylecache[stylestring]; } var str, alpha = 1; stylestring = string(stylestring); if (stylestring.charat(0) == '#') { str = stylestring; } else if (/^rgb/.test(stylestring)) { var parts = getrgbhslcontent(stylestring); var str = '#', n; for (var i = 0; i < 3; i++) { if (parts[i].indexof('%') != -1) { n = math.floor(percent(parts[i]) * 255); } else { n = +parts[i]; } str += dectohex[clamp(n, 0, 255)]; } alpha = +parts[3]; } else if (/^hsl/.test(stylestring)) { var parts = getrgbhslcontent(stylestring); str = hsltorgb(parts); alpha = parts[3]; } else { str = colordata[stylestring] || stylestring; } return processstylecache[stylestring] = { color: str, alpha: alpha }; } var default_style = { style: 'normal', variant: 'normal', weight: 'normal', size: 12, family: '微软雅黑' }; var fontstylecache = {}; function processfontstyle(stylestring) { if (fontstylecache[stylestring]) { return fontstylecache[stylestring]; } var el = document.createelement('div'); var style = el.style; var fontfamily; try { style.font = stylestring; fontfamily = style.fontfamily.split(',')[0]; } catch (ex) { } return fontstylecache[stylestring] = { style: style.fontstyle || default_style.style, variant: style.fontvariant || default_style.variant, weight: style.fontweight || default_style.weight, size: style.fontsize || default_style.size, family: fontfamily || default_style.family }; } function getcomputedstyle(style, element) { var computedstyle = {}; for (var p in style) { computedstyle[p] = style[p]; } var canvasfontsize = parsefloat(element.currentstyle.fontsize), fontsize = parsefloat(style.size); if (typeof style.size == 'number') { computedstyle.size = style.size; } else if (style.size.indexof('px') != -1) { computedstyle.size = fontsize; } else if (style.size.indexof('em') != -1) { computedstyle.size = canvasfontsize * fontsize; } else if (style.size.indexof('%') != -1) { computedstyle.size = canvasfontsize / 100 * fontsize; } else if (style.size.indexof('pt') != -1) { computedstyle.size = fontsize / 0.75; } else { computedstyle.size = canvasfontsize; } return computedstyle; } function buildstyle(style) { return style.style + ' ' + style.variant + ' ' + style.weight + ' ' + style.size + 'px \'' + style.family + '\''; } var linecapmap = { 'butt': 'flat', 'round': 'round' }; function processlinecap(linecap) { return linecapmap[linecap] || 'square'; } function canvasrenderingcontext2d_(canvaselement) { this.m_ = creatematrixidentity(); this.mstack_ = []; this.astack_ = []; this.currentpath_ = []; this.strokestyle = '#000'; this.fillstyle = '#000'; this.linewidth = 1; this.linejoin = 'miter'; this.linecap = 'butt'; this.miterlimit = z * 1; this.globalalpha = 1; this.font = '12px 微软雅黑'; this.textalign = 'left'; this.textbaseline = 'alphabetic'; this.canvas = canvaselement; var csstext = 'width:' + canvaselement.clientwidth + 'px;height:' + canvaselement.clientheight + 'px;overflow:hidden;position:absolute'; var el = canvaselement.ownerdocument.createelement('div'); el.style.csstext = csstext; canvaselement.appendchild(el); var overlayel = el.clonenode(false); overlayel.style.backgroundcolor = '#fff'; overlayel.style.filter = 'alpha(opacity=0)'; canvaselement.appendchild(overlayel); this.element_ = el; this.scalex_ = 1; this.scaley_ = 1; this.linescale_ = 1; } var contextprototype = canvasrenderingcontext2d_.prototype; contextprototype.clearrect = function () { if (this.textmeasureel_) { this.textmeasureel_.removenode(true); this.textmeasureel_ = null; } this.element_.innerhtml = ''; }; contextprototype.beginpath = function () { this.currentpath_ = []; }; contextprototype.moveto = function (ax, ay) { var p = getcoords(this, ax, ay); this.currentpath_.push({ type: 'moveto', x: p.x, y: p.y }); this.currentx_ = p.x; this.currenty_ = p.y; }; contextprototype.lineto = function (ax, ay) { var p = getcoords(this, ax, ay); this.currentpath_.push({ type: 'lineto', x: p.x, y: p.y }); this.currentx_ = p.x; this.currenty_ = p.y; }; contextprototype.beziercurveto = function (acp1x, acp1y, acp2x, acp2y, ax, ay) { var p = getcoords(this, ax, ay); var cp1 = getcoords(this, acp1x, acp1y); var cp2 = getcoords(this, acp2x, acp2y); beziercurveto(this, cp1, cp2, p); }; function beziercurveto(self, cp1, cp2, p) { self.currentpath_.push({ type: 'beziercurveto', cp1x: cp1.x, cp1y: cp1.y, cp2x: cp2.x, cp2y: cp2.y, x: p.x, y: p.y }); self.currentx_ = p.x; self.currenty_ = p.y; } contextprototype.quadraticcurveto = function (acpx, acpy, ax, ay) { var cp = getcoords(this, acpx, acpy); var p = getcoords(this, ax, ay); var cp1 = { x: this.currentx_ + 2 / 3 * (cp.x - this.currentx_), y: this.currenty_ + 2 / 3 * (cp.y - this.currenty_) }; var cp2 = { x: cp1.x + (p.x - this.currentx_) / 3, y: cp1.y + (p.y - this.currenty_) / 3 }; beziercurveto(this, cp1, cp2, p); }; contextprototype.arc = function (ax, ay, aradius, astartangle, aendangle, aclockwise) { aradius *= z; var arctype = aclockwise ? 'at' : 'wa'; var xstart = ax + mc(astartangle) * aradius - z2; var ystart = ay + ms(astartangle) * aradius - z2; var xend = ax + mc(aendangle) * aradius - z2; var yend = ay + ms(aendangle) * aradius - z2; if (xstart == xend && !aclockwise) { xstart += 0.125; } var p = getcoords(this, ax, ay); var pstart = getcoords(this, xstart, ystart); var pend = getcoords(this, xend, yend); this.currentpath_.push({ type: arctype, x: p.x, y: p.y, radius: aradius, xstart: pstart.x, ystart: pstart.y, xend: pend.x, yend: pend.y }); }; contextprototype.rect = function (ax, ay, awidth, aheight) { this.moveto(ax, ay); this.lineto(ax + awidth, ay); this.lineto(ax + awidth, ay + aheight); this.lineto(ax, ay + aheight); this.closepath(); }; contextprototype.strokerect = function (ax, ay, awidth, aheight) { var oldpath = this.currentpath_; this.beginpath(); this.moveto(ax, ay); this.lineto(ax + awidth, ay); this.lineto(ax + awidth, ay + aheight); this.lineto(ax, ay + aheight); this.closepath(); this.stroke(); this.currentpath_ = oldpath; }; contextprototype.fillrect = function (ax, ay, awidth, aheight) { var oldpath = this.currentpath_; this.beginpath(); this.moveto(ax, ay); this.lineto(ax + awidth, ay); this.lineto(ax + awidth, ay + aheight); this.lineto(ax, ay + aheight); this.closepath(); this.fill(); this.currentpath_ = oldpath; }; contextprototype.createlineargradient = function (ax0, ay0, ax1, ay1) { var gradient = new canvasgradient_('gradient'); gradient.x0_ = ax0; gradient.y0_ = ay0; gradient.x1_ = ax1; gradient.y1_ = ay1; return gradient; }; contextprototype.createradialgradient = function (ax0, ay0, ar0, ax1, ay1, ar1) { var gradient = new canvasgradient_('gradientradial'); gradient.x0_ = ax0; gradient.y0_ = ay0; gradient.r0_ = ar0; gradient.x1_ = ax1; gradient.y1_ = ay1; gradient.r1_ = ar1; return gradient; }; contextprototype.drawimage = function (image, var_args) { var dx, dy, dw, dh, sx, sy, sw, sh; var oldruntimewidth = image.runtimestyle.width; var oldruntimeheight = image.runtimestyle.height; image.runtimestyle.width = 'auto'; image.runtimestyle.height = 'auto'; var w = image.width; var h = image.height; image.runtimestyle.width = oldruntimewidth; image.runtimestyle.height = oldruntimeheight; if (arguments.length == 3) { dx = arguments[1]; dy = arguments[2]; sx = sy = 0; sw = dw = w; sh = dh = h; } else if (arguments.length == 5) { dx = arguments[1]; dy = arguments[2]; dw = arguments[3]; dh = arguments[4]; sx = sy = 0; sw = w; sh = h; } else if (arguments.length == 9) { sx = arguments[1]; sy = arguments[2]; sw = arguments[3]; sh = arguments[4]; dx = arguments[5]; dy = arguments[6]; dw = arguments[7]; dh = arguments[8]; } else { throw error('invalid number of arguments'); } var d = getcoords(this, dx, dy); var w2 = sw / 2; var h2 = sh / 2; var vmlstr = []; var w = 10; var h = 10; var scalex = scaley = 1; vmlstr.push(' '); if (sx || sy) { vmlstr.push('
'); } vmlstr.push('
'); if (sx || sy) vmlstr.push('
'); vmlstr.push('
'); this.element_.insertadjacenthtml('beforeend', vmlstr.join('')); }; contextprototype.stroke = function (afill) { var linestr = []; var lineopen = false; var w = 10; var h = 10; linestr.push(''); if (!afill) { appendstroke(this, linestr); } else { appendfill(this, linestr, min, max); } linestr.push(''); this.element_.insertadjacenthtml('beforeend', linestr.join('')); }; function appendstroke(ctx, linestr) { var a = processstyle(ctx.strokestyle); var color = a.color; var opacity = a.alpha * ctx.globalalpha; var linewidth = ctx.linescale_ * ctx.linewidth; if (linewidth < 1) { opacity *= linewidth; } linestr.push(''); } function appendfill(ctx, linestr, min, max) { var fillstyle = ctx.fillstyle; var arcscalex = ctx.scalex_; var arcscaley = ctx.scaley_; var width = max.x - min.x; var height = max.y - min.y; if (fillstyle instanceof canvasgradient_) { var angle = 0; var focus = { x: 0, y: 0 }; var shift = 0; var expansion = 1; if (fillstyle.type_ == 'gradient') { var x0 = fillstyle.x0_ / arcscalex; var y0 = fillstyle.y0_ / arcscaley; var x1 = fillstyle.x1_ / arcscalex; var y1 = fillstyle.y1_ / arcscaley; var p0 = getcoords(ctx, x0, y0); var p1 = getcoords(ctx, x1, y1); var dx = p1.x - p0.x; var dy = p1.y - p0.y; angle = math.atan2(dx, dy) * 180 / math.pi; if (angle < 0) { angle += 360; } if (angle < 0.000001) { angle = 0; } } else { var p0 = getcoords(ctx, fillstyle.x0_, fillstyle.y0_); focus = { x: (p0.x - min.x) / width, y: (p0.y - min.y) / height }; width /= arcscalex * z; height /= arcscaley * z; var dimension = m.max(width, height); shift = 2 * fillstyle.r0_ / dimension; expansion = 2 * fillstyle.r1_ / dimension - shift; } var stops = fillstyle.colors_; stops.sort(function (cs1, cs2) { return cs1.offset - cs2.offset; }); var length = stops.length; var color1 = stops[0].color; var color2 = stops[length - 1].color; var opacity1 = stops[0].alpha * ctx.globalalpha; var opacity2 = stops[length - 1].alpha * ctx.globalalpha; var colors = []; for (var i = 0; i < length; i++) { var stop = stops[i]; colors.push(stop.offset * expansion + shift + ' ' + stop.color); } linestr.push(''); } else if (fillstyle instanceof canvaspattern_) { if (width && height) { var deltaleft = -min.x; var deltatop = -min.y; linestr.push(''); } } else { var a = processstyle(ctx.fillstyle); var color = a.color; var opacity = a.alpha * ctx.globalalpha; linestr.push(''); } } contextprototype.fill = function () { this.stroke(true); }; contextprototype.closepath = function () { this.currentpath_.push({ type: 'close' }); }; function getcoords(ctx, ax, ay) { var m = ctx.m_; return { x: z * (ax * m[0][0] + ay * m[1][0] + m[2][0]) - z2, y: z * (ax * m[0][1] + ay * m[1][1] + m[2][1]) - z2 }; } ; contextprototype.save = function () { var o = {}; copystate(this, o); this.astack_.push(o); this.mstack_.push(this.m_); this.m_ = matrixmultiply(creatematrixidentity(), this.m_); }; contextprototype.restore = function () { if (this.astack_.length) { copystate(this.astack_.pop(), this); this.m_ = this.mstack_.pop(); } }; function matrixisfinite(m) { return isfinite(m[0][0]) && isfinite(m[0][1]) && isfinite(m[1][0]) && isfinite(m[1][1]) && isfinite(m[2][0]) && isfinite(m[2][1]); } function setm(ctx, m, updatelinescale) { if (!matrixisfinite(m)) { return; } ctx.m_ = m; ctx.scalex_ = math.sqrt(m[0][0] * m[0][0] + m[0][1] * m[0][1]); ctx.scaley_ = math.sqrt(m[1][0] * m[1][0] + m[1][1] * m[1][1]); if (updatelinescale) { var det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; ctx.linescale_ = sqrt(abs(det)); } } contextprototype.translate = function (ax, ay) { var m1 = [ [ 1, 0, 0 ], [ 0, 1, 0 ], [ ax, ay, 1 ] ]; setm(this, matrixmultiply(m1, this.m_), false); }; contextprototype.rotate = function (arot) { var c = mc(arot); var s = ms(arot); var m1 = [ [ c, s, 0 ], [ -s, c, 0 ], [ 0, 0, 1 ] ]; setm(this, matrixmultiply(m1, this.m_), false); }; contextprototype.scale = function (ax, ay) { var m1 = [ [ ax, 0, 0 ], [ 0, ay, 0 ], [ 0, 0, 1 ] ]; setm(this, matrixmultiply(m1, this.m_), true); }; contextprototype.transform = function (m11, m12, m21, m22, dx, dy) { var m1 = [ [ m11, m12, 0 ], [ m21, m22, 0 ], [ dx, dy, 1 ] ]; setm(this, matrixmultiply(m1, this.m_), true); }; contextprototype.settransform = function (m11, m12, m21, m22, dx, dy) { var m = [ [ m11, m12, 0 ], [ m21, m22, 0 ], [ dx, dy, 1 ] ]; setm(this, m, true); }; contextprototype.drawtext_ = function (text, x, y, maxwidth, stroke) { var m = this.m_, delta = 1000, left = 0, right = delta, offset = { x: 0, y: 0 }, linestr = []; var fontstyle = getcomputedstyle(processfontstyle(this.font), this.element_); var fontstylestring = buildstyle(fontstyle); var elementstyle = this.element_.currentstyle; var textalign = this.textalign.tolowercase(); switch (textalign) { case 'left': case 'center': case 'right': break; case 'end': textalign = elementstyle.direction == 'ltr' ? 'right' : 'left'; break; case 'start': textalign = elementstyle.direction == 'rtl' ? 'right' : 'left'; break; default: textalign = 'left'; } switch (this.textbaseline) { case 'hanging': case 'top': offset.y = fontstyle.size / 1.75; break; case 'middle': break; default: case null: case 'alphabetic': case 'ideographic': case 'bottom': offset.y = -fontstyle.size / 2.25; break; } switch (textalign) { case 'right': left = delta; right = 0.05; break; case 'center': left = right = delta / 2; break; } var d = getcoords(this, x + offset.x, y + offset.y); linestr.push(''); if (stroke) { appendstroke(this, linestr); } else { appendfill(this, linestr, { x: -left, y: 0 }, { x: right, y: fontstyle.size }); } var skewm = m[0][0].tofixed(3) + ',' + m[1][0].tofixed(3) + ',' + m[0][1].tofixed(3) + ',' + m[1][1].tofixed(3) + ',0,0'; var skewoffset = mr(d.x / z) + ',' + mr(d.y / z); linestr.push('', '', ''); this.element_.insertadjacenthtml('beforeend', linestr.join('')); }; contextprototype.filltext = function (text, x, y, maxwidth) { this.drawtext_(text, x, y, maxwidth, false); }; contextprototype.stroketext = function (text, x, y, maxwidth) { this.drawtext_(text, x, y, maxwidth, true); }; contextprototype.measuretext = function (text) { if (!this.textmeasureel_) { var s = ''; this.element_.insertadjacenthtml('beforeend', s); this.textmeasureel_ = this.element_.lastchild; } var doc = this.element_.ownerdocument; this.textmeasureel_.innerhtml = ''; try { this.textmeasureel_.style.font = this.font; } catch (ex) { } this.textmeasureel_.appendchild(doc.createtextnode(text)); return { width: this.textmeasureel_.offsetwidth }; }; contextprototype.clip = function () { }; contextprototype.arcto = function () { }; contextprototype.createpattern = function (image, repetition) { return new canvaspattern_(image, repetition); }; function canvasgradient_(atype) { this.type_ = atype; this.x0_ = 0; this.y0_ = 0; this.r0_ = 0; this.x1_ = 0; this.y1_ = 0; this.r1_ = 0; this.colors_ = []; } canvasgradient_.prototype.addcolorstop = function (aoffset, acolor) { acolor = processstyle(acolor); this.colors_.push({ offset: aoffset, color: acolor.color, alpha: acolor.alpha }); }; function canvaspattern_(image, repetition) { assertimageisvalid(image); switch (repetition) { case 'repeat': case null: case '': this.repetition_ = 'repeat'; break; case 'repeat-x': case 'repeat-y': case 'no-repeat': this.repetition_ = repetition; break; default: throwexception('syntax_err'); } this.src_ = image.src; this.width_ = image.width; this.height_ = image.height; } function throwexception(s) { throw new domexception_(s); } function assertimageisvalid(img) { if (!img || img.nodetype != 1 || img.tagname != 'img') { throwexception('type_mismatch_err'); } if (img.readystate != 'complete') { throwexception('invalid_state_err'); } } function domexception_(s) { this.code = this[s]; this.message = s + ': dom exception ' + this.code; } var p = domexception_.prototype = new error(); p.index_size_err = 1; p.domstring_size_err = 2; p.hierarchy_request_err = 3; p.wrong_document_err = 4; p.invalid_character_err = 5; p.no_data_allowed_err = 6; p.no_modification_allowed_err = 7; p.not_found_err = 8; p.not_supported_err = 9; p.inuse_attribute_err = 10; p.invalid_state_err = 11; p.syntax_err = 12; p.invalid_modification_err = 13; p.namespace_err = 14; p.invalid_access_err = 15; p.validation_err = 16; p.type_mismatch_err = 17; g_vmlcanvasmanager = g_vmlcanvasmanager_; canvasrenderingcontext2d = canvasrenderingcontext2d_; canvasgradient = canvasgradient_; canvaspattern = canvaspattern_; domexception = domexception_; }()); } else { g_vmlcanvasmanager = false; } return g_vmlcanvasmanager; });define('zrender/mixin/eventful', ['require'], function (require) { var eventful = function () { this._handlers = {}; }; eventful.prototype.one = function (event, handler, context) { var _h = this._handlers; if (!handler || !event) { return this; } if (!_h[event]) { _h[event] = []; } _h[event].push({ h: handler, one: true, ctx: context || this }); return this; }; eventful.prototype.bind = function (event, handler, context) { var _h = this._handlers; if (!handler || !event) { return this; } if (!_h[event]) { _h[event] = []; } _h[event].push({ h: handler, one: false, ctx: context || this }); return this; }; eventful.prototype.unbind = function (event, handler) { var _h = this._handlers; if (!event) { this._handlers = {}; return this; } if (handler) { if (_h[event]) { var newlist = []; for (var i = 0, l = _h[event].length; i < l; i++) { if (_h[event][i]['h'] != handler) { newlist.push(_h[event][i]); } } _h[event] = newlist; } if (_h[event] && _h[event].length === 0) { delete _h[event]; } } else { delete _h[event]; } return this; }; eventful.prototype.dispatch = function (type) { if (this._handlers[type]) { var args = arguments; var arglen = args.length; if (arglen > 3) { args = array.prototype.slice.call(args, 1); } var _h = this._handlers[type]; var len = _h.length; for (var i = 0; i < len;) { switch (arglen) { case 1: _h[i]['h'].call(_h[i]['ctx']); break; case 2: _h[i]['h'].call(_h[i]['ctx'], args[1]); break; case 3: _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]); break; default: _h[i]['h'].apply(_h[i]['ctx'], args); break; } if (_h[i]['one']) { _h.splice(i, 1); len--; } else { i++; } } } return this; }; eventful.prototype.dispatchwithcontext = function (type) { if (this._handlers[type]) { var args = arguments; var arglen = args.length; if (arglen > 4) { args = array.prototype.slice.call(args, 1, args.length - 1); } var ctx = args[args.length - 1]; var _h = this._handlers[type]; var len = _h.length; for (var i = 0; i < len;) { switch (arglen) { case 1: _h[i]['h'].call(ctx); break; case 2: _h[i]['h'].call(ctx, args[1]); break; case 3: _h[i]['h'].call(ctx, args[1], args[2]); break; default: _h[i]['h'].apply(ctx, args); break; } if (_h[i]['one']) { _h.splice(i, 1); len--; } else { i++; } } } return this; }; return eventful; });define('zrender/tool/log', [ 'require', '../config' ], function (require) { var config = require('../config'); return function () { if (config.debugmode === 0) { return; } else if (config.debugmode == 1) { for (var k in arguments) { throw new error(arguments[k]); } } else if (config.debugmode > 1) { for (var k in arguments) { console.log(arguments[k]); } } }; });define('zrender/tool/guid', [], function () { var idstart = 2311; return function () { return 'zrender__' + idstart++; }; });define('zrender/handler', [ 'require', './config', './tool/env', './tool/event', './tool/util', './tool/vector', './tool/matrix', './mixin/eventful' ], function (require) { 'use strict'; var config = require('./config'); var env = require('./tool/env'); var eventtool = require('./tool/event'); var util = require('./tool/util'); var vec2 = require('./tool/vector'); var mat2d = require('./tool/matrix'); var event = config.event; var eventful = require('./mixin/eventful'); var domhandlernames = [ 'resize', 'click', 'dblclick', 'mousewheel', 'mousemove', 'mouseout', 'mouseup', 'mousedown', 'touchstart', 'touchend', 'touchmove' ]; var iszrenderelement = function (event) { if (window.g_vmlcanvasmanager) { return true; } event = event || window.event; var target = event.toelement || event.relatedtarget || event.srcelement || event.target; return target && target.classname.match(config.elementclassname); }; var domhandlers = { resize: function (event) { event = event || window.event; this._lasthover = null; this._ismousedown = 0; this.dispatch(event.resize, event); }, click: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = this._zrendereventfixed(event); var _lasthover = this._lasthover; if (_lasthover && _lasthover.clickable || !_lasthover) { if (this._clickthreshold < 5) { this._dispatchagency(_lasthover, event.click, event); } } this._mousemovehandler(event); }, dblclick: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = event || window.event; event = this._zrendereventfixed(event); var _lasthover = this._lasthover; if (_lasthover && _lasthover.clickable || !_lasthover) { if (this._clickthreshold < 5) { this._dispatchagency(_lasthover, event.dblclick, event); } } this._mousemovehandler(event); }, mousewheel: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = this._zrendereventfixed(event); var delta = event.wheeldelta || -event.detail; var scale = delta > 0 ? 1.1 : 1 / 1.1; var needsrefresh = false; var mousex = this._mousex; var mousey = this._mousey; this.painter.eachbuildinlayer(function (layer) { var pos = layer.position; if (layer.zoomable) { layer.__zoom = layer.__zoom || 1; var newzoom = layer.__zoom; newzoom *= scale; newzoom = math.max(math.min(layer.maxzoom, newzoom), layer.minzoom); scale = newzoom / layer.__zoom; layer.__zoom = newzoom; pos[0] -= (mousex - pos[0]) * (scale - 1); pos[1] -= (mousey - pos[1]) * (scale - 1); layer.scale[0] *= scale; layer.scale[1] *= scale; layer.dirty = true; needsrefresh = true; eventtool.stop(event); } }); if (needsrefresh) { this.painter.refresh(); } this._dispatchagency(this._lasthover, event.mousewheel, event); this._mousemovehandler(event); }, mousemove: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } if (this.painter.isloading()) { return; } event = this._zrendereventfixed(event); this._lastx = this._mousex; this._lasty = this._mousey; this._mousex = eventtool.getx(event); this._mousey = eventtool.gety(event); var dx = this._mousex - this._lastx; var dy = this._mousey - this._lasty; this._processdragstart(event); this._hasfound = 0; this._event = event; this._iterateandfindhover(); if (!this._hasfound) { if (!this._draggingtarget || this._lasthover && this._lasthover != this._draggingtarget) { this._processoutshape(event); this._processdragleave(event); } this._lasthover = null; this.storage.delhover(); this.painter.clearhover(); } var cursor = 'default'; if (this._draggingtarget) { this.storage.drift(this._draggingtarget.id, dx, dy); this._draggingtarget.modself(); this.storage.addhover(this._draggingtarget); this._clickthreshold++; } else if (this._ismousedown) { var needsrefresh = false; this.painter.eachbuildinlayer(function (layer) { if (layer.panable) { cursor = 'move'; layer.position[0] += dx; layer.position[1] += dy; needsrefresh = true; layer.dirty = true; } }); if (needsrefresh) { this.painter.refresh(); } } if (this._draggingtarget || this._hasfound && this._lasthover.draggable) { cursor = 'move'; } else if (this._hasfound && this._lasthover.clickable) { cursor = 'pointer'; } this.root.style.cursor = cursor; this._dispatchagency(this._lasthover, event.mousemove, event); if (this._draggingtarget || this._hasfound || this.storage.hashovershape()) { this.painter.refreshhover(); } }, mouseout: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = this._zrendereventfixed(event); var element = event.toelement || event.relatedtarget; if (element != this.root) { while (element && element.nodetype != 9) { if (element == this.root) { this._mousemovehandler(event); return; } element = element.parentnode; } } event.zrenderx = this._lastx; event.zrendery = this._lasty; this.root.style.cursor = 'default'; this._ismousedown = 0; this._processoutshape(event); this._processdrop(event); this._processdragend(event); if (!this.painter.isloading()) { this.painter.refreshhover(); } this.dispatch(event.globalout, event); }, mousedown: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } this._clickthreshold = 0; if (this._lastdownbutton == 2) { this._lastdownbutton = event.button; this._mousedowntarget = null; return; } this._lastmousedownmoment = new date(); event = this._zrendereventfixed(event); this._ismousedown = 1; this._mousedowntarget = this._lasthover; this._dispatchagency(this._lasthover, event.mousedown, event); this._lastdownbutton = event.button; }, mouseup: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = this._zrendereventfixed(event); this.root.style.cursor = 'default'; this._ismousedown = 0; this._mousedowntarget = null; this._dispatchagency(this._lasthover, event.mouseup, event); this._processdrop(event); this._processdragend(event); }, touchstart: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = this._zrendereventfixed(event, true); this._lasttouchmoment = new date(); this._mobilefindfixed(event); this._mousedownhandler(event); }, touchmove: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = this._zrendereventfixed(event, true); this._mousemovehandler(event); if (this._isdragging) { eventtool.stop(event); } }, touchend: function (event, manually) { if (!iszrenderelement(event) && !manually) { return; } event = this._zrendereventfixed(event, true); this._mouseuphandler(event); var now = new date(); if (now - this._lasttouchmoment < event.touchclickdelay) { this._mobilefindfixed(event); this._clickhandler(event); if (now - this._lastclickmoment < event.touchclickdelay / 2) { this._dblclickhandler(event); if (this._lasthover && this._lasthover.clickable) { eventtool.stop(event); } } this._lastclickmoment = now; } this.painter.clearhover(); } }; function bind2arg(handler, context) { return function (arg1, arg2) { return handler.call(context, arg1, arg2); }; } function bind3arg(handler, context) { return function (arg1, arg2, arg3) { return handler.call(context, arg1, arg2, arg3); }; } function initdomhandler(instance) { var len = domhandlernames.length; while (len--) { var name = domhandlernames[len]; instance['_' + name + 'handler'] = bind2arg(domhandlers[name], instance); } } var handler = function (root, storage, painter) { eventful.call(this); this.root = root; this.storage = storage; this.painter = painter; this._lastx = this._lasty = this._mousex = this._mousey = 0; this._findhover = bind3arg(findhover, this); this._domhover = painter.getdomhover(); initdomhandler(this); if (window.addeventlistener) { window.addeventlistener('resize', this._resizehandler); if (env.os.tablet || env.os.phone) { root.addeventlistener('touchstart', this._touchstarthandler); root.addeventlistener('touchmove', this._touchmovehandler); root.addeventlistener('touchend', this._touchendhandler); } else { root.addeventlistener('click', this._clickhandler); root.addeventlistener('dblclick', this._dblclickhandler); root.addeventlistener('mousewheel', this._mousewheelhandler); root.addeventlistener('mousemove', this._mousemovehandler); root.addeventlistener('mousedown', this._mousedownhandler); root.addeventlistener('mouseup', this._mouseuphandler); } root.addeventlistener('dommousescroll', this._mousewheelhandler); root.addeventlistener('mouseout', this._mouseouthandler); } else { window.attachevent('onresize', this._resizehandler); root.attachevent('onclick', this._clickhandler); root.ondblclick = this._dblclickhandler; root.attachevent('onmousewheel', this._mousewheelhandler); root.attachevent('onmousemove', this._mousemovehandler); root.attachevent('onmouseout', this._mouseouthandler); root.attachevent('onmousedown', this._mousedownhandler); root.attachevent('onmouseup', this._mouseuphandler); } }; handler.prototype.on = function (eventname, handler, context) { this.bind(eventname, handler, context); return this; }; handler.prototype.un = function (eventname, handler) { this.unbind(eventname, handler); return this; }; handler.prototype.trigger = function (eventname, eventargs) { switch (eventname) { case event.resize: case event.click: case event.dblclick: case event.mousewheel: case event.mousemove: case event.mousedown: case event.mouseup: case event.mouseout: this['_' + eventname + 'handler'](eventargs, true); break; } }; handler.prototype.dispose = function () { var root = this.root; if (window.removeeventlistener) { window.removeeventlistener('resize', this._resizehandler); if (env.os.tablet || env.os.phone) { root.removeeventlistener('touchstart', this._touchstarthandler); root.removeeventlistener('touchmove', this._touchmovehandler); root.removeeventlistener('touchend', this._touchendhandler); } else { root.removeeventlistener('click', this._clickhandler); root.removeeventlistener('dblclick', this._dblclickhandler); root.removeeventlistener('mousewheel', this._mousewheelhandler); root.removeeventlistener('mousemove', this._mousemovehandler); root.removeeventlistener('mousedown', this._mousedownhandler); root.removeeventlistener('mouseup', this._mouseuphandler); } root.removeeventlistener('dommousescroll', this._mousewheelhandler); root.removeeventlistener('mouseout', this._mouseouthandler); } else { window.detachevent('onresize', this._resizehandler); root.detachevent('onclick', this._clickhandler); root.detachevent('dblclick', this._dblclickhandler); root.detachevent('onmousewheel', this._mousewheelhandler); root.detachevent('onmousemove', this._mousemovehandler); root.detachevent('onmouseout', this._mouseouthandler); root.detachevent('onmousedown', this._mousedownhandler); root.detachevent('onmouseup', this._mouseuphandler); } this.root = this._domhover = this.storage = this.painter = null; this.un(); }; handler.prototype._processdragstart = function (event) { var _lasthover = this._lasthover; if (this._ismousedown && _lasthover && _lasthover.draggable && !this._draggingtarget && this._mousedowntarget == _lasthover) { if (_lasthover.dragenabletime && new date() - this._lastmousedownmoment < _lasthover.dragenabletime) { return; } var _draggingtarget = _lasthover; this._draggingtarget = _draggingtarget; this._isdragging = 1; _draggingtarget.invisible = true; this.storage.mod(_draggingtarget.id); this._dispatchagency(_draggingtarget, event.dragstart, event); this.painter.refresh(); } }; handler.prototype._processdragenter = function (event) { if (this._draggingtarget) { this._dispatchagency(this._lasthover, event.dragenter, event, this._draggingtarget); } }; handler.prototype._processdragover = function (event) { if (this._draggingtarget) { this._dispatchagency(this._lasthover, event.dragover, event, this._draggingtarget); } }; handler.prototype._processdragleave = function (event) { if (this._draggingtarget) { this._dispatchagency(this._lasthover, event.dragleave, event, this._draggingtarget); } }; handler.prototype._processdrop = function (event) { if (this._draggingtarget) { this._draggingtarget.invisible = false; this.storage.mod(this._draggingtarget.id); this.painter.refresh(); this._dispatchagency(this._lasthover, event.drop, event, this._draggingtarget); } }; handler.prototype._processdragend = function (event) { if (this._draggingtarget) { this._dispatchagency(this._draggingtarget, event.dragend, event); this._lasthover = null; } this._isdragging = 0; this._draggingtarget = null; }; handler.prototype._processovershape = function (event) { this._dispatchagency(this._lasthover, event.mouseover, event); }; handler.prototype._processoutshape = function (event) { this._dispatchagency(this._lasthover, event.mouseout, event); }; handler.prototype._dispatchagency = function (targetshape, eventname, event, draggedshape) { var eventhandler = 'on' + eventname; var eventpacket = { type: eventname, event: event, target: targetshape, cancelbubble: false }; var el = targetshape; if (draggedshape) { eventpacket.dragged = draggedshape; } while (el) { el[eventhandler] && (eventpacket.cancelbubble = el[eventhandler](eventpacket)); el.dispatch(eventname, eventpacket); el = el.parent; if (eventpacket.cancelbubble) { break; } } if (targetshape) { if (!eventpacket.cancelbubble) { this.dispatch(eventname, eventpacket); } } else if (!draggedshape) { var eveobj = { type: eventname, event: event }; this.dispatch(eventname, eveobj); this.painter.eachotherlayer(function (layer) { if (typeof layer[eventhandler] == 'function') { layer[eventhandler](eveobj); } if (layer.dispatch) { layer.dispatch(eventname, eveobj); } }); } }; handler.prototype._iterateandfindhover = function () { var invtransform = mat2d.create(); return function () { var list = this.storage.getshapelist(); var currentzlevel; var currentlayer; var tmp = [ 0, 0 ]; for (var i = list.length - 1; i >= 0; i--) { var shape = list[i]; if (currentzlevel !== shape.zlevel) { currentlayer = this.painter.getlayer(shape.zlevel, currentlayer); tmp[0] = this._mousex; tmp[1] = this._mousey; if (currentlayer.needtransform) { mat2d.invert(invtransform, currentlayer.transform); vec2.applytransform(tmp, tmp, invtransform); } } if (this._findhover(shape, tmp[0], tmp[1])) { break; } } }; }(); var mobile_touch_offsets = [ { x: 10 }, { x: -20 }, { x: 10, y: 10 }, { y: -20 } ]; handler.prototype._mobilefindfixed = function (event) { this._lasthover = null; this._mousex = event.zrenderx; this._mousey = event.zrendery; this._event = event; this._iterateandfindhover(); for (var i = 0; !this._lasthover && i < mobile_touch_offsets.length; i++) { var offset = mobile_touch_offsets[i]; offset.x && (this._mousex += offset.x); offset.y && (this._mousey += offset.y); this._iterateandfindhover(); } if (this._lasthover) { event.zrenderx = this._mousex; event.zrendery = this._mousey; } }; function findhover(shape, x, y) { if (this._draggingtarget && this._draggingtarget.id == shape.id || shape.issilent()) { return false; } var event = this._event; if (shape.iscover(x, y)) { if (shape.hoverable) { this.storage.addhover(shape); } var p = shape.parent; while (p) { if (p.clipshape && !p.clipshape.iscover(this._mousex, this._mousey)) { return false; } p = p.parent; } if (this._lasthover != shape) { this._processoutshape(event); this._processdragleave(event); this._lasthover = shape; this._processdragenter(event); } this._processovershape(event); this._processdragover(event); this._hasfound = 1; return true; } return false; } handler.prototype._zrendereventfixed = function (event, istouch) { if (event.zrenderfixed) { return event; } if (!istouch) { event = event || window.event; var target = event.toelement || event.relatedtarget || event.srcelement || event.target; if (target && target != this._domhover) { event.zrenderx = (typeof event.offsetx != 'undefined' ? event.offsetx : event.layerx) + target.offsetleft; event.zrendery = (typeof event.offsety != 'undefined' ? event.offsety : event.layery) + target.offsettop; } } else { var touch = event.type != 'touchend' ? event.targettouches[0] : event.changedtouches[0]; if (touch) { var rbounding = this.painter._domroot.getboundingclientrect(); event.zrenderx = touch.clientx - rbounding.left; event.zrendery = touch.clienty - rbounding.top; } } event.zrenderfixed = 1; return event; }; util.merge(handler.prototype, eventful.prototype, true); return handler; });define('zrender/painter', [ 'require', './config', './tool/util', './tool/log', './loadingeffect/base', './layer', './shape/image' ], function (require) { 'use strict'; var config = require('./config'); var util = require('./tool/util'); var log = require('./tool/log'); var baseloadingeffect = require('./loadingeffect/base'); var layer = require('./layer'); function returnfalse() { return false; } function donothing() { } function islayervalid(layer) { if (!layer) { return false; } if (layer.isbuildin) { return true; } if (typeof layer.resize !== 'function' || typeof layer.refresh !== 'function') { return false; } return true; } var painter = function (root, storage) { this.root = root; root.style['-webkit-tap-highlight-color'] = 'transparent'; root.style['-webkit-user-select'] = 'none'; root.style['user-select'] = 'none'; root.style['-webkit-touch-callout'] = 'none'; this.storage = storage; root.innerhtml = ''; this._width = this._getwidth(); this._height = this._getheight(); var domroot = document.createelement('div'); this._domroot = domroot; domroot.style.position = 'relative'; domroot.style.overflow = 'hidden'; domroot.style.width = this._width + 'px'; domroot.style.height = this._height + 'px'; root.appendchild(domroot); this._layers = {}; this._zlevellist = []; this._layerconfig = {}; this._loadingeffect = new baseloadingeffect({}); this.shapetoimage = this._createshapetoimageprocessor(); this._bgdom = document.createelement('div'); this._bgdom.style.csstext = [ 'position:absolute;left:0px;top:0px;width:', this._width, 'px;height:', this._height + 'px;', '-webkit-user-select:none;user-select;none;', '-webkit-touch-callout:none;' ].join(''); this._bgdom.setattribute('data-zr-dom-id', 'bg'); this._bgdom.classname = config.elementclassname; domroot.appendchild(this._bgdom); this._bgdom.onselectstart = returnfalse; var hoverlayer = new layer('_zrender_hover_', this); this._layers['hover'] = hoverlayer; domroot.appendchild(hoverlayer.dom); hoverlayer.initcontext(); hoverlayer.dom.onselectstart = returnfalse; hoverlayer.dom.style['-webkit-user-select'] = 'none'; hoverlayer.dom.style['user-select'] = 'none'; hoverlayer.dom.style['-webkit-touch-callout'] = 'none'; this.refreshnextframe = null; }; painter.prototype.render = function (callback) { if (this.isloading()) { this.hideloading(); } this.refresh(callback, true); return this; }; painter.prototype.refresh = function (callback, paintall) { var list = this.storage.getshapelist(true); this._paintlist(list, paintall); for (var i = 0; i < this._zlevellist.length; i++) { var z = this._zlevellist[i]; var layer = this._layers[z]; if (!layer.isbuildin && layer.refresh) { layer.refresh(); } } if (typeof callback == 'function') { callback(); } return this; }; painter.prototype._preprocesslayer = function (layer) { layer.unusedcount++; layer.updatetransform(); }; painter.prototype._postprocesslayer = function (layer) { layer.dirty = false; if (layer.unusedcount == 1) { layer.clear(); } }; painter.prototype._paintlist = function (list, paintall) { if (typeof paintall == 'undefined') { paintall = false; } this._updatelayerstatus(list); var currentlayer; var currentzlevel; var ctx; this.eachbuildinlayer(this._preprocesslayer); for (var i = 0, l = list.length; i < l; i++) { var shape = list[i]; if (currentzlevel !== shape.zlevel) { if (currentlayer) { if (currentlayer.needtransform) { ctx.restore(); } ctx.flush && ctx.flush(); } currentzlevel = shape.zlevel; currentlayer = this.getlayer(currentzlevel); if (!currentlayer.isbuildin) { log('zlevel ' + currentzlevel + ' has been used by unkown layer ' + currentlayer.id); } ctx = currentlayer.ctx; currentlayer.unusedcount = 0; if (currentlayer.dirty || paintall) { currentlayer.clear(); } if (currentlayer.needtransform) { ctx.save(); currentlayer.settransform(ctx); } } if ((currentlayer.dirty || paintall) && !shape.invisible) { if (!shape.onbrush || shape.onbrush && !shape.onbrush(ctx, false)) { if (config.catchbrushexception) { try { shape.brush(ctx, false, this.refreshnextframe); } catch (error) { log(error, 'brush error of ' + shape.type, shape); } } else { shape.brush(ctx, false, this.refreshnextframe); } } } shape.__dirty = false; } if (currentlayer) { if (currentlayer.needtransform) { ctx.restore(); } ctx.flush && ctx.flush(); } this.eachbuildinlayer(this._postprocesslayer); }; painter.prototype.getlayer = function (zlevel) { var layer = this._layers[zlevel]; if (!layer) { layer = new layer(zlevel, this); layer.isbuildin = true; if (this._layerconfig[zlevel]) { util.merge(layer, this._layerconfig[zlevel], true); } layer.updatetransform(); this.insertlayer(zlevel, layer); layer.initcontext(); } return layer; }; painter.prototype.insertlayer = function (zlevel, layer) { if (this._layers[zlevel]) { log('zlevel ' + zlevel + ' has been used already'); return; } if (!islayervalid(layer)) { log('layer of zlevel ' + zlevel + ' is not valid'); return; } var len = this._zlevellist.length; var prevlayer = null; var i = -1; if (len > 0 && zlevel > this._zlevellist[0]) { for (i = 0; i < len - 1; i++) { if (this._zlevellist[i] < zlevel && this._zlevellist[i + 1] > zlevel) { break; } } prevlayer = this._layers[this._zlevellist[i]]; } this._zlevellist.splice(i + 1, 0, zlevel); var prevdom = prevlayer ? prevlayer.dom : this._bgdom; if (prevdom.nextsibling) { prevdom.parentnode.insertbefore(layer.dom, prevdom.nextsibling); } else { prevdom.parentnode.appendchild(layer.dom); } this._layers[zlevel] = layer; }; painter.prototype.eachlayer = function (cb, context) { for (var i = 0; i < this._zlevellist.length; i++) { var z = this._zlevellist[i]; cb.call(context, this._layers[z], z); } }; painter.prototype.eachbuildinlayer = function (cb, context) { for (var i = 0; i < this._zlevellist.length; i++) { var z = this._zlevellist[i]; var layer = this._layers[z]; if (layer.isbuildin) { cb.call(context, layer, z); } } }; painter.prototype.eachotherlayer = function (cb, context) { for (var i = 0; i < this._zlevellist.length; i++) { var z = this._zlevellist[i]; var layer = this._layers[z]; if (!layer.isbuildin) { cb.call(context, layer, z); } } }; painter.prototype.getlayers = function () { return this._layers; }; painter.prototype._updatelayerstatus = function (list) { var layers = this._layers; var elcounts = {}; this.eachbuildinlayer(function (layer, z) { elcounts[z] = layer.elcount; layer.elcount = 0; }); for (var i = 0, l = list.length; i < l; i++) { var shape = list[i]; var zlevel = shape.zlevel; var layer = layers[zlevel]; if (layer) { layer.elcount++; if (layer.dirty) { continue; } layer.dirty = shape.__dirty; } } this.eachbuildinlayer(function (layer, z) { if (elcounts[z] !== layer.elcount) { layer.dirty = true; } }); }; painter.prototype.refreshshapes = function (shapelist, callback) { for (var i = 0, l = shapelist.length; i < l; i++) { var shape = shapelist[i]; shape.modself(); } this.refresh(callback); return this; }; painter.prototype.setloadingeffect = function (loadingeffect) { this._loadingeffect = loadingeffect; return this; }; painter.prototype.clear = function () { this.eachbuildinlayer(this._clearlayer); return this; }; painter.prototype._clearlayer = function (layer) { layer.clear(); }; painter.prototype.modlayer = function (zlevel, config) { if (config) { if (!this._layerconfig[zlevel]) { this._layerconfig[zlevel] = config; } else { util.merge(this._layerconfig[zlevel], config, true); } var layer = this._layers[zlevel]; if (layer) { util.merge(layer, this._layerconfig[zlevel], true); } } }; painter.prototype.dellayer = function (zlevel) { var layer = this._layers[zlevel]; if (!layer) { return; } this.modlayer(zlevel, { position: layer.position, rotation: layer.rotation, scale: layer.scale }); layer.dom.parentnode.removechild(layer.dom); delete this._layers[zlevel]; this._zlevellist.splice(util.indexof(this._zlevellist, zlevel), 1); }; painter.prototype.refreshhover = function () { this.clearhover(); var list = this.storage.gethovershapes(true); for (var i = 0, l = list.length; i < l; i++) { this._brushhover(list[i]); } var ctx = this._layers.hover.ctx; ctx.flush && ctx.flush(); this.storage.delhover(); return this; }; painter.prototype.clearhover = function () { var hover = this._layers.hover; hover && hover.clear(); return this; }; painter.prototype.showloading = function (loadingeffect) { this._loadingeffect && this._loadingeffect.stop(); loadingeffect && this.setloadingeffect(loadingeffect); this._loadingeffect.start(this); this.loading = true; return this; }; painter.prototype.hideloading = function () { this._loadingeffect.stop(); this.clearhover(); this.loading = false; return this; }; painter.prototype.isloading = function () { return this.loading; }; painter.prototype.resize = function () { var domroot = this._domroot; domroot.style.display = 'none'; var width = this._getwidth(); var height = this._getheight(); domroot.style.display = ''; if (this._width != width || height != this._height) { this._width = width; this._height = height; domroot.style.width = width + 'px'; domroot.style.height = height + 'px'; for (var id in this._layers) { this._layers[id].resize(width, height); } this.refresh(null, true); } return this; }; painter.prototype.clearlayer = function (zlevel) { var layer = this._layers[zlevel]; if (layer) { layer.clear(); } }; painter.prototype.dispose = function () { if (this.isloading()) { this.hideloading(); } this.root.innerhtml = ''; this.root = this.storage = this._domroot = this._layers = null; }; painter.prototype.getdomhover = function () { return this._layers.hover.dom; }; painter.prototype.todataurl = function (type, backgroundcolor, args) { if (window['g_vmlcanvasmanager']) { return null; } var imagelayer = new layer('image', this); this._bgdom.appendchild(imagelayer.dom); imagelayer.initcontext(); var ctx = imagelayer.ctx; imagelayer.clearcolor = backgroundcolor || '#fff'; imagelayer.clear(); var self = this; this.storage.itershape(function (shape) { if (!shape.invisible) { if (!shape.onbrush || shape.onbrush && !shape.onbrush(ctx, false)) { if (config.catchbrushexception) { try { shape.brush(ctx, false, self.refreshnextframe); } catch (error) { log(error, 'brush error of ' + shape.type, shape); } } else { shape.brush(ctx, false, self.refreshnextframe); } } } }, { normal: 'up', update: true }); var image = imagelayer.dom.todataurl(type, args); ctx = null; this._bgdom.removechild(imagelayer.dom); return image; }; painter.prototype.getwidth = function () { return this._width; }; painter.prototype.getheight = function () { return this._height; }; painter.prototype._getwidth = function () { var root = this.root; var stl = root.currentstyle || document.defaultview.getcomputedstyle(root); return ((root.clientwidth || parseint(stl.width, 10)) - parseint(stl.paddingleft, 10) - parseint(stl.paddingright, 10)).tofixed(0) - 0; }; painter.prototype._getheight = function () { var root = this.root; var stl = root.currentstyle || document.defaultview.getcomputedstyle(root); return ((root.clientheight || parseint(stl.height, 10)) - parseint(stl.paddingtop, 10) - parseint(stl.paddingbottom, 10)).tofixed(0) - 0; }; painter.prototype._brushhover = function (shape) { var ctx = this._layers.hover.ctx; if (!shape.onbrush || shape.onbrush && !shape.onbrush(ctx, true)) { var layer = this.getlayer(shape.zlevel); if (layer.needtransform) { ctx.save(); layer.settransform(ctx); } if (config.catchbrushexception) { try { shape.brush(ctx, true, this.refreshnextframe); } catch (error) { log(error, 'hoverbrush error of ' + shape.type, shape); } } else { shape.brush(ctx, true, this.refreshnextframe); } if (layer.needtransform) { ctx.restore(); } } }; painter.prototype._shapetoimage = function (id, shape, width, height, devicepixelratio) { var canvas = document.createelement('canvas'); var ctx = canvas.getcontext('2d'); canvas.style.width = width + 'px'; canvas.style.height = height + 'px'; canvas.setattribute('width', width * devicepixelratio); canvas.setattribute('height', height * devicepixelratio); ctx.clearrect(0, 0, width * devicepixelratio, height * devicepixelratio); var shapetransform = { position: shape.position, rotation: shape.rotation, scale: shape.scale }; shape.position = [ 0, 0, 0 ]; shape.rotation = 0; shape.scale = [ 1, 1 ]; if (shape) { shape.brush(ctx, false); } var imageshape = require('./shape/image'); var imgshape = new imageshape({ id: id, style: { x: 0, y: 0, image: canvas } }); if (shapetransform.position != null) { imgshape.position = shape.position = shapetransform.position; } if (shapetransform.rotation != null) { imgshape.rotation = shape.rotation = shapetransform.rotation; } if (shapetransform.scale != null) { imgshape.scale = shape.scale = shapetransform.scale; } return imgshape; }; painter.prototype._createshapetoimageprocessor = function () { if (window['g_vmlcanvasmanager']) { return donothing; } var me = this; return function (id, e, width, height) { return me._shapetoimage(id, e, width, height, config.devicepixelratio); }; }; return painter; });define('zrender/storage', [ 'require', './tool/util', './group' ], function (require) { 'use strict'; var util = require('./tool/util'); var group = require('./group'); var defaultiterateoption = { hover: false, normal: 'down', update: false }; function shapecomparefunc(a, b) { if (a.zlevel == b.zlevel) { if (a.z == b.z) { return a.__renderidx - b.__renderidx; } return a.z - b.z; } return a.zlevel - b.zlevel; } var storage = function () { this._elements = {}; this._hoverelements = []; this._roots = []; this._shapelist = []; this._shapelistoffset = 0; }; storage.prototype.itershape = function (fun, option) { if (!option) { option = defaultiterateoption; } if (option.hover) { for (var i = 0, l = this._hoverelements.length; i < l; i++) { var el = this._hoverelements[i]; el.updatetransform(); if (fun(el)) { return this; } } } if (option.update) { this.updateshapelist(); } switch (option.normal) { case 'down': var l = this._shapelist.length; while (l--) { if (fun(this._shapelist[l])) { return this; } } break; default: for (var i = 0, l = this._shapelist.length; i < l; i++) { if (fun(this._shapelist[i])) { return this; } } break; } return this; }; storage.prototype.gethovershapes = function (update) { var hoverelements = []; for (var i = 0, l = this._hoverelements.length; i < l; i++) { hoverelements.push(this._hoverelements[i]); var target = this._hoverelements[i].hoverconnect; if (target) { var shape; target = target instanceof array ? target : [target]; for (var j = 0, k = target.length; j < k; j++) { shape = target[j].id ? target[j] : this.get(target[j]); if (shape) { hoverelements.push(shape); } } } } hoverelements.sort(shapecomparefunc); if (update) { for (var i = 0, l = hoverelements.length; i < l; i++) { hoverelements[i].updatetransform(); } } return hoverelements; }; storage.prototype.getshapelist = function (update) { if (update) { this.updateshapelist(); } return this._shapelist; }; storage.prototype.updateshapelist = function () { this._shapelistoffset = 0; for (var i = 0, len = this._roots.length; i < len; i++) { var root = this._roots[i]; this._updateandaddshape(root); } this._shapelist.length = this._shapelistoffset; for (var i = 0, len = this._shapelist.length; i < len; i++) { this._shapelist[i].__renderidx = i; } this._shapelist.sort(shapecomparefunc); }; storage.prototype._updateandaddshape = function (el, clipshapes) { if (el.ignore) { return; } el.updatetransform(); if (el.clipshape) { el.clipshape.parent = el; el.clipshape.updatetransform(); if (clipshapes) { clipshapes = clipshapes.slice(); clipshapes.push(el.clipshape); } else { clipshapes = [el.clipshape]; } } if (el.type == 'group') { for (var i = 0; i < el._children.length; i++) { var child = el._children[i]; child.__dirty = el.__dirty || child.__dirty; this._updateandaddshape(child, clipshapes); } el.__dirty = false; } else { el.__clipshapes = clipshapes; this._shapelist[this._shapelistoffset++] = el; } }; storage.prototype.mod = function (el, params) { if (typeof el === 'string') { el = this._elements[el]; } if (el) { el.modself(); if (params) { if (params.parent || params._storage || params.__clipshapes) { var target = {}; for (var name in params) { if (name === 'parent' || name === '_storage' || name === '__clipshapes') { continue; } if (params.hasownproperty(name)) { target[name] = params[name]; } } util.merge(el, target, true); } else { util.merge(el, params, true); } } } return this; }; storage.prototype.drift = function (shapeid, dx, dy) { var shape = this._elements[shapeid]; if (shape) { shape.needtransform = true; if (shape.draggable === 'horizontal') { dy = 0; } else if (shape.draggable === 'vertical') { dx = 0; } if (!shape.ondrift || shape.ondrift && !shape.ondrift(dx, dy)) { shape.drift(dx, dy); } } return this; }; storage.prototype.addhover = function (shape) { shape.updateneedtransform(); this._hoverelements.push(shape); return this; }; storage.prototype.delhover = function () { this._hoverelements = []; return this; }; storage.prototype.hashovershape = function () { return this._hoverelements.length > 0; }; storage.prototype.addroot = function (el) { if (this._elements[el.id]) { return; } if (el instanceof group) { el.addchildrentostorage(this); } this.addtomap(el); this._roots.push(el); }; storage.prototype.delroot = function (elid) { if (typeof elid == 'undefined') { for (var i = 0; i < this._roots.length; i++) { var root = this._roots[i]; if (root instanceof group) { root.delchildrenfromstorage(this); } } this._elements = {}; this._hoverelements = []; this._roots = []; this._shapelist = []; this._shapelistoffset = 0; return; } if (elid instanceof array) { for (var i = 0, l = elid.length; i < l; i++) { this.delroot(elid[i]); } return; } var el; if (typeof elid == 'string') { el = this._elements[elid]; } else { el = elid; } var idx = util.indexof(this._roots, el); if (idx >= 0) { this.delfrommap(el.id); this._roots.splice(idx, 1); if (el instanceof group) { el.delchildrenfromstorage(this); } } }; storage.prototype.addtomap = function (el) { if (el instanceof group) { el._storage = this; } el.modself(); this._elements[el.id] = el; return this; }; storage.prototype.get = function (elid) { return this._elements[elid]; }; storage.prototype.delfrommap = function (elid) { var el = this._elements[elid]; if (el) { delete this._elements[elid]; if (el instanceof group) { el._storage = null; } } return this; }; storage.prototype.dispose = function () { this._elements = this._renderlist = this._roots = this._hoverelements = null; }; return storage; });define('zrender/animation/animation', [ 'require', './clip', '../tool/color', '../tool/util', '../tool/event' ], function (require) { 'use strict'; var clip = require('./clip'); var color = require('../tool/color'); var util = require('../tool/util'); var dispatcher = require('../tool/event').dispatcher; var requestanimationframe = window.requestanimationframe || window.msrequestanimationframe || window.mozrequestanimationframe || window.webkitrequestanimationframe || function (func) { settimeout(func, 16); }; var arrayslice = array.prototype.slice; var animation = function (options) { options = options || {}; this.stage = options.stage || {}; this.onframe = options.onframe || function () { }; this._clips = []; this._running = false; this._time = 0; dispatcher.call(this); }; animation.prototype = { add: function (clip) { this._clips.push(clip); }, remove: function (clip) { if (clip.__instep) { clip.__needsremove = true; } else { var idx = util.indexof(this._clips, clip); if (idx >= 0) { this._clips.splice(idx, 1); } } }, _update: function () { var time = new date().gettime(); var delta = time - this._time; var clips = this._clips; var len = clips.length; var deferredevents = []; var deferredclips = []; for (var i = 0; i < len; i++) { var clip = clips[i]; clip.__instep = true; var e = clip.step(time); clip.__instep = false; if (e) { deferredevents.push(e); deferredclips.push(clip); } } for (var i = 0; i < len;) { if (clips[i].__needsremove) { clips[i] = clips[len - 1]; clips.pop(); len--; } else { i++; } } len = deferredevents.length; for (var i = 0; i < len; i++) { deferredclips[i].fire(deferredevents[i]); } this._time = time; this.onframe(delta); this.dispatch('frame', delta); if (this.stage.update) { this.stage.update(); } }, start: function () { var self = this; this._running = true; function step() { if (self._running) { requestanimationframe(step); self._update(); } } this._time = new date().gettime(); requestanimationframe(step); }, stop: function () { this._running = false; }, clear: function () { this._clips = []; }, animate: function (target, options) { options = options || {}; var deferred = new animator(target, options.loop, options.getter, options.setter); deferred.animation = this; return deferred; }, constructor: animation }; util.merge(animation.prototype, dispatcher.prototype, true); function _defaultgetter(target, key) { return target[key]; } function _defaultsetter(target, key, value) { target[key] = value; } function _interpolatenumber(p0, p1, percent) { return (p1 - p0) * percent + p0; } function _interpolatearray(p0, p1, percent, out, arrdim) { var len = p0.length; if (arrdim == 1) { for (var i = 0; i < len; i++) { out[i] = _interpolatenumber(p0[i], p1[i], percent); } } else { var len2 = p0[0].length; for (var i = 0; i < len; i++) { for (var j = 0; j < len2; j++) { out[i][j] = _interpolatenumber(p0[i][j], p1[i][j], percent); } } } } function _isarraylike(data) { switch (typeof data) { case 'undefined': case 'string': return false; } return typeof data.length !== 'undefined'; } function _catmullrominterpolatearray(p0, p1, p2, p3, t, t2, t3, out, arrdim) { var len = p0.length; if (arrdim == 1) { for (var i = 0; i < len; i++) { out[i] = _catmullrominterpolate(p0[i], p1[i], p2[i], p3[i], t, t2, t3); } } else { var len2 = p0[0].length; for (var i = 0; i < len; i++) { for (var j = 0; j < len2; j++) { out[i][j] = _catmullrominterpolate(p0[i][j], p1[i][j], p2[i][j], p3[i][j], t, t2, t3); } } } } function _catmullrominterpolate(p0, p1, p2, p3, t, t2, t3) { var v0 = (p2 - p0) * 0.5; var v1 = (p3 - p1) * 0.5; return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1; } function _clonevalue(value) { if (_isarraylike(value)) { var len = value.length; if (_isarraylike(value[0])) { var ret = []; for (var i = 0; i < len; i++) { ret.push(arrayslice.call(value[i])); } return ret; } else { return arrayslice.call(value); } } else { return value; } } function rgba2string(rgba) { rgba[0] = math.floor(rgba[0]); rgba[1] = math.floor(rgba[1]); rgba[2] = math.floor(rgba[2]); return 'rgba(' + rgba.join(',') + ')'; } var animator = function (target, loop, getter, setter) { this._tracks = {}; this._target = target; this._loop = loop || false; this._getter = getter || _defaultgetter; this._setter = setter || _defaultsetter; this._clipcount = 0; this._delay = 0; this._donelist = []; this._onframelist = []; this._cliplist = []; }; animator.prototype = { when: function (time, props) { for (var propname in props) { if (!this._tracks[propname]) { this._tracks[propname] = []; if (time !== 0) { this._tracks[propname].push({ time: 0, value: _clonevalue(this._getter(this._target, propname)) }); } } this._tracks[propname].push({ time: parseint(time, 10), value: props[propname] }); } return this; }, during: function (callback) { this._onframelist.push(callback); return this; }, start: function (easing) { var self = this; var setter = this._setter; var getter = this._getter; var usespline = easing === 'spline'; var ondestroy = function () { self._clipcount--; if (self._clipcount === 0) { self._tracks = {}; var len = self._donelist.length; for (var i = 0; i < len; i++) { self._donelist[i].call(self); } } }; var createtrackclip = function (keyframes, propname) { var tracklen = keyframes.length; if (!tracklen) { return; } var firstval = keyframes[0].value; var isvaluearray = _isarraylike(firstval); var isvaluecolor = false; var arrdim = isvaluearray && _isarraylike(firstval[0]) ? 2 : 1; keyframes.sort(function (a, b) { return a.time - b.time; }); var trackmaxtime; if (tracklen) { trackmaxtime = keyframes[tracklen - 1].time; } else { return; } var kfpercents = []; var kfvalues = []; for (var i = 0; i < tracklen; i++) { kfpercents.push(keyframes[i].time / trackmaxtime); var value = keyframes[i].value; if (typeof value == 'string') { value = color.toarray(value); if (value.length === 0) { value[0] = value[1] = value[2] = 0; value[3] = 1; } isvaluecolor = true; } kfvalues.push(value); } var cachekey = 0; var cachepercent = 0; var start; var i; var w; var p0; var p1; var p2; var p3; if (isvaluecolor) { var rgba = [ 0, 0, 0, 0 ]; } var onframe = function (target, percent) { if (percent < cachepercent) { start = math.min(cachekey + 1, tracklen - 1); for (i = start; i >= 0; i--) { if (kfpercents[i] <= percent) { break; } } i = math.min(i, tracklen - 2); } else { for (i = cachekey; i < tracklen; i++) { if (kfpercents[i] > percent) { break; } } i = math.min(i - 1, tracklen - 2); } cachekey = i; cachepercent = percent; var range = kfpercents[i + 1] - kfpercents[i]; if (range === 0) { return; } else { w = (percent - kfpercents[i]) / range; } if (usespline) { p1 = kfvalues[i]; p0 = kfvalues[i === 0 ? i : i - 1]; p2 = kfvalues[i > tracklen - 2 ? tracklen - 1 : i + 1]; p3 = kfvalues[i > tracklen - 3 ? tracklen - 1 : i + 2]; if (isvaluearray) { _catmullrominterpolatearray(p0, p1, p2, p3, w, w * w, w * w * w, getter(target, propname), arrdim); } else { var value; if (isvaluecolor) { value = _catmullrominterpolatearray(p0, p1, p2, p3, w, w * w, w * w * w, rgba, 1); value = rgba2string(rgba); } else { value = _catmullrominterpolate(p0, p1, p2, p3, w, w * w, w * w * w); } setter(target, propname, value); } } else { if (isvaluearray) { _interpolatearray(kfvalues[i], kfvalues[i + 1], w, getter(target, propname), arrdim); } else { var value; if (isvaluecolor) { _interpolatearray(kfvalues[i], kfvalues[i + 1], w, rgba, 1); value = rgba2string(rgba); } else { value = _interpolatenumber(kfvalues[i], kfvalues[i + 1], w); } setter(target, propname, value); } } for (i = 0; i < self._onframelist.length; i++) { self._onframelist[i](target, percent); } }; var clip = new clip({ target: self._target, life: trackmaxtime, loop: self._loop, delay: self._delay, onframe: onframe, ondestroy: ondestroy }); if (easing && easing !== 'spline') { clip.easing = easing; } self._cliplist.push(clip); self._clipcount++; self.animation.add(clip); }; for (var propname in this._tracks) { createtrackclip(this._tracks[propname], propname); } return this; }, stop: function () { for (var i = 0; i < this._cliplist.length; i++) { var clip = this._cliplist[i]; this.animation.remove(clip); } this._cliplist = []; }, delay: function (time) { this._delay = time; return this; }, done: function (cb) { if (cb) { this._donelist.push(cb); } return this; } }; return animation; });define('zrender/tool/vector', [], function () { var arrayctor = typeof float32array === 'undefined' ? array : float32array; var vector = { create: function (x, y) { var out = new arrayctor(2); out[0] = x || 0; out[1] = y || 0; return out; }, copy: function (out, v) { out[0] = v[0]; out[1] = v[1]; return out; }, clone: function (v) { var out = new arrayctor(2); out[0] = v[0]; out[1] = v[1]; return out; }, set: function (out, a, b) { out[0] = a; out[1] = b; return out; }, add: function (out, v1, v2) { out[0] = v1[0] + v2[0]; out[1] = v1[1] + v2[1]; return out; }, scaleandadd: function (out, v1, v2, a) { out[0] = v1[0] + v2[0] * a; out[1] = v1[1] + v2[1] * a; return out; }, sub: function (out, v1, v2) { out[0] = v1[0] - v2[0]; out[1] = v1[1] - v2[1]; return out; }, len: function (v) { return math.sqrt(this.lensquare(v)); }, lensquare: function (v) { return v[0] * v[0] + v[1] * v[1]; }, mul: function (out, v1, v2) { out[0] = v1[0] * v2[0]; out[1] = v1[1] * v2[1]; return out; }, div: function (out, v1, v2) { out[0] = v1[0] / v2[0]; out[1] = v1[1] / v2[1]; return out; }, dot: function (v1, v2) { return v1[0] * v2[0] + v1[1] * v2[1]; }, scale: function (out, v, s) { out[0] = v[0] * s; out[1] = v[1] * s; return out; }, normalize: function (out, v) { var d = vector.len(v); if (d === 0) { out[0] = 0; out[1] = 0; } else { out[0] = v[0] / d; out[1] = v[1] / d; } return out; }, distance: function (v1, v2) { return math.sqrt((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1])); }, distancesquare: function (v1, v2) { return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]); }, negate: function (out, v) { out[0] = -v[0]; out[1] = -v[1]; return out; }, lerp: function (out, v1, v2, t) { out[0] = v1[0] + t * (v2[0] - v1[0]); out[1] = v1[1] + t * (v2[1] - v1[1]); return out; }, applytransform: function (out, v, m) { var x = v[0]; var y = v[1]; out[0] = m[0] * x + m[2] * y + m[4]; out[1] = m[1] * x + m[3] * y + m[5]; return out; }, min: function (out, v1, v2) { out[0] = math.min(v1[0], v2[0]); out[1] = math.min(v1[1], v2[1]); return out; }, max: function (out, v1, v2) { out[0] = math.max(v1[0], v2[0]); out[1] = math.max(v1[1], v2[1]); return out; } }; vector.length = vector.len; vector.lengthsquare = vector.lensquare; vector.dist = vector.distance; vector.distsquare = vector.distancesquare; return vector; });define('zrender/tool/matrix', [], function () { var arrayctor = typeof float32array === 'undefined' ? array : float32array; var matrix = { create: function () { var out = new arrayctor(6); matrix.identity(out); return out; }, identity: function (out) { out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 1; out[4] = 0; out[5] = 0; return out; }, copy: function (out, m) { out[0] = m[0]; out[1] = m[1]; out[2] = m[2]; out[3] = m[3]; out[4] = m[4]; out[5] = m[5]; return out; }, mul: function (out, m1, m2) { out[0] = m1[0] * m2[0] + m1[2] * m2[1]; out[1] = m1[1] * m2[0] + m1[3] * m2[1]; out[2] = m1[0] * m2[2] + m1[2] * m2[3]; out[3] = m1[1] * m2[2] + m1[3] * m2[3]; out[4] = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]; out[5] = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]; return out; }, translate: function (out, a, v) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; out[4] = a[4] + v[0]; out[5] = a[5] + v[1]; return out; }, rotate: function (out, a, rad) { var aa = a[0]; var ac = a[2]; var atx = a[4]; var ab = a[1]; var ad = a[3]; var aty = a[5]; var st = math.sin(rad); var ct = math.cos(rad); out[0] = aa * ct + ab * st; out[1] = -aa * st + ab * ct; out[2] = ac * ct + ad * st; out[3] = -ac * st + ct * ad; out[4] = ct * atx + st * aty; out[5] = ct * aty - st * atx; return out; }, scale: function (out, a, v) { var vx = v[0]; var vy = v[1]; out[0] = a[0] * vx; out[1] = a[1] * vy; out[2] = a[2] * vx; out[3] = a[3] * vy; out[4] = a[4] * vx; out[5] = a[5] * vy; return out; }, invert: function (out, a) { var aa = a[0]; var ac = a[2]; var atx = a[4]; var ab = a[1]; var ad = a[3]; var aty = a[5]; var det = aa * ad - ab * ac; if (!det) { return null; } det = 1 / det; out[0] = ad * det; out[1] = -ab * det; out[2] = -ac * det; out[3] = aa * det; out[4] = (ac * aty - ad * atx) * det; out[5] = (ab * atx - aa * aty) * det; return out; } }; return matrix; });define('zrender/loadingeffect/base', [ 'require', '../tool/util', '../shape/text', '../shape/rectangle' ], function (require) { var util = require('../tool/util'); var textshape = require('../shape/text'); var rectangleshape = require('../shape/rectangle'); var default_text = 'loading...'; var default_text_font = 'normal 16px arial'; function base(options) { this.setoptions(options); } base.prototype.createtextshape = function (textstyle) { return new textshape({ highlightstyle: util.merge({ x: this.canvaswidth / 2, y: this.canvasheight / 2, text: default_text, textalign: 'center', textbaseline: 'middle', textfont: default_text_font, color: '#333', brushtype: 'fill' }, textstyle, true) }); }; base.prototype.createbackgroundshape = function (color) { return new rectangleshape({ highlightstyle: { x: 0, y: 0, width: this.canvaswidth, height: this.canvasheight, brushtype: 'fill', color: color } }); }; base.prototype.start = function (painter) { this.canvaswidth = painter._width; this.canvasheight = painter._height; function addshapehandle(param) { painter.storage.addhover(param); } function refreshhandle() { painter.refreshhover(); } this.loadingtimer = this._start(addshapehandle, refreshhandle); }; base.prototype._start = function () { return setinterval(function () { }, 10000); }; base.prototype.stop = function () { clearinterval(this.loadingtimer); }; base.prototype.setoptions = function (options) { this.options = options || {}; }; base.prototype.adjust = function (value, region) { if (value <= region[0]) { value = region[0]; } else if (value >= region[1]) { value = region[1]; } return value; }; base.prototype.getlocation = function (loc, totalwidth, totalheight) { var x = loc.x != null ? loc.x : 'center'; switch (x) { case 'center': x = math.floor((this.canvaswidth - totalwidth) / 2); break; case 'left': x = 0; break; case 'right': x = this.canvaswidth - totalwidth; break; } var y = loc.y != null ? loc.y : 'center'; switch (y) { case 'center': y = math.floor((this.canvasheight - totalheight) / 2); break; case 'top': y = 0; break; case 'bottom': y = this.canvasheight - totalheight; break; } return { x: x, y: y, width: totalwidth, height: totalheight }; }; return base; });define('zrender/layer', [ 'require', './mixin/transformable', './tool/util', './config' ], function (require) { var transformable = require('./mixin/transformable'); var util = require('./tool/util'); var vmlcanvasmanager = window['g_vmlcanvasmanager']; var config = require('./config'); function returnfalse() { return false; } function createdom(id, type, painter) { var newdom = document.createelement(type); var width = painter.getwidth(); var height = painter.getheight(); newdom.style.position = 'absolute'; newdom.style.left = 0; newdom.style.top = 0; newdom.style.width = width + 'px'; newdom.style.height = height + 'px'; newdom.width = width * config.devicepixelratio; newdom.height = height * config.devicepixelratio; newdom.setattribute('data-zr-dom-id', id); return newdom; } var layer = function (id, painter) { this.id = id; this.dom = createdom(id, 'canvas', painter); this.dom.onselectstart = returnfalse; this.dom.style['-webkit-user-select'] = 'none'; this.dom.style['user-select'] = 'none'; this.dom.style['-webkit-touch-callout'] = 'none'; this.dom.style['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)'; this.dom.classname = config.elementclassname; vmlcanvasmanager && vmlcanvasmanager.initelement(this.dom); this.domback = null; this.ctxback = null; this.painter = painter; this.unusedcount = 0; this.config = null; this.dirty = true; this.elcount = 0; this.clearcolor = 0; this.motionblur = false; this.lastframealpha = 0.7; this.zoomable = false; this.panable = false; this.maxzoom = infinity; this.minzoom = 0; transformable.call(this); }; layer.prototype.initcontext = function () { this.ctx = this.dom.getcontext('2d'); var dpr = config.devicepixelratio; if (dpr != 1) { this.ctx.scale(dpr, dpr); } }; layer.prototype.createbackbuffer = function () { if (vmlcanvasmanager) { return; } this.domback = createdom('back-' + this.id, 'canvas', this.painter); this.ctxback = this.domback.getcontext('2d'); var dpr = config.devicepixelratio; if (dpr != 1) { this.ctxback.scale(dpr, dpr); } }; layer.prototype.resize = function (width, height) { var dpr = config.devicepixelratio; this.dom.style.width = width + 'px'; this.dom.style.height = height + 'px'; this.dom.setattribute('width', width * dpr); this.dom.setattribute('height', height * dpr); if (dpr != 1) { this.ctx.scale(dpr, dpr); } if (this.domback) { this.domback.setattribute('width', width * dpr); this.domback.setattribute('height', height * dpr); if (dpr != 1) { this.ctxback.scale(dpr, dpr); } } }; layer.prototype.clear = function () { var dom = this.dom; var ctx = this.ctx; var width = dom.width; var height = dom.height; var haveclearcolor = this.clearcolor && !vmlcanvasmanager; var havemotionblur = this.motionblur && !vmlcanvasmanager; var lastframealpha = this.lastframealpha; var dpr = config.devicepixelratio; if (havemotionblur) { if (!this.domback) { this.createbackbuffer(); } this.ctxback.globalcompositeoperation = 'copy'; this.ctxback.drawimage(dom, 0, 0, width / dpr, height / dpr); } ctx.clearrect(0, 0, width / dpr, height / dpr); if (haveclearcolor) { ctx.save(); ctx.fillstyle = this.clearcolor; ctx.fillrect(0, 0, width / dpr, height / dpr); ctx.restore(); } if (havemotionblur) { var domback = this.domback; ctx.save(); ctx.globalalpha = lastframealpha; ctx.drawimage(domback, 0, 0, width / dpr, height / dpr); ctx.restore(); } }; util.merge(layer.prototype, transformable.prototype); return layer; });define('zrender/shape/text', [ 'require', '../tool/area', './base', '../tool/util' ], function (require) { var area = require('../tool/area'); var base = require('./base'); var text = function (options) { base.call(this, options); }; text.prototype = { type: 'text', brush: function (ctx, ishighlight) { var style = this.style; if (ishighlight) { style = this.gethighlightstyle(style, this.highlightstyle || {}); } if (typeof style.text == 'undefined' || style.text === false) { return; } ctx.save(); this.doclip(ctx); this.setcontext(ctx, style); this.settransform(ctx); if (style.textfont) { ctx.font = style.textfont; } ctx.textalign = style.textalign || 'start'; ctx.textbaseline = style.textbaseline || 'middle'; var text = (style.text + '').split('\n'); var lineheight = area.gettextheight('国', style.textfont); var rect = this.getrect(style); var x = style.x; var y; if (style.textbaseline == 'top') { y = rect.y; } else if (style.textbaseline == 'bottom') { y = rect.y + lineheight; } else { y = rect.y + lineheight / 2; } for (var i = 0, l = text.length; i < l; i++) { if (style.maxwidth) { switch (style.brushtype) { case 'fill': ctx.filltext(text[i], x, y, style.maxwidth); break; case 'stroke': ctx.stroketext(text[i], x, y, style.maxwidth); break; case 'both': ctx.filltext(text[i], x, y, style.maxwidth); ctx.stroketext(text[i], x, y, style.maxwidth); break; default: ctx.filltext(text[i], x, y, style.maxwidth); } } else { switch (style.brushtype) { case 'fill': ctx.filltext(text[i], x, y); break; case 'stroke': ctx.stroketext(text[i], x, y); break; case 'both': ctx.filltext(text[i], x, y); ctx.stroketext(text[i], x, y); break; default: ctx.filltext(text[i], x, y); } } y += lineheight; } ctx.restore(); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } var width = area.gettextwidth(style.text, style.textfont); var height = area.gettextheight(style.text, style.textfont); var textx = style.x; if (style.textalign == 'end' || style.textalign == 'right') { textx -= width; } else if (style.textalign == 'center') { textx -= width / 2; } var texty; if (style.textbaseline == 'top') { texty = style.y; } else if (style.textbaseline == 'bottom') { texty = style.y - height; } else { texty = style.y - height / 2; } style.__rect = { x: textx, y: texty, width: width, height: height }; return style.__rect; } }; require('../tool/util').inherits(text, base); return text; });define('zrender/shape/rectangle', [ 'require', './base', '../tool/util' ], function (require) { var base = require('./base'); var rectangle = function (options) { base.call(this, options); }; rectangle.prototype = { type: 'rectangle', _buildradiuspath: function (ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; var r = style.radius; var r1; var r2; var r3; var r4; if (typeof r === 'number') { r1 = r2 = r3 = r4 = r; } else if (r instanceof array) { if (r.length === 1) { r1 = r2 = r3 = r4 = r[0]; } else if (r.length === 2) { r1 = r3 = r[0]; r2 = r4 = r[1]; } else if (r.length === 3) { r1 = r[0]; r2 = r4 = r[1]; r3 = r[2]; } else { r1 = r[0]; r2 = r[1]; r3 = r[2]; r4 = r[3]; } } else { r1 = r2 = r3 = r4 = 0; } var total; if (r1 + r2 > width) { total = r1 + r2; r1 *= width / total; r2 *= width / total; } if (r3 + r4 > width) { total = r3 + r4; r3 *= width / total; r4 *= width / total; } if (r2 + r3 > height) { total = r2 + r3; r2 *= height / total; r3 *= height / total; } if (r1 + r4 > height) { total = r1 + r4; r1 *= height / total; r4 *= height / total; } ctx.moveto(x + r1, y); ctx.lineto(x + width - r2, y); r2 !== 0 && ctx.quadraticcurveto(x + width, y, x + width, y + r2); ctx.lineto(x + width, y + height - r3); r3 !== 0 && ctx.quadraticcurveto(x + width, y + height, x + width - r3, y + height); ctx.lineto(x + r4, y + height); r4 !== 0 && ctx.quadraticcurveto(x, y + height, x, y + height - r4); ctx.lineto(x, y + r1); r1 !== 0 && ctx.quadraticcurveto(x, y, x + r1, y); }, buildpath: function (ctx, style) { if (!style.radius) { ctx.moveto(style.x, style.y); ctx.lineto(style.x + style.width, style.y); ctx.lineto(style.x + style.width, style.y + style.height); ctx.lineto(style.x, style.y + style.height); ctx.lineto(style.x, style.y); } else { this._buildradiuspath(ctx, style); } ctx.closepath(); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } var linewidth; if (style.brushtype == 'stroke' || style.brushtype == 'fill') { linewidth = style.linewidth || 1; } else { linewidth = 0; } style.__rect = { x: math.round(style.x - linewidth / 2), y: math.round(style.y - linewidth / 2), width: style.width + linewidth, height: style.height + linewidth }; return style.__rect; } }; require('../tool/util').inherits(rectangle, base); return rectangle; });define('zrender/tool/area', [ 'require', './util', './curve' ], function (require) { 'use strict'; var util = require('./util'); var curve = require('./curve'); var _ctx; var _textwidthcache = {}; var _textheightcache = {}; var _textwidthcachecounter = 0; var _textheightcachecounter = 0; var text_cache_max = 5000; var pi2 = math.pi * 2; function normalizeradian(angle) { angle %= pi2; if (angle < 0) { angle += pi2; } return angle; } function isinside(shape, area, x, y) { if (!area || !shape) { return false; } var zonetype = shape.type; _ctx = _ctx || util.getcontext(); var _mathreturn = _mathmethod(shape, area, x, y); if (typeof _mathreturn != 'undefined') { return _mathreturn; } if (shape.buildpath && _ctx.ispointinpath) { return _buildpathmethod(shape, _ctx, area, x, y); } switch (zonetype) { case 'ellipse': return true; case 'trochoid': var _r = area.location == 'out' ? area.r1 + area.r2 + area.d : area.r1 - area.r2 + area.d; return isinsidecircle(area, x, y, _r); case 'rose': return isinsidecircle(area, x, y, area.maxr); default: return false; } } function _mathmethod(shape, area, x, y) { var zonetype = shape.type; switch (zonetype) { case 'bezier-curve': if (typeof area.cpx2 === 'undefined') { return isinsidequadraticstroke(area.xstart, area.ystart, area.cpx1, area.cpy1, area.xend, area.yend, area.linewidth, x, y); } return isinsidecubicstroke(area.xstart, area.ystart, area.cpx1, area.cpy1, area.cpx2, area.cpy2, area.xend, area.yend, area.linewidth, x, y); case 'line': return isinsideline(area.xstart, area.ystart, area.xend, area.yend, area.linewidth, x, y); case 'polyline': return isinsidepolyline(area.pointlist, area.linewidth, x, y); case 'ring': return isinsidering(area.x, area.y, area.r0, area.r, x, y); case 'circle': return isinsidecircle(area.x, area.y, area.r, x, y); case 'sector': var startangle = area.startangle * math.pi / 180; var endangle = area.endangle * math.pi / 180; if (!area.clockwise) { startangle = -startangle; endangle = -endangle; } return isinsidesector(area.x, area.y, area.r0, area.r, startangle, endangle, !area.clockwise, x, y); case 'path': return area.patharray && isinsidepath(area.patharray, math.max(area.linewidth, 5), area.brushtype, x, y); case 'polygon': case 'star': case 'isogon': return isinsidepolygon(area.pointlist, x, y); case 'text': var rect = area.__rect || shape.getrect(area); return isinsiderect(rect.x, rect.y, rect.width, rect.height, x, y); case 'rectangle': case 'image': return isinsiderect(area.x, area.y, area.width, area.height, x, y); } } function _buildpathmethod(shape, context, area, x, y) { context.beginpath(); shape.buildpath(context, area); context.closepath(); return context.ispointinpath(x, y); } function isoutside(shape, area, x, y) { return !isinside(shape, area, x, y); } function isinsideline(x0, y0, x1, y1, linewidth, x, y) { if (linewidth === 0) { return false; } var _l = math.max(linewidth, 5); var _a = 0; var _b = x0; if (y > y0 + _l && y > y1 + _l || y < y0 - _l && y < y1 - _l || x > x0 + _l && x > x1 + _l || x < x0 - _l && x < x1 - _l) { return false; } if (x0 !== x1) { _a = (y0 - y1) / (x0 - x1); _b = (x0 * y1 - x1 * y0) / (x0 - x1); } else { return math.abs(x - x0) <= _l / 2; } var tmp = _a * x - y + _b; var _s = tmp * tmp / (_a * _a + 1); return _s <= _l / 2 * _l / 2; } function isinsidecubicstroke(x0, y0, x1, y1, x2, y2, x3, y3, linewidth, x, y) { if (linewidth === 0) { return false; } var _l = math.max(linewidth, 5); if (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l) { return false; } var d = curve.cubicprojectpoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, null); return d <= _l / 2; } function isinsidequadraticstroke(x0, y0, x1, y1, x2, y2, linewidth, x, y) { if (linewidth === 0) { return false; } var _l = math.max(linewidth, 5); if (y > y0 + _l && y > y1 + _l && y > y2 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l) { return false; } var d = curve.quadraticprojectpoint(x0, y0, x1, y1, x2, y2, x, y, null); return d <= _l / 2; } function isinsidearcstroke(cx, cy, r, startangle, endangle, anticlockwise, linewidth, x, y) { if (linewidth === 0) { return false; } var _l = math.max(linewidth, 5); x -= cx; y -= cy; var d = math.sqrt(x * x + y * y); if (d - _l > r || d + _l < r) { return false; } if (math.abs(startangle - endangle) >= pi2) { return true; } if (anticlockwise) { var tmp = startangle; startangle = normalizeradian(endangle); endangle = normalizeradian(tmp); } else { startangle = normalizeradian(startangle); endangle = normalizeradian(endangle); } if (startangle > endangle) { endangle += pi2; } var angle = math.atan2(y, x); if (angle < 0) { angle += pi2; } return angle >= startangle && angle <= endangle || angle + pi2 >= startangle && angle + pi2 <= endangle; } function isinsidepolyline(points, linewidth, x, y) { var linewidth = math.max(linewidth, 10); for (var i = 0, l = points.length - 1; i < l; i++) { var x0 = points[i][0]; var y0 = points[i][1]; var x1 = points[i + 1][0]; var y1 = points[i + 1][1]; if (isinsideline(x0, y0, x1, y1, linewidth, x, y)) { return true; } } return false; } function isinsidering(cx, cy, r0, r, x, y) { var d = (x - cx) * (x - cx) + (y - cy) * (y - cy); return d < r * r && d > r0 * r0; } function isinsiderect(x0, y0, width, height, x, y) { return x >= x0 && x <= x0 + width && y >= y0 && y <= y0 + height; } function isinsidecircle(x0, y0, r, x, y) { return (x - x0) * (x - x0) + (y - y0) * (y - y0) < r * r; } function isinsidesector(cx, cy, r0, r, startangle, endangle, anticlockwise, x, y) { return isinsidearcstroke(cx, cy, (r0 + r) / 2, startangle, endangle, anticlockwise, r - r0, x, y); } function isinsidepolygon(points, x, y) { var n = points.length; var w = 0; for (var i = 0, j = n - 1; i < n; i++) { var x0 = points[j][0]; var y0 = points[j][1]; var x1 = points[i][0]; var y1 = points[i][1]; w += windingline(x0, y0, x1, y1, x, y); j = i; } return w !== 0; } function windingline(x0, y0, x1, y1, x, y) { if (y > y0 && y > y1 || y < y0 && y < y1) { return 0; } if (y1 == y0) { return 0; } var dir = y1 < y0 ? 1 : -1; var t = (y - y0) / (y1 - y0); var x_ = t * (x1 - x0) + x0; return x_ > x ? dir : 0; } var roots = [ -1, -1, -1 ]; var extrema = [ -1, -1 ]; function swapextrema() { var tmp = extrema[0]; extrema[0] = extrema[1]; extrema[1] = tmp; } function windingcubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) { if (y > y0 && y > y1 && y > y2 && y > y3 || y < y0 && y < y1 && y < y2 && y < y3) { return 0; } var nroots = curve.cubicrootat(y0, y1, y2, y3, y, roots); if (nroots === 0) { return 0; } else { var w = 0; var nextrema = -1; var y0_, y1_; for (var i = 0; i < nroots; i++) { var t = roots[i]; var x_ = curve.cubicat(x0, x1, x2, x3, t); if (x_ < x) { continue; } if (nextrema < 0) { nextrema = curve.cubicextrema(y0, y1, y2, y3, extrema); if (extrema[1] < extrema[0] && nextrema > 1) { swapextrema(); } y0_ = curve.cubicat(y0, y1, y2, y3, extrema[0]); if (nextrema > 1) { y1_ = curve.cubicat(y0, y1, y2, y3, extrema[1]); } } if (nextrema == 2) { if (t < extrema[0]) { w += y0_ < y0 ? 1 : -1; } else if (t < extrema[1]) { w += y1_ < y0_ ? 1 : -1; } else { w += y3 < y1_ ? 1 : -1; } } else { if (t < extrema[0]) { w += y0_ < y0 ? 1 : -1; } else { w += y3 < y0_ ? 1 : -1; } } } return w; } } function windingquadratic(x0, y0, x1, y1, x2, y2, x, y) { if (y > y0 && y > y1 && y > y2 || y < y0 && y < y1 && y < y2) { return 0; } var nroots = curve.quadraticrootat(y0, y1, y2, y, roots); if (nroots === 0) { return 0; } else { var t = curve.quadraticextremum(y0, y1, y2); if (t >= 0 && t <= 1) { var w = 0; var y_ = curve.quadraticat(y0, y1, y2, t); for (var i = 0; i < nroots; i++) { var x_ = curve.quadraticat(x0, x1, x2, roots[i]); if (x_ < x) { continue; } if (roots[i] < t) { w += y_ < y0 ? 1 : -1; } else { w += y2 < y_ ? 1 : -1; } } return w; } else { var x_ = curve.quadraticat(x0, x1, x2, roots[0]); if (x_ < x) { return 0; } return y2 < y0 ? 1 : -1; } } } function windingarc(cx, cy, r, startangle, endangle, anticlockwise, x, y) { y -= cy; if (y > r || y < -r) { return 0; } var tmp = math.sqrt(r * r - y * y); roots[0] = -tmp; roots[1] = tmp; if (math.abs(startangle - endangle) >= pi2) { startangle = 0; endangle = pi2; var dir = anticlockwise ? 1 : -1; if (x >= roots[0] + cx && x <= roots[1] + cx) { return dir; } else { return 0; } } if (anticlockwise) { var tmp = startangle; startangle = normalizeradian(endangle); endangle = normalizeradian(tmp); } else { startangle = normalizeradian(startangle); endangle = normalizeradian(endangle); } if (startangle > endangle) { endangle += pi2; } var w = 0; for (var i = 0; i < 2; i++) { var x_ = roots[i]; if (x_ + cx > x) { var angle = math.atan2(y, x_); var dir = anticlockwise ? 1 : -1; if (angle < 0) { angle = pi2 + angle; } if (angle >= startangle && angle <= endangle || angle + pi2 >= startangle && angle + pi2 <= endangle) { if (angle > math.pi / 2 && angle < math.pi * 1.5) { dir = -dir; } w += dir; } } } return w; } function isinsidepath(patharray, linewidth, brushtype, x, y) { var w = 0; var xi = 0; var yi = 0; var x0 = 0; var y0 = 0; var beginsubpath = true; var firstcmd = true; brushtype = brushtype || 'fill'; var hasstroke = brushtype === 'stroke' || brushtype === 'both'; var hasfill = brushtype === 'fill' || brushtype === 'both'; for (var i = 0; i < patharray.length; i++) { var seg = patharray[i]; var p = seg.points; if (beginsubpath || seg.command === 'm') { if (i > 0) { if (hasfill) { w += windingline(xi, yi, x0, y0, x, y); } if (w !== 0) { return true; } } x0 = p[p.length - 2]; y0 = p[p.length - 1]; beginsubpath = false; if (firstcmd && seg.command !== 'a') { firstcmd = false; xi = x0; yi = y0; } } switch (seg.command) { case 'm': xi = p[0]; yi = p[1]; break; case 'l': if (hasstroke) { if (isinsideline(xi, yi, p[0], p[1], linewidth, x, y)) { return true; } } if (hasfill) { w += windingline(xi, yi, p[0], p[1], x, y); } xi = p[0]; yi = p[1]; break; case 'c': if (hasstroke) { if (isinsidecubicstroke(xi, yi, p[0], p[1], p[2], p[3], p[4], p[5], linewidth, x, y)) { return true; } } if (hasfill) { w += windingcubic(xi, yi, p[0], p[1], p[2], p[3], p[4], p[5], x, y); } xi = p[4]; yi = p[5]; break; case 'q': if (hasstroke) { if (isinsidequadraticstroke(xi, yi, p[0], p[1], p[2], p[3], linewidth, x, y)) { return true; } } if (hasfill) { w += windingquadratic(xi, yi, p[0], p[1], p[2], p[3], x, y); } xi = p[2]; yi = p[3]; break; case 'a': var cx = p[0]; var cy = p[1]; var rx = p[2]; var ry = p[3]; var theta = p[4]; var dtheta = p[5]; var x1 = math.cos(theta) * rx + cx; var y1 = math.sin(theta) * ry + cy; if (!firstcmd) { w += windingline(xi, yi, x1, y1); } else { firstcmd = false; x0 = x1; y0 = y1; } var _x = (x - cx) * ry / rx + cx; if (hasstroke) { if (isinsidearcstroke(cx, cy, ry, theta, theta + dtheta, 1 - p[7], linewidth, _x, y)) { return true; } } if (hasfill) { w += windingarc(cx, cy, ry, theta, theta + dtheta, 1 - p[7], _x, y); } xi = math.cos(theta + dtheta) * rx + cx; yi = math.sin(theta + dtheta) * ry + cy; break; case 'z': if (hasstroke) { if (isinsideline(xi, yi, x0, y0, linewidth, x, y)) { return true; } } beginsubpath = true; break; } } if (hasfill) { w += windingline(xi, yi, x0, y0, x, y); } return w !== 0; } function gettextwidth(text, textfont) { var key = text + ':' + textfont; if (_textwidthcache[key]) { return _textwidthcache[key]; } _ctx = _ctx || util.getcontext(); _ctx.save(); if (textfont) { _ctx.font = textfont; } text = (text + '').split('\n'); var width = 0; for (var i = 0, l = text.length; i < l; i++) { width = math.max(_ctx.measuretext(text[i]).width, width); } _ctx.restore(); _textwidthcache[key] = width; if (++_textwidthcachecounter > text_cache_max) { _textwidthcachecounter = 0; _textwidthcache = {}; } return width; } function gettextheight(text, textfont) { var key = text + ':' + textfont; if (_textheightcache[key]) { return _textheightcache[key]; } _ctx = _ctx || util.getcontext(); _ctx.save(); if (textfont) { _ctx.font = textfont; } text = (text + '').split('\n'); var height = (_ctx.measuretext('国').width + 2) * text.length; _ctx.restore(); _textheightcache[key] = height; if (++_textheightcachecounter > text_cache_max) { _textheightcachecounter = 0; _textheightcache = {}; } return height; } return { isinside: isinside, isoutside: isoutside, gettextwidth: gettextwidth, gettextheight: gettextheight, isinsidepath: isinsidepath, isinsidepolygon: isinsidepolygon, isinsidesector: isinsidesector, isinsidecircle: isinsidecircle, isinsideline: isinsideline, isinsiderect: isinsiderect, isinsidepolyline: isinsidepolyline, isinsidecubicstroke: isinsidecubicstroke, isinsidequadraticstroke: isinsidequadraticstroke }; });define('zrender/shape/base', [ 'require', '../tool/matrix', '../tool/guid', '../tool/util', '../tool/log', '../mixin/transformable', '../mixin/eventful', '../tool/area', '../tool/color' ], function (require) { var vmlcanvasmanager = window['g_vmlcanvasmanager']; var matrix = require('../tool/matrix'); var guid = require('../tool/guid'); var util = require('../tool/util'); var log = require('../tool/log'); var transformable = require('../mixin/transformable'); var eventful = require('../mixin/eventful'); function _filltext(ctx, text, x, y, textfont, textalign, textbaseline) { if (textfont) { ctx.font = textfont; } ctx.textalign = textalign; ctx.textbaseline = textbaseline; var rect = _gettextrect(text, x, y, textfont, textalign, textbaseline); text = (text + '').split('\n'); var lineheight = require('../tool/area').gettextheight('国', textfont); switch (textbaseline) { case 'top': y = rect.y; break; case 'bottom': y = rect.y + lineheight; break; default: y = rect.y + lineheight / 2; } for (var i = 0, l = text.length; i < l; i++) { ctx.filltext(text[i], x, y); y += lineheight; } } function _gettextrect(text, x, y, textfont, textalign, textbaseline) { var area = require('../tool/area'); var width = area.gettextwidth(text, textfont); var lineheight = area.gettextheight('国', textfont); text = (text + '').split('\n'); switch (textalign) { case 'end': case 'right': x -= width; break; case 'center': x -= width / 2; break; } switch (textbaseline) { case 'top': break; case 'bottom': y -= lineheight * text.length; break; default: y -= lineheight * text.length / 2; } return { x: x, y: y, width: width, height: lineheight * text.length }; } var base = function (options) { options = options || {}; this.id = options.id || guid(); for (var key in options) { this[key] = options[key]; } this.style = this.style || {}; this.highlightstyle = this.highlightstyle || null; this.parent = null; this.__dirty = true; this.__clipshapes = []; transformable.call(this); eventful.call(this); }; base.prototype.invisible = false; base.prototype.ignore = false; base.prototype.zlevel = 0; base.prototype.draggable = false; base.prototype.clickable = false; base.prototype.hoverable = true; base.prototype.z = 0; base.prototype.brush = function (ctx, ishighlight) { var style = this.beforebrush(ctx, ishighlight); ctx.beginpath(); this.buildpath(ctx, style); switch (style.brushtype) { case 'both': ctx.fill(); case 'stroke': style.linewidth > 0 && ctx.stroke(); break; default: ctx.fill(); } this.drawtext(ctx, style, this.style); this.afterbrush(ctx); }; base.prototype.beforebrush = function (ctx, ishighlight) { var style = this.style; if (this.brushtypeonly) { style.brushtype = this.brushtypeonly; } if (ishighlight) { style = this.gethighlightstyle(style, this.highlightstyle || {}, this.brushtypeonly); } if (this.brushtypeonly == 'stroke') { style.strokecolor = style.strokecolor || style.color; } ctx.save(); this.doclip(ctx); this.setcontext(ctx, style); this.settransform(ctx); return style; }; base.prototype.afterbrush = function (ctx) { ctx.restore(); }; var style_ctx_map = [ [ 'color', 'fillstyle' ], [ 'strokecolor', 'strokestyle' ], [ 'opacity', 'globalalpha' ], [ 'linecap', 'linecap' ], [ 'linejoin', 'linejoin' ], [ 'miterlimit', 'miterlimit' ], [ 'linewidth', 'linewidth' ], [ 'shadowblur', 'shadowblur' ], [ 'shadowcolor', 'shadowcolor' ], [ 'shadowoffsetx', 'shadowoffsetx' ], [ 'shadowoffsety', 'shadowoffsety' ] ]; base.prototype.setcontext = function (ctx, style) { for (var i = 0, len = style_ctx_map.length; i < len; i++) { var styleprop = style_ctx_map[i][0]; var stylevalue = style[styleprop]; var ctxprop = style_ctx_map[i][1]; if (typeof stylevalue != 'undefined') { ctx[ctxprop] = stylevalue; } } }; var clipshapeinvtransform = matrix.create(); base.prototype.doclip = function (ctx) { if (this.__clipshapes && !vmlcanvasmanager) { for (var i = 0; i < this.__clipshapes.length; i++) { var clipshape = this.__clipshapes[i]; if (clipshape.needtransform) { var m = clipshape.transform; matrix.invert(clipshapeinvtransform, m); ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); } ctx.beginpath(); clipshape.buildpath(ctx, clipshape.style); ctx.clip(); if (clipshape.needtransform) { var m = clipshapeinvtransform; ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); } } } }; base.prototype.gethighlightstyle = function (style, highlightstyle, brushtypeonly) { var newstyle = {}; for (var k in style) { newstyle[k] = style[k]; } var color = require('../tool/color'); var highlightcolor = color.gethighlightcolor(); if (style.brushtype != 'stroke') { newstyle.strokecolor = highlightcolor; newstyle.linewidth = (style.linewidth || 1) + this.gethighlightzoom(); newstyle.brushtype = 'both'; } else { if (brushtypeonly != 'stroke') { newstyle.strokecolor = highlightcolor; newstyle.linewidth = (style.linewidth || 1) + this.gethighlightzoom(); } else { newstyle.strokecolor = highlightstyle.strokecolor || color.mix(style.strokecolor, color.torgb(highlightcolor)); } } for (var k in highlightstyle) { if (typeof highlightstyle[k] != 'undefined') { newstyle[k] = highlightstyle[k]; } } return newstyle; }; base.prototype.gethighlightzoom = function () { return this.type != 'text' ? 6 : 2; }; base.prototype.drift = function (dx, dy) { this.position[0] += dx; this.position[1] += dy; }; base.prototype.buildpath = function (ctx, style) { log('buildpath not implemented in ' + this.type); }; base.prototype.getrect = function (style) { log('getrect not implemented in ' + this.type); }; base.prototype.iscover = function (x, y) { var originpos = this.transformcoordtolocal(x, y); x = originpos[0]; y = originpos[1]; if (this.iscoverrect(x, y)) { return require('../tool/area').isinside(this, this.style, x, y); } return false; }; base.prototype.iscoverrect = function (x, y) { var rect = this.style.__rect; if (!rect) { rect = this.style.__rect = this.getrect(this.style); } return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height; }; base.prototype.drawtext = function (ctx, style, normalstyle) { if (typeof style.text == 'undefined' || style.text === false) { return; } var textcolor = style.textcolor || style.color || style.strokecolor; ctx.fillstyle = textcolor; var dd = 10; var al; var bl; var tx; var ty; var textposition = style.textposition || this.textposition || 'top'; switch (textposition) { case 'inside': case 'top': case 'bottom': case 'left': case 'right': if (this.getrect) { var rect = (normalstyle || style).__rect || this.getrect(normalstyle || style); switch (textposition) { case 'inside': tx = rect.x + rect.width / 2; ty = rect.y + rect.height / 2; al = 'center'; bl = 'middle'; if (style.brushtype != 'stroke' && textcolor == style.color) { ctx.fillstyle = '#fff'; } break; case 'left': tx = rect.x - dd; ty = rect.y + rect.height / 2; al = 'end'; bl = 'middle'; break; case 'right': tx = rect.x + rect.width + dd; ty = rect.y + rect.height / 2; al = 'start'; bl = 'middle'; break; case 'top': tx = rect.x + rect.width / 2; ty = rect.y - dd; al = 'center'; bl = 'bottom'; break; case 'bottom': tx = rect.x + rect.width / 2; ty = rect.y + rect.height + dd; al = 'center'; bl = 'top'; break; } } break; case 'start': case 'end': var pointlist = style.pointlist || [ [ style.xstart || 0, style.ystart || 0 ], [ style.xend || 0, style.yend || 0 ] ]; var length = pointlist.length; if (length < 2) { return; } var xstart; var xend; var ystart; var yend; switch (textposition) { case 'start': xstart = pointlist[1][0]; xend = pointlist[0][0]; ystart = pointlist[1][1]; yend = pointlist[0][1]; break; case 'end': xstart = pointlist[length - 2][0]; xend = pointlist[length - 1][0]; ystart = pointlist[length - 2][1]; yend = pointlist[length - 1][1]; break; } tx = xend; ty = yend; var angle = math.atan((ystart - yend) / (xend - xstart)) / math.pi * 180; if (xend - xstart < 0) { angle += 180; } else if (ystart - yend < 0) { angle += 360; } dd = 5; if (angle >= 30 && angle <= 150) { al = 'center'; bl = 'bottom'; ty -= dd; } else if (angle > 150 && angle < 210) { al = 'right'; bl = 'middle'; tx -= dd; } else if (angle >= 210 && angle <= 330) { al = 'center'; bl = 'top'; ty += dd; } else { al = 'left'; bl = 'middle'; tx += dd; } break; case 'specific': tx = style.textx || 0; ty = style.texty || 0; al = 'start'; bl = 'middle'; break; } if (tx != null && ty != null) { _filltext(ctx, style.text, tx, ty, style.textfont, style.textalign || al, style.textbaseline || bl); } }; base.prototype.modself = function () { this.__dirty = true; if (this.style) { this.style.__rect = null; } if (this.highlightstyle) { this.highlightstyle.__rect = null; } }; base.prototype.issilent = function () { return !(this.hoverable || this.draggable || this.clickable || this.onmousemove || this.onmouseover || this.onmouseout || this.onmousedown || this.onmouseup || this.onclick || this.ondragenter || this.ondragover || this.ondragleave || this.ondrop); }; util.merge(base.prototype, transformable.prototype, true); util.merge(base.prototype, eventful.prototype, true); return base; });define('zrender/tool/curve', [ 'require', './vector' ], function (require) { var vector = require('./vector'); 'use strict'; var epsilon = 0.0001; var three_sqrt = math.sqrt(3); var one_third = 1 / 3; var _v0 = vector.create(); var _v1 = vector.create(); var _v2 = vector.create(); function isaroundzero(val) { return val > -epsilon && val < epsilon; } function isnotaroundzero(val) { return val > epsilon || val < -epsilon; } function cubicat(p0, p1, p2, p3, t) { var onet = 1 - t; return onet * onet * (onet * p0 + 3 * t * p1) + t * t * (t * p3 + 3 * onet * p2); } function cubicderivativeat(p0, p1, p2, p3, t) { var onet = 1 - t; return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t); } function cubicrootat(p0, p1, p2, p3, val, roots) { var a = p3 + 3 * (p1 - p2) - p0; var b = 3 * (p2 - p1 * 2 + p0); var c = 3 * (p1 - p0); var d = p0 - val; var a = b * b - 3 * a * c; var b = b * c - 9 * a * d; var c = c * c - 3 * b * d; var n = 0; if (isaroundzero(a) && isaroundzero(b)) { if (isaroundzero(b)) { roots[0] = 0; } else { var t1 = -c / b; if (t1 >= 0 && t1 <= 1) { roots[n++] = t1; } } } else { var disc = b * b - 4 * a * c; if (isaroundzero(disc)) { var k = b / a; var t1 = -b / a + k; var t2 = -k / 2; if (t1 >= 0 && t1 <= 1) { roots[n++] = t1; } if (t2 >= 0 && t2 <= 1) { roots[n++] = t2; } } else if (disc > 0) { var discsqrt = math.sqrt(disc); var y1 = a * b + 1.5 * a * (-b + discsqrt); var y2 = a * b + 1.5 * a * (-b - discsqrt); if (y1 < 0) { y1 = -math.pow(-y1, one_third); } else { y1 = math.pow(y1, one_third); } if (y2 < 0) { y2 = -math.pow(-y2, one_third); } else { y2 = math.pow(y2, one_third); } var t1 = (-b - (y1 + y2)) / (3 * a); if (t1 >= 0 && t1 <= 1) { roots[n++] = t1; } } else { var t = (2 * a * b - 3 * a * b) / (2 * math.sqrt(a * a * a)); var theta = math.acos(t) / 3; var asqrt = math.sqrt(a); var tmp = math.cos(theta); var t1 = (-b - 2 * asqrt * tmp) / (3 * a); var t2 = (-b + asqrt * (tmp + three_sqrt * math.sin(theta))) / (3 * a); var t3 = (-b + asqrt * (tmp - three_sqrt * math.sin(theta))) / (3 * a); if (t1 >= 0 && t1 <= 1) { roots[n++] = t1; } if (t2 >= 0 && t2 <= 1) { roots[n++] = t2; } if (t3 >= 0 && t3 <= 1) { roots[n++] = t3; } } } return n; } function cubicextrema(p0, p1, p2, p3, extrema) { var b = 6 * p2 - 12 * p1 + 6 * p0; var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2; var c = 3 * p1 - 3 * p0; var n = 0; if (isaroundzero(a)) { if (isnotaroundzero(b)) { var t1 = -c / b; if (t1 >= 0 && t1 <= 1) { extrema[n++] = t1; } } } else { var disc = b * b - 4 * a * c; if (isaroundzero(disc)) { extrema[0] = -b / (2 * a); } else if (disc > 0) { var discsqrt = math.sqrt(disc); var t1 = (-b + discsqrt) / (2 * a); var t2 = (-b - discsqrt) / (2 * a); if (t1 >= 0 && t1 <= 1) { extrema[n++] = t1; } if (t2 >= 0 && t2 <= 1) { extrema[n++] = t2; } } } return n; } function cubicsubdivide(p0, p1, p2, p3, t, out) { var p01 = (p1 - p0) * t + p0; var p12 = (p2 - p1) * t + p1; var p23 = (p3 - p2) * t + p2; var p012 = (p12 - p01) * t + p01; var p123 = (p23 - p12) * t + p12; var p0123 = (p123 - p012) * t + p012; out[0] = p0; out[1] = p01; out[2] = p012; out[3] = p0123; out[4] = p0123; out[5] = p123; out[6] = p23; out[7] = p3; } function cubicprojectpoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, out) { var t; var interval = 0.005; var d = infinity; _v0[0] = x; _v0[1] = y; for (var _t = 0; _t < 1; _t += 0.05) { _v1[0] = cubicat(x0, x1, x2, x3, _t); _v1[1] = cubicat(y0, y1, y2, y3, _t); var d1 = vector.distsquare(_v0, _v1); if (d1 < d) { t = _t; d = d1; } } d = infinity; for (var i = 0; i < 32; i++) { if (interval < epsilon) { break; } var prev = t - interval; var next = t + interval; _v1[0] = cubicat(x0, x1, x2, x3, prev); _v1[1] = cubicat(y0, y1, y2, y3, prev); var d1 = vector.distsquare(_v1, _v0); if (prev >= 0 && d1 < d) { t = prev; d = d1; } else { _v2[0] = cubicat(x0, x1, x2, x3, next); _v2[1] = cubicat(y0, y1, y2, y3, next); var d2 = vector.distsquare(_v2, _v0); if (next <= 1 && d2 < d) { t = next; d = d2; } else { interval *= 0.5; } } } if (out) { out[0] = cubicat(x0, x1, x2, x3, t); out[1] = cubicat(y0, y1, y2, y3, t); } return math.sqrt(d); } function quadraticat(p0, p1, p2, t) { var onet = 1 - t; return onet * (onet * p0 + 2 * t * p1) + t * t * p2; } function quadraticderivativeat(p0, p1, p2, t) { return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1)); } function quadraticrootat(p0, p1, p2, val, roots) { var a = p0 - 2 * p1 + p2; var b = 2 * (p1 - p0); var c = p0 - val; var n = 0; if (isaroundzero(a)) { if (isnotaroundzero(b)) { var t1 = -c / b; if (t1 >= 0 && t1 <= 1) { roots[n++] = t1; } } } else { var disc = b * b - 4 * a * c; if (isaroundzero(disc)) { var t1 = -b / (2 * a); if (t1 >= 0 && t1 <= 1) { roots[n++] = t1; } } else if (disc > 0) { var discsqrt = math.sqrt(disc); var t1 = (-b + discsqrt) / (2 * a); var t2 = (-b - discsqrt) / (2 * a); if (t1 >= 0 && t1 <= 1) { roots[n++] = t1; } if (t2 >= 0 && t2 <= 1) { roots[n++] = t2; } } } return n; } function quadraticextremum(p0, p1, p2) { var divider = p0 + p2 - 2 * p1; if (divider === 0) { return 0.5; } else { return (p0 - p1) / divider; } } function quadraticsubdivide(p0, p1, p2, t, out) { var p01 = (p1 - p0) * t + p0; var p12 = (p2 - p1) * t + p1; var p012 = (p12 - p01) * t + p01; out[0] = p0; out[1] = p01; out[2] = p012; out[3] = p012; out[4] = p12; out[5] = p2; } function quadraticprojectpoint(x0, y0, x1, y1, x2, y2, x, y, out) { var t; var interval = 0.005; var d = infinity; _v0[0] = x; _v0[1] = y; for (var _t = 0; _t < 1; _t += 0.05) { _v1[0] = quadraticat(x0, x1, x2, _t); _v1[1] = quadraticat(y0, y1, y2, _t); var d1 = vector.distsquare(_v0, _v1); if (d1 < d) { t = _t; d = d1; } } d = infinity; for (var i = 0; i < 32; i++) { if (interval < epsilon) { break; } var prev = t - interval; var next = t + interval; _v1[0] = quadraticat(x0, x1, x2, prev); _v1[1] = quadraticat(y0, y1, y2, prev); var d1 = vector.distsquare(_v1, _v0); if (prev >= 0 && d1 < d) { t = prev; d = d1; } else { _v2[0] = quadraticat(x0, x1, x2, next); _v2[1] = quadraticat(y0, y1, y2, next); var d2 = vector.distsquare(_v2, _v0); if (next <= 1 && d2 < d) { t = next; d = d2; } else { interval *= 0.5; } } } if (out) { out[0] = quadraticat(x0, x1, x2, t); out[1] = quadraticat(y0, y1, y2, t); } return math.sqrt(d); } return { cubicat: cubicat, cubicderivativeat: cubicderivativeat, cubicrootat: cubicrootat, cubicextrema: cubicextrema, cubicsubdivide: cubicsubdivide, cubicprojectpoint: cubicprojectpoint, quadraticat: quadraticat, quadraticderivativeat: quadraticderivativeat, quadraticrootat: quadraticrootat, quadraticextremum: quadraticextremum, quadraticsubdivide: quadraticsubdivide, quadraticprojectpoint: quadraticprojectpoint }; });define('zrender/mixin/transformable', [ 'require', '../tool/matrix', '../tool/vector' ], function (require) { 'use strict'; var matrix = require('../tool/matrix'); var vector = require('../tool/vector'); var origin = [ 0, 0 ]; var mtranslate = matrix.translate; var epsilon = 0.00005; function isaroundzero(val) { return val > -epsilon && val < epsilon; } function isnotaroundzero(val) { return val > epsilon || val < -epsilon; } var transformable = function () { if (!this.position) { this.position = [ 0, 0 ]; } if (typeof this.rotation == 'undefined') { this.rotation = [ 0, 0, 0 ]; } if (!this.scale) { this.scale = [ 1, 1, 0, 0 ]; } this.needlocaltransform = false; this.needtransform = false; }; transformable.prototype = { constructor: transformable, updateneedtransform: function () { this.needlocaltransform = isnotaroundzero(this.rotation[0]) || isnotaroundzero(this.position[0]) || isnotaroundzero(this.position[1]) || isnotaroundzero(this.scale[0] - 1) || isnotaroundzero(this.scale[1] - 1); }, updatetransform: function () { this.updateneedtransform(); var parenthastransform = this.parent && this.parent.needtransform; this.needtransform = this.needlocaltransform || parenthastransform; if (!this.needtransform) { return; } var m = this.transform || matrix.create(); matrix.identity(m); if (this.needlocaltransform) { var scale = this.scale; if (isnotaroundzero(scale[0]) || isnotaroundzero(scale[1])) { origin[0] = -scale[2] || 0; origin[1] = -scale[3] || 0; var haveorigin = isnotaroundzero(origin[0]) || isnotaroundzero(origin[1]); if (haveorigin) { mtranslate(m, m, origin); } matrix.scale(m, m, scale); if (haveorigin) { origin[0] = -origin[0]; origin[1] = -origin[1]; mtranslate(m, m, origin); } } if (this.rotation instanceof array) { if (this.rotation[0] !== 0) { origin[0] = -this.rotation[1] || 0; origin[1] = -this.rotation[2] || 0; var haveorigin = isnotaroundzero(origin[0]) || isnotaroundzero(origin[1]); if (haveorigin) { mtranslate(m, m, origin); } matrix.rotate(m, m, this.rotation[0]); if (haveorigin) { origin[0] = -origin[0]; origin[1] = -origin[1]; mtranslate(m, m, origin); } } } else { if (this.rotation !== 0) { matrix.rotate(m, m, this.rotation); } } if (isnotaroundzero(this.position[0]) || isnotaroundzero(this.position[1])) { mtranslate(m, m, this.position); } } if (parenthastransform) { if (this.needlocaltransform) { matrix.mul(m, this.parent.transform, m); } else { matrix.copy(m, this.parent.transform); } } this.transform = m; this.invtransform = this.invtransform || matrix.create(); matrix.invert(this.invtransform, m); }, settransform: function (ctx) { if (this.needtransform) { var m = this.transform; ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]); } }, lookat: function () { var v = vector.create(); return function (target) { if (!this.transform) { this.transform = matrix.create(); } var m = this.transform; vector.sub(v, target, this.position); if (isaroundzero(v[0]) && isaroundzero(v[1])) { return; } vector.normalize(v, v); var scale = this.scale; m[2] = v[0] * scale[1]; m[3] = v[1] * scale[1]; m[0] = v[1] * scale[0]; m[1] = -v[0] * scale[0]; m[4] = this.position[0]; m[5] = this.position[1]; this.decomposetransform(); }; }(), decomposetransform: function () { if (!this.transform) { return; } var m = this.transform; var sx = m[0] * m[0] + m[1] * m[1]; var position = this.position; var scale = this.scale; var rotation = this.rotation; if (isnotaroundzero(sx - 1)) { sx = math.sqrt(sx); } var sy = m[2] * m[2] + m[3] * m[3]; if (isnotaroundzero(sy - 1)) { sy = math.sqrt(sy); } position[0] = m[4]; position[1] = m[5]; scale[0] = sx; scale[1] = sy; scale[2] = scale[3] = 0; rotation[0] = math.atan2(-m[1] / sy, m[0] / sx); rotation[1] = rotation[2] = 0; }, transformcoordtolocal: function (x, y) { var v2 = [ x, y ]; if (this.needtransform && this.invtransform) { vector.applytransform(v2, v2, this.invtransform); } return v2; } }; return transformable; });define('zrender/group', [ 'require', './tool/guid', './tool/util', './mixin/transformable', './mixin/eventful' ], function (require) { var guid = require('./tool/guid'); var util = require('./tool/util'); var transformable = require('./mixin/transformable'); var eventful = require('./mixin/eventful'); var group = function (options) { options = options || {}; this.id = options.id || guid(); for (var key in options) { this[key] = options[key]; } this.type = 'group'; this.clipshape = null; this._children = []; this._storage = null; this.__dirty = true; transformable.call(this); eventful.call(this); }; group.prototype.ignore = false; group.prototype.children = function () { return this._children.slice(); }; group.prototype.childat = function (idx) { return this._children[idx]; }; group.prototype.addchild = function (child) { if (child == this) { return; } if (child.parent == this) { return; } if (child.parent) { child.parent.removechild(child); } this._children.push(child); child.parent = this; if (this._storage && this._storage !== child._storage) { this._storage.addtomap(child); if (child instanceof group) { child.addchildrentostorage(this._storage); } } }; group.prototype.removechild = function (child) { var idx = util.indexof(this._children, child); if (idx >= 0) { this._children.splice(idx, 1); } child.parent = null; if (this._storage) { this._storage.delfrommap(child.id); if (child instanceof group) { child.delchildrenfromstorage(this._storage); } } }; group.prototype.clearchildren = function () { for (var i = 0; i < this._children.length; i++) { var child = this._children[i]; if (this._storage) { this._storage.delfrommap(child.id); if (child instanceof group) { child.delchildrenfromstorage(this._storage); } } } this._children.length = 0; }; group.prototype.eachchild = function (cb, context) { var havecontext = !!context; for (var i = 0; i < this._children.length; i++) { var child = this._children[i]; if (havecontext) { cb.call(context, child); } else { cb(child); } } }; group.prototype.traverse = function (cb, context) { var havecontext = !!context; for (var i = 0; i < this._children.length; i++) { var child = this._children[i]; if (havecontext) { cb.call(context, child); } else { cb(child); } if (child.type === 'group') { child.traverse(cb, context); } } }; group.prototype.addchildrentostorage = function (storage) { for (var i = 0; i < this._children.length; i++) { var child = this._children[i]; storage.addtomap(child); if (child instanceof group) { child.addchildrentostorage(storage); } } }; group.prototype.delchildrenfromstorage = function (storage) { for (var i = 0; i < this._children.length; i++) { var child = this._children[i]; storage.delfrommap(child.id); if (child instanceof group) { child.delchildrenfromstorage(storage); } } }; group.prototype.modself = function () { this.__dirty = true; }; util.merge(group.prototype, transformable.prototype, true); util.merge(group.prototype, eventful.prototype, true); return group; });define('zrender/animation/clip', [ 'require', './easing' ], function (require) { var easing = require('./easing'); function clip(options) { this._targetpool = options.target || {}; if (!(this._targetpool instanceof array)) { this._targetpool = [this._targetpool]; } this._life = options.life || 1000; this._delay = options.delay || 0; this._starttime = new date().gettime() + this._delay; this._endtime = this._starttime + this._life * 1000; this.loop = typeof options.loop == 'undefined' ? false : options.loop; this.gap = options.gap || 0; this.easing = options.easing || 'linear'; this.onframe = options.onframe; this.ondestroy = options.ondestroy; this.onrestart = options.onrestart; } clip.prototype = { step: function (time) { var percent = (time - this._starttime) / this._life; if (percent < 0) { return; } percent = math.min(percent, 1); var easingfunc = typeof this.easing == 'string' ? easing[this.easing] : this.easing; var schedule = typeof easingfunc === 'function' ? easingfunc(percent) : percent; this.fire('frame', schedule); if (percent == 1) { if (this.loop) { this.restart(); return 'restart'; } this.__needsremove = true; return 'destroy'; } return null; }, restart: function () { var time = new date().gettime(); var remainder = (time - this._starttime) % this._life; this._starttime = new date().gettime() - remainder + this.gap; this.__needsremove = false; }, fire: function (eventtype, arg) { for (var i = 0, len = this._targetpool.length; i < len; i++) { if (this['on' + eventtype]) { this['on' + eventtype](this._targetpool[i], arg); } } }, constructor: clip }; return clip; });define('zrender/animation/easing', [], function () { var easing = { linear: function (k) { return k; }, quadraticin: function (k) { return k * k; }, quadraticout: function (k) { return k * (2 - k); }, quadraticinout: function (k) { if ((k *= 2) < 1) { return 0.5 * k * k; } return -0.5 * (--k * (k - 2) - 1); }, cubicin: function (k) { return k * k * k; }, cubicout: function (k) { return --k * k * k + 1; }, cubicinout: function (k) { if ((k *= 2) < 1) { return 0.5 * k * k * k; } return 0.5 * ((k -= 2) * k * k + 2); }, quarticin: function (k) { return k * k * k * k; }, quarticout: function (k) { return 1 - --k * k * k * k; }, quarticinout: function (k) { if ((k *= 2) < 1) { return 0.5 * k * k * k * k; } return -0.5 * ((k -= 2) * k * k * k - 2); }, quinticin: function (k) { return k * k * k * k * k; }, quinticout: function (k) { return --k * k * k * k * k + 1; }, quinticinout: function (k) { if ((k *= 2) < 1) { return 0.5 * k * k * k * k * k; } return 0.5 * ((k -= 2) * k * k * k * k + 2); }, sinusoidalin: function (k) { return 1 - math.cos(k * math.pi / 2); }, sinusoidalout: function (k) { return math.sin(k * math.pi / 2); }, sinusoidalinout: function (k) { return 0.5 * (1 - math.cos(math.pi * k)); }, exponentialin: function (k) { return k === 0 ? 0 : math.pow(1024, k - 1); }, exponentialout: function (k) { return k === 1 ? 1 : 1 - math.pow(2, -10 * k); }, exponentialinout: function (k) { if (k === 0) { return 0; } if (k === 1) { return 1; } if ((k *= 2) < 1) { return 0.5 * math.pow(1024, k - 1); } return 0.5 * (-math.pow(2, -10 * (k - 1)) + 2); }, circularin: function (k) { return 1 - math.sqrt(1 - k * k); }, circularout: function (k) { return math.sqrt(1 - --k * k); }, circularinout: function (k) { if ((k *= 2) < 1) { return -0.5 * (math.sqrt(1 - k * k) - 1); } return 0.5 * (math.sqrt(1 - (k -= 2) * k) + 1); }, elasticin: function (k) { var s; var a = 0.1; var p = 0.4; if (k === 0) { return 0; } if (k === 1) { return 1; } if (!a || a < 1) { a = 1; s = p / 4; } else { s = p * math.asin(1 / a) / (2 * math.pi); } return -(a * math.pow(2, 10 * (k -= 1)) * math.sin((k - s) * (2 * math.pi) / p)); }, elasticout: function (k) { var s; var a = 0.1; var p = 0.4; if (k === 0) { return 0; } if (k === 1) { return 1; } if (!a || a < 1) { a = 1; s = p / 4; } else { s = p * math.asin(1 / a) / (2 * math.pi); } return a * math.pow(2, -10 * k) * math.sin((k - s) * (2 * math.pi) / p) + 1; }, elasticinout: function (k) { var s; var a = 0.1; var p = 0.4; if (k === 0) { return 0; } if (k === 1) { return 1; } if (!a || a < 1) { a = 1; s = p / 4; } else { s = p * math.asin(1 / a) / (2 * math.pi); } if ((k *= 2) < 1) { return -0.5 * (a * math.pow(2, 10 * (k -= 1)) * math.sin((k - s) * (2 * math.pi) / p)); } return a * math.pow(2, -10 * (k -= 1)) * math.sin((k - s) * (2 * math.pi) / p) * 0.5 + 1; }, backin: function (k) { var s = 1.70158; return k * k * ((s + 1) * k - s); }, backout: function (k) { var s = 1.70158; return --k * k * ((s + 1) * k + s) + 1; }, backinout: function (k) { var s = 1.70158 * 1.525; if ((k *= 2) < 1) { return 0.5 * (k * k * ((s + 1) * k - s)); } return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); }, bouncein: function (k) { return 1 - easing.bounceout(1 - k); }, bounceout: function (k) { if (k < 1 / 2.75) { return 7.5625 * k * k; } else if (k < 2 / 2.75) { return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75; } else if (k < 2.5 / 2.75) { return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375; } else { return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375; } }, bounceinout: function (k) { if (k < 0.5) { return easing.bouncein(k * 2) * 0.5; } return easing.bounceout(k * 2 - 1) * 0.5 + 0.5; } }; return easing; });define('echarts/chart/base', [ 'require', 'zrender/shape/image', '../util/shape/icon', '../util/shape/markline', '../util/shape/symbol', 'zrender/shape/polyline', 'zrender/shape/shapebundle', '../config', '../util/ecdata', '../util/ecanimation', '../util/eceffect', '../util/accmath', '../component/base', '../layout/edgebundling', 'zrender/tool/util', 'zrender/tool/area' ], function (require) { var imageshape = require('zrender/shape/image'); var iconshape = require('../util/shape/icon'); var marklineshape = require('../util/shape/markline'); var symbolshape = require('../util/shape/symbol'); var polylineshape = require('zrender/shape/polyline'); var shapebundle = require('zrender/shape/shapebundle'); var ecconfig = require('../config'); var ecdata = require('../util/ecdata'); var ecanimation = require('../util/ecanimation'); var eceffect = require('../util/eceffect'); var accmath = require('../util/accmath'); var componentbase = require('../component/base'); var edgebundling = require('../layout/edgebundling'); var zrutil = require('zrender/tool/util'); var zrarea = require('zrender/tool/area'); function iscoordavailable(coord) { return coord.x != null && coord.y != null; } function base(ectheme, messagecenter, zr, option, mychart) { componentbase.call(this, ectheme, messagecenter, zr, option, mychart); var self = this; this.selectedmap = {}; this.lastshapelist = []; this.shapehandler = { onclick: function () { self.isclick = true; }, ondragover: function (param) { var calculableshape = param.target; calculableshape.highlightstyle = calculableshape.highlightstyle || {}; var highlightstyle = calculableshape.highlightstyle; var brushtype = highlightstyle.brushtyep; var strokecolor = highlightstyle.strokecolor; var linewidth = highlightstyle.linewidth; highlightstyle.brushtype = 'stroke'; highlightstyle.strokecolor = self.ectheme.calculablecolor || ecconfig.calculablecolor; highlightstyle.linewidth = calculableshape.type === 'icon' ? 30 : 10; self.zr.addhovershape(calculableshape); settimeout(function () { if (highlightstyle) { highlightstyle.brushtype = brushtype; highlightstyle.strokecolor = strokecolor; highlightstyle.linewidth = linewidth; } }, 20); }, ondrop: function (param) { if (ecdata.get(param.dragged, 'data') != null) { self.isdrop = true; } }, ondragend: function () { self.isdragend = true; } }; } base.prototype = { setcalculable: function (shape) { shape.dragenabletime = this.ectheme.drag_enable_time || ecconfig.drag_enable_time; shape.ondragover = this.shapehandler.ondragover; shape.ondragend = this.shapehandler.ondragend; shape.ondrop = this.shapehandler.ondrop; return shape; }, ondrop: function (param, status) { if (!this.isdrop || !param.target || status.dragin) { return; } var target = param.target; var dragged = param.dragged; var seriesindex = ecdata.get(target, 'seriesindex'); var dataindex = ecdata.get(target, 'dataindex'); var series = this.series; var data; var legend = this.component.legend; if (dataindex === -1) { if (ecdata.get(dragged, 'seriesindex') == seriesindex) { status.dragout = status.dragin = status.needrefresh = true; this.isdrop = false; return; } data = { value: ecdata.get(dragged, 'value'), name: ecdata.get(dragged, 'name') }; if (this.type === ecconfig.chart_type_pie && data.value < 0) { data.value = 0; } var hasfind = false; var sdata = series[seriesindex].data; for (var i = 0, l = sdata.length; i < l; i++) { if (sdata[i].name === data.name && sdata[i].value === '-') { series[seriesindex].data[i].value = data.value; hasfind = true; } } !hasfind && series[seriesindex].data.push(data); legend && legend.add(data.name, dragged.style.color || dragged.style.strokecolor); } else { data = series[seriesindex].data[dataindex] || '-'; if (data.value != null) { if (data.value != '-') { series[seriesindex].data[dataindex].value = accmath.accadd(series[seriesindex].data[dataindex].value, ecdata.get(dragged, 'value')); } else { series[seriesindex].data[dataindex].value = ecdata.get(dragged, 'value'); } if (this.type === ecconfig.chart_type_funnel || this.type === ecconfig.chart_type_pie) { legend && legend.getrelatedamount(data.name) === 1 && this.component.legend.del(data.name); data.name += this.option.nameconnector + ecdata.get(dragged, 'name'); legend && legend.add(data.name, dragged.style.color || dragged.style.strokecolor); } } else { if (data != '-') { series[seriesindex].data[dataindex] = accmath.accadd(series[seriesindex].data[dataindex], ecdata.get(dragged, 'value')); } else { series[seriesindex].data[dataindex] = ecdata.get(dragged, 'value'); } } } status.dragin = status.dragin || true; this.isdrop = false; var self = this; settimeout(function () { self.zr.trigger('mousemove', param.event); }, 300); return; }, ondragend: function (param, status) { if (!this.isdragend || !param.target || status.dragout) { return; } var target = param.target; var seriesindex = ecdata.get(target, 'seriesindex'); var dataindex = ecdata.get(target, 'dataindex'); var series = this.series; if (series[seriesindex].data[dataindex].value != null) { series[seriesindex].data[dataindex].value = '-'; var name = series[seriesindex].data[dataindex].name; var legend = this.component.legend; if (legend && legend.getrelatedamount(name) === 0) { legend.del(name); } } else { series[seriesindex].data[dataindex] = '-'; } status.dragout = true; status.needrefresh = true; this.isdragend = false; return; }, onlegendselected: function (param, status) { var legendselected = param.selected; for (var itemname in this.selectedmap) { if (this.selectedmap[itemname] != legendselected[itemname]) { status.needrefresh = true; } this.selectedmap[itemname] = legendselected[itemname]; } return; }, _buildposition: function () { this._symbol = this.option.symbollist; this._sindex2shapemap = {}; this._sindex2colormap = {}; this.selectedmap = {}; this.xmarkmap = {}; var series = this.series; var _position2sindexmap = { top: [], bottom: [], left: [], right: [], other: [] }; var xaxisindex; var yaxisindex; var xaxis; var yaxis; for (var i = 0, l = series.length; i < l; i++) { if (series[i].type === this.type) { series[i] = this.reformoption(series[i]); this.legendhoverlink = series[i].legendhoverlink || this.legendhoverlink; xaxisindex = series[i].xaxisindex; yaxisindex = series[i].yaxisindex; xaxis = this.component.xaxis.getaxis(xaxisindex); yaxis = this.component.yaxis.getaxis(yaxisindex); if (xaxis.type === ecconfig.component_type_axis_category) { _position2sindexmap[xaxis.getposition()].push(i); } else if (yaxis.type === ecconfig.component_type_axis_category) { _position2sindexmap[yaxis.getposition()].push(i); } else { _position2sindexmap.other.push(i); } } } for (var position in _position2sindexmap) { if (_position2sindexmap[position].length > 0) { this._buildsingleposition(position, _position2sindexmap[position]); } } this.addshapelist(); }, _buildsingleposition: function (position, seriesarray) { var mapdata = this._mapdata(seriesarray); var locationmap = mapdata.locationmap; var maxdatalength = mapdata.maxdatalength; if (maxdatalength === 0 || locationmap.length === 0) { return; } switch (position) { case 'bottom': case 'top': this._buildhorizontal(seriesarray, maxdatalength, locationmap, this.xmarkmap); break; case 'left': case 'right': this._buildvertical(seriesarray, maxdatalength, locationmap, this.xmarkmap); break; case 'other': this._buildother(seriesarray, maxdatalength, locationmap, this.xmarkmap); break; } for (var i = 0, l = seriesarray.length; i < l; i++) { this.buildmark(seriesarray[i]); } }, _mapdata: function (seriesarray) { var series = this.series; var serie; var dataindex = 0; var stackmap = {}; var magicstackkey = '__kener__stack__'; var stackkey; var seriename; var legend = this.component.legend; var locationmap = []; var maxdatalength = 0; var iconshape; for (var i = 0, l = seriesarray.length; i < l; i++) { serie = series[seriesarray[i]]; seriename = serie.name; this._sindex2shapemap[seriesarray[i]] = this._sindex2shapemap[seriesarray[i]] || this.query(serie, 'symbol') || this._symbol[i % this._symbol.length]; if (legend) { this.selectedmap[seriename] = legend.isselected(seriename); this._sindex2colormap[seriesarray[i]] = legend.getcolor(seriename); iconshape = legend.getitemshape(seriename); if (iconshape) { var style = iconshape.style; if (this.type == ecconfig.chart_type_line) { style.icontype = 'legendlineicon'; style.symbol = this._sindex2shapemap[seriesarray[i]]; } else if (serie.itemstyle.normal.barborderwidth > 0) { var highlightstyle = iconshape.highlightstyle; style.brushtype = 'both'; style.x += 1; style.y += 1; style.width -= 2; style.height -= 2; style.strokecolor = highlightstyle.strokecolor = serie.itemstyle.normal.barbordercolor; highlightstyle.linewidth = 3; } legend.setitemshape(seriename, iconshape); } } else { this.selectedmap[seriename] = true; this._sindex2colormap[seriesarray[i]] = this.zr.getcolor(seriesarray[i]); } if (this.selectedmap[seriename]) { stackkey = serie.stack || magicstackkey + seriesarray[i]; if (stackmap[stackkey] == null) { stackmap[stackkey] = dataindex; locationmap[dataindex] = [seriesarray[i]]; dataindex++; } else { locationmap[stackmap[stackkey]].push(seriesarray[i]); } } maxdatalength = math.max(maxdatalength, serie.data.length); } return { locationmap: locationmap, maxdatalength: maxdatalength }; }, _calculmarkmapxy: function (xmarkmap, locationmap, xy) { var series = this.series; for (var j = 0, k = locationmap.length; j < k; j++) { for (var m = 0, n = locationmap[j].length; m < n; m++) { var seriesindex = locationmap[j][m]; var valueindex = xy == 'xy' ? 0 : ''; var grid = this.component.grid; var tarmark = xmarkmap[seriesindex]; if (xy.indexof('x') != '-1') { if (tarmark['counter' + valueindex] > 0) { tarmark['average' + valueindex] = tarmark['sum' + valueindex] / tarmark['counter' + valueindex]; } var x = this.component.xaxis.getaxis(series[seriesindex].xaxisindex || 0).getcoord(tarmark['average' + valueindex]); tarmark['averageline' + valueindex] = [ [ x, grid.getyend() ], [ x, grid.gety() ] ]; tarmark['minline' + valueindex] = [ [ tarmark['minx' + valueindex], grid.getyend() ], [ tarmark['minx' + valueindex], grid.gety() ] ]; tarmark['maxline' + valueindex] = [ [ tarmark['maxx' + valueindex], grid.getyend() ], [ tarmark['maxx' + valueindex], grid.gety() ] ]; tarmark.ishorizontal = false; } valueindex = xy == 'xy' ? 1 : ''; if (xy.indexof('y') != '-1') { if (tarmark['counter' + valueindex] > 0) { tarmark['average' + valueindex] = tarmark['sum' + valueindex] / tarmark['counter' + valueindex]; } var y = this.component.yaxis.getaxis(series[seriesindex].yaxisindex || 0).getcoord(tarmark['average' + valueindex]); tarmark['averageline' + valueindex] = [ [ grid.getx(), y ], [ grid.getxend(), y ] ]; tarmark['minline' + valueindex] = [ [ grid.getx(), tarmark['miny' + valueindex] ], [ grid.getxend(), tarmark['miny' + valueindex] ] ]; tarmark['maxline' + valueindex] = [ [ grid.getx(), tarmark['maxy' + valueindex] ], [ grid.getxend(), tarmark['maxy' + valueindex] ] ]; tarmark.ishorizontal = true; } } } }, addlabel: function (tarshape, serie, data, name, orient) { var querytarget = [ data, serie ]; var nlabel = this.deepmerge(querytarget, 'itemstyle.normal.label'); var elabel = this.deepmerge(querytarget, 'itemstyle.emphasis.label'); var ntextstyle = nlabel.textstyle || {}; var etextstyle = elabel.textstyle || {}; if (nlabel.show) { var style = tarshape.style; style.text = this._getlabeltext(serie, data, name, 'normal'); style.textposition = nlabel.position == null ? orient === 'horizontal' ? 'right' : 'top' : nlabel.position; style.textcolor = ntextstyle.color; style.textfont = this.getfont(ntextstyle); style.textalign = ntextstyle.align; style.textbaseline = ntextstyle.baseline; } if (elabel.show) { var highlightstyle = tarshape.highlightstyle; highlightstyle.text = this._getlabeltext(serie, data, name, 'emphasis'); highlightstyle.textposition = nlabel.show ? tarshape.style.textposition : elabel.position == null ? orient === 'horizontal' ? 'right' : 'top' : elabel.position; highlightstyle.textcolor = etextstyle.color; highlightstyle.textfont = this.getfont(etextstyle); highlightstyle.textalign = etextstyle.align; highlightstyle.textbaseline = etextstyle.baseline; } return tarshape; }, _getlabeltext: function (serie, data, name, status) { var formatter = this.deepquery([ data, serie ], 'itemstyle.' + status + '.label.formatter'); if (!formatter && status === 'emphasis') { formatter = this.deepquery([ data, serie ], 'itemstyle.normal.label.formatter'); } var value = this.getdatafromoption(data, '-'); if (formatter) { if (typeof formatter === 'function') { return formatter.call(this.mychart, { seriesname: serie.name, series: serie, name: name, value: value, data: data, status: status }); } else if (typeof formatter === 'string') { formatter = formatter.replace('{a}', '{a0}').replace('{b}', '{b0}').replace('{c}', '{c0}').replace('{a0}', serie.name).replace('{b0}', name).replace('{c0}', this.numaddcommas(value)); return formatter; } } else { if (value instanceof array) { return value[2] != null ? this.numaddcommas(value[2]) : value[0] + ' , ' + value[1]; } else { return this.numaddcommas(value); } } }, buildmark: function (seriesindex) { var serie = this.series[seriesindex]; if (this.selectedmap[serie.name]) { serie.markline && this._buildmarkline(seriesindex); serie.markpoint && this._buildmarkpoint(seriesindex); } }, _buildmarkpoint: function (seriesindex) { var attachstyle = (this.markattachstyle || {})[seriesindex]; var serie = this.series[seriesindex]; var mpdata; var pos; var markpoint = zrutil.clone(serie.markpoint); for (var i = 0, l = markpoint.data.length; i < l; i++) { mpdata = markpoint.data[i]; pos = this.getmarkcoord(seriesindex, mpdata); mpdata.x = mpdata.x != null ? mpdata.x : pos[0]; mpdata.y = mpdata.y != null ? mpdata.y : pos[1]; if (mpdata.type && (mpdata.type === 'max' || mpdata.type === 'min')) { mpdata.value = pos[3]; mpdata.name = mpdata.name || mpdata.type; mpdata.symbolsize = mpdata.symbolsize || zrarea.gettextwidth(pos[3], this.getfont()) / 2 + 5; } } var shapelist = this._markpoint(seriesindex, markpoint); for (var i = 0, l = shapelist.length; i < l; i++) { var tarshape = shapelist[i]; tarshape.zlevel = serie.zlevel; tarshape.z = serie.z + 1; for (var key in attachstyle) { tarshape[key] = zrutil.clone(attachstyle[key]); } this.shapelist.push(tarshape); } if (this.type === ecconfig.chart_type_force || this.type === ecconfig.chart_type_chord) { for (var i = 0, l = shapelist.length; i < l; i++) { this.zr.addshape(shapelist[i]); } } }, _buildmarkline: function (seriesindex) { var attachstyle = (this.markattachstyle || {})[seriesindex]; var serie = this.series[seriesindex]; var pos; var markline = zrutil.clone(serie.markline); for (var i = 0, l = markline.data.length; i < l; i++) { var mldata = markline.data[i]; if (mldata.type && (mldata.type === 'max' || mldata.type === 'min' || mldata.type === 'average')) { pos = this.getmarkcoord(seriesindex, mldata); markline.data[i] = [ zrutil.clone(mldata), {} ]; markline.data[i][0].name = mldata.name || mldata.type; markline.data[i][0].value = mldata.type !== 'average' ? pos[3] : +pos[3].tofixed(markline.precision != null ? markline.precision : this.deepquery([ this.ectheme, ecconfig ], 'markline.precision')); pos = pos[2]; mldata = [ {}, {} ]; } else { pos = [ this.getmarkcoord(seriesindex, mldata[0]), this.getmarkcoord(seriesindex, mldata[1]) ]; } if (pos == null || pos[0] == null || pos[1] == null) { continue; } markline.data[i][0].x = mldata[0].x != null ? mldata[0].x : pos[0][0]; markline.data[i][0].y = mldata[0].y != null ? mldata[0].y : pos[0][1]; markline.data[i][1].x = mldata[1].x != null ? mldata[1].x : pos[1][0]; markline.data[i][1].y = mldata[1].y != null ? mldata[1].y : pos[1][1]; } var shapelist = this._markline(seriesindex, markline); var islarge = markline.large; if (islarge) { var shapebundle = new shapebundle({ style: { shapelist: shapelist } }); var firstshape = shapelist[0]; if (firstshape) { zrutil.merge(shapebundle.style, firstshape.style); zrutil.merge(shapebundle.highlightstyle = {}, firstshape.highlightstyle); shapebundle.style.brushtype = 'stroke'; shapebundle.zlevel = serie.zlevel; shapebundle.z = serie.z + 1; shapebundle.hoverable = false; for (var key in attachstyle) { shapebundle[key] = zrutil.clone(attachstyle[key]); } } this.shapelist.push(shapebundle); this.zr.addshape(shapebundle); shapebundle._mark = 'largeline'; var effect = markline.effect; if (effect.show) { shapebundle.effect = effect; } } else { for (var i = 0, l = shapelist.length; i < l; i++) { var tarshape = shapelist[i]; tarshape.zlevel = serie.zlevel; tarshape.z = serie.z + 1; for (var key in attachstyle) { tarshape[key] = zrutil.clone(attachstyle[key]); } this.shapelist.push(tarshape); } if (this.type === ecconfig.chart_type_force || this.type === ecconfig.chart_type_chord) { for (var i = 0, l = shapelist.length; i < l; i++) { this.zr.addshape(shapelist[i]); } } } }, _markpoint: function (seriesindex, mpoption) { var serie = this.series[seriesindex]; var component = this.component; zrutil.merge(zrutil.merge(mpoption, zrutil.clone(this.ectheme.markpoint || {})), zrutil.clone(ecconfig.markpoint)); mpoption.name = serie.name; var plist = []; var data = mpoption.data; var itemshape; var datarange = component.datarange; var legend = component.legend; var color; var value; var querytarget; var ncolor; var ecolor; var effect; var zrwidth = this.zr.getwidth(); var zrheight = this.zr.getheight(); if (!mpoption.large) { for (var i = 0, l = data.length; i < l; i++) { if (data[i].x == null || data[i].y == null) { continue; } value = data[i].value != null ? data[i].value : ''; if (legend) { color = legend.getcolor(serie.name); } if (datarange) { color = isnan(value) ? color : datarange.getcolor(value); querytarget = [ data[i], mpoption ]; ncolor = this.deepquery(querytarget, 'itemstyle.normal.color') || color; ecolor = this.deepquery(querytarget, 'itemstyle.emphasis.color') || ncolor; if (ncolor == null && ecolor == null) { continue; } } color = color == null ? this.zr.getcolor(seriesindex) : color; data[i].tooltip = data[i].tooltip || mpoption.tooltip || { trigger: 'item' }; data[i].name = data[i].name != null ? data[i].name : ''; data[i].value = value; itemshape = this.getsymbolshape(mpoption, seriesindex, data[i], i, data[i].name, this.parsepercent(data[i].x, zrwidth), this.parsepercent(data[i].y, zrheight), 'pin', color, 'rgba(0,0,0,0)', 'horizontal'); itemshape._mark = 'point'; effect = this.deepmerge([ data[i], mpoption ], 'effect'); if (effect.show) { itemshape.effect = effect; } if (serie.type === ecconfig.chart_type_map) { itemshape._geo = this.getmarkgeo(data[i]); } ecdata.pack(itemshape, serie, seriesindex, data[i], i, data[i].name, value); plist.push(itemshape); } } else { itemshape = this.getlargemarkpointshape(seriesindex, mpoption); itemshape._mark = 'largepoint'; itemshape && plist.push(itemshape); } return plist; }, _markline: function () { function normalizeoptionvalue(mloption, key) { mloption[key] = mloption[key] instanceof array ? mloption[key].length > 1 ? mloption[key] : [ mloption[key][0], mloption[key][0] ] : [ mloption[key], mloption[key] ]; } return function (seriesindex, mloption) { var serie = this.series[seriesindex]; var component = this.component; var datarange = component.datarange; var legend = component.legend; zrutil.merge(zrutil.merge(mloption, zrutil.clone(this.ectheme.markline || {})), zrutil.clone(ecconfig.markline)); var defaultcolor = legend ? legend.getcolor(serie.name) : this.zr.getcolor(seriesindex); normalizeoptionvalue(mloption, 'symbol'); normalizeoptionvalue(mloption, 'symbolsize'); normalizeoptionvalue(mloption, 'symbolrotate'); var data = mloption.data; var edges = []; var zrwidth = this.zr.getwidth(); var zrheight = this.zr.getheight(); for (var i = 0; i < data.length; i++) { var mldata = data[i]; if (iscoordavailable(mldata[0]) && iscoordavailable(mldata[1])) { var mergedata = this.deepmerge(mldata); var querytarget = [ mergedata, mloption ]; var color = defaultcolor; var value = mergedata.value != null ? mergedata.value : ''; if (datarange) { color = isnan(value) ? color : datarange.getcolor(value); var ncolor = this.deepquery(querytarget, 'itemstyle.normal.color') || color; var ecolor = this.deepquery(querytarget, 'itemstyle.emphasis.color') || ncolor; if (ncolor == null && ecolor == null) { continue; } } mldata[0].tooltip = mergedata.tooltip || mloption.tooltip || { trigger: 'item' }; mldata[0].name = mldata[0].name || ''; mldata[1].name = mldata[1].name || ''; mldata[0].value = value; edges.push({ points: [ [ this.parsepercent(mldata[0].x, zrwidth), this.parsepercent(mldata[0].y, zrheight) ], [ this.parsepercent(mldata[1].x, zrwidth), this.parsepercent(mldata[1].y, zrheight) ] ], rawdata: mldata, color: color }); } } var enablebundling = this.query(mloption, 'bundling.enable'); if (enablebundling) { var edgebundling = new edgebundling(); edgebundling.maxturningangle = this.query(mloption, 'bundling.maxturningangle') / 180 * math.pi; edges = edgebundling.run(edges); } mloption.name = serie.name; var shapelist = []; for (var i = 0, l = edges.length; i < l; i++) { var edge = edges[i]; var rawedge = edge.rawedge || edge; var mldata = rawedge.rawdata; var value = mldata.value != null ? mldata.value : ''; var itemshape = this.getmarklineshape(mloption, seriesindex, mldata, i, edge.points, enablebundling, rawedge.color); itemshape._mark = 'line'; var effect = this.deepmerge([ mldata[0], mldata[1], mloption ], 'effect'); if (effect.show) { itemshape.effect = effect; itemshape.effect.large = mloption.large; } if (serie.type === ecconfig.chart_type_map) { itemshape._geo = [ this.getmarkgeo(mldata[0]), this.getmarkgeo(mldata[1]) ]; } ecdata.pack(itemshape, serie, seriesindex, mldata[0], i, mldata[0].name + (mldata[1].name !== '' ? ' > ' + mldata[1].name : ''), value); shapelist.push(itemshape); } return shapelist; }; }(), getmarkcoord: function () { return [ 0, 0 ]; }, getsymbolshape: function (serie, seriesindex, data, dataindex, name, x, y, symbol, color, emptycolor, orient) { var querytarget = [ data, serie ]; var value = this.getdatafromoption(data, '-'); symbol = this.deepquery(querytarget, 'symbol') || symbol; var symbolsize = this.deepquery(querytarget, 'symbolsize'); symbolsize = typeof symbolsize === 'function' ? symbolsize(value) : symbolsize; if (typeof symbolsize === 'number') { symbolsize = [ symbolsize, symbolsize ]; } var symbolrotate = this.deepquery(querytarget, 'symbolrotate'); var normal = this.deepmerge(querytarget, 'itemstyle.normal'); var emphasis = this.deepmerge(querytarget, 'itemstyle.emphasis'); var nborderwidth = normal.borderwidth != null ? normal.borderwidth : normal.linestyle && normal.linestyle.width; if (nborderwidth == null) { nborderwidth = symbol.match('empty') ? 2 : 0; } var eborderwidth = emphasis.borderwidth != null ? emphasis.borderwidth : emphasis.linestyle && emphasis.linestyle.width; if (eborderwidth == null) { eborderwidth = nborderwidth + 2; } var ncolor = this.getitemstylecolor(normal.color, seriesindex, dataindex, data); var ecolor = this.getitemstylecolor(emphasis.color, seriesindex, dataindex, data); var width = symbolsize[0]; var height = symbolsize[1]; var itemshape = new iconshape({ style: { icontype: symbol.replace('empty', '').tolowercase(), x: x - width, y: y - height, width: width * 2, height: height * 2, brushtype: 'both', color: symbol.match('empty') ? emptycolor : ncolor || color, strokecolor: normal.bordercolor || ncolor || color, linewidth: nborderwidth }, highlightstyle: { color: symbol.match('empty') ? emptycolor : ecolor || ncolor || color, strokecolor: emphasis.bordercolor || normal.bordercolor || ecolor || ncolor || color, linewidth: eborderwidth }, clickable: this.deepquery(querytarget, 'clickable') }); if (symbol.match('image')) { itemshape.style.image = symbol.replace(new regexp('^image:\\/\\/'), ''); itemshape = new imageshape({ style: itemshape.style, highlightstyle: itemshape.highlightstyle, clickable: this.deepquery(querytarget, 'clickable') }); } if (symbolrotate != null) { itemshape.rotation = [ symbolrotate * math.pi / 180, x, y ]; } if (symbol.match('star')) { itemshape.style.icontype = 'star'; itemshape.style.n = symbol.replace('empty', '').replace('star', '') - 0 || 5; } if (symbol === 'none') { itemshape.invisible = true; itemshape.hoverable = false; } itemshape = this.addlabel(itemshape, serie, data, name, orient); if (symbol.match('empty')) { if (itemshape.style.textcolor == null) { itemshape.style.textcolor = itemshape.style.strokecolor; } if (itemshape.highlightstyle.textcolor == null) { itemshape.highlightstyle.textcolor = itemshape.highlightstyle.strokecolor; } } ecdata.pack(itemshape, serie, seriesindex, data, dataindex, name); itemshape._x = x; itemshape._y = y; itemshape._dataindex = dataindex; itemshape._seriesindex = seriesindex; return itemshape; }, getmarklineshape: function (mloption, seriesindex, data, dataindex, points, bundling, color) { var value0 = data[0].value != null ? data[0].value : '-'; var value1 = data[1].value != null ? data[1].value : '-'; var symbol = [ data[0].symbol || mloption.symbol[0], data[1].symbol || mloption.symbol[1] ]; var symbolsize = [ data[0].symbolsize || mloption.symbolsize[0], data[1].symbolsize || mloption.symbolsize[1] ]; symbolsize[0] = typeof symbolsize[0] === 'function' ? symbolsize[0](value0) : symbolsize[0]; symbolsize[1] = typeof symbolsize[1] === 'function' ? symbolsize[1](value1) : symbolsize[1]; var symbolrotate = [ this.query(data[0], 'symbolrotate') || mloption.symbolrotate[0], this.query(data[1], 'symbolrotate') || mloption.symbolrotate[1] ]; var querytarget = [ data[0], data[1], mloption ]; var normal = this.deepmerge(querytarget, 'itemstyle.normal'); normal.color = this.getitemstylecolor(normal.color, seriesindex, dataindex, data); var emphasis = this.deepmerge(querytarget, 'itemstyle.emphasis'); emphasis.color = this.getitemstylecolor(emphasis.color, seriesindex, dataindex, data); var nlinestyle = normal.linestyle; var elinestyle = emphasis.linestyle; var nborderwidth = nlinestyle.width; if (nborderwidth == null) { nborderwidth = normal.borderwidth; } var eborderwidth = elinestyle.width; if (eborderwidth == null) { eborderwidth = emphasis.borderwidth != null ? emphasis.borderwidth : nborderwidth + 2; } var smoothness = this.deepquery(querytarget, 'smoothness'); if (!this.deepquery(querytarget, 'smooth')) { smoothness = 0; } var shapector = bundling ? polylineshape : marklineshape; var itemshape = new shapector({ style: { symbol: symbol, symbolsize: symbolsize, symbolrotate: symbolrotate, brushtype: 'both', linetype: nlinestyle.type, shadowcolor: nlinestyle.shadowcolor || nlinestyle.color || normal.bordercolor || normal.color || color, shadowblur: nlinestyle.shadowblur, shadowoffsetx: nlinestyle.shadowoffsetx, shadowoffsety: nlinestyle.shadowoffsety, color: normal.color || color, strokecolor: nlinestyle.color || normal.bordercolor || normal.color || color, linewidth: nborderwidth, symbolbordercolor: normal.bordercolor || normal.color || color, symbolborder: normal.borderwidth }, highlightstyle: { shadowcolor: elinestyle.shadowcolor, shadowblur: elinestyle.shadowblur, shadowoffsetx: elinestyle.shadowoffsetx, shadowoffsety: elinestyle.shadowoffsety, color: emphasis.color || normal.color || color, strokecolor: elinestyle.color || nlinestyle.color || emphasis.bordercolor || normal.bordercolor || emphasis.color || normal.color || color, linewidth: eborderwidth, symbolbordercolor: emphasis.bordercolor || normal.bordercolor || emphasis.color || normal.color || color, symbolborder: emphasis.borderwidth == null ? normal.borderwidth + 2 : emphasis.borderwidth }, clickable: this.deepquery(querytarget, 'clickable') }); var shapestyle = itemshape.style; if (bundling) { shapestyle.pointlist = points; shapestyle.smooth = smoothness; } else { shapestyle.xstart = points[0][0]; shapestyle.ystart = points[0][1]; shapestyle.xend = points[1][0]; shapestyle.yend = points[1][1]; shapestyle.curveness = smoothness; itemshape.updatepoints(itemshape.style); } itemshape = this.addlabel(itemshape, mloption, data[0], data[0].name + ' : ' + data[1].name); return itemshape; }, getlargemarkpointshape: function (seriesindex, mpoption) { var serie = this.series[seriesindex]; var component = this.component; var data = mpoption.data; var itemshape; var datarange = component.datarange; var legend = component.legend; var color; var value; var querytarget = [ data[0], mpoption ]; var ncolor; var ecolor; var effect; if (legend) { color = legend.getcolor(serie.name); } if (datarange) { value = data[0].value != null ? data[0].value : ''; color = isnan(value) ? color : datarange.getcolor(value); ncolor = this.deepquery(querytarget, 'itemstyle.normal.color') || color; ecolor = this.deepquery(querytarget, 'itemstyle.emphasis.color') || ncolor; if (ncolor == null && ecolor == null) { return; } } color = this.deepmerge(querytarget, 'itemstyle.normal').color || color; var symbol = this.deepquery(querytarget, 'symbol') || 'circle'; symbol = symbol.replace('empty', '').replace(/\d/g, ''); effect = this.deepmerge([ data[0], mpoption ], 'effect'); var devicepixelratio = window.devicepixelratio || 1; itemshape = new symbolshape({ style: { pointlist: data, color: color, strokecolor: color, shadowcolor: effect.shadowcolor || color, shadowblur: (effect.shadowblur != null ? effect.shadowblur : 8) * devicepixelratio, size: this.deepquery(querytarget, 'symbolsize'), icontype: symbol, brushtype: 'fill', linewidth: 1 }, draggable: false, hoverable: false }); if (effect.show) { itemshape.effect = effect; } return itemshape; }, backupshapelist: function () { if (this.shapelist && this.shapelist.length > 0) { this.lastshapelist = this.shapelist; this.shapelist = []; } else { this.lastshapelist = []; } }, addshapelist: function () { var maxlenth = this.option.animationthreshold / (this.canvassupported ? 2 : 4); var lastshapelist = this.lastshapelist; var shapelist = this.shapelist; var isupdate = lastshapelist.length > 0; var duration = isupdate ? this.query(this.option, 'animationdurationupdate') : this.query(this.option, 'animationduration'); var easing = this.query(this.option, 'animationeasing'); var delay; var key; var oldmap = {}; var newmap = {}; if (this.option.animation && !this.option.renderasimage && shapelist.length < maxlenth && !this.motionlessonce) { for (var i = 0, l = lastshapelist.length; i < l; i++) { key = this._getanimationkey(lastshapelist[i]); if (key.match('undefined')) { this.zr.delshape(lastshapelist[i].id); } else { key += lastshapelist[i].type; if (oldmap[key]) { this.zr.delshape(lastshapelist[i].id); } else { oldmap[key] = lastshapelist[i]; } } } for (var i = 0, l = shapelist.length; i < l; i++) { key = this._getanimationkey(shapelist[i]); if (key.match('undefined')) { this.zr.addshape(shapelist[i]); } else { key += shapelist[i].type; newmap[key] = shapelist[i]; } } for (key in oldmap) { if (!newmap[key]) { this.zr.delshape(oldmap[key].id); } } for (key in newmap) { if (oldmap[key]) { this.zr.delshape(oldmap[key].id); this._animatemod(oldmap[key], newmap[key], duration, easing, 0, isupdate); } else { delay = (this.type == ecconfig.chart_type_line || this.type == ecconfig.chart_type_radar) && key.indexof('icon') !== 0 ? duration / 2 : 0; this._animatemod(false, newmap[key], duration, easing, delay, isupdate); } } this.zr.refresh(); this.animationeffect(); } else { this.motionlessonce = false; this.zr.delshape(lastshapelist); for (var i = 0, l = shapelist.length; i < l; i++) { this.zr.addshape(shapelist[i]); } } }, _getanimationkey: function (shape) { if (this.type != ecconfig.chart_type_map && this.type != ecconfig.chart_type_treemap && this.type != ecconfig.chart_type_venn && this.type != ecconfig.chart_type_tree) { return ecdata.get(shape, 'seriesindex') + '_' + ecdata.get(shape, 'dataindex') + (shape._mark ? shape._mark : '') + (this.type === ecconfig.chart_type_radar ? ecdata.get(shape, 'special') : ''); } else { return ecdata.get(shape, 'seriesindex') + '_' + ecdata.get(shape, 'dataindex') + (shape._mark ? shape._mark : 'undefined'); } }, _animatemod: function (oldshape, newshape, duration, easing, delay, isupdate) { switch (newshape.type) { case 'polyline': case 'half-smooth-polygon': ecanimation.pointlist(this.zr, oldshape, newshape, duration, easing); break; case 'rectangle': ecanimation.rectangle(this.zr, oldshape, newshape, duration, easing); break; case 'image': case 'icon': ecanimation.icon(this.zr, oldshape, newshape, duration, easing, delay); break; case 'candle': if (!isupdate) { ecanimation.candle(this.zr, oldshape, newshape, duration, easing); } else { this.zr.addshape(newshape); } break; case 'ring': case 'sector': case 'circle': if (!isupdate) { ecanimation.ring(this.zr, oldshape, newshape, duration + (ecdata.get(newshape, 'dataindex') || 0) % 20 * 100, easing); } else if (newshape.type === 'sector') { ecanimation.sector(this.zr, oldshape, newshape, duration, easing); } else { this.zr.addshape(newshape); } break; case 'text': ecanimation.text(this.zr, oldshape, newshape, duration, easing); break; case 'polygon': if (!isupdate) { ecanimation.polygon(this.zr, oldshape, newshape, duration, easing); } else { ecanimation.pointlist(this.zr, oldshape, newshape, duration, easing); } break; case 'ribbon': ecanimation.ribbon(this.zr, oldshape, newshape, duration, easing); break; case 'gauge-pointer': ecanimation.gaugepointer(this.zr, oldshape, newshape, duration, easing); break; case 'mark-line': ecanimation.markline(this.zr, oldshape, newshape, duration, easing); break; case 'bezier-curve': case 'line': ecanimation.line(this.zr, oldshape, newshape, duration, easing); break; default: this.zr.addshape(newshape); break; } }, animationmark: function (duration, easing, shapelist) { var shapelist = shapelist || this.shapelist; for (var i = 0, l = shapelist.length; i < l; i++) { if (!shapelist[i]._mark) { continue; } this._animatemod(false, shapelist[i], duration, easing, 0, true); } this.animationeffect(shapelist); }, animationeffect: function (shapelist) { !shapelist && this.cleareffectshape(); shapelist = shapelist || this.shapelist; if (shapelist == null) { return; } var zlevel = ecconfig.effect_zlevel; if (this.canvassupported) { this.zr.modlayer(zlevel, { motionblur: true, lastframealpha: this.option.effectblendalpha || ecconfig.effectblendalpha }); } var shape; for (var i = 0, l = shapelist.length; i < l; i++) { shape = shapelist[i]; if (!(shape._mark && shape.effect && shape.effect.show && eceffect[shape._mark])) { continue; } eceffect[shape._mark](this.zr, this.effectlist, shape, zlevel); this.effectlist[this.effectlist.length - 1]._mark = shape._mark; } }, cleareffectshape: function (clearmotionblur) { var effectlist = this.effectlist; if (this.zr && effectlist && effectlist.length > 0) { clearmotionblur && this.zr.modlayer(ecconfig.effect_zlevel, { motionblur: false }); this.zr.delshape(effectlist); for (var i = 0; i < effectlist.length; i++) { if (effectlist[i].effectanimator) { effectlist[i].effectanimator.stop(); } } } this.effectlist = []; }, addmark: function (seriesindex, markdata, marktype) { var serie = this.series[seriesindex]; if (this.selectedmap[serie.name]) { var duration = this.query(this.option, 'animationdurationupdate'); var easing = this.query(this.option, 'animationeasing'); var orimarkdata = serie[marktype].data; var lastlength = this.shapelist.length; serie[marktype].data = markdata.data; this['_build' + marktype.replace('m', 'm')](seriesindex); if (this.option.animation && !this.option.renderasimage) { this.animationmark(duration, easing, this.shapelist.slice(lastlength)); } else { for (var i = lastlength, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } this.zr.refreshnextframe(); } serie[marktype].data = orimarkdata; } }, delmark: function (seriesindex, markname, marktype) { marktype = marktype.replace('mark', '').replace('large', '').tolowercase(); var serie = this.series[seriesindex]; if (this.selectedmap[serie.name]) { var needrefresh = false; var shapelist = [ this.shapelist, this.effectlist ]; var len = 2; while (len--) { for (var i = 0, l = shapelist[len].length; i < l; i++) { if (shapelist[len][i]._mark == marktype && ecdata.get(shapelist[len][i], 'seriesindex') == seriesindex && ecdata.get(shapelist[len][i], 'name') == markname) { this.zr.delshape(shapelist[len][i].id); shapelist[len].splice(i, 1); needrefresh = true; break; } } } needrefresh && this.zr.refreshnextframe(); } } }; zrutil.inherits(base, componentbase); return base; });define('zrender/shape/circle', [ 'require', './base', '../tool/util' ], function (require) { 'use strict'; var base = require('./base'); var circle = function (options) { base.call(this, options); }; circle.prototype = { type: 'circle', buildpath: function (ctx, style) { ctx.moveto(style.x + style.r, style.y); ctx.arc(style.x, style.y, style.r, 0, math.pi * 2, true); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } var linewidth; if (style.brushtype == 'stroke' || style.brushtype == 'fill') { linewidth = style.linewidth || 1; } else { linewidth = 0; } style.__rect = { x: math.round(style.x - style.r - linewidth / 2), y: math.round(style.y - style.r - linewidth / 2), width: style.r * 2 + linewidth, height: style.r * 2 + linewidth }; return style.__rect; } }; require('../tool/util').inherits(circle, base); return circle; });define('echarts/util/accmath', [], function () { function accdiv(arg1, arg2) { var s1 = arg1.tostring(); var s2 = arg2.tostring(); var m = 0; try { m = s2.split('.')[1].length; } catch (e) { } try { m -= s1.split('.')[1].length; } catch (e) { } return (s1.replace('.', '') - 0) / (s2.replace('.', '') - 0) * math.pow(10, m); } function accmul(arg1, arg2) { var s1 = arg1.tostring(); var s2 = arg2.tostring(); var m = 0; try { m += s1.split('.')[1].length; } catch (e) { } try { m += s2.split('.')[1].length; } catch (e) { } return (s1.replace('.', '') - 0) * (s2.replace('.', '') - 0) / math.pow(10, m); } function accadd(arg1, arg2) { var r1 = 0; var r2 = 0; try { r1 = arg1.tostring().split('.')[1].length; } catch (e) { } try { r2 = arg2.tostring().split('.')[1].length; } catch (e) { } var m = math.pow(10, math.max(r1, r2)); return (math.round(arg1 * m) + math.round(arg2 * m)) / m; } function accsub(arg1, arg2) { return accadd(arg1, -arg2); } return { accdiv: accdiv, accmul: accmul, accadd: accadd, accsub: accsub }; });define('echarts/util/shape/icon', [ 'require', 'zrender/tool/util', 'zrender/shape/star', 'zrender/shape/heart', 'zrender/shape/droplet', 'zrender/shape/image', 'zrender/shape/base' ], function (require) { var zrutil = require('zrender/tool/util'); function _iconmark(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x, y + style.height); ctx.lineto(x + 5 * dx, y + 14 * dy); ctx.lineto(x + style.width, y + 3 * dy); ctx.lineto(x + 13 * dx, y); ctx.lineto(x + 2 * dx, y + 11 * dy); ctx.lineto(x, y + style.height); ctx.moveto(x + 6 * dx, y + 10 * dy); ctx.lineto(x + 14 * dx, y + 2 * dy); ctx.moveto(x + 10 * dx, y + 13 * dy); ctx.lineto(x + style.width, y + 13 * dy); ctx.moveto(x + 13 * dx, y + 10 * dy); ctx.lineto(x + 13 * dx, y + style.height); } function _iconmarkundo(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x, y + style.height); ctx.lineto(x + 5 * dx, y + 14 * dy); ctx.lineto(x + style.width, y + 3 * dy); ctx.lineto(x + 13 * dx, y); ctx.lineto(x + 2 * dx, y + 11 * dy); ctx.lineto(x, y + style.height); ctx.moveto(x + 6 * dx, y + 10 * dy); ctx.lineto(x + 14 * dx, y + 2 * dy); ctx.moveto(x + 10 * dx, y + 13 * dy); ctx.lineto(x + style.width, y + 13 * dy); } function _iconmarkclear(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x + 4 * dx, y + 15 * dy); ctx.lineto(x + 9 * dx, y + 13 * dy); ctx.lineto(x + 14 * dx, y + 8 * dy); ctx.lineto(x + 11 * dx, y + 5 * dy); ctx.lineto(x + 6 * dx, y + 10 * dy); ctx.lineto(x + 4 * dx, y + 15 * dy); ctx.moveto(x + 5 * dx, y); ctx.lineto(x + 11 * dx, y); ctx.moveto(x + 5 * dx, y + dy); ctx.lineto(x + 11 * dx, y + dy); ctx.moveto(x, y + 2 * dy); ctx.lineto(x + style.width, y + 2 * dy); ctx.moveto(x, y + 5 * dy); ctx.lineto(x + 3 * dx, y + style.height); ctx.lineto(x + 13 * dx, y + style.height); ctx.lineto(x + style.width, y + 5 * dy); } function _icondatazoom(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x, y + 3 * dy); ctx.lineto(x + 6 * dx, y + 3 * dy); ctx.moveto(x + 3 * dx, y); ctx.lineto(x + 3 * dx, y + 6 * dy); ctx.moveto(x + 3 * dx, y + 8 * dy); ctx.lineto(x + 3 * dx, y + style.height); ctx.lineto(x + style.width, y + style.height); ctx.lineto(x + style.width, y + 3 * dy); ctx.lineto(x + 8 * dx, y + 3 * dy); } function _icondatazoomreset(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x + 6 * dx, y); ctx.lineto(x + 2 * dx, y + 3 * dy); ctx.lineto(x + 6 * dx, y + 6 * dy); ctx.moveto(x + 2 * dx, y + 3 * dy); ctx.lineto(x + 14 * dx, y + 3 * dy); ctx.lineto(x + 14 * dx, y + 11 * dy); ctx.moveto(x + 2 * dx, y + 5 * dy); ctx.lineto(x + 2 * dx, y + 13 * dy); ctx.lineto(x + 14 * dx, y + 13 * dy); ctx.moveto(x + 10 * dx, y + 10 * dy); ctx.lineto(x + 14 * dx, y + 13 * dy); ctx.lineto(x + 10 * dx, y + style.height); } function _iconrestore(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; var r = style.width / 2; ctx.linewidth = 1.5; ctx.arc(x + r, y + r, r - dx, 0, math.pi * 2 / 3); ctx.moveto(x + 3 * dx, y + style.height); ctx.lineto(x + 0 * dx, y + 12 * dy); ctx.lineto(x + 5 * dx, y + 11 * dy); ctx.moveto(x, y + 8 * dy); ctx.arc(x + r, y + r, r - dx, math.pi, math.pi * 5 / 3); ctx.moveto(x + 13 * dx, y); ctx.lineto(x + style.width, y + 4 * dy); ctx.lineto(x + 11 * dx, y + 5 * dy); } function _iconlinechart(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x, y); ctx.lineto(x, y + style.height); ctx.lineto(x + style.width, y + style.height); ctx.moveto(x + 2 * dx, y + 14 * dy); ctx.lineto(x + 7 * dx, y + 6 * dy); ctx.lineto(x + 11 * dx, y + 11 * dy); ctx.lineto(x + 15 * dx, y + 2 * dy); } function _iconbarchart(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x, y); ctx.lineto(x, y + style.height); ctx.lineto(x + style.width, y + style.height); ctx.moveto(x + 3 * dx, y + 14 * dy); ctx.lineto(x + 3 * dx, y + 6 * dy); ctx.lineto(x + 4 * dx, y + 6 * dy); ctx.lineto(x + 4 * dx, y + 14 * dy); ctx.moveto(x + 7 * dx, y + 14 * dy); ctx.lineto(x + 7 * dx, y + 2 * dy); ctx.lineto(x + 8 * dx, y + 2 * dy); ctx.lineto(x + 8 * dx, y + 14 * dy); ctx.moveto(x + 11 * dx, y + 14 * dy); ctx.lineto(x + 11 * dx, y + 9 * dy); ctx.lineto(x + 12 * dx, y + 9 * dy); ctx.lineto(x + 12 * dx, y + 14 * dy); } function _iconpiechart(ctx, style) { var x = style.x; var y = style.y; var width = style.width - 2; var height = style.height - 2; var r = math.min(width, height) / 2; y += 2; ctx.moveto(x + r + 3, y + r - 3); ctx.arc(x + r + 3, y + r - 3, r - 1, 0, -math.pi / 2, true); ctx.lineto(x + r + 3, y + r - 3); ctx.moveto(x + r, y); ctx.lineto(x + r, y + r); ctx.arc(x + r, y + r, r, -math.pi / 2, math.pi * 2, true); ctx.lineto(x + r, y + r); ctx.linewidth = 1.5; } function _iconfunnelchart(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; y -= dy; ctx.moveto(x + 1 * dx, y + 2 * dy); ctx.lineto(x + 15 * dx, y + 2 * dy); ctx.lineto(x + 14 * dx, y + 3 * dy); ctx.lineto(x + 2 * dx, y + 3 * dy); ctx.moveto(x + 3 * dx, y + 6 * dy); ctx.lineto(x + 13 * dx, y + 6 * dy); ctx.lineto(x + 12 * dx, y + 7 * dy); ctx.lineto(x + 4 * dx, y + 7 * dy); ctx.moveto(x + 5 * dx, y + 10 * dy); ctx.lineto(x + 11 * dx, y + 10 * dy); ctx.lineto(x + 10 * dx, y + 11 * dy); ctx.lineto(x + 6 * dx, y + 11 * dy); ctx.moveto(x + 7 * dx, y + 14 * dy); ctx.lineto(x + 9 * dx, y + 14 * dy); ctx.lineto(x + 8 * dx, y + 15 * dy); ctx.lineto(x + 7 * dx, y + 15 * dy); } function _iconforcechart(ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; var dx = width / 16; var dy = height / 16; var r = math.min(dx, dy) * 2; ctx.moveto(x + dx + r, y + dy + r); ctx.arc(x + dx, y + dy, r, math.pi / 4, math.pi * 3); ctx.lineto(x + 7 * dx - r, y + 6 * dy - r); ctx.arc(x + 7 * dx, y + 6 * dy, r, math.pi / 4 * 5, math.pi * 4); ctx.arc(x + 7 * dx, y + 6 * dy, r / 2, math.pi / 4 * 5, math.pi * 4); ctx.moveto(x + 7 * dx - r / 2, y + 6 * dy + r); ctx.lineto(x + dx + r, y + 14 * dy - r); ctx.arc(x + dx, y + 14 * dy, r, -math.pi / 4, math.pi * 2); ctx.moveto(x + 7 * dx + r / 2, y + 6 * dy); ctx.lineto(x + 14 * dx - r, y + 10 * dy - r / 2); ctx.moveto(x + 16 * dx, y + 10 * dy); ctx.arc(x + 14 * dx, y + 10 * dy, r, 0, math.pi * 3); ctx.linewidth = 1.5; } function _iconchordchart(ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; var r = math.min(width, height) / 2; ctx.moveto(x + width, y + height / 2); ctx.arc(x + r, y + r, r, 0, math.pi * 2); ctx.arc(x + r, y, r, math.pi / 4, math.pi / 5 * 4); ctx.arc(x, y + r, r, -math.pi / 3, math.pi / 3); ctx.arc(x + width, y + height, r, math.pi, math.pi / 2 * 3); ctx.linewidth = 1.5; } function _iconstackchart(ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; var dy = math.round(height / 3); var delta = math.round((dy - 2) / 2); var len = 3; while (len--) { ctx.rect(x, y + dy * len + delta, width, 2); } } function _icontiledchart(ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; var dx = math.round(width / 3); var delta = math.round((dx - 2) / 2); var len = 3; while (len--) { ctx.rect(x + dx * len + delta, y, 2, height); } } function _icondataview(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; ctx.moveto(x + dx, y); ctx.lineto(x + dx, y + style.height); ctx.lineto(x + 15 * dx, y + style.height); ctx.lineto(x + 15 * dx, y); ctx.lineto(x + dx, y); ctx.moveto(x + 3 * dx, y + 3 * dx); ctx.lineto(x + 13 * dx, y + 3 * dx); ctx.moveto(x + 3 * dx, y + 6 * dx); ctx.lineto(x + 13 * dx, y + 6 * dx); ctx.moveto(x + 3 * dx, y + 9 * dx); ctx.lineto(x + 13 * dx, y + 9 * dx); ctx.moveto(x + 3 * dx, y + 12 * dx); ctx.lineto(x + 9 * dx, y + 12 * dx); } function _iconsave(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; var dy = style.height / 16; ctx.moveto(x, y); ctx.lineto(x, y + style.height); ctx.lineto(x + style.width, y + style.height); ctx.lineto(x + style.width, y); ctx.lineto(x, y); ctx.moveto(x + 4 * dx, y); ctx.lineto(x + 4 * dx, y + 8 * dy); ctx.lineto(x + 12 * dx, y + 8 * dy); ctx.lineto(x + 12 * dx, y); ctx.moveto(x + 6 * dx, y + 11 * dy); ctx.lineto(x + 6 * dx, y + 13 * dy); ctx.lineto(x + 10 * dx, y + 13 * dy); ctx.lineto(x + 10 * dx, y + 11 * dy); ctx.lineto(x + 6 * dx, y + 11 * dy); } function _iconcross(ctx, style) { var x = style.x; var y = style.y; var width = style.width; var height = style.height; ctx.moveto(x, y + height / 2); ctx.lineto(x + width, y + height / 2); ctx.moveto(x + width / 2, y); ctx.lineto(x + width / 2, y + height); } function _iconcircle(ctx, style) { var width = style.width / 2; var height = style.height / 2; var r = math.min(width, height); ctx.moveto(style.x + width + r, style.y + height); ctx.arc(style.x + width, style.y + height, r, 0, math.pi * 2); ctx.closepath(); } function _iconrectangle(ctx, style) { ctx.rect(style.x, style.y, style.width, style.height); ctx.closepath(); } function _icontriangle(ctx, style) { var width = style.width / 2; var height = style.height / 2; var x = style.x + width; var y = style.y + height; var symbolsize = math.min(width, height); ctx.moveto(x, y - symbolsize); ctx.lineto(x + symbolsize, y + symbolsize); ctx.lineto(x - symbolsize, y + symbolsize); ctx.lineto(x, y - symbolsize); ctx.closepath(); } function _icondiamond(ctx, style) { var width = style.width / 2; var height = style.height / 2; var x = style.x + width; var y = style.y + height; var symbolsize = math.min(width, height); ctx.moveto(x, y - symbolsize); ctx.lineto(x + symbolsize, y); ctx.lineto(x, y + symbolsize); ctx.lineto(x - symbolsize, y); ctx.lineto(x, y - symbolsize); ctx.closepath(); } function _iconarrow(ctx, style) { var x = style.x; var y = style.y; var dx = style.width / 16; ctx.moveto(x + 8 * dx, y); ctx.lineto(x + dx, y + style.height); ctx.lineto(x + 8 * dx, y + style.height / 4 * 3); ctx.lineto(x + 15 * dx, y + style.height); ctx.lineto(x + 8 * dx, y); ctx.closepath(); } function _iconstar(ctx, style) { var starshape = require('zrender/shape/star'); var width = style.width / 2; var height = style.height / 2; starshape.prototype.buildpath(ctx, { x: style.x + width, y: style.y + height, r: math.min(width, height), n: style.n || 5 }); } function _iconheart(ctx, style) { var heartshape = require('zrender/shape/heart'); heartshape.prototype.buildpath(ctx, { x: style.x + style.width / 2, y: style.y + style.height * 0.2, a: style.width / 2, b: style.height * 0.8 }); } function _icondroplet(ctx, style) { var dropletshape = require('zrender/shape/droplet'); dropletshape.prototype.buildpath(ctx, { x: style.x + style.width * 0.5, y: style.y + style.height * 0.5, a: style.width * 0.5, b: style.height * 0.8 }); } function _iconpin(ctx, style) { var x = style.x; var y = style.y - style.height / 2 * 1.5; var width = style.width / 2; var height = style.height / 2; var r = math.min(width, height); ctx.arc(x + width, y + height, r, math.pi / 5 * 4, math.pi / 5); ctx.lineto(x + width, y + height + r * 1.5); ctx.closepath(); } function _iconimage(ctx, style, refreshnextframe) { var imageshape = require('zrender/shape/image'); this._imageshape = this._imageshape || new imageshape({ style: {} }); for (var name in style) { this._imageshape.style[name] = style[name]; } this._imageshape.brush(ctx, false, refreshnextframe); } var base = require('zrender/shape/base'); function icon(options) { base.call(this, options); } icon.prototype = { type: 'icon', iconlibrary: { mark: _iconmark, markundo: _iconmarkundo, markclear: _iconmarkclear, datazoom: _icondatazoom, datazoomreset: _icondatazoomreset, restore: _iconrestore, linechart: _iconlinechart, barchart: _iconbarchart, piechart: _iconpiechart, funnelchart: _iconfunnelchart, forcechart: _iconforcechart, chordchart: _iconchordchart, stackchart: _iconstackchart, tiledchart: _icontiledchart, dataview: _icondataview, saveasimage: _iconsave, cross: _iconcross, circle: _iconcircle, rectangle: _iconrectangle, triangle: _icontriangle, diamond: _icondiamond, arrow: _iconarrow, star: _iconstar, heart: _iconheart, droplet: _icondroplet, pin: _iconpin, image: _iconimage }, brush: function (ctx, ishighlight, refreshnextframe) { var style = ishighlight ? this.highlightstyle : this.style; style = style || {}; var icontype = style.icontype || this.style.icontype; if (icontype === 'image') { var imageshape = require('zrender/shape/image'); imageshape.prototype.brush.call(this, ctx, ishighlight, refreshnextframe); } else { var style = this.beforebrush(ctx, ishighlight); ctx.beginpath(); this.buildpath(ctx, style, refreshnextframe); switch (style.brushtype) { case 'both': ctx.fill(); case 'stroke': style.linewidth > 0 && ctx.stroke(); break; default: ctx.fill(); } this.drawtext(ctx, style, this.style); this.afterbrush(ctx); } }, buildpath: function (ctx, style, refreshnextframe) { if (this.iconlibrary[style.icontype]) { this.iconlibrary[style.icontype].call(this, ctx, style, refreshnextframe); } else { ctx.moveto(style.x, style.y); ctx.lineto(style.x + style.width, style.y); ctx.lineto(style.x + style.width, style.y + style.height); ctx.lineto(style.x, style.y + style.height); ctx.lineto(style.x, style.y); ctx.closepath(); } return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } style.__rect = { x: math.round(style.x), y: math.round(style.y - (style.icontype == 'pin' ? style.height / 2 * 1.5 : 0)), width: style.width, height: style.height * (style.icontype === 'pin' ? 1.25 : 1) }; return style.__rect; }, iscover: function (x, y) { var originpos = this.transformcoordtolocal(x, y); x = originpos[0]; y = originpos[1]; var rect = this.style.__rect; if (!rect) { rect = this.style.__rect = this.getrect(this.style); } var delta = rect.height < 8 || rect.width < 8 ? 4 : 0; return x >= rect.x - delta && x <= rect.x + rect.width + delta && y >= rect.y - delta && y <= rect.y + rect.height + delta; } }; zrutil.inherits(icon, base); return icon; });define('echarts/util/shape/markline', [ 'require', 'zrender/shape/base', './icon', 'zrender/shape/line', 'zrender/shape/beziercurve', 'zrender/tool/area', 'zrender/shape/util/dashedlineto', 'zrender/tool/util', 'zrender/tool/curve' ], function (require) { var base = require('zrender/shape/base'); var iconshape = require('./icon'); var lineshape = require('zrender/shape/line'); var lineinstance = new lineshape({}); var curveshape = require('zrender/shape/beziercurve'); var curveinstance = new curveshape({}); var area = require('zrender/tool/area'); var dashedlineto = require('zrender/shape/util/dashedlineto'); var zrutil = require('zrender/tool/util'); var curvetool = require('zrender/tool/curve'); function markline(options) { base.call(this, options); if (this.style.curveness > 0) { this.updatepoints(this.style); } if (this.highlightstyle.curveness > 0) { this.updatepoints(this.highlightstyle); } } markline.prototype = { type: 'mark-line', brush: function (ctx, ishighlight) { var style = this.style; if (ishighlight) { style = this.gethighlightstyle(style, this.highlightstyle || {}); } ctx.save(); this.setcontext(ctx, style); this.settransform(ctx); ctx.save(); ctx.beginpath(); this.buildpath(ctx, style); ctx.stroke(); ctx.restore(); this.brushsymbol(ctx, style, 0); this.brushsymbol(ctx, style, 1); this.drawtext(ctx, style, this.style); ctx.restore(); }, buildpath: function (ctx, style) { var linetype = style.linetype || 'solid'; ctx.moveto(style.xstart, style.ystart); if (style.curveness > 0) { var linedash = null; switch (linetype) { case 'dashed': linedash = [ 5, 5 ]; break; case 'dotted': linedash = [ 1, 1 ]; break; } if (linedash && ctx.setlinedash) { ctx.setlinedash(linedash); } ctx.quadraticcurveto(style.cpx1, style.cpy1, style.xend, style.yend); } else { if (linetype == 'solid') { ctx.lineto(style.xend, style.yend); } else { var dashlength = (style.linewidth || 1) * (style.linetype == 'dashed' ? 5 : 1); dashedlineto(ctx, style.xstart, style.ystart, style.xend, style.yend, dashlength); } } }, updatepoints: function (style) { var curveness = style.curveness || 0; var inv = 1; var x0 = style.xstart; var y0 = style.ystart; var x2 = style.xend; var y2 = style.yend; var x1 = (x0 + x2) / 2 - inv * (y0 - y2) * curveness; var y1 = (y0 + y2) / 2 - inv * (x2 - x0) * curveness; style.cpx1 = x1; style.cpy1 = y1; }, brushsymbol: function (ctx, style, idx) { if (style.symbol[idx] == 'none') { return; } ctx.save(); ctx.beginpath(); ctx.linewidth = style.symbolborder; ctx.strokestyle = style.symbolbordercolor; var symbol = style.symbol[idx].replace('empty', '').tolowercase(); if (style.symbol[idx].match('empty')) { ctx.fillstyle = '#fff'; } var x0 = style.xstart; var y0 = style.ystart; var x2 = style.xend; var y2 = style.yend; var x = idx === 0 ? x0 : x2; var y = idx === 0 ? y0 : y2; var curveness = style.curveness || 0; var rotate = style.symbolrotate[idx] != null ? style.symbolrotate[idx] - 0 : 0; rotate = rotate / 180 * math.pi; if (symbol == 'arrow' && rotate === 0) { if (curveness === 0) { var sign = idx === 0 ? -1 : 1; rotate = math.pi / 2 + math.atan2(sign * (y2 - y0), sign * (x2 - x0)); } else { var x1 = style.cpx1; var y1 = style.cpy1; var quadraticderivativeat = curvetool.quadraticderivativeat; var dx = quadraticderivativeat(x0, x1, x2, idx); var dy = quadraticderivativeat(y0, y1, y2, idx); rotate = math.pi / 2 + math.atan2(dy, dx); } } ctx.translate(x, y); if (rotate !== 0) { ctx.rotate(rotate); } var symbolsize = style.symbolsize[idx]; iconshape.prototype.buildpath(ctx, { x: -symbolsize, y: -symbolsize, width: symbolsize * 2, height: symbolsize * 2, icontype: symbol }); ctx.closepath(); ctx.fill(); ctx.stroke(); ctx.restore(); }, getrect: function (style) { style.curveness > 0 ? curveinstance.getrect(style) : lineinstance.getrect(style); return style.__rect; }, iscover: function (x, y) { var originpos = this.transformcoordtolocal(x, y); x = originpos[0]; y = originpos[1]; if (this.iscoverrect(x, y)) { return this.style.curveness > 0 ? area.isinside(curveinstance, this.style, x, y) : area.isinside(lineinstance, this.style, x, y); } return false; } }; zrutil.inherits(markline, base); return markline; });define('echarts/util/shape/symbol', [ 'require', 'zrender/shape/base', 'zrender/shape/polygon', 'zrender/tool/util', './normaliscover' ], function (require) { var base = require('zrender/shape/base'); var polygonshape = require('zrender/shape/polygon'); var polygoninstance = new polygonshape({}); var zrutil = require('zrender/tool/util'); function symbol(options) { base.call(this, options); } symbol.prototype = { type: 'symbol', buildpath: function (ctx, style) { var pointlist = style.pointlist; var len = pointlist.length; if (len === 0) { return; } var subsize = 10000; var subsetlength = math.ceil(len / subsize); var sub; var sublen; var isarray = pointlist[0] instanceof array; var size = style.size ? style.size : 2; var cursize = size; var halfsize = size / 2; var pi2 = math.pi * 2; var percent; var x; var y; for (var j = 0; j < subsetlength; j++) { ctx.beginpath(); sub = j * subsize; sublen = sub + subsize; sublen = sublen > len ? len : sublen; for (var i = sub; i < sublen; i++) { if (style.random) { percent = style['randommap' + i % 20] / 100; cursize = size * percent * percent; halfsize = cursize / 2; } if (isarray) { x = pointlist[i][0]; y = pointlist[i][1]; } else { x = pointlist[i].x; y = pointlist[i].y; } if (cursize < 3) { ctx.rect(x - halfsize, y - halfsize, cursize, cursize); } else { switch (style.icontype) { case 'circle': ctx.moveto(x, y); ctx.arc(x, y, halfsize, 0, pi2, true); break; case 'diamond': ctx.moveto(x, y - halfsize); ctx.lineto(x + halfsize / 3, y - halfsize / 3); ctx.lineto(x + halfsize, y); ctx.lineto(x + halfsize / 3, y + halfsize / 3); ctx.lineto(x, y + halfsize); ctx.lineto(x - halfsize / 3, y + halfsize / 3); ctx.lineto(x - halfsize, y); ctx.lineto(x - halfsize / 3, y - halfsize / 3); ctx.lineto(x, y - halfsize); break; default: ctx.rect(x - halfsize, y - halfsize, cursize, cursize); } } } ctx.closepath(); if (j < subsetlength - 1) { switch (style.brushtype) { case 'both': ctx.fill(); style.linewidth > 0 && ctx.stroke(); break; case 'stroke': style.linewidth > 0 && ctx.stroke(); break; default: ctx.fill(); } } } }, getrect: function (style) { return style.__rect || polygoninstance.getrect(style); }, iscover: require('./normaliscover') }; zrutil.inherits(symbol, base); return symbol; });define('zrender/shape/polyline', [ 'require', './base', './util/smoothspline', './util/smoothbezier', './util/dashedlineto', './polygon', '../tool/util' ], function (require) { var base = require('./base'); var smoothspline = require('./util/smoothspline'); var smoothbezier = require('./util/smoothbezier'); var dashedlineto = require('./util/dashedlineto'); var polyline = function (options) { this.brushtypeonly = 'stroke'; this.textposition = 'end'; base.call(this, options); }; polyline.prototype = { type: 'polyline', buildpath: function (ctx, style) { var pointlist = style.pointlist; if (pointlist.length < 2) { return; } var len = math.min(style.pointlist.length, math.round(style.pointlistlength || style.pointlist.length)); if (style.smooth && style.smooth !== 'spline') { if (!style.controlpointlist) { this.updatecontrolpoints(style); } var controlpointlist = style.controlpointlist; ctx.moveto(pointlist[0][0], pointlist[0][1]); var cp1; var cp2; var p; for (var i = 0; i < len - 1; i++) { cp1 = controlpointlist[i * 2]; cp2 = controlpointlist[i * 2 + 1]; p = pointlist[i + 1]; ctx.beziercurveto(cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]); } } else { if (style.smooth === 'spline') { pointlist = smoothspline(pointlist); len = pointlist.length; } if (!style.linetype || style.linetype == 'solid') { ctx.moveto(pointlist[0][0], pointlist[0][1]); for (var i = 1; i < len; i++) { ctx.lineto(pointlist[i][0], pointlist[i][1]); } } else if (style.linetype == 'dashed' || style.linetype == 'dotted') { var dashlength = (style.linewidth || 1) * (style.linetype == 'dashed' ? 5 : 1); ctx.moveto(pointlist[0][0], pointlist[0][1]); for (var i = 1; i < len; i++) { dashedlineto(ctx, pointlist[i - 1][0], pointlist[i - 1][1], pointlist[i][0], pointlist[i][1], dashlength); } } } return; }, updatecontrolpoints: function (style) { style.controlpointlist = smoothbezier(style.pointlist, style.smooth, false, style.smoothconstraint); }, getrect: function (style) { return require('./polygon').prototype.getrect(style); } }; require('../tool/util').inherits(polyline, base); return polyline; });define('zrender/shape/shapebundle', [ 'require', './base', '../tool/util' ], function (require) { var base = require('./base'); var shapebundle = function (options) { base.call(this, options); }; shapebundle.prototype = { constructor: shapebundle, type: 'shape-bundle', brush: function (ctx, ishighlight) { var style = this.beforebrush(ctx, ishighlight); ctx.beginpath(); for (var i = 0; i < style.shapelist.length; i++) { var subshape = style.shapelist[i]; var subshapestyle = subshape.style; if (ishighlight) { subshapestyle = subshape.gethighlightstyle(subshapestyle, subshape.highlightstyle || {}, subshape.brushtypeonly); } subshape.buildpath(ctx, subshapestyle); } switch (style.brushtype) { case 'both': ctx.fill(); case 'stroke': style.linewidth > 0 && ctx.stroke(); break; default: ctx.fill(); } this.drawtext(ctx, style, this.style); this.afterbrush(ctx); }, getrect: function (style) { if (style.__rect) { return style.__rect; } var minx = infinity; var maxx = -infinity; var miny = infinity; var maxy = -infinity; for (var i = 0; i < style.shapelist.length; i++) { var subshape = style.shapelist[i]; var subrect = subshape.getrect(subshape.style); var minx = math.min(subrect.x, minx); var miny = math.min(subrect.y, miny); var maxx = math.max(subrect.x + subrect.width, maxx); var maxy = math.max(subrect.y + subrect.height, maxy); } style.__rect = { x: minx, y: miny, width: maxx - minx, height: maxy - miny }; return style.__rect; }, iscover: function (x, y) { var originpos = this.transformcoordtolocal(x, y); x = originpos[0]; y = originpos[1]; if (this.iscoverrect(x, y)) { for (var i = 0; i < this.style.shapelist.length; i++) { var subshape = this.style.shapelist[i]; if (subshape.iscover(x, y)) { return true; } } } return false; } }; require('../tool/util').inherits(shapebundle, base); return shapebundle; });define('echarts/util/ecanimation', [ 'require', 'zrender/tool/util', 'zrender/tool/curve', 'zrender/shape/polygon' ], function (require) { var zrutil = require('zrender/tool/util'); var curvetool = require('zrender/tool/curve'); function pointlist(zr, oldshape, newshape, duration, easing) { var newpointlist = newshape.style.pointlist; var newpointlistlen = newpointlist.length; var oldpointlist; if (!oldshape) { oldpointlist = []; if (newshape._orient != 'vertical') { var y = newpointlist[0][1]; for (var i = 0; i < newpointlistlen; i++) { oldpointlist[i] = [ newpointlist[i][0], y ]; } } else { var x = newpointlist[0][0]; for (var i = 0; i < newpointlistlen; i++) { oldpointlist[i] = [ x, newpointlist[i][1] ]; } } if (newshape.type == 'half-smooth-polygon') { oldpointlist[newpointlistlen - 1] = zrutil.clone(newpointlist[newpointlistlen - 1]); oldpointlist[newpointlistlen - 2] = zrutil.clone(newpointlist[newpointlistlen - 2]); } oldshape = { style: { pointlist: oldpointlist } }; } oldpointlist = oldshape.style.pointlist; var oldpointlistlen = oldpointlist.length; if (oldpointlistlen == newpointlistlen) { newshape.style.pointlist = oldpointlist; } else if (oldpointlistlen < newpointlistlen) { newshape.style.pointlist = oldpointlist.concat(newpointlist.slice(oldpointlistlen)); } else { newshape.style.pointlist = oldpointlist.slice(0, newpointlistlen); } zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { pointlist: newpointlist }).during(function () { if (newshape.updatecontrolpoints) { newshape.updatecontrolpoints(newshape.style); } }).done(function () { newshape.__animating = false; }).start(easing); } function clonestyle(target, source) { var len = arguments.length; for (var i = 2; i < len; i++) { var prop = arguments[i]; target.style[prop] = source.style[prop]; } } function rectangle(zr, oldshape, newshape, duration, easing) { var newshapestyle = newshape.style; if (!oldshape) { oldshape = { position: newshape.position, style: { x: newshapestyle.x, y: newshape._orient == 'vertical' ? newshapestyle.y + newshapestyle.height : newshapestyle.y, width: newshape._orient == 'vertical' ? newshapestyle.width : 0, height: newshape._orient != 'vertical' ? newshapestyle.height : 0 } }; } var newx = newshapestyle.x; var newy = newshapestyle.y; var newwidth = newshapestyle.width; var newheight = newshapestyle.height; var newposition = [ newshape.position[0], newshape.position[1] ]; clonestyle(newshape, oldshape, 'x', 'y', 'width', 'height'); newshape.position = oldshape.position; zr.addshape(newshape); if (newposition[0] != oldshape.position[0] || newposition[1] != oldshape.position[1]) { zr.animate(newshape.id, '').when(duration, { position: newposition }).start(easing); } newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { x: newx, y: newy, width: newwidth, height: newheight }).done(function () { newshape.__animating = false; }).start(easing); } function candle(zr, oldshape, newshape, duration, easing) { if (!oldshape) { var y = newshape.style.y; oldshape = { style: { y: [ y[0], y[0], y[0], y[0] ] } }; } var newy = newshape.style.y; newshape.style.y = oldshape.style.y; zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { y: newy }).done(function () { newshape.__animating = false; }).start(easing); } function ring(zr, oldshape, newshape, duration, easing) { var x = newshape.style.x; var y = newshape.style.y; var r0 = newshape.style.r0; var r = newshape.style.r; newshape.__animating = true; if (newshape._animationadd != 'r') { newshape.style.r0 = 0; newshape.style.r = 0; newshape.rotation = [ math.pi * 2, x, y ]; zr.addshape(newshape); zr.animate(newshape.id, 'style').when(duration, { r0: r0, r: r }).done(function () { newshape.__animating = false; }).start(easing); zr.animate(newshape.id, '').when(duration, { rotation: [ 0, x, y ] }).start(easing); } else { newshape.style.r0 = newshape.style.r; zr.addshape(newshape); zr.animate(newshape.id, 'style').when(duration, { r0: r0 }).done(function () { newshape.__animating = false; }).start(easing); } } function sector(zr, oldshape, newshape, duration, easing) { if (!oldshape) { if (newshape._animationadd != 'r') { oldshape = { style: { startangle: newshape.style.startangle, endangle: newshape.style.startangle } }; } else { oldshape = { style: { r0: newshape.style.r } }; } } var startangle = newshape.style.startangle; var endangle = newshape.style.endangle; clonestyle(newshape, oldshape, 'startangle', 'endangle'); zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { startangle: startangle, endangle: endangle }).done(function () { newshape.__animating = false; }).start(easing); } function text(zr, oldshape, newshape, duration, easing) { if (!oldshape) { oldshape = { style: { x: newshape.style.textalign == 'left' ? newshape.style.x + 100 : newshape.style.x - 100, y: newshape.style.y } }; } var x = newshape.style.x; var y = newshape.style.y; clonestyle(newshape, oldshape, 'x', 'y'); zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { x: x, y: y }).done(function () { newshape.__animating = false; }).start(easing); } function polygon(zr, oldshape, newshape, duration, easing) { var rect = require('zrender/shape/polygon').prototype.getrect(newshape.style); var x = rect.x + rect.width / 2; var y = rect.y + rect.height / 2; newshape.scale = [ 0.1, 0.1, x, y ]; zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, '').when(duration, { scale: [ 1, 1, x, y ] }).done(function () { newshape.__animating = false; }).start(easing); } function ribbon(zr, oldshape, newshape, duration, easing) { if (!oldshape) { oldshape = { style: { source0: 0, source1: newshape.style.source1 > 0 ? 360 : -360, target0: 0, target1: newshape.style.target1 > 0 ? 360 : -360 } }; } var source0 = newshape.style.source0; var source1 = newshape.style.source1; var target0 = newshape.style.target0; var target1 = newshape.style.target1; if (oldshape.style) { clonestyle(newshape, oldshape, 'source0', 'source1', 'target0', 'target1'); } zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { source0: source0, source1: source1, target0: target0, target1: target1 }).done(function () { newshape.__animating = false; }).start(easing); } function gaugepointer(zr, oldshape, newshape, duration, easing) { if (!oldshape) { oldshape = { style: { angle: newshape.style.startangle } }; } var angle = newshape.style.angle; newshape.style.angle = oldshape.style.angle; zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { angle: angle }).done(function () { newshape.__animating = false; }).start(easing); } function icon(zr, oldshape, newshape, duration, easing, delay) { newshape.style._x = newshape.style.x; newshape.style._y = newshape.style.y; newshape.style._width = newshape.style.width; newshape.style._height = newshape.style.height; if (!oldshape) { var x = newshape._x || 0; var y = newshape._y || 0; newshape.scale = [ 0.01, 0.01, x, y ]; zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, '').delay(delay).when(duration, { scale: [ 1, 1, x, y ] }).done(function () { newshape.__animating = false; }).start(easing || 'quinticout'); } else { rectangle(zr, oldshape, newshape, duration, easing); } } function line(zr, oldshape, newshape, duration, easing) { if (!oldshape) { oldshape = { style: { xstart: newshape.style.xstart, ystart: newshape.style.ystart, xend: newshape.style.xstart, yend: newshape.style.ystart } }; } var xstart = newshape.style.xstart; var xend = newshape.style.xend; var ystart = newshape.style.ystart; var yend = newshape.style.yend; clonestyle(newshape, oldshape, 'xstart', 'xend', 'ystart', 'yend'); zr.addshape(newshape); newshape.__animating = true; zr.animate(newshape.id, 'style').when(duration, { xstart: xstart, xend: xend, ystart: ystart, yend: yend }).done(function () { newshape.__animating = false; }).start(easing); } function markline(zr, oldshape, newshape, duration, easing) { easing = easing || 'quinticout'; newshape.__animating = true; zr.addshape(newshape); var newshapestyle = newshape.style; var animationdone = function () { newshape.__animating = false; }; var x0 = newshapestyle.xstart; var y0 = newshapestyle.ystart; var x2 = newshapestyle.xend; var y2 = newshapestyle.yend; if (newshapestyle.curveness > 0) { newshape.updatepoints(newshapestyle); var obj = { p: 0 }; var x1 = newshapestyle.cpx1; var y1 = newshapestyle.cpy1; var newxarr = []; var newyarr = []; var subdivide = curvetool.quadraticsubdivide; zr.animation.animate(obj).when(duration, { p: 1 }).during(function () { subdivide(x0, x1, x2, obj.p, newxarr); subdivide(y0, y1, y2, obj.p, newyarr); newshapestyle.cpx1 = newxarr[1]; newshapestyle.cpy1 = newyarr[1]; newshapestyle.xend = newxarr[2]; newshapestyle.yend = newyarr[2]; zr.modshape(newshape); }).done(animationdone).start(easing); } else { zr.animate(newshape.id, 'style').when(0, { xend: x0, yend: y0 }).when(duration, { xend: x2, yend: y2 }).done(animationdone).start(easing); } } return { pointlist: pointlist, rectangle: rectangle, candle: candle, ring: ring, sector: sector, text: text, polygon: polygon, ribbon: ribbon, gaugepointer: gaugepointer, icon: icon, line: line, markline: markline }; });define('echarts/util/eceffect', [ 'require', '../util/ecdata', 'zrender/shape/circle', 'zrender/shape/image', 'zrender/tool/curve', '../util/shape/icon', '../util/shape/symbol', 'zrender/shape/shapebundle', 'zrender/shape/polyline', 'zrender/tool/vector', 'zrender/tool/env' ], function (require) { var ecdata = require('../util/ecdata'); var circleshape = require('zrender/shape/circle'); var imageshape = require('zrender/shape/image'); var curvetool = require('zrender/tool/curve'); var iconshape = require('../util/shape/icon'); var symbolshape = require('../util/shape/symbol'); var shapebundle = require('zrender/shape/shapebundle'); var polyline = require('zrender/shape/polyline'); var vec2 = require('zrender/tool/vector'); var canvassupported = require('zrender/tool/env').canvassupported; function point(zr, effectlist, shape, zlevel) { var effect = shape.effect; var color = effect.color || shape.style.strokecolor || shape.style.color; var shadowcolor = effect.shadowcolor || color; var size = effect.scalesize; var distance = effect.bouncedistance; var shadowblur = typeof effect.shadowblur != 'undefined' ? effect.shadowblur : size; var effectshape; if (shape.type !== 'image') { effectshape = new iconshape({ zlevel: zlevel, style: { brushtype: 'stroke', icontype: shape.style.icontype != 'droplet' ? shape.style.icontype : 'circle', x: shadowblur + 1, y: shadowblur + 1, n: shape.style.n, width: shape.style._width * size, height: shape.style._height * size, linewidth: 1, strokecolor: color, shadowcolor: shadowcolor, shadowblur: shadowblur }, draggable: false, hoverable: false }); if (shape.style.icontype == 'pin') { effectshape.style.y += effectshape.style.height / 2 * 1.5; } if (canvassupported) { effectshape.style.image = zr.shapetoimage(effectshape, effectshape.style.width + shadowblur * 2 + 2, effectshape.style.height + shadowblur * 2 + 2).style.image; effectshape = new imageshape({ zlevel: effectshape.zlevel, style: effectshape.style, draggable: false, hoverable: false }); } } else { effectshape = new imageshape({ zlevel: zlevel, style: shape.style, draggable: false, hoverable: false }); } ecdata.clone(shape, effectshape); effectshape.position = shape.position; effectlist.push(effectshape); zr.addshape(effectshape); var devicepixelratio = shape.type !== 'image' ? window.devicepixelratio || 1 : 1; var offset = (effectshape.style.width / devicepixelratio - shape.style._width) / 2; effectshape.style.x = shape.style._x - offset; effectshape.style.y = shape.style._y - offset; if (shape.style.icontype == 'pin') { effectshape.style.y -= shape.style.height / 2 * 1.5; } var duration = (effect.period + math.random() * 10) * 100; zr.modshape(shape.id, { invisible: true }); var centerx = effectshape.style.x + effectshape.style.width / 2 / devicepixelratio; var centery = effectshape.style.y + effectshape.style.height / 2 / devicepixelratio; if (effect.type === 'scale') { zr.modshape(effectshape.id, { scale: [ 0.1, 0.1, centerx, centery ] }); zr.animate(effectshape.id, '', effect.loop).when(duration, { scale: [ 1, 1, centerx, centery ] }).done(function () { shape.effect.show = false; zr.delshape(effectshape.id); }).start(); } else { zr.animate(effectshape.id, 'style', effect.loop).when(duration, { y: effectshape.style.y - distance }).when(duration * 2, { y: effectshape.style.y }).done(function () { shape.effect.show = false; zr.delshape(effectshape.id); }).start(); } } function largepoint(zr, effectlist, shape, zlevel) { var effect = shape.effect; var color = effect.color || shape.style.strokecolor || shape.style.color; var size = effect.scalesize; var shadowcolor = effect.shadowcolor || color; var shadowblur = typeof effect.shadowblur != 'undefined' ? effect.shadowblur : size * 2; var devicepixelratio = window.devicepixelratio || 1; var effectshape = new symbolshape({ zlevel: zlevel, position: shape.position, scale: shape.scale, style: { pointlist: shape.style.pointlist, icontype: shape.style.icontype, color: color, strokecolor: color, shadowcolor: shadowcolor, shadowblur: shadowblur * devicepixelratio, random: true, brushtype: 'fill', linewidth: 1, size: shape.style.size }, draggable: false, hoverable: false }); effectlist.push(effectshape); zr.addshape(effectshape); zr.modshape(shape.id, { invisible: true }); var duration = math.round(effect.period * 100); var clip1 = {}; var clip2 = {}; for (var i = 0; i < 20; i++) { effectshape.style['randommap' + i] = 0; clip1 = {}; clip1['randommap' + i] = 100; clip2 = {}; clip2['randommap' + i] = 0; effectshape.style['randommap' + i] = math.random() * 100; zr.animate(effectshape.id, 'style', true).when(duration, clip1).when(duration * 2, clip2).when(duration * 3, clip1).when(duration * 4, clip1).delay(math.random() * duration * i).start(); } } function line(zr, effectlist, shape, zlevel, islarge) { var effect = shape.effect; var shapestyle = shape.style; var color = effect.color || shapestyle.strokecolor || shapestyle.color; var shadowcolor = effect.shadowcolor || shapestyle.strokecolor || color; var size = shapestyle.linewidth * effect.scalesize; var shadowblur = typeof effect.shadowblur != 'undefined' ? effect.shadowblur : size; var effectshape = new circleshape({ zlevel: zlevel, style: { x: shadowblur, y: shadowblur, r: size, color: color, shadowcolor: shadowcolor, shadowblur: shadowblur }, hoverable: false }); var offset = 0; if (canvassupported && !islarge) { var zlevel = effectshape.zlevel; effectshape = zr.shapetoimage(effectshape, (size + shadowblur) * 2, (size + shadowblur) * 2); effectshape.zlevel = zlevel; effectshape.hoverable = false; offset = shadowblur; } if (!islarge) { ecdata.clone(shape, effectshape); effectshape.position = shape.position; effectlist.push(effectshape); zr.addshape(effectshape); } var effectdone = function () { if (!islarge) { shape.effect.show = false; zr.delshape(effectshape.id); } effectshape.effectanimator = null; }; if (shape instanceof polyline) { var distancelist = [0]; var totaldist = 0; var pointlist = shapestyle.pointlist; var controlpointlist = shapestyle.controlpointlist; for (var i = 1; i < pointlist.length; i++) { if (controlpointlist) { var cp1 = controlpointlist[(i - 1) * 2]; var cp2 = controlpointlist[(i - 1) * 2 + 1]; totaldist += vec2.dist(pointlist[i - 1], cp1) + vec2.dist(cp1, cp2) + vec2.dist(cp2, pointlist[i]); } else { totaldist += vec2.dist(pointlist[i - 1], pointlist[i]); } distancelist.push(totaldist); } var obj = { p: 0 }; var animator = zr.animation.animate(obj, { loop: effect.loop }); for (var i = 0; i < distancelist.length; i++) { animator.when(distancelist[i] * effect.period, { p: i }); } animator.during(function () { var i = math.floor(obj.p); var x, y; if (i == pointlist.length - 1) { x = pointlist[i][0]; y = pointlist[i][1]; } else { var t = obj.p - i; var p0 = pointlist[i]; var p1 = pointlist[i + 1]; if (controlpointlist) { var cp1 = controlpointlist[i * 2]; var cp2 = controlpointlist[i * 2 + 1]; x = curvetool.cubicat(p0[0], cp1[0], cp2[0], p1[0], t); y = curvetool.cubicat(p0[1], cp1[1], cp2[1], p1[1], t); } else { x = (p1[0] - p0[0]) * t + p0[0]; y = (p1[1] - p0[1]) * t + p0[1]; } } effectshape.style.x = x; effectshape.style.y = y; if (!islarge) { zr.modshape(effectshape); } }).done(effectdone).start(); animator.duration = totaldist * effect.period; effectshape.effectanimator = animator; } else { var x0 = shapestyle.xstart - offset; var y0 = shapestyle.ystart - offset; var x2 = shapestyle.xend - offset; var y2 = shapestyle.yend - offset; effectshape.style.x = x0; effectshape.style.y = y0; var distance = (x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0); var duration = math.round(math.sqrt(math.round(distance * effect.period * effect.period))); if (shape.style.curveness > 0) { var x1 = shapestyle.cpx1 - offset; var y1 = shapestyle.cpy1 - offset; effectshape.effectanimator = zr.animation.animate(effectshape, { loop: effect.loop }).when(duration, { p: 1 }).during(function (target, t) { effectshape.style.x = curvetool.quadraticat(x0, x1, x2, t); effectshape.style.y = curvetool.quadraticat(y0, y1, y2, t); if (!islarge) { zr.modshape(effectshape); } }).done(effectdone).start(); } else { effectshape.effectanimator = zr.animation.animate(effectshape.style, { loop: effect.loop }).when(duration, { x: x2, y: y2 }).during(function () { if (!islarge) { zr.modshape(effectshape); } }).done(effectdone).start(); } effectshape.effectanimator.duration = duration; } return effectshape; } function largeline(zr, effectlist, shape, zlevel) { var effectshape = new shapebundle({ style: { shapelist: [] }, zlevel: zlevel, hoverable: false }); var shapelist = shape.style.shapelist; var effect = shape.effect; effectshape.position = shape.position; var maxduration = 0; var subeffectanimators = []; for (var i = 0; i < shapelist.length; i++) { shapelist[i].effect = effect; var subeffectshape = line(zr, null, shapelist[i], zlevel, true); var subeffectanimator = subeffectshape.effectanimator; effectshape.style.shapelist.push(subeffectshape); if (subeffectanimator.duration > maxduration) { maxduration = subeffectanimator.duration; } if (i === 0) { effectshape.style.color = subeffectshape.style.color; effectshape.style.shadowblur = subeffectshape.style.shadowblur; effectshape.style.shadowcolor = subeffectshape.style.shadowcolor; } subeffectanimators.push(subeffectanimator); } effectlist.push(effectshape); zr.addshape(effectshape); var clearallanimators = function () { for (var i = 0; i < subeffectanimators.length; i++) { subeffectanimators[i].stop(); } }; if (maxduration) { effectshape.__dummy = 0; var animator = zr.animate(effectshape.id, '', effect.loop).when(maxduration, { __dummy: 1 }).during(function () { zr.modshape(effectshape); }).done(function () { shape.effect.show = false; zr.delshape(effectshape.id); }).start(); var oldstop = animator.stop; animator.stop = function () { clearallanimators(); oldstop.call(this); }; } } return { point: point, largepoint: largepoint, line: line, largeline: largeline }; });define('echarts/component/base', [ 'require', '../config', '../util/ecdata', '../util/ecquery', '../util/number', 'zrender/tool/util', 'zrender/tool/env' ], function (require) { var ecconfig = require('../config'); var ecdata = require('../util/ecdata'); var ecquery = require('../util/ecquery'); var number = require('../util/number'); var zrutil = require('zrender/tool/util'); function base(ectheme, messagecenter, zr, option, mychart) { this.ectheme = ectheme; this.messagecenter = messagecenter; this.zr = zr; this.option = option; this.series = option.series; this.mychart = mychart; this.component = mychart.component; this.shapelist = []; this.effectlist = []; var self = this; self._onlegendhoverlink = function (param) { if (self.legendhoverlink) { var targetname = param.target; var name; for (var i = self.shapelist.length - 1; i >= 0; i--) { name = self.type == ecconfig.chart_type_pie || self.type == ecconfig.chart_type_funnel ? ecdata.get(self.shapelist[i], 'name') : (ecdata.get(self.shapelist[i], 'series') || {}).name; if (name == targetname && !self.shapelist[i].invisible && !self.shapelist[i].__animating) { self.zr.addhovershape(self.shapelist[i]); } } } }; messagecenter && messagecenter.bind(ecconfig.event.legend_hoverlink, this._onlegendhoverlink); } base.prototype = { canvassupported: require('zrender/tool/env').canvassupported, _getz: function (zwhat) { if (this[zwhat] != null) { return this[zwhat]; } var opt = this.ectheme[this.type]; if (opt && opt[zwhat] != null) { return opt[zwhat]; } opt = ecconfig[this.type]; if (opt && opt[zwhat] != null) { return opt[zwhat]; } return 0; }, getzlevelbase: function () { return this._getz('zlevel'); }, getzbase: function () { return this._getz('z'); }, reformoption: function (opt) { opt = zrutil.merge(zrutil.merge(opt || {}, zrutil.clone(this.ectheme[this.type] || {})), zrutil.clone(ecconfig[this.type] || {})); this.z = opt.z; this.zlevel = opt.zlevel; return opt; }, reformcssarray: function (p) { if (p instanceof array) { switch (p.length + '') { case '4': return p; case '3': return [ p[0], p[1], p[2], p[1] ]; case '2': return [ p[0], p[1], p[0], p[1] ]; case '1': return [ p[0], p[0], p[0], p[0] ]; case '0': return [ 0, 0, 0, 0 ]; } } else { return [ p, p, p, p ]; } }, getshapebyid: function (id) { for (var i = 0, l = this.shapelist.length; i < l; i++) { if (this.shapelist[i].id === id) { return this.shapelist[i]; } } return null; }, getfont: function (textstyle) { var finaltextstyle = this.gettextstyle(zrutil.clone(textstyle)); return finaltextstyle.fontstyle + ' ' + finaltextstyle.fontweight + ' ' + finaltextstyle.fontsize + 'px ' + finaltextstyle.fontfamily; }, gettextstyle: function (targetstyle) { return zrutil.merge(zrutil.merge(targetstyle || {}, this.ectheme.textstyle), ecconfig.textstyle); }, getitemstylecolor: function (itemcolor, seriesindex, dataindex, data) { return typeof itemcolor === 'function' ? itemcolor.call(this.mychart, { seriesindex: seriesindex, series: this.series[seriesindex], dataindex: dataindex, data: data }) : itemcolor; }, getdatafromoption: function (data, defaultdata) { return data != null ? data.value != null ? data.value : data : defaultdata; }, subpixeloptimize: function (position, linewidth) { if (linewidth % 2 === 1) { position = math.floor(position) + 0.5; } else { position = math.round(position); } return position; }, resize: function () { this.refresh && this.refresh(); this.cleareffectshape && this.cleareffectshape(true); var self = this; settimeout(function () { self.animationeffect && self.animationeffect(); }, 200); }, clear: function () { this.cleareffectshape && this.cleareffectshape(); this.zr && this.zr.delshape(this.shapelist); this.shapelist = []; }, dispose: function () { this.onbefordispose && this.onbefordispose(); this.clear(); this.shapelist = null; this.effectlist = null; this.messagecenter && this.messagecenter.unbind(ecconfig.event.legend_hoverlink, this._onlegendhoverlink); this.onafterdispose && this.onafterdispose(); }, query: ecquery.query, deepquery: ecquery.deepquery, deepmerge: ecquery.deepmerge, parsepercent: number.parsepercent, parsecenter: number.parsecenter, parseradius: number.parseradius, numaddcommas: number.addcommas, getprecision: number.getprecision }; return base; });define('echarts/layout/edgebundling', [ 'require', '../data/kdtree', 'zrender/tool/vector' ], function (require) { var kdtree = require('../data/kdtree'); var vec2 = require('zrender/tool/vector'); var v2create = vec2.create; var v2distsquare = vec2.distsquare; var v2dist = vec2.dist; var v2copy = vec2.copy; var v2clone = vec2.clone; function squareddistance(a, b) { a = a.array; b = b.array; var x = b[0] - a[0]; var y = b[1] - a[1]; var z = b[2] - a[2]; var w = b[3] - a[3]; return x * x + y * y + z * z + w * w; } function coarsenededge(group) { this.points = [ group.mp0, group.mp1 ]; this.group = group; } function edge(edge) { var points = edge.points; if (points[0][1] < points[1][1] || edge instanceof coarsenededge) { this.array = [ points[0][0], points[0][1], points[1][0], points[1][1] ]; this._startpoint = points[0]; this._endpoint = points[1]; } else { this.array = [ points[1][0], points[1][1], points[0][0], points[0][1] ]; this._startpoint = points[1]; this._endpoint = points[0]; } this.ink = v2dist(points[0], points[1]); this.edge = edge; this.group = null; } edge.prototype.getstartpoint = function () { return this._startpoint; }; edge.prototype.getendpoint = function () { return this._endpoint; }; function bundlededgegroup() { this.edgelist = []; this.mp0 = v2create(); this.mp1 = v2create(); this.ink = 0; } bundlededgegroup.prototype.addedge = function (edge) { edge.group = this; this.edgelist.push(edge); }; bundlededgegroup.prototype.removeedge = function (edge) { edge.group = null; this.edgelist.splice(this.edgelist.indexof(edge), 1); }; function edgebundling() { this.maxnearestedge = 6; this.maxturningangle = math.pi / 4; this.maxiteration = 20; } edgebundling.prototype = { constructor: edgebundling, run: function (rawedges) { var res = this._iterate(rawedges); var niterate = 0; while (niterate++ < this.maxiteration) { var coarsenededges = []; for (var i = 0; i < res.groups.length; i++) { coarsenededges.push(new coarsenededge(res.groups[i])); } var newres = this._iterate(coarsenededges); if (newres.savedink <= 0) { break; } else { res = newres; } } var newedges = []; function pointapproxequal(p0, p1) { return v2distsquare(p0, p1) < 1e-10; } function cleanedgepoints(edgepoints, rawedgepoints) { var res = []; var off = 0; for (var i = 0; i < edgepoints.length; i++) { if (!(off > 0 && pointapproxequal(edgepoints[i], res[off - 1]))) { res[off++] = v2clone(edgepoints[i]); } } if (rawedgepoints[0] && !pointapproxequal(res[0], rawedgepoints[0])) { res = res.reverse(); } return res; } var buildnewedges = function (groups, fromedgepoints) { var newedgepoints; for (var i = 0; i < groups.length; i++) { var group = groups[i]; if (group.edgelist[0] && group.edgelist[0].edge instanceof coarsenededge) { var newgroups = []; for (var j = 0; j < group.edgelist.length; j++) { newgroups.push(group.edgelist[j].edge.group); } if (!fromedgepoints) { newedgepoints = []; } else { newedgepoints = fromedgepoints.slice(); } newedgepoints.unshift(group.mp0); newedgepoints.push(group.mp1); buildnewedges(newgroups, newedgepoints); } else { for (var j = 0; j < group.edgelist.length; j++) { var edge = group.edgelist[j]; if (!fromedgepoints) { newedgepoints = []; } else { newedgepoints = fromedgepoints.slice(); } newedgepoints.unshift(group.mp0); newedgepoints.push(group.mp1); newedgepoints.unshift(edge.getstartpoint()); newedgepoints.push(edge.getendpoint()); newedges.push({ points: cleanedgepoints(newedgepoints, edge.edge.points), rawedge: edge.edge }); } } } }; buildnewedges(res.groups); return newedges; }, _iterate: function (rawedges) { var edges = []; var groups = []; var totalsavedink = 0; for (var i = 0; i < rawedges.length; i++) { var edge = new edge(rawedges[i]); edges.push(edge); } var tree = new kdtree(edges, 4); var nearests = []; var _mp0 = v2create(); var _mp1 = v2create(); var _newgroupink = 0; var mp0 = v2create(); var mp1 = v2create(); var newgroupink = 0; for (var i = 0; i < edges.length; i++) { var edge = edges[i]; if (edge.group) { continue; } tree.nearestn(edge, this.maxnearestedge, squareddistance, nearests); var maxsavedink = 0; var mostsavinginkedge = null; var lastcheckedgroup = null; for (var j = 0; j < nearests.length; j++) { var nearest = nearests[j]; var savedink = 0; if (nearest.group) { if (nearest.group !== lastcheckedgroup) { lastcheckedgroup = nearest.group; _newgroupink = this._calculategroupedgeink(nearest.group, edge, _mp0, _mp1); savedink = nearest.group.ink + edge.ink - _newgroupink; } } else { _newgroupink = this._calculateedgeedgeink(edge, nearest, _mp0, _mp1); savedink = nearest.ink + edge.ink - _newgroupink; } if (savedink > maxsavedink) { maxsavedink = savedink; mostsavinginkedge = nearest; v2copy(mp1, _mp1); v2copy(mp0, _mp0); newgroupink = _newgroupink; } } if (mostsavinginkedge) { totalsavedink += maxsavedink; var group; if (!mostsavinginkedge.group) { group = new bundlededgegroup(); groups.push(group); group.addedge(mostsavinginkedge); } group = mostsavinginkedge.group; v2copy(group.mp0, mp0); v2copy(group.mp1, mp1); group.ink = newgroupink; mostsavinginkedge.group.addedge(edge); } else { var group = new bundlededgegroup(); groups.push(group); v2copy(group.mp0, edge.getstartpoint()); v2copy(group.mp1, edge.getendpoint()); group.ink = edge.ink; group.addedge(edge); } } return { groups: groups, edges: edges, savedink: totalsavedink }; }, _calculateedgeedgeink: function () { var startpointset = []; var endpointset = []; return function (e0, e1, mp0, mp1) { startpointset[0] = e0.getstartpoint(); startpointset[1] = e1.getstartpoint(); endpointset[0] = e0.getendpoint(); endpointset[1] = e1.getendpoint(); this._calculatemeetpoints(startpointset, endpointset, mp0, mp1); var ink = v2dist(startpointset[0], mp0) + v2dist(mp0, mp1) + v2dist(mp1, endpointset[0]) + v2dist(startpointset[1], mp0) + v2dist(mp1, endpointset[1]); return ink; }; }(), _calculategroupedgeink: function (group, edgetryadd, mp0, mp1) { var startpointset = []; var endpointset = []; for (var i = 0; i < group.edgelist.length; i++) { var edge = group.edgelist[i]; startpointset.push(edge.getstartpoint()); endpointset.push(edge.getendpoint()); } startpointset.push(edgetryadd.getstartpoint()); endpointset.push(edgetryadd.getendpoint()); this._calculatemeetpoints(startpointset, endpointset, mp0, mp1); var ink = v2dist(mp0, mp1); for (var i = 0; i < startpointset.length; i++) { ink += v2dist(startpointset[i], mp0) + v2dist(endpointset[i], mp1); } return ink; }, _calculatemeetpoints: function () { var cp0 = v2create(); var cp1 = v2create(); return function (startpointset, endpointset, mp0, mp1) { vec2.set(cp0, 0, 0); vec2.set(cp1, 0, 0); var len = startpointset.length; for (var i = 0; i < len; i++) { vec2.add(cp0, cp0, startpointset[i]); } vec2.scale(cp0, cp0, 1 / len); len = endpointset.length; for (var i = 0; i < len; i++) { vec2.add(cp1, cp1, endpointset[i]); } vec2.scale(cp1, cp1, 1 / len); this._limitturningangle(startpointset, cp0, cp1, mp0); this._limitturningangle(endpointset, cp1, cp0, mp1); }; }(), _limitturningangle: function () { var v10 = v2create(); var vtmp = v2create(); var project = v2create(); var tmpout = v2create(); return function (pointset, p0, p1, out) { var maxturninganglecos = math.cos(this.maxturningangle); var maxturningangletan = math.tan(this.maxturningangle); vec2.sub(v10, p0, p1); vec2.normalize(v10, v10); vec2.copy(out, p0); var maxmovement = 0; for (var i = 0; i < pointset.length; i++) { var p = pointset[i]; vec2.sub(vtmp, p, p0); var len = vec2.len(vtmp); vec2.scale(vtmp, vtmp, 1 / len); var turninganglecos = vec2.dot(vtmp, v10); if (turninganglecos < maxturninganglecos) { vec2.scaleandadd(project, p0, v10, len * turninganglecos); var distance = v2dist(project, p); var d = distance / maxturningangletan; vec2.scaleandadd(tmpout, project, v10, -d); var movement = v2distsquare(tmpout, p0); if (movement > maxmovement) { maxmovement = movement; vec2.copy(out, tmpout); } } } }; }() }; return edgebundling; });define('zrender/shape/star', [ 'require', '../tool/math', './base', '../tool/util' ], function (require) { var math = require('../tool/math'); var sin = math.sin; var cos = math.cos; var pi = math.pi; var base = require('./base'); var star = function (options) { base.call(this, options); }; star.prototype = { type: 'star', buildpath: function (ctx, style) { var n = style.n; if (!n || n < 2) { return; } var x = style.x; var y = style.y; var r = style.r; var r0 = style.r0; if (r0 == null) { r0 = n > 4 ? r * cos(2 * pi / n) / cos(pi / n) : r / 3; } var dstep = pi / n; var deg = -pi / 2; var xstart = x + r * cos(deg); var ystart = y + r * sin(deg); deg += dstep; var pointlist = style.pointlist = []; pointlist.push([ xstart, ystart ]); for (var i = 0, end = n * 2 - 1, ri; i < end; i++) { ri = i % 2 === 0 ? r0 : r; pointlist.push([ x + ri * cos(deg), y + ri * sin(deg) ]); deg += dstep; } pointlist.push([ xstart, ystart ]); ctx.moveto(pointlist[0][0], pointlist[0][1]); for (var i = 0; i < pointlist.length; i++) { ctx.lineto(pointlist[i][0], pointlist[i][1]); } ctx.closepath(); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } var linewidth; if (style.brushtype == 'stroke' || style.brushtype == 'fill') { linewidth = style.linewidth || 1; } else { linewidth = 0; } style.__rect = { x: math.round(style.x - style.r - linewidth / 2), y: math.round(style.y - style.r - linewidth / 2), width: style.r * 2 + linewidth, height: style.r * 2 + linewidth }; return style.__rect; } }; require('../tool/util').inherits(star, base); return star; });define('zrender/shape/heart', [ 'require', './base', './util/pathproxy', '../tool/area', '../tool/util' ], function (require) { 'use strict'; var base = require('./base'); var pathproxy = require('./util/pathproxy'); var area = require('../tool/area'); var heart = function (options) { base.call(this, options); this._pathproxy = new pathproxy(); }; heart.prototype = { type: 'heart', buildpath: function (ctx, style) { var path = this._pathproxy || new pathproxy(); path.begin(ctx); path.moveto(style.x, style.y); path.beziercurveto(style.x + style.a / 2, style.y - style.b * 2 / 3, style.x + style.a * 2, style.y + style.b / 3, style.x, style.y + style.b); path.beziercurveto(style.x - style.a * 2, style.y + style.b / 3, style.x - style.a / 2, style.y - style.b * 2 / 3, style.x, style.y); path.closepath(); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } if (!this._pathproxy.isempty()) { this.buildpath(null, style); } return this._pathproxy.fastboundingrect(); }, iscover: function (x, y) { var originpos = this.transformcoordtolocal(x, y); x = originpos[0]; y = originpos[1]; if (this.iscoverrect(x, y)) { return area.isinsidepath(this._pathproxy.pathcommands, this.style.linewidth, this.style.brushtype, x, y); } } }; require('../tool/util').inherits(heart, base); return heart; });define('zrender/shape/droplet', [ 'require', './base', './util/pathproxy', '../tool/area', '../tool/util' ], function (require) { 'use strict'; var base = require('./base'); var pathproxy = require('./util/pathproxy'); var area = require('../tool/area'); var droplet = function (options) { base.call(this, options); this._pathproxy = new pathproxy(); }; droplet.prototype = { type: 'droplet', buildpath: function (ctx, style) { var path = this._pathproxy || new pathproxy(); path.begin(ctx); path.moveto(style.x, style.y + style.a); path.beziercurveto(style.x + style.a, style.y + style.a, style.x + style.a * 3 / 2, style.y - style.a / 3, style.x, style.y - style.b); path.beziercurveto(style.x - style.a * 3 / 2, style.y - style.a / 3, style.x - style.a, style.y + style.a, style.x, style.y + style.a); path.closepath(); }, getrect: function (style) { if (style.__rect) { return style.__rect; } if (!this._pathproxy.isempty()) { this.buildpath(null, style); } return this._pathproxy.fastboundingrect(); }, iscover: function (x, y) { var originpos = this.transformcoordtolocal(x, y); x = originpos[0]; y = originpos[1]; if (this.iscoverrect(x, y)) { return area.isinsidepath(this._pathproxy.pathcommands, this.style.linewidth, this.style.brushtype, x, y); } } }; require('../tool/util').inherits(droplet, base); return droplet; });define('zrender/tool/math', [], function () { var _radians = math.pi / 180; function sin(angle, isdegrees) { return math.sin(isdegrees ? angle * _radians : angle); } function cos(angle, isdegrees) { return math.cos(isdegrees ? angle * _radians : angle); } function degreetoradian(angle) { return angle * _radians; } function radiantodegree(angle) { return angle / _radians; } return { sin: sin, cos: cos, degreetoradian: degreetoradian, radiantodegree: radiantodegree }; });define('zrender/shape/util/pathproxy', [ 'require', '../../tool/vector' ], function (require) { var vector = require('../../tool/vector'); var pathsegment = function (command, points) { this.command = command; this.points = points || null; }; var pathproxy = function () { this.pathcommands = []; this._ctx = null; this._min = []; this._max = []; }; pathproxy.prototype.fastboundingrect = function () { var min = this._min; var max = this._max; min[0] = min[1] = infinity; max[0] = max[1] = -infinity; for (var i = 0; i < this.pathcommands.length; i++) { var seg = this.pathcommands[i]; var p = seg.points; switch (seg.command) { case 'm': vector.min(min, min, p); vector.max(max, max, p); break; case 'l': vector.min(min, min, p); vector.max(max, max, p); break; case 'c': for (var j = 0; j < 6; j += 2) { min[0] = math.min(min[0], min[0], p[j]); min[1] = math.min(min[1], min[1], p[j + 1]); max[0] = math.max(max[0], max[0], p[j]); max[1] = math.max(max[1], max[1], p[j + 1]); } break; case 'q': for (var j = 0; j < 4; j += 2) { min[0] = math.min(min[0], min[0], p[j]); min[1] = math.min(min[1], min[1], p[j + 1]); max[0] = math.max(max[0], max[0], p[j]); max[1] = math.max(max[1], max[1], p[j + 1]); } break; case 'a': var cx = p[0]; var cy = p[1]; var rx = p[2]; var ry = p[3]; min[0] = math.min(min[0], min[0], cx - rx); min[1] = math.min(min[1], min[1], cy - ry); max[0] = math.max(max[0], max[0], cx + rx); max[1] = math.max(max[1], max[1], cy + ry); break; } } return { x: min[0], y: min[1], width: max[0] - min[0], height: max[1] - min[1] }; }; pathproxy.prototype.begin = function (ctx) { this._ctx = ctx || null; this.pathcommands.length = 0; return this; }; pathproxy.prototype.moveto = function (x, y) { this.pathcommands.push(new pathsegment('m', [ x, y ])); if (this._ctx) { this._ctx.moveto(x, y); } return this; }; pathproxy.prototype.lineto = function (x, y) { this.pathcommands.push(new pathsegment('l', [ x, y ])); if (this._ctx) { this._ctx.lineto(x, y); } return this; }; pathproxy.prototype.beziercurveto = function (x1, y1, x2, y2, x3, y3) { this.pathcommands.push(new pathsegment('c', [ x1, y1, x2, y2, x3, y3 ])); if (this._ctx) { this._ctx.beziercurveto(x1, y1, x2, y2, x3, y3); } return this; }; pathproxy.prototype.quadraticcurveto = function (x1, y1, x2, y2) { this.pathcommands.push(new pathsegment('q', [ x1, y1, x2, y2 ])); if (this._ctx) { this._ctx.quadraticcurveto(x1, y1, x2, y2); } return this; }; pathproxy.prototype.arc = function (cx, cy, r, startangle, endangle, anticlockwise) { this.pathcommands.push(new pathsegment('a', [ cx, cy, r, r, startangle, endangle - startangle, 0, anticlockwise ? 0 : 1 ])); if (this._ctx) { this._ctx.arc(cx, cy, r, startangle, endangle, anticlockwise); } return this; }; pathproxy.prototype.arcto = function (x1, y1, x2, y2, radius) { if (this._ctx) { this._ctx.arcto(x1, y1, x2, y2, radius); } return this; }; pathproxy.prototype.rect = function (x, y, w, h) { if (this._ctx) { this._ctx.rect(x, y, w, h); } return this; }; pathproxy.prototype.closepath = function () { this.pathcommands.push(new pathsegment('z')); if (this._ctx) { this._ctx.closepath(); } return this; }; pathproxy.prototype.isempty = function () { return this.pathcommands.length === 0; }; pathproxy.pathsegment = pathsegment; return pathproxy; });define('zrender/shape/line', [ 'require', './base', './util/dashedlineto', '../tool/util' ], function (require) { var base = require('./base'); var dashedlineto = require('./util/dashedlineto'); var line = function (options) { this.brushtypeonly = 'stroke'; this.textposition = 'end'; base.call(this, options); }; line.prototype = { type: 'line', buildpath: function (ctx, style) { if (!style.linetype || style.linetype == 'solid') { ctx.moveto(style.xstart, style.ystart); ctx.lineto(style.xend, style.yend); } else if (style.linetype == 'dashed' || style.linetype == 'dotted') { var dashlength = (style.linewidth || 1) * (style.linetype == 'dashed' ? 5 : 1); dashedlineto(ctx, style.xstart, style.ystart, style.xend, style.yend, dashlength); } }, getrect: function (style) { if (style.__rect) { return style.__rect; } var linewidth = style.linewidth || 1; style.__rect = { x: math.min(style.xstart, style.xend) - linewidth, y: math.min(style.ystart, style.yend) - linewidth, width: math.abs(style.xstart - style.xend) + linewidth, height: math.abs(style.ystart - style.yend) + linewidth }; return style.__rect; } }; require('../tool/util').inherits(line, base); return line; });define('zrender/shape/beziercurve', [ 'require', './base', '../tool/util' ], function (require) { 'use strict'; var base = require('./base'); var beziercurve = function (options) { this.brushtypeonly = 'stroke'; this.textposition = 'end'; base.call(this, options); }; beziercurve.prototype = { type: 'bezier-curve', buildpath: function (ctx, style) { ctx.moveto(style.xstart, style.ystart); if (typeof style.cpx2 != 'undefined' && typeof style.cpy2 != 'undefined') { ctx.beziercurveto(style.cpx1, style.cpy1, style.cpx2, style.cpy2, style.xend, style.yend); } else { ctx.quadraticcurveto(style.cpx1, style.cpy1, style.xend, style.yend); } }, getrect: function (style) { if (style.__rect) { return style.__rect; } var _minx = math.min(style.xstart, style.xend, style.cpx1); var _miny = math.min(style.ystart, style.yend, style.cpy1); var _maxx = math.max(style.xstart, style.xend, style.cpx1); var _maxy = math.max(style.ystart, style.yend, style.cpy1); var _x2 = style.cpx2; var _y2 = style.cpy2; if (typeof _x2 != 'undefined' && typeof _y2 != 'undefined') { _minx = math.min(_minx, _x2); _miny = math.min(_miny, _y2); _maxx = math.max(_maxx, _x2); _maxy = math.max(_maxy, _y2); } var linewidth = style.linewidth || 1; style.__rect = { x: _minx - linewidth, y: _miny - linewidth, width: _maxx - _minx + linewidth, height: _maxy - _miny + linewidth }; return style.__rect; } }; require('../tool/util').inherits(beziercurve, base); return beziercurve; });define('zrender/shape/util/dashedlineto', [], function () { var dashpattern = [ 5, 5 ]; return function (ctx, x1, y1, x2, y2, dashlength) { if (ctx.setlinedash) { dashpattern[0] = dashpattern[1] = dashlength; ctx.setlinedash(dashpattern); ctx.moveto(x1, y1); ctx.lineto(x2, y2); return; } dashlength = typeof dashlength != 'number' ? 5 : dashlength; var dx = x2 - x1; var dy = y2 - y1; var numdashes = math.floor(math.sqrt(dx * dx + dy * dy) / dashlength); dx = dx / numdashes; dy = dy / numdashes; var flag = true; for (var i = 0; i < numdashes; ++i) { if (flag) { ctx.moveto(x1, y1); } else { ctx.lineto(x1, y1); } flag = !flag; x1 += dx; y1 += dy; } ctx.lineto(x2, y2); }; });define('zrender/shape/polygon', [ 'require', './base', './util/smoothspline', './util/smoothbezier', './util/dashedlineto', '../tool/util' ], function (require) { var base = require('./base'); var smoothspline = require('./util/smoothspline'); var smoothbezier = require('./util/smoothbezier'); var dashedlineto = require('./util/dashedlineto'); var polygon = function (options) { base.call(this, options); }; polygon.prototype = { type: 'polygon', buildpath: function (ctx, style) { var pointlist = style.pointlist; if (pointlist.length < 2) { return; } if (style.smooth && style.smooth !== 'spline') { var controlpoints = smoothbezier(pointlist, style.smooth, true, style.smoothconstraint); ctx.moveto(pointlist[0][0], pointlist[0][1]); var cp1; var cp2; var p; var len = pointlist.length; for (var i = 0; i < len; i++) { cp1 = controlpoints[i * 2]; cp2 = controlpoints[i * 2 + 1]; p = pointlist[(i + 1) % len]; ctx.beziercurveto(cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]); } } else { if (style.smooth === 'spline') { pointlist = smoothspline(pointlist, true); } if (!style.linetype || style.linetype == 'solid') { ctx.moveto(pointlist[0][0], pointlist[0][1]); for (var i = 1, l = pointlist.length; i < l; i++) { ctx.lineto(pointlist[i][0], pointlist[i][1]); } ctx.lineto(pointlist[0][0], pointlist[0][1]); } else if (style.linetype == 'dashed' || style.linetype == 'dotted') { var dashlength = style._dashlength || (style.linewidth || 1) * (style.linetype == 'dashed' ? 5 : 1); style._dashlength = dashlength; ctx.moveto(pointlist[0][0], pointlist[0][1]); for (var i = 1, l = pointlist.length; i < l; i++) { dashedlineto(ctx, pointlist[i - 1][0], pointlist[i - 1][1], pointlist[i][0], pointlist[i][1], dashlength); } dashedlineto(ctx, pointlist[pointlist.length - 1][0], pointlist[pointlist.length - 1][1], pointlist[0][0], pointlist[0][1], dashlength); } } ctx.closepath(); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } var minx = number.max_value; var maxx = number.min_value; var miny = number.max_value; var maxy = number.min_value; var pointlist = style.pointlist; for (var i = 0, l = pointlist.length; i < l; i++) { if (pointlist[i][0] < minx) { minx = pointlist[i][0]; } if (pointlist[i][0] > maxx) { maxx = pointlist[i][0]; } if (pointlist[i][1] < miny) { miny = pointlist[i][1]; } if (pointlist[i][1] > maxy) { maxy = pointlist[i][1]; } } var linewidth; if (style.brushtype == 'stroke' || style.brushtype == 'fill') { linewidth = style.linewidth || 1; } else { linewidth = 0; } style.__rect = { x: math.round(minx - linewidth / 2), y: math.round(miny - linewidth / 2), width: maxx - minx + linewidth, height: maxy - miny + linewidth }; return style.__rect; } }; require('../tool/util').inherits(polygon, base); return polygon; });define('echarts/util/shape/normaliscover', [], function () { return function (x, y) { var originpos = this.transformcoordtolocal(x, y); x = originpos[0]; y = originpos[1]; return this.iscoverrect(x, y); }; });define('zrender/shape/util/smoothspline', [ 'require', '../../tool/vector' ], function (require) { var vector = require('../../tool/vector'); function interpolate(p0, p1, p2, p3, t, t2, t3) { var v0 = (p2 - p0) * 0.5; var v1 = (p3 - p1) * 0.5; return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1; } return function (points, isloop, constraint) { var len = points.length; var ret = []; var distance = 0; for (var i = 1; i < len; i++) { distance += vector.distance(points[i - 1], points[i]); } var segs = distance / 5; segs = segs < len ? len : segs; for (var i = 0; i < segs; i++) { var pos = i / (segs - 1) * (isloop ? len : len - 1); var idx = math.floor(pos); var w = pos - idx; var p0; var p1 = points[idx % len]; var p2; var p3; if (!isloop) { p0 = points[idx === 0 ? idx : idx - 1]; p2 = points[idx > len - 2 ? len - 1 : idx + 1]; p3 = points[idx > len - 3 ? len - 1 : idx + 2]; } else { p0 = points[(idx - 1 + len) % len]; p2 = points[(idx + 1) % len]; p3 = points[(idx + 2) % len]; } var w2 = w * w; var w3 = w * w2; ret.push([ interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3) ]); } return ret; }; });define('zrender/shape/util/smoothbezier', [ 'require', '../../tool/vector' ], function (require) { var vector = require('../../tool/vector'); return function (points, smooth, isloop, constraint) { var cps = []; var v = []; var v1 = []; var v2 = []; var prevpoint; var nextpoint; var hasconstraint = !!constraint; var min, max; if (hasconstraint) { min = [ infinity, infinity ]; max = [ -infinity, -infinity ]; for (var i = 0, len = points.length; i < len; i++) { vector.min(min, min, points[i]); vector.max(max, max, points[i]); } vector.min(min, min, constraint[0]); vector.max(max, max, constraint[1]); } for (var i = 0, len = points.length; i < len; i++) { var point = points[i]; var prevpoint; var nextpoint; if (isloop) { prevpoint = points[i ? i - 1 : len - 1]; nextpoint = points[(i + 1) % len]; } else { if (i === 0 || i === len - 1) { cps.push(vector.clone(points[i])); continue; } else { prevpoint = points[i - 1]; nextpoint = points[i + 1]; } } vector.sub(v, nextpoint, prevpoint); vector.scale(v, v, smooth); var d0 = vector.distance(point, prevpoint); var d1 = vector.distance(point, nextpoint); var sum = d0 + d1; if (sum !== 0) { d0 /= sum; d1 /= sum; } vector.scale(v1, v, -d0); vector.scale(v2, v, d1); var cp0 = vector.add([], point, v1); var cp1 = vector.add([], point, v2); if (hasconstraint) { vector.max(cp0, cp0, min); vector.min(cp0, cp0, max); vector.max(cp1, cp1, min); vector.min(cp1, cp1, max); } cps.push(cp0); cps.push(cp1); } if (isloop) { cps.push(vector.clone(cps.shift())); } return cps; }; });define('echarts/util/ecquery', [ 'require', 'zrender/tool/util' ], function (require) { var zrutil = require('zrender/tool/util'); function query(optiontarget, optionlocation) { if (typeof optiontarget == 'undefined') { return; } if (!optionlocation) { return optiontarget; } optionlocation = optionlocation.split('.'); var length = optionlocation.length; var curidx = 0; while (curidx < length) { optiontarget = optiontarget[optionlocation[curidx]]; if (typeof optiontarget == 'undefined') { return; } curidx++; } return optiontarget; } function deepquery(ctrlist, optionlocation) { var finaloption; for (var i = 0, l = ctrlist.length; i < l; i++) { finaloption = query(ctrlist[i], optionlocation); if (typeof finaloption != 'undefined') { return finaloption; } } } function deepmerge(ctrlist, optionlocation) { var finaloption; var len = ctrlist.length; while (len--) { var tempoption = query(ctrlist[len], optionlocation); if (typeof tempoption != 'undefined') { if (typeof finaloption == 'undefined') { finaloption = zrutil.clone(tempoption); } else { zrutil.merge(finaloption, tempoption, true); } } } return finaloption; } return { query: query, deepquery: deepquery, deepmerge: deepmerge }; });define('echarts/util/number', [], function () { function _trim(str) { return str.replace(/^\s+/, '').replace(/\s+$/, ''); } function parsepercent(value, maxvalue) { if (typeof value === 'string') { if (_trim(value).match(/%$/)) { return parsefloat(value) / 100 * maxvalue; } return parsefloat(value); } return value; } function parsecenter(zr, center) { return [ parsepercent(center[0], zr.getwidth()), parsepercent(center[1], zr.getheight()) ]; } function parseradius(zr, radius) { if (!(radius instanceof array)) { radius = [ 0, radius ]; } var zrsize = math.min(zr.getwidth(), zr.getheight()) / 2; return [ parsepercent(radius[0], zrsize), parsepercent(radius[1], zrsize) ]; } function addcommas(x) { if (isnan(x)) { return '-'; } x = (x + '').split('.'); return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,') + (x.length > 1 ? '.' + x[1] : ''); } function getprecision(val) { var e = 1; var count = 0; while (math.round(val * e) / e !== val) { e *= 10; count++; } return count; } return { parsepercent: parsepercent, parsecenter: parsecenter, parseradius: parseradius, addcommas: addcommas, getprecision: getprecision }; });define('echarts/data/kdtree', [ 'require', './quickselect' ], function (require) { var quickselect = require('./quickselect'); function node(axis, data) { this.left = null; this.right = null; this.axis = axis; this.data = data; } var kdtree = function (points, dimension) { if (!points.length) { return; } if (!dimension) { dimension = points[0].array.length; } this.dimension = dimension; this.root = this._buildtree(points, 0, points.length - 1, 0); this._stack = []; this._nearstnlist = []; }; kdtree.prototype._buildtree = function (points, left, right, axis) { if (right < left) { return null; } var medianindex = math.floor((left + right) / 2); medianindex = quickselect(points, left, right, medianindex, function (a, b) { return a.array[axis] - b.array[axis]; }); var median = points[medianindex]; var node = new node(axis, median); axis = (axis + 1) % this.dimension; if (right > left) { node.left = this._buildtree(points, left, medianindex - 1, axis); node.right = this._buildtree(points, medianindex + 1, right, axis); } return node; }; kdtree.prototype.nearest = function (target, squareddistance) { var curr = this.root; var stack = this._stack; var idx = 0; var mindist = infinity; var nearestnode = null; if (curr.data !== target) { mindist = squareddistance(curr.data, target); nearestnode = curr; } if (target.array[curr.axis] < curr.data.array[curr.axis]) { curr.right && (stack[idx++] = curr.right); curr.left && (stack[idx++] = curr.left); } else { curr.left && (stack[idx++] = curr.left); curr.right && (stack[idx++] = curr.right); } while (idx--) { curr = stack[idx]; var currdist = target.array[curr.axis] - curr.data.array[curr.axis]; var isleft = currdist < 0; var needscheckotherside = false; currdist = currdist * currdist; if (currdist < mindist) { currdist = squareddistance(curr.data, target); if (currdist < mindist && curr.data !== target) { mindist = currdist; nearestnode = curr; } needscheckotherside = true; } if (isleft) { if (needscheckotherside) { curr.right && (stack[idx++] = curr.right); } curr.left && (stack[idx++] = curr.left); } else { if (needscheckotherside) { curr.left && (stack[idx++] = curr.left); } curr.right && (stack[idx++] = curr.right); } } return nearestnode.data; }; kdtree.prototype._addnearest = function (found, dist, node) { var nearestnlist = this._nearstnlist; for (var i = found - 1; i > 0; i--) { if (dist >= nearestnlist[i - 1].dist) { break; } else { nearestnlist[i].dist = nearestnlist[i - 1].dist; nearestnlist[i].node = nearestnlist[i - 1].node; } } nearestnlist[i].dist = dist; nearestnlist[i].node = node; }; kdtree.prototype.nearestn = function (target, n, squareddistance, output) { if (n <= 0) { output.length = 0; return output; } var curr = this.root; var stack = this._stack; var idx = 0; var nearestnlist = this._nearstnlist; for (var i = 0; i < n; i++) { if (!nearestnlist[i]) { nearestnlist[i] = {}; } nearestnlist[i].dist = 0; nearestnlist[i].node = null; } var currdist = squareddistance(curr.data, target); var found = 0; if (curr.data !== target) { found++; this._addnearest(found, currdist, curr); } if (target.array[curr.axis] < curr.data.array[curr.axis]) { curr.right && (stack[idx++] = curr.right); curr.left && (stack[idx++] = curr.left); } else { curr.left && (stack[idx++] = curr.left); curr.right && (stack[idx++] = curr.right); } while (idx--) { curr = stack[idx]; var currdist = target.array[curr.axis] - curr.data.array[curr.axis]; var isleft = currdist < 0; var needscheckotherside = false; currdist = currdist * currdist; if (found < n || currdist < nearestnlist[found - 1].dist) { currdist = squareddistance(curr.data, target); if ((found < n || currdist < nearestnlist[found - 1].dist) && curr.data !== target) { if (found < n) { found++; } this._addnearest(found, currdist, curr); } needscheckotherside = true; } if (isleft) { if (needscheckotherside) { curr.right && (stack[idx++] = curr.right); } curr.left && (stack[idx++] = curr.left); } else { if (needscheckotherside) { curr.left && (stack[idx++] = curr.left); } curr.right && (stack[idx++] = curr.right); } } for (var i = 0; i < found; i++) { output[i] = nearestnlist[i].node.data; } output.length = found; return output; }; return kdtree; });define('echarts/data/quickselect', ['require'], function (require) { function defaultcomparefunc(a, b) { return a - b; } function swapelement(list, idx0, idx1) { var tmp = list[idx0]; list[idx0] = list[idx1]; list[idx1] = tmp; } function select(list, left, right, nth, comparefunc) { var pivotidx = left; while (right > left) { var pivotidx = math.round((right + left) / 2); var pivotvalue = list[pivotidx]; swapelement(list, pivotidx, right); pivotidx = left; for (var i = left; i <= right - 1; i++) { if (comparefunc(pivotvalue, list[i]) >= 0) { swapelement(list, i, pivotidx); pivotidx++; } } swapelement(list, right, pivotidx); if (pivotidx === nth) { return pivotidx; } else if (pivotidx < nth) { left = pivotidx + 1; } else { right = pivotidx - 1; } } return left; } function quickselect(list, left, right, nth, comparefunc) { if (arguments.length <= 3) { nth = left; if (arguments.length == 2) { comparefunc = defaultcomparefunc; } else { comparefunc = right; } left = 0; right = list.length - 1; } return select(list, left, right, nth, comparefunc); } return quickselect; });define('echarts/component/dataview', [ 'require', './base', '../config', 'zrender/tool/util', '../component' ], function (require) { var base = require('./base'); var ecconfig = require('../config'); var zrutil = require('zrender/tool/util'); function dataview(ectheme, messagecenter, zr, option, mychart) { base.call(this, ectheme, messagecenter, zr, option, mychart); this.dom = mychart.dom; this._tdom = document.createelement('div'); this._textarea = document.createelement('textarea'); this._buttonrefresh = document.createelement('button'); this._buttonrefresh.setattribute('type', 'button'); this._buttonclose = document.createelement('button'); this._buttonclose.setattribute('type', 'button'); this._hasshow = false; this._zrheight = zr.getheight(); this._zrwidth = zr.getwidth(); this._tdom.classname = 'echarts-dataview'; this.hide(); this.dom.firstchild.appendchild(this._tdom); if (window.addeventlistener) { this._tdom.addeventlistener('click', this._stop); this._tdom.addeventlistener('mousewheel', this._stop); this._tdom.addeventlistener('mousemove', this._stop); this._tdom.addeventlistener('mousedown', this._stop); this._tdom.addeventlistener('mouseup', this._stop); this._tdom.addeventlistener('touchstart', this._stop); this._tdom.addeventlistener('touchmove', this._stop); this._tdom.addeventlistener('touchend', this._stop); } else { this._tdom.attachevent('onclick', this._stop); this._tdom.attachevent('onmousewheel', this._stop); this._tdom.attachevent('onmousemove', this._stop); this._tdom.attachevent('onmousedown', this._stop); this._tdom.attachevent('onmouseup', this._stop); } } dataview.prototype = { type: ecconfig.component_type_dataview, _lang: [ 'data view', 'close', 'refresh' ], _gcsstext: 'position:absolute;' + 'display:block;' + 'overflow:hidden;' + 'transition:height 0.8s,background-color 1s;' + '-moz-transition:height 0.8s,background-color 1s;' + '-webkit-transition:height 0.8s,background-color 1s;' + '-o-transition:height 0.8s,background-color 1s;' + 'z-index:1;' + 'left:0;' + 'top:0;', hide: function () { this._sizecsstext = 'width:' + this._zrwidth + 'px;' + 'height:' + 0 + 'px;' + 'background-color:#f0ffff;'; this._tdom.style.csstext = this._gcsstext + this._sizecsstext; }, show: function (newoption) { this._hasshow = true; var lang = this.query(this.option, 'toolbox.feature.dataview.lang') || this._lang; this.option = newoption; this._tdom.innerhtml = '

' + (lang[0] || this._lang[0]) + '

'; var customcontent = this.query(this.option, 'toolbox.feature.dataview.optiontocontent'); if (typeof customcontent != 'function') { this._textarea.value = this._optiontocontent(); } else { this._textarea = document.createelement('div'); this._textarea.innerhtml = customcontent(this.option); } this._textarea.style.csstext = 'display:block;margin:0 0 8px 0;padding:4px 6px;overflow:auto;' + 'width:100%;' + 'height:' + (this._zrheight - 100) + 'px;'; this._tdom.appendchild(this._textarea); this._buttonclose.style.csstext = 'float:right;padding:1px 6px;'; this._buttonclose.innerhtml = lang[1] || this._lang[1]; var self = this; this._buttonclose.onclick = function () { self.hide(); }; this._tdom.appendchild(this._buttonclose); if (this.query(this.option, 'toolbox.feature.dataview.readonly') === false) { this._buttonrefresh.style.csstext = 'float:right;margin-right:10px;padding:1px 6px;'; this._buttonrefresh.innerhtml = lang[2] || this._lang[2]; this._buttonrefresh.onclick = function () { self._save(); }; this._textarea.readonly = false; this._textarea.style.cursor = 'default'; } else { this._buttonrefresh.style.csstext = 'display:none'; this._textarea.readonly = true; this._textarea.style.cursor = 'text'; } this._tdom.appendchild(this._buttonrefresh); this._sizecsstext = 'width:' + this._zrwidth + 'px;' + 'height:' + this._zrheight + 'px;' + 'background-color:#fff;'; this._tdom.style.csstext = this._gcsstext + this._sizecsstext; }, _optiontocontent: function () { var i; var j; var k; var len; var data; var valuelist; var axislist = []; var content = ''; if (this.option.xaxis) { if (this.option.xaxis instanceof array) { axislist = this.option.xaxis; } else { axislist = [this.option.xaxis]; } for (i = 0, len = axislist.length; i < len; i++) { if ((axislist[i].type || 'category') == 'category') { valuelist = []; for (j = 0, k = axislist[i].data.length; j < k; j++) { valuelist.push(this.getdatafromoption(axislist[i].data[j])); } content += valuelist.join(', ') + '\n\n'; } } } if (this.option.yaxis) { if (this.option.yaxis instanceof array) { axislist = this.option.yaxis; } else { axislist = [this.option.yaxis]; } for (i = 0, len = axislist.length; i < len; i++) { if (axislist[i].type == 'category') { valuelist = []; for (j = 0, k = axislist[i].data.length; j < k; j++) { valuelist.push(this.getdatafromoption(axislist[i].data[j])); } content += valuelist.join(', ') + '\n\n'; } } } var series = this.option.series; var itemname; for (i = 0, len = series.length; i < len; i++) { valuelist = []; for (j = 0, k = series[i].data.length; j < k; j++) { data = series[i].data[j]; if (series[i].type == ecconfig.chart_type_pie || series[i].type == ecconfig.chart_type_map) { itemname = (data.name || '-') + ':'; } else { itemname = ''; } if (series[i].type == ecconfig.chart_type_scatter) { data = this.getdatafromoption(data).join(', '); } valuelist.push(itemname + this.getdatafromoption(data)); } content += (series[i].name || '-') + ' : \n'; content += valuelist.join(series[i].type == ecconfig.chart_type_scatter ? '\n' : ', '); content += '\n\n'; } return content; }, _save: function () { var customcontent = this.query(this.option, 'toolbox.feature.dataview.contenttooption'); if (typeof customcontent != 'function') { var text = this._textarea.value.split('\n'); var content = []; for (var i = 0, l = text.length; i < l; i++) { text[i] = this._trim(text[i]); if (text[i] !== '') { content.push(text[i]); } } this._contenttooption(content); } else { customcontent(this._textarea, this.option); } this.hide(); var self = this; settimeout(function () { self.messagecenter && self.messagecenter.dispatch(ecconfig.event.data_view_changed, null, { option: self.option }, self.mychart); }, self.canvassupported ? 800 : 100); }, _contenttooption: function (content) { var i; var j; var k; var len; var data; var axislist = []; var contentidx = 0; var contentvaluelist; var value; if (this.option.xaxis) { if (this.option.xaxis instanceof array) { axislist = this.option.xaxis; } else { axislist = [this.option.xaxis]; } for (i = 0, len = axislist.length; i < len; i++) { if ((axislist[i].type || 'category') == 'category') { contentvaluelist = content[contentidx].split(','); for (j = 0, k = axislist[i].data.length; j < k; j++) { value = this._trim(contentvaluelist[j] || ''); data = axislist[i].data[j]; if (typeof axislist[i].data[j].value != 'undefined') { axislist[i].data[j].value = value; } else { axislist[i].data[j] = value; } } contentidx++; } } } if (this.option.yaxis) { if (this.option.yaxis instanceof array) { axislist = this.option.yaxis; } else { axislist = [this.option.yaxis]; } for (i = 0, len = axislist.length; i < len; i++) { if (axislist[i].type == 'category') { contentvaluelist = content[contentidx].split(','); for (j = 0, k = axislist[i].data.length; j < k; j++) { value = this._trim(contentvaluelist[j] || ''); data = axislist[i].data[j]; if (typeof axislist[i].data[j].value != 'undefined') { axislist[i].data[j].value = value; } else { axislist[i].data[j] = value; } } contentidx++; } } } var series = this.option.series; for (i = 0, len = series.length; i < len; i++) { contentidx++; if (series[i].type == ecconfig.chart_type_scatter) { for (var j = 0, k = series[i].data.length; j < k; j++) { contentvaluelist = content[contentidx]; value = contentvaluelist.replace(' ', '').split(','); if (typeof series[i].data[j].value != 'undefined') { series[i].data[j].value = value; } else { series[i].data[j] = value; } contentidx++; } } else { contentvaluelist = content[contentidx].split(','); for (var j = 0, k = series[i].data.length; j < k; j++) { value = (contentvaluelist[j] || '').replace(/.*:/, ''); value = this._trim(value); value = value != '-' && value !== '' ? value - 0 : '-'; if (typeof series[i].data[j].value != 'undefined') { series[i].data[j].value = value; } else { series[i].data[j] = value; } } contentidx++; } } }, _trim: function (str) { var trimer = new regexp('(^[\\s\\t\\xa0\\u3000]+)|([\\u3000\\xa0\\s\\t]+$)', 'g'); return str.replace(trimer, ''); }, _stop: function (e) { e = e || window.event; if (e.stoppropagation) { e.stoppropagation(); } else { e.cancelbubble = true; } }, resize: function () { this._zrheight = this.zr.getheight(); this._zrwidth = this.zr.getwidth(); if (this._tdom.offsetheight > 10) { this._sizecsstext = 'width:' + this._zrwidth + 'px;' + 'height:' + this._zrheight + 'px;' + 'background-color:#fff;'; this._tdom.style.csstext = this._gcsstext + this._sizecsstext; this._textarea.style.csstext = 'display:block;margin:0 0 8px 0;' + 'padding:4px 6px;overflow:auto;' + 'width:100%;' + 'height:' + (this._zrheight - 100) + 'px;'; } }, dispose: function () { if (window.removeeventlistener) { this._tdom.removeeventlistener('click', this._stop); this._tdom.removeeventlistener('mousewheel', this._stop); this._tdom.removeeventlistener('mousemove', this._stop); this._tdom.removeeventlistener('mousedown', this._stop); this._tdom.removeeventlistener('mouseup', this._stop); this._tdom.removeeventlistener('touchstart', this._stop); this._tdom.removeeventlistener('touchmove', this._stop); this._tdom.removeeventlistener('touchend', this._stop); } else { this._tdom.detachevent('onclick', this._stop); this._tdom.detachevent('onmousewheel', this._stop); this._tdom.detachevent('onmousemove', this._stop); this._tdom.detachevent('onmousedown', this._stop); this._tdom.detachevent('onmouseup', this._stop); } this._buttonrefresh.onclick = null; this._buttonclose.onclick = null; if (this._hasshow) { this._tdom.removechild(this._textarea); this._tdom.removechild(this._buttonrefresh); this._tdom.removechild(this._buttonclose); } this._textarea = null; this._buttonrefresh = null; this._buttonclose = null; this.dom.firstchild.removechild(this._tdom); this._tdom = null; } }; zrutil.inherits(dataview, base); require('../component').define('dataview', dataview); return dataview; });define('echarts/util/shape/cross', [ 'require', 'zrender/shape/base', 'zrender/shape/line', 'zrender/tool/util', './normaliscover' ], function (require) { var base = require('zrender/shape/base'); var lineshape = require('zrender/shape/line'); var zrutil = require('zrender/tool/util'); function cross(options) { base.call(this, options); } cross.prototype = { type: 'cross', buildpath: function (ctx, style) { var rect = style.rect; style.xstart = rect.x; style.xend = rect.x + rect.width; style.ystart = style.yend = style.y; lineshape.prototype.buildpath(ctx, style); style.xstart = style.xend = style.x; style.ystart = rect.y; style.yend = rect.y + rect.height; lineshape.prototype.buildpath(ctx, style); }, getrect: function (style) { return style.rect; }, iscover: require('./normaliscover') }; zrutil.inherits(cross, base); return cross; });define('zrender/shape/sector', [ 'require', '../tool/math', '../tool/computeboundingbox', '../tool/vector', './base', '../tool/util' ], function (require) { var math = require('../tool/math'); var computeboundingbox = require('../tool/computeboundingbox'); var vec2 = require('../tool/vector'); var base = require('./base'); var min0 = vec2.create(); var min1 = vec2.create(); var max0 = vec2.create(); var max1 = vec2.create(); var sector = function (options) { base.call(this, options); }; sector.prototype = { type: 'sector', buildpath: function (ctx, style) { var x = style.x; var y = style.y; var r0 = style.r0 || 0; var r = style.r; var startangle = style.startangle; var endangle = style.endangle; var clockwise = style.clockwise || false; startangle = math.degreetoradian(startangle); endangle = math.degreetoradian(endangle); if (!clockwise) { startangle = -startangle; endangle = -endangle; } var unitx = math.cos(startangle); var unity = math.sin(startangle); ctx.moveto(unitx * r0 + x, unity * r0 + y); ctx.lineto(unitx * r + x, unity * r + y); ctx.arc(x, y, r, startangle, endangle, !clockwise); ctx.lineto(math.cos(endangle) * r0 + x, math.sin(endangle) * r0 + y); if (r0 !== 0) { ctx.arc(x, y, r0, endangle, startangle, clockwise); } ctx.closepath(); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } var x = style.x; var y = style.y; var r0 = style.r0 || 0; var r = style.r; var startangle = math.degreetoradian(style.startangle); var endangle = math.degreetoradian(style.endangle); var clockwise = style.clockwise; if (!clockwise) { startangle = -startangle; endangle = -endangle; } if (r0 > 1) { computeboundingbox.arc(x, y, r0, startangle, endangle, !clockwise, min0, max0); } else { min0[0] = max0[0] = x; min0[1] = max0[1] = y; } computeboundingbox.arc(x, y, r, startangle, endangle, !clockwise, min1, max1); vec2.min(min0, min0, min1); vec2.max(max0, max0, max1); style.__rect = { x: min0[0], y: min0[1], width: max0[0] - min0[0], height: max0[1] - min0[1] }; return style.__rect; } }; require('../tool/util').inherits(sector, base); return sector; });define('echarts/util/shape/candle', [ 'require', 'zrender/shape/base', 'zrender/tool/util', './normaliscover' ], function (require) { var base = require('zrender/shape/base'); var zrutil = require('zrender/tool/util'); function candle(options) { base.call(this, options); } candle.prototype = { type: 'candle', _numberorder: function (a, b) { return b - a; }, buildpath: function (ctx, style) { var ylist = zrutil.clone(style.y).sort(this._numberorder); ctx.moveto(style.x, ylist[3]); ctx.lineto(style.x, ylist[2]); ctx.moveto(style.x - style.width / 2, ylist[2]); ctx.rect(style.x - style.width / 2, ylist[2], style.width, ylist[1] - ylist[2]); ctx.moveto(style.x, ylist[1]); ctx.lineto(style.x, ylist[0]); }, getrect: function (style) { if (!style.__rect) { var linewidth = 0; if (style.brushtype == 'stroke' || style.brushtype == 'fill') { linewidth = style.linewidth || 1; } var ylist = zrutil.clone(style.y).sort(this._numberorder); style.__rect = { x: math.round(style.x - style.width / 2 - linewidth / 2), y: math.round(ylist[3] - linewidth / 2), width: style.width + linewidth, height: ylist[0] - ylist[3] + linewidth }; } return style.__rect; }, iscover: require('./normaliscover') }; zrutil.inherits(candle, base); return candle; });define('zrender/tool/computeboundingbox', [ 'require', './vector', './curve' ], function (require) { var vec2 = require('./vector'); var curve = require('./curve'); function computeboundingbox(points, min, max) { if (points.length === 0) { return; } var left = points[0][0]; var right = points[0][0]; var top = points[0][1]; var bottom = points[0][1]; for (var i = 1; i < points.length; i++) { var p = points[i]; if (p[0] < left) { left = p[0]; } if (p[0] > right) { right = p[0]; } if (p[1] < top) { top = p[1]; } if (p[1] > bottom) { bottom = p[1]; } } min[0] = left; min[1] = top; max[0] = right; max[1] = bottom; } function computecubebezierboundingbox(p0, p1, p2, p3, min, max) { var xdim = []; curve.cubicextrema(p0[0], p1[0], p2[0], p3[0], xdim); for (var i = 0; i < xdim.length; i++) { xdim[i] = curve.cubicat(p0[0], p1[0], p2[0], p3[0], xdim[i]); } var ydim = []; curve.cubicextrema(p0[1], p1[1], p2[1], p3[1], ydim); for (var i = 0; i < ydim.length; i++) { ydim[i] = curve.cubicat(p0[1], p1[1], p2[1], p3[1], ydim[i]); } xdim.push(p0[0], p3[0]); ydim.push(p0[1], p3[1]); var left = math.min.apply(null, xdim); var right = math.max.apply(null, xdim); var top = math.min.apply(null, ydim); var bottom = math.max.apply(null, ydim); min[0] = left; min[1] = top; max[0] = right; max[1] = bottom; } function computequadraticbezierboundingbox(p0, p1, p2, min, max) { var t1 = curve.quadraticextremum(p0[0], p1[0], p2[0]); var t2 = curve.quadraticextremum(p0[1], p1[1], p2[1]); t1 = math.max(math.min(t1, 1), 0); t2 = math.max(math.min(t2, 1), 0); var ct1 = 1 - t1; var ct2 = 1 - t2; var x1 = ct1 * ct1 * p0[0] + 2 * ct1 * t1 * p1[0] + t1 * t1 * p2[0]; var y1 = ct1 * ct1 * p0[1] + 2 * ct1 * t1 * p1[1] + t1 * t1 * p2[1]; var x2 = ct2 * ct2 * p0[0] + 2 * ct2 * t2 * p1[0] + t2 * t2 * p2[0]; var y2 = ct2 * ct2 * p0[1] + 2 * ct2 * t2 * p1[1] + t2 * t2 * p2[1]; min[0] = math.min(p0[0], p2[0], x1, x2); min[1] = math.min(p0[1], p2[1], y1, y2); max[0] = math.max(p0[0], p2[0], x1, x2); max[1] = math.max(p0[1], p2[1], y1, y2); } var start = vec2.create(); var end = vec2.create(); var extremity = vec2.create(); var computearcboundingbox = function (x, y, r, startangle, endangle, anticlockwise, min, max) { if (math.abs(startangle - endangle) >= math.pi * 2) { min[0] = x - r; min[1] = y - r; max[0] = x + r; max[1] = y + r; return; } start[0] = math.cos(startangle) * r + x; start[1] = math.sin(startangle) * r + y; end[0] = math.cos(endangle) * r + x; end[1] = math.sin(endangle) * r + y; vec2.min(min, start, end); vec2.max(max, start, end); startangle = startangle % (math.pi * 2); if (startangle < 0) { startangle = startangle + math.pi * 2; } endangle = endangle % (math.pi * 2); if (endangle < 0) { endangle = endangle + math.pi * 2; } if (startangle > endangle && !anticlockwise) { endangle += math.pi * 2; } else if (startangle < endangle && anticlockwise) { startangle += math.pi * 2; } if (anticlockwise) { var tmp = endangle; endangle = startangle; startangle = tmp; } for (var angle = 0; angle < endangle; angle += math.pi / 2) { if (angle > startangle) { extremity[0] = math.cos(angle) * r + x; extremity[1] = math.sin(angle) * r + y; vec2.min(min, extremity, min); vec2.max(max, extremity, max); } } }; computeboundingbox.cubebezier = computecubebezierboundingbox; computeboundingbox.quadraticbezier = computequadraticbezierboundingbox; computeboundingbox.arc = computearcboundingbox; return computeboundingbox; });define('echarts/util/shape/chain', [ 'require', 'zrender/shape/base', './icon', 'zrender/shape/util/dashedlineto', 'zrender/tool/util', 'zrender/tool/matrix' ], function (require) { var base = require('zrender/shape/base'); var iconshape = require('./icon'); var dashedlineto = require('zrender/shape/util/dashedlineto'); var zrutil = require('zrender/tool/util'); var matrix = require('zrender/tool/matrix'); function chain(options) { base.call(this, options); } chain.prototype = { type: 'chain', brush: function (ctx, ishighlight) { var style = this.style; if (ishighlight) { style = this.gethighlightstyle(style, this.highlightstyle || {}); } ctx.save(); this.setcontext(ctx, style); this.settransform(ctx); ctx.save(); ctx.beginpath(); this.buildlinepath(ctx, style); ctx.stroke(); ctx.restore(); this.brushsymbol(ctx, style); ctx.restore(); return; }, buildlinepath: function (ctx, style) { var x = style.x; var y = style.y + 5; var width = style.width; var height = style.height / 2 - 10; ctx.moveto(x, y); ctx.lineto(x, y + height); ctx.moveto(x + width, y); ctx.lineto(x + width, y + height); ctx.moveto(x, y + height / 2); if (!style.linetype || style.linetype == 'solid') { ctx.lineto(x + width, y + height / 2); } else if (style.linetype == 'dashed' || style.linetype == 'dotted') { var dashlength = (style.linewidth || 1) * (style.linetype == 'dashed' ? 5 : 1); dashedlineto(ctx, x, y + height / 2, x + width, y + height / 2, dashlength); } }, brushsymbol: function (ctx, style) { var y = style.y + style.height / 4; ctx.save(); var chainpoint = style.chainpoint; var curpoint; for (var idx = 0, l = chainpoint.length; idx < l; idx++) { curpoint = chainpoint[idx]; if (curpoint.symbol != 'none') { ctx.beginpath(); var symbolsize = curpoint.symbolsize; iconshape.prototype.buildpath(ctx, { icontype: curpoint.symbol, x: curpoint.x - symbolsize, y: y - symbolsize, width: symbolsize * 2, height: symbolsize * 2, n: curpoint.n }); ctx.fillstyle = curpoint.isempty ? '#fff' : style.strokecolor; ctx.closepath(); ctx.fill(); ctx.stroke(); } if (curpoint.showlabel) { ctx.font = curpoint.textfont; ctx.fillstyle = curpoint.textcolor; ctx.textalign = curpoint.textalign; ctx.textbaseline = curpoint.textbaseline; if (curpoint.rotation) { ctx.save(); this._updatetexttransform(ctx, curpoint.rotation); ctx.filltext(curpoint.name, curpoint.textx, curpoint.texty); ctx.restore(); } else { ctx.filltext(curpoint.name, curpoint.textx, curpoint.texty); } } } ctx.restore(); }, _updatetexttransform: function (ctx, rotation) { var _transform = matrix.create(); matrix.identity(_transform); if (rotation[0] !== 0) { var originx = rotation[1] || 0; var originy = rotation[2] || 0; if (originx || originy) { matrix.translate(_transform, _transform, [ -originx, -originy ]); } matrix.rotate(_transform, _transform, rotation[0]); if (originx || originy) { matrix.translate(_transform, _transform, [ originx, originy ]); } } ctx.transform.apply(ctx, _transform); }, iscover: function (x, y) { var rect = this.style; if (x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height) { return true; } else { return false; } } }; zrutil.inherits(chain, base); return chain; });define('zrender/shape/ring', [ 'require', './base', '../tool/util' ], function (require) { var base = require('./base'); var ring = function (options) { base.call(this, options); }; ring.prototype = { type: 'ring', buildpath: function (ctx, style) { ctx.arc(style.x, style.y, style.r, 0, math.pi * 2, false); ctx.moveto(style.x + style.r0, style.y); ctx.arc(style.x, style.y, style.r0, 0, math.pi * 2, true); return; }, getrect: function (style) { if (style.__rect) { return style.__rect; } var linewidth; if (style.brushtype == 'stroke' || style.brushtype == 'fill') { linewidth = style.linewidth || 1; } else { linewidth = 0; } style.__rect = { x: math.round(style.x - style.r - linewidth / 2), y: math.round(style.y - style.r - linewidth / 2), width: style.r * 2 + linewidth, height: style.r * 2 + linewidth }; return style.__rect; } }; require('../tool/util').inherits(ring, base); return ring; });define('echarts/component/axis', [ 'require', './base', 'zrender/shape/line', '../config', '../util/ecdata', 'zrender/tool/util', 'zrender/tool/color', './categoryaxis', './valueaxis', '../component' ], function (require) { var base = require('./base'); var lineshape = require('zrender/shape/line'); var ecconfig = require('../config'); var ecdata = require('../util/ecdata'); var zrutil = require('zrender/tool/util'); var zrcolor = require('zrender/tool/color'); function axis(ectheme, messagecenter, zr, option, mychart, axistype) { base.call(this, ectheme, messagecenter, zr, option, mychart); this.axistype = axistype; this._axislist = []; this.refresh(option); } axis.prototype = { type: ecconfig.component_type_axis, axisbase: { _buildaxisline: function () { var linewidth = this.option.axisline.linestyle.width; var halflinewidth = linewidth / 2; var axshape = { _axisshape: 'axisline', zlevel: this.getzlevelbase(), z: this.getzbase() + 3, hoverable: false }; var grid = this.grid; switch (this.option.position) { case 'left': axshape.style = { xstart: grid.getx() - halflinewidth, ystart: grid.getyend(), xend: grid.getx() - halflinewidth, yend: grid.gety(), linecap: 'round' }; break; case 'right': axshape.style = { xstart: grid.getxend() + halflinewidth, ystart: grid.getyend(), xend: grid.getxend() + halflinewidth, yend: grid.gety(), linecap: 'round' }; break; case 'bottom': axshape.style = { xstart: grid.getx(), ystart: grid.getyend() + halflinewidth, xend: grid.getxend(), yend: grid.getyend() + halflinewidth, linecap: 'round' }; break; case 'top': axshape.style = { xstart: grid.getx(), ystart: grid.gety() - halflinewidth, xend: grid.getxend(), yend: grid.gety() - halflinewidth, linecap: 'round' }; break; } var style = axshape.style; if (this.option.name !== '') { style.text = this.option.name; style.textposition = this.option.namelocation; style.textfont = this.getfont(this.option.nametextstyle); if (this.option.nametextstyle.align) { style.textalign = this.option.nametextstyle.align; } if (this.option.nametextstyle.baseline) { style.textbaseline = this.option.nametextstyle.baseline; } if (this.option.nametextstyle.color) { style.textcolor = this.option.nametextstyle.color; } } style.strokecolor = this.option.axisline.linestyle.color; style.linewidth = linewidth; if (this.ishorizontal()) { style.ystart = style.yend = this.subpixeloptimize(style.yend, linewidth); } else { style.xstart = style.xend = this.subpixeloptimize(style.xend, linewidth); } style.linetype = this.option.axisline.linestyle.type; axshape = new lineshape(axshape); this.shapelist.push(axshape); }, _axislabelclickable: function (clickable, axshape) { if (clickable) { ecdata.pack(axshape, undefined, -1, undefined, -1, axshape.style.text); axshape.hoverable = true; axshape.clickable = true; axshape.highlightstyle = { color: zrcolor.lift(axshape.style.color, 1), brushtype: 'fill' }; return axshape; } else { return axshape; } }, refixaxisshape: function (zerox, zeroy) { if (!this.option.axisline.onzero) { return; } var ticklength; if (this.ishorizontal() && zeroy != null) { for (var i = 0, l = this.shapelist.length; i < l; i++) { if (this.shapelist[i]._axisshape === 'axisline') { this.shapelist[i].style.ystart = this.shapelist[i].style.yend = this.subpixeloptimize(zeroy, this.shapelist[i].stylelinewidth); this.zr.modshape(this.shapelist[i].id); } else if (this.shapelist[i]._axisshape === 'axistick') { ticklength = this.shapelist[i].style.yend - this.shapelist[i].style.ystart; this.shapelist[i].style.ystart = zeroy - ticklength; this.shapelist[i].style.yend = zeroy; this.zr.modshape(this.shapelist[i].id); } } } if (!this.ishorizontal() && zerox != null) { for (var i = 0, l = this.shapelist.length; i < l; i++) { if (this.shapelist[i]._axisshape === 'axisline') { this.shapelist[i].style.xstart = this.shapelist[i].style.xend = this.subpixeloptimize(zerox, this.shapelist[i].stylelinewidth); this.zr.modshape(this.shapelist[i].id); } else if (this.shapelist[i]._axisshape === 'axistick') { ticklength = this.shapelist[i].style.xend - this.shapelist[i].style.xstart; this.shapelist[i].style.xstart = zerox; this.shapelist[i].style.xend = zerox + ticklength; this.zr.modshape(this.shapelist[i].id); } } } }, getposition: function () { return this.option.position; }, ishorizontal: function () { return this.option.position === 'bottom' || this.option.position === 'top'; } }, reformoption: function (opt) { if (!opt || opt instanceof array && opt.length === 0) { opt = [{ type: ecconfig.component_type_axis_value }]; } else if (!(opt instanceof array)) { opt = [opt]; } if (opt.length > 2) { opt = [ opt[0], opt[1] ]; } if (this.axistype === 'xaxis') { if (!opt[0].position || opt[0].position != 'bottom' && opt[0].position != 'top') { opt[0].position = 'bottom'; } if (opt.length > 1) { opt[1].position = opt[0].position === 'bottom' ? 'top' : 'bottom'; } for (var i = 0, l = opt.length; i < l; i++) { opt[i].type = opt[i].type || 'category'; opt[i].xaxisindex = i; opt[i].yaxisindex = -1; } } else { if (!opt[0].position || opt[0].position != 'left' && opt[0].position != 'right') { opt[0].position = 'left'; } if (opt.length > 1) { opt[1].position = opt[0].position === 'left' ? 'right' : 'left'; } for (var i = 0, l = opt.length; i < l; i++) { opt[i].type = opt[i].type || 'value'; opt[i].xaxisindex = -1; opt[i].yaxisindex = i; } } return opt; }, refresh: function (newoption) { var axisoption; if (newoption) { this.option = newoption; if (this.axistype === 'xaxis') { this.option.xaxis = this.reformoption(newoption.xaxis); axisoption = this.option.xaxis; } else { this.option.yaxis = this.reformoption(newoption.yaxis); axisoption = this.option.yaxis; } this.series = newoption.series; } var categoryaxis = require('./categoryaxis'); var valueaxis = require('./valueaxis'); var len = math.max(axisoption && axisoption.length || 0, this._axislist.length); for (var i = 0; i < len; i++) { if (this._axislist[i] && newoption && (!axisoption[i] || this._axislist[i].type != axisoption[i].type)) { this._axislist[i].dispose && this._axislist[i].dispose(); this._axislist[i] = false; } if (this._axislist[i]) { this._axislist[i].refresh && this._axislist[i].refresh(axisoption ? axisoption[i] : false, this.series); } else if (axisoption && axisoption[i]) { this._axislist[i] = axisoption[i].type === 'category' ? new categoryaxis(this.ectheme, this.messagecenter, this.zr, axisoption[i], this.mychart, this.axisbase) : new valueaxis(this.ectheme, this.messagecenter, this.zr, axisoption[i], this.mychart, this.axisbase, this.series); } } }, getaxis: function (idx) { return this._axislist[idx]; }, getaxiscount: function () { return this._axislist.length; }, clear: function () { for (var i = 0, l = this._axislist.length; i < l; i++) { this._axislist[i].dispose && this._axislist[i].dispose(); } this._axislist = []; } }; zrutil.inherits(axis, base); require('../component').define('axis', axis); return axis; });define('echarts/component/grid', [ 'require', './base', 'zrender/shape/rectangle', '../config', 'zrender/tool/util', '../component' ], function (require) { var base = require('./base'); var rectangleshape = require('zrender/shape/rectangle'); var ecconfig = require('../config'); ecconfig.grid = { zlevel: 0, z: 0, x: 80, y: 60, x2: 80, y2: 60, backgroundcolor: 'rgba(0,0,0,0)', borderwidth: 1, bordercolor: '#ccc' }; var zrutil = require('zrender/tool/util'); function grid(ectheme, messagecenter, zr, option, mychart) { base.call(this, ectheme, messagecenter, zr, option, mychart); this.refresh(option); } grid.prototype = { type: ecconfig.component_type_grid, getx: function () { return this._x; }, gety: function () { return this._y; }, getwidth: function () { return this._width; }, getheight: function () { return this._height; }, getxend: function () { return this._x + this._width; }, getyend: function () { return this._y + this._height; }, getarea: function () { return { x: this._x, y: this._y, width: this._width, height: this._height }; }, getbbox: function () { return [ [ this._x, this._y ], [ this.getxend(), this.getyend() ] ]; }, refixaxisshape: function (component) { var zerox; var zeroy; var axislist = component.xaxis._axislist.concat(component.yaxis ? component.yaxis._axislist : []); var len = axislist.length; var axis; while (len--) { axis = axislist[len]; if (axis.type == ecconfig.component_type_axis_value && axis._min < 0 && axis._max >= 0) { axis.ishorizontal() ? zerox = axis.getcoord(0) : zeroy = axis.getcoord(0); } } if (typeof zerox != 'undefined' || typeof zeroy != 'undefined') { len = axislist.length; while (len--) { axislist[len].refixaxisshape(zerox, zeroy); } } }, refresh: function (newoption) { if (newoption || this._zrwidth != this.zr.getwidth() || this._zrheight != this.zr.getheight()) { this.clear(); this.option = newoption || this.option; this.option.grid = this.reformoption(this.option.grid); var gridoption = this.option.grid; this._zrwidth = this.zr.getwidth(); this._zrheight = this.zr.getheight(); this._x = this.parsepercent(gridoption.x, this._zrwidth); this._y = this.parsepercent(gridoption.y, this._zrheight); var x2 = this.parsepercent(gridoption.x2, this._zrwidth); var y2 = this.parsepercent(gridoption.y2, this._zrheight); if (typeof gridoption.width == 'undefined') { this._width = this._zrwidth - this._x - x2; } else { this._width = this.parsepercent(gridoption.width, this._zrwidth); } this._width = this._width <= 0 ? 10 : this._width; if (typeof gridoption.height == 'undefined') { this._height = this._zrheight - this._y - y2; } else { this._height = this.parsepercent(gridoption.height, this._zrheight); } this._height = this._height <= 0 ? 10 : this._height; this._x = this.subpixeloptimize(this._x, gridoption.borderwidth); this._y = this.subpixeloptimize(this._y, gridoption.borderwidth); this.shapelist.push(new rectangleshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this._x, y: this._y, width: this._width, height: this._height, brushtype: gridoption.borderwidth > 0 ? 'both' : 'fill', color: gridoption.backgroundcolor, strokecolor: gridoption.bordercolor, linewidth: gridoption.borderwidth } })); this.zr.addshape(this.shapelist[0]); } } }; zrutil.inherits(grid, base); require('../component').define('grid', grid); return grid; });define('echarts/component/datazoom', [ 'require', './base', 'zrender/shape/rectangle', 'zrender/shape/polygon', '../util/shape/icon', '../config', '../util/date', 'zrender/tool/util', '../component' ], function (require) { var base = require('./base'); var rectangleshape = require('zrender/shape/rectangle'); var polygonshape = require('zrender/shape/polygon'); var iconshape = require('../util/shape/icon'); var ecconfig = require('../config'); ecconfig.datazoom = { zlevel: 0, z: 4, show: false, orient: 'horizontal', backgroundcolor: 'rgba(0,0,0,0)', databackgroundcolor: '#eee', fillercolor: 'rgba(144,197,237,0.2)', handlecolor: 'rgba(70,130,180,0.8)', handlesize: 8, showdetail: true, realtime: true }; var ecdate = require('../util/date'); var zrutil = require('zrender/tool/util'); function datazoom(ectheme, messagecenter, zr, option, mychart) { base.call(this, ectheme, messagecenter, zr, option, mychart); var self = this; self._ondrift = function (dx, dy) { return self.__ondrift(this, dx, dy); }; self._ondragend = function () { return self.__ondragend(); }; this._fillersize = 30; this._issilence = false; this._zoom = {}; this.option.datazoom = this.reformoption(this.option.datazoom); this.zoomoption = this.option.datazoom; this._handlesize = this.zoomoption.handlesize; if (!this.mychart.canvassupported) { this.zoomoption.realtime = false; } this._location = this._getlocation(); this._zoom = this._getzoom(); this._backupdata(); if (this.option.datazoom.show) { this._buildshape(); } this._syncdata(); } datazoom.prototype = { type: ecconfig.component_type_datazoom, _buildshape: function () { this._buildbackground(); this._buildfiller(); this._buildhandle(); this._buildframe(); for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } this._syncframeshape(); }, _getlocation: function () { var x; var y; var width; var height; var grid = this.component.grid; if (this.zoomoption.orient == 'horizontal') { width = this.zoomoption.width || grid.getwidth(); height = this.zoomoption.height || this._fillersize; x = this.zoomoption.x != null ? this.zoomoption.x : grid.getx(); y = this.zoomoption.y != null ? this.zoomoption.y : this.zr.getheight() - height - 2; } else { width = this.zoomoption.width || this._fillersize; height = this.zoomoption.height || grid.getheight(); x = this.zoomoption.x != null ? this.zoomoption.x : 2; y = this.zoomoption.y != null ? this.zoomoption.y : grid.gety(); } return { x: x, y: y, width: width, height: height }; }, _getzoom: function () { var series = this.option.series; var xaxis = this.option.xaxis; if (xaxis && !(xaxis instanceof array)) { xaxis = [xaxis]; this.option.xaxis = xaxis; } var yaxis = this.option.yaxis; if (yaxis && !(yaxis instanceof array)) { yaxis = [yaxis]; this.option.yaxis = yaxis; } var zoomseriesindex = []; var xaxisindex; var yaxisindex; var zoptidx = this.zoomoption.xaxisindex; if (xaxis && zoptidx == null) { xaxisindex = []; for (var i = 0, l = xaxis.length; i < l; i++) { if (xaxis[i].type == 'category' || xaxis[i].type == null) { xaxisindex.push(i); } } } else { if (zoptidx instanceof array) { xaxisindex = zoptidx; } else if (zoptidx != null) { xaxisindex = [zoptidx]; } else { xaxisindex = []; } } zoptidx = this.zoomoption.yaxisindex; if (yaxis && zoptidx == null) { yaxisindex = []; for (var i = 0, l = yaxis.length; i < l; i++) { if (yaxis[i].type == 'category') { yaxisindex.push(i); } } } else { if (zoptidx instanceof array) { yaxisindex = zoptidx; } else if (zoptidx != null) { yaxisindex = [zoptidx]; } else { yaxisindex = []; } } var serie; for (var i = 0, l = series.length; i < l; i++) { serie = series[i]; if (serie.type != ecconfig.chart_type_line && serie.type != ecconfig.chart_type_bar && serie.type != ecconfig.chart_type_scatter && serie.type != ecconfig.chart_type_k) { continue; } for (var j = 0, k = xaxisindex.length; j < k; j++) { if (xaxisindex[j] == (serie.xaxisindex || 0)) { zoomseriesindex.push(i); break; } } for (var j = 0, k = yaxisindex.length; j < k; j++) { if (yaxisindex[j] == (serie.yaxisindex || 0)) { zoomseriesindex.push(i); break; } } if (this.zoomoption.xaxisindex == null && this.zoomoption.yaxisindex == null && serie.data && this.getdatafromoption(serie.data[0]) instanceof array && (serie.type == ecconfig.chart_type_scatter || serie.type == ecconfig.chart_type_line || serie.type == ecconfig.chart_type_bar)) { zoomseriesindex.push(i); } } var start = this._zoom.start != null ? this._zoom.start : this.zoomoption.start != null ? this.zoomoption.start : 0; var end = this._zoom.end != null ? this._zoom.end : this.zoomoption.end != null ? this.zoomoption.end : 100; if (start > end) { start = start + end; end = start - end; start = start - end; } var size = math.round((end - start) / 100 * (this.zoomoption.orient == 'horizontal' ? this._location.width : this._location.height)); return { start: start, end: end, start2: 0, end2: 100, size: size, xaxisindex: xaxisindex, yaxisindex: yaxisindex, seriesindex: zoomseriesindex, scattermap: this._zoom.scattermap || {} }; }, _backupdata: function () { this._originaldata = { xaxis: {}, yaxis: {}, series: {} }; var xaxis = this.option.xaxis; var xaxisindex = this._zoom.xaxisindex; for (var i = 0, l = xaxisindex.length; i < l; i++) { this._originaldata.xaxis[xaxisindex[i]] = xaxis[xaxisindex[i]].data; } var yaxis = this.option.yaxis; var yaxisindex = this._zoom.yaxisindex; for (var i = 0, l = yaxisindex.length; i < l; i++) { this._originaldata.yaxis[yaxisindex[i]] = yaxis[yaxisindex[i]].data; } var series = this.option.series; var seriesindex = this._zoom.seriesindex; var serie; for (var i = 0, l = seriesindex.length; i < l; i++) { serie = series[seriesindex[i]]; this._originaldata.series[seriesindex[i]] = serie.data; if (serie.data && this.getdatafromoption(serie.data[0]) instanceof array && (serie.type == ecconfig.chart_type_scatter || serie.type == ecconfig.chart_type_line || serie.type == ecconfig.chart_type_bar)) { this._backupscale(); this._calculscattermap(seriesindex[i]); } } }, _calculscattermap: function (seriesindex) { this._zoom.scattermap = this._zoom.scattermap || {}; this._zoom.scattermap[seriesindex] = this._zoom.scattermap[seriesindex] || {}; var componentlibrary = require('../component'); var axis = componentlibrary.get('axis'); var axisoption = zrutil.clone(this.option.xaxis); if (axisoption[0].type == 'category') { axisoption[0].type = 'value'; } if (axisoption[1] && axisoption[1].type == 'category') { axisoption[1].type = 'value'; } var vaxis = new axis(this.ectheme, null, false, { xaxis: axisoption, series: this.option.series }, this, 'xaxis'); var axisindex = this.option.series[seriesindex].xaxisindex || 0; this._zoom.scattermap[seriesindex].x = vaxis.getaxis(axisindex).getextremum(); vaxis.dispose(); axisoption = zrutil.clone(this.option.yaxis); if (axisoption[0].type == 'category') { axisoption[0].type = 'value'; } if (axisoption[1] && axisoption[1].type == 'category') { axisoption[1].type = 'value'; } vaxis = new axis(this.ectheme, null, false, { yaxis: axisoption, series: this.option.series }, this, 'yaxis'); axisindex = this.option.series[seriesindex].yaxisindex || 0; this._zoom.scattermap[seriesindex].y = vaxis.getaxis(axisindex).getextremum(); vaxis.dispose(); }, _buildbackground: function () { var width = this._location.width; var height = this._location.height; this.shapelist.push(new rectangleshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this._location.x, y: this._location.y, width: width, height: height, color: this.zoomoption.backgroundcolor } })); var maxlength = 0; var xaxis = this._originaldata.xaxis; var xaxisindex = this._zoom.xaxisindex; for (var i = 0, l = xaxisindex.length; i < l; i++) { maxlength = math.max(maxlength, xaxis[xaxisindex[i]].length); } var yaxis = this._originaldata.yaxis; var yaxisindex = this._zoom.yaxisindex; for (var i = 0, l = yaxisindex.length; i < l; i++) { maxlength = math.max(maxlength, yaxis[yaxisindex[i]].length); } var seriesindex = this._zoom.seriesindex[0]; var data = this._originaldata.series[seriesindex]; var maxvalue = number.min_value; var minvalue = number.max_value; var value; for (var i = 0, l = data.length; i < l; i++) { value = this.getdatafromoption(data[i], 0); if (this.option.series[seriesindex].type == ecconfig.chart_type_k) { value = value[1]; } if (isnan(value)) { value = 0; } maxvalue = math.max(maxvalue, value); minvalue = math.min(minvalue, value); } var valuerange = maxvalue - minvalue; var pointlist = []; var x = width / (maxlength - (maxlength > 1 ? 1 : 0)); var y = height / (maxlength - (maxlength > 1 ? 1 : 0)); var step = 1; if (this.zoomoption.orient == 'horizontal' && x < 1) { step = math.floor(maxlength * 3 / width); } else if (this.zoomoption.orient == 'vertical' && y < 1) { step = math.floor(maxlength * 3 / height); } for (var i = 0, l = maxlength; i < l; i += step) { value = this.getdatafromoption(data[i], 0); if (this.option.series[seriesindex].type == ecconfig.chart_type_k) { value = value[1]; } if (isnan(value)) { value = 0; } if (this.zoomoption.orient == 'horizontal') { pointlist.push([ this._location.x + x * i, this._location.y + height - 1 - math.round((value - minvalue) / valuerange * (height - 10)) ]); } else { pointlist.push([ this._location.x + 1 + math.round((value - minvalue) / valuerange * (width - 10)), this._location.y + y * (l - i - 1) ]); } } if (this.zoomoption.orient == 'horizontal') { pointlist.push([ this._location.x + width, this._location.y + height ]); pointlist.push([ this._location.x, this._location.y + height ]); } else { pointlist.push([ this._location.x, this._location.y ]); pointlist.push([ this._location.x, this._location.y + height ]); } this.shapelist.push(new polygonshape({ zlevel: this.getzlevelbase(), z: this.getzbase(), style: { pointlist: pointlist, color: this.zoomoption.databackgroundcolor }, hoverable: false })); }, _buildfiller: function () { this._fillershae = { zlevel: this.getzlevelbase(), z: this.getzbase(), draggable: true, ondrift: this._ondrift, ondragend: this._ondragend, _type: 'filler' }; if (this.zoomoption.orient == 'horizontal') { this._fillershae.style = { x: this._location.x + math.round(this._zoom.start / 100 * this._location.width) + this._handlesize, y: this._location.y, width: this._zoom.size - this._handlesize * 2, height: this._location.height, color: this.zoomoption.fillercolor, text: ':::', textposition: 'inside' }; } else { this._fillershae.style = { x: this._location.x, y: this._location.y + math.round(this._zoom.start / 100 * this._location.height) + this._handlesize, width: this._location.width, height: this._zoom.size - this._handlesize * 2, color: this.zoomoption.fillercolor, text: '::', textposition: 'inside' }; } this._fillershae.highlightstyle = { brushtype: 'fill', color: 'rgba(0,0,0,0)' }; this._fillershae = new rectangleshape(this._fillershae); this.shapelist.push(this._fillershae); }, _buildhandle: function () { var detail = this.zoomoption.showdetail ? this._getdetail() : { start: '', end: '' }; this._startshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), draggable: true, style: { icontype: 'rectangle', x: this._location.x, y: this._location.y, width: this._handlesize, height: this._handlesize, color: this.zoomoption.handlecolor, text: '=', textposition: 'inside' }, highlightstyle: { text: detail.start, brushtype: 'fill', textposition: 'left' }, ondrift: this._ondrift, ondragend: this._ondragend }; if (this.zoomoption.orient == 'horizontal') { this._startshape.style.height = this._location.height; this._endshape = zrutil.clone(this._startshape); this._startshape.style.x = this._fillershae.style.x - this._handlesize, this._endshape.style.x = this._fillershae.style.x + this._fillershae.style.width; this._endshape.highlightstyle.text = detail.end; this._endshape.highlightstyle.textposition = 'right'; } else { this._startshape.style.width = this._location.width; this._endshape = zrutil.clone(this._startshape); this._startshape.style.y = this._fillershae.style.y + this._fillershae.style.height; this._startshape.highlightstyle.textposition = 'bottom'; this._endshape.style.y = this._fillershae.style.y - this._handlesize; this._endshape.highlightstyle.text = detail.end; this._endshape.highlightstyle.textposition = 'top'; } this._startshape = new iconshape(this._startshape); this._endshape = new iconshape(this._endshape); this.shapelist.push(this._startshape); this.shapelist.push(this._endshape); }, _buildframe: function () { var x = this.subpixeloptimize(this._location.x, 1); var y = this.subpixeloptimize(this._location.y, 1); this._startframeshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: x, y: y, width: this._location.width - (x > this._location.x ? 1 : 0), height: this._location.height - (y > this._location.y ? 1 : 0), linewidth: 1, brushtype: 'stroke', strokecolor: this.zoomoption.handlecolor } }; this._endframeshape = zrutil.clone(this._startframeshape); this._startframeshape = new rectangleshape(this._startframeshape); this._endframeshape = new rectangleshape(this._endframeshape); this.shapelist.push(this._startframeshape); this.shapelist.push(this._endframeshape); return; }, _synchandleshape: function () { if (this.zoomoption.orient == 'horizontal') { this._startshape.style.x = this._fillershae.style.x - this._handlesize; this._endshape.style.x = this._fillershae.style.x + this._fillershae.style.width; this._zoom.start = (this._startshape.style.x - this._location.x) / this._location.width * 100; this._zoom.end = (this._endshape.style.x + this._handlesize - this._location.x) / this._location.width * 100; } else { this._startshape.style.y = this._fillershae.style.y + this._fillershae.style.height; this._endshape.style.y = this._fillershae.style.y - this._handlesize; this._zoom.start = (this._location.y + this._location.height - this._startshape.style.y) / this._location.height * 100; this._zoom.end = (this._location.y + this._location.height - this._endshape.style.y - this._handlesize) / this._location.height * 100; } this.zr.modshape(this._startshape.id); this.zr.modshape(this._endshape.id); this._syncframeshape(); this.zr.refreshnextframe(); }, _syncfillershape: function () { var a; var b; if (this.zoomoption.orient == 'horizontal') { a = this._startshape.style.x; b = this._endshape.style.x; this._fillershae.style.x = math.min(a, b) + this._handlesize; this._fillershae.style.width = math.abs(a - b) - this._handlesize; this._zoom.start = (math.min(a, b) - this._location.x) / this._location.width * 100; this._zoom.end = (math.max(a, b) + this._handlesize - this._location.x) / this._location.width * 100; } else { a = this._startshape.style.y; b = this._endshape.style.y; this._fillershae.style.y = math.min(a, b) + this._handlesize; this._fillershae.style.height = math.abs(a - b) - this._handlesize; this._zoom.start = (this._location.y + this._location.height - math.max(a, b)) / this._location.height * 100; this._zoom.end = (this._location.y + this._location.height - math.min(a, b) - this._handlesize) / this._location.height * 100; } this.zr.modshape(this._fillershae.id); this._syncframeshape(); this.zr.refreshnextframe(); }, _syncframeshape: function () { if (this.zoomoption.orient == 'horizontal') { this._startframeshape.style.width = this._fillershae.style.x - this._location.x; this._endframeshape.style.x = this._fillershae.style.x + this._fillershae.style.width; this._endframeshape.style.width = this._location.x + this._location.width - this._endframeshape.style.x; } else { this._startframeshape.style.y = this._fillershae.style.y + this._fillershae.style.height; this._startframeshape.style.height = this._location.y + this._location.height - this._startframeshape.style.y; this._endframeshape.style.height = this._fillershae.style.y - this._location.y; } this.zr.modshape(this._startframeshape.id); this.zr.modshape(this._endframeshape.id); }, _syncshape: function () { if (!this.zoomoption.show) { return; } if (this.zoomoption.orient == 'horizontal') { this._startshape.style.x = this._location.x + this._zoom.start / 100 * this._location.width; this._endshape.style.x = this._location.x + this._zoom.end / 100 * this._location.width - this._handlesize; this._fillershae.style.x = this._startshape.style.x + this._handlesize; this._fillershae.style.width = this._endshape.style.x - this._startshape.style.x - this._handlesize; } else { this._startshape.style.y = this._location.y + this._location.height - this._zoom.start / 100 * this._location.height; this._endshape.style.y = this._location.y + this._location.height - this._zoom.end / 100 * this._location.height - this._handlesize; this._fillershae.style.y = this._endshape.style.y + this._handlesize; this._fillershae.style.height = this._startshape.style.y - this._endshape.style.y - this._handlesize; } this.zr.modshape(this._startshape.id); this.zr.modshape(this._endshape.id); this.zr.modshape(this._fillershae.id); this._syncframeshape(); this.zr.refresh(); }, _syncdata: function (dispatchnow) { var target; var start; var end; var length; var data; for (var key in this._originaldata) { target = this._originaldata[key]; for (var idx in target) { data = target[idx]; if (data == null) { continue; } length = data.length; start = math.floor(this._zoom.start / 100 * length); end = math.ceil(this._zoom.end / 100 * length); if (!(this.getdatafromoption(data[0]) instanceof array) || this.option[key][idx].type == ecconfig.chart_type_k) { this.option[key][idx].data = data.slice(start, end); } else { this._setscale(); this.option[key][idx].data = this._synscatterdata(idx, data); } } } if (!this._issilence && (this.zoomoption.realtime || dispatchnow)) { this.messagecenter.dispatch(ecconfig.event.data_zoom, null, { zoom: this._zoom }, this.mychart); } }, _synscatterdata: function (seriesindex, data) { if (this._zoom.start === 0 && this._zoom.end == 100 && this._zoom.start2 === 0 && this._zoom.end2 == 100) { return data; } var newdata = []; var scale = this._zoom.scattermap[seriesindex]; var total; var xstart; var xend; var ystart; var yend; if (this.zoomoption.orient == 'horizontal') { total = scale.x.max - scale.x.min; xstart = this._zoom.start / 100 * total + scale.x.min; xend = this._zoom.end / 100 * total + scale.x.min; total = scale.y.max - scale.y.min; ystart = this._zoom.start2 / 100 * total + scale.y.min; yend = this._zoom.end2 / 100 * total + scale.y.min; } else { total = scale.x.max - scale.x.min; xstart = this._zoom.start2 / 100 * total + scale.x.min; xend = this._zoom.end2 / 100 * total + scale.x.min; total = scale.y.max - scale.y.min; ystart = this._zoom.start / 100 * total + scale.y.min; yend = this._zoom.end / 100 * total + scale.y.min; } var datamappingmethods; if (datamappingmethods = scale.x.datamappingmethods) { xstart = datamappingmethods.coord2value(xstart); xend = datamappingmethods.coord2value(xend); } if (datamappingmethods = scale.y.datamappingmethods) { ystart = datamappingmethods.coord2value(ystart); yend = datamappingmethods.coord2value(yend); } var value; for (var i = 0, l = data.length; i < l; i++) { value = data[i].value || data[i]; if (value[0] >= xstart && value[0] <= xend && value[1] >= ystart && value[1] <= yend) { newdata.push(data[i]); } } return newdata; }, _setscale: function () { var needscale = this._zoom.start !== 0 || this._zoom.end !== 100 || this._zoom.start2 !== 0 || this._zoom.end2 !== 100; var axis = { xaxis: this.option.xaxis, yaxis: this.option.yaxis }; for (var key in axis) { for (var i = 0, l = axis[key].length; i < l; i++) { axis[key][i].scale = needscale || axis[key][i]._scale; } } }, _backupscale: function () { var axis = { xaxis: this.option.xaxis, yaxis: this.option.yaxis }; for (var key in axis) { for (var i = 0, l = axis[key].length; i < l; i++) { axis[key][i]._scale = axis[key][i].scale; } } }, _getdetail: function () { var key = [ 'xaxis', 'yaxis' ]; for (var i = 0, l = key.length; i < l; i++) { var target = this._originaldata[key[i]]; for (var idx in target) { var data = target[idx]; if (data == null) { continue; } var length = data.length; var start = math.floor(this._zoom.start / 100 * length); var end = math.ceil(this._zoom.end / 100 * length); end -= end > 0 ? 1 : 0; return { start: this.getdatafromoption(data[start]), end: this.getdatafromoption(data[end]) }; } } key = this.zoomoption.orient == 'horizontal' ? 'xaxis' : 'yaxis'; var seriesindex = this._zoom.seriesindex[0]; var axisindex = this.option.series[seriesindex][key + 'index'] || 0; var axistype = this.option[key][axisindex].type; var min = this._zoom.scattermap[seriesindex][key.charat(0)].min; var max = this._zoom.scattermap[seriesindex][key.charat(0)].max; var gap = max - min; if (axistype == 'value') { return { start: min + gap * this._zoom.start / 100, end: min + gap * this._zoom.end / 100 }; } else if (axistype == 'time') { max = min + gap * this._zoom.end / 100; min = min + gap * this._zoom.start / 100; var formatter = ecdate.getautoformatter(min, max).formatter; return { start: ecdate.format(formatter, min), end: ecdate.format(formatter, max) }; } return { start: '', end: '' }; }, __ondrift: function (shape, dx, dy) { if (this.zoomoption.zoomlock) { shape = this._fillershae; } var detailsize = shape._type == 'filler' ? this._handlesize : 0; if (this.zoomoption.orient == 'horizontal') { if (shape.style.x + dx - detailsize <= this._location.x) { shape.style.x = this._location.x + detailsize; } else if (shape.style.x + dx + shape.style.width + detailsize >= this._location.x + this._location.width) { shape.style.x = this._location.x + this._location.width - shape.style.width - detailsize; } else { shape.style.x += dx; } } else { if (shape.style.y + dy - detailsize <= this._location.y) { shape.style.y = this._location.y + detailsize; } else if (shape.style.y + dy + shape.style.height + detailsize >= this._location.y + this._location.height) { shape.style.y = this._location.y + this._location.height - shape.style.height - detailsize; } else { shape.style.y += dy; } } if (shape._type == 'filler') { this._synchandleshape(); } else { this._syncfillershape(); } if (this.zoomoption.realtime) { this._syncdata(); } if (this.zoomoption.showdetail) { var detail = this._getdetail(); this._startshape.style.text = this._startshape.highlightstyle.text = detail.start; this._endshape.style.text = this._endshape.highlightstyle.text = detail.end; this._startshape.style.textposition = this._startshape.highlightstyle.textposition; this._endshape.style.textposition = this._endshape.highlightstyle.textposition; } return true; }, __ondragend: function () { if (this.zoomoption.showdetail) { this._startshape.style.text = this._endshape.style.text = '='; this._startshape.style.textposition = this._endshape.style.textposition = 'inside'; this.zr.modshape(this._startshape.id); this.zr.modshape(this._endshape.id); this.zr.refreshnextframe(); } this.isdragend = true; }, ondragend: function (param, status) { if (!this.isdragend || !param.target) { return; } !this.zoomoption.realtime && this._syncdata(); status.dragout = true; status.dragin = true; if (!this._issilence && !this.zoomoption.realtime) { this.messagecenter.dispatch(ecconfig.event.data_zoom, null, { zoom: this._zoom }, this.mychart); } status.needrefresh = false; this.isdragend = false; return; }, ondatazoom: function (param, status) { status.needrefresh = true; return; }, absolutezoom: function (param) { this._zoom.start = param.start; this._zoom.end = param.end; this._zoom.start2 = param.start2; this._zoom.end2 = param.end2; this._syncshape(); this._syncdata(true); return; }, rectzoom: function (param) { if (!param) { this._zoom.start = this._zoom.start2 = 0; this._zoom.end = this._zoom.end2 = 100; this._syncshape(); this._syncdata(true); return this._zoom; } var gridarea = this.component.grid.getarea(); var rect = { x: param.x, y: param.y, width: param.width, height: param.height }; if (rect.width < 0) { rect.x += rect.width; rect.width = -rect.width; } if (rect.height < 0) { rect.y += rect.height; rect.height = -rect.height; } if (rect.x > gridarea.x + gridarea.width || rect.y > gridarea.y + gridarea.height) { return false; } if (rect.x < gridarea.x) { rect.x = gridarea.x; } if (rect.x + rect.width > gridarea.x + gridarea.width) { rect.width = gridarea.x + gridarea.width - rect.x; } if (rect.y + rect.height > gridarea.y + gridarea.height) { rect.height = gridarea.y + gridarea.height - rect.y; } var total; var sdx = (rect.x - gridarea.x) / gridarea.width; var edx = 1 - (rect.x + rect.width - gridarea.x) / gridarea.width; var sdy = 1 - (rect.y + rect.height - gridarea.y) / gridarea.height; var edy = (rect.y - gridarea.y) / gridarea.height; if (this.zoomoption.orient == 'horizontal') { total = this._zoom.end - this._zoom.start; this._zoom.start += total * sdx; this._zoom.end -= total * edx; total = this._zoom.end2 - this._zoom.start2; this._zoom.start2 += total * sdy; this._zoom.end2 -= total * edy; } else { total = this._zoom.end - this._zoom.start; this._zoom.start += total * sdy; this._zoom.end -= total * edy; total = this._zoom.end2 - this._zoom.start2; this._zoom.start2 += total * sdx; this._zoom.end2 -= total * edx; } this._syncshape(); this._syncdata(true); return this._zoom; }, syncbackupdata: function (curoption) { var start; var target = this._originaldata['series']; var curseries = curoption.series; var curdata; for (var i = 0, l = curseries.length; i < l; i++) { curdata = curseries[i].data || curseries[i].eventlist; if (target[i]) { start = math.floor(this._zoom.start / 100 * target[i].length); } else { start = 0; } for (var j = 0, k = curdata.length; j < k; j++) { if (target[i]) { target[i][j + start] = curdata[j]; } } } }, syncoption: function (magicoption) { this.silence(true); this.option = magicoption; this.option.datazoom = this.reformoption(this.option.datazoom); this.zoomoption = this.option.datazoom; if (!this.mychart.canvassupported) { this.zoomoption.realtime = false; } this.clear(); this._location = this._getlocation(); this._zoom = this._getzoom(); this._backupdata(); if (this.option.datazoom && this.option.datazoom.show) { this._buildshape(); } this._syncdata(); this.silence(false); }, silence: function (s) { this._issilence = s; }, getrealdataindex: function (sidx, didx) { if (!this._originaldata || this._zoom.start === 0 && this._zoom.end == 100) { return didx; } var sreies = this._originaldata.series; if (sreies[sidx]) { return math.floor(this._zoom.start / 100 * sreies[sidx].length) + didx; } return -1; }, resize: function () { this.clear(); this._location = this._getlocation(); this._zoom = this._getzoom(); if (this.option.datazoom.show) { this._buildshape(); } } }; zrutil.inherits(datazoom, base); require('../component').define('datazoom', datazoom); return datazoom; });define('echarts/component/categoryaxis', [ 'require', './base', 'zrender/shape/text', 'zrender/shape/line', 'zrender/shape/rectangle', '../config', 'zrender/tool/util', 'zrender/tool/area', '../component' ], function (require) { var base = require('./base'); var textshape = require('zrender/shape/text'); var lineshape = require('zrender/shape/line'); var rectangleshape = require('zrender/shape/rectangle'); var ecconfig = require('../config'); ecconfig.categoryaxis = { zlevel: 0, z: 0, show: true, position: 'bottom', name: '', namelocation: 'end', nametextstyle: {}, boundarygap: true, axisline: { show: true, onzero: true, linestyle: { color: '#48b', width: 2, type: 'solid' } }, axistick: { show: true, interval: 'auto', inside: false, length: 5, linestyle: { color: '#333', width: 1 } }, axislabel: { show: true, interval: 'auto', rotate: 0, margin: 8, textstyle: { color: '#333' } }, splitline: { show: true, linestyle: { color: ['#ccc'], width: 1, type: 'solid' } }, splitarea: { show: false, areastyle: { color: [ 'rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)' ] } } }; var zrutil = require('zrender/tool/util'); var zrarea = require('zrender/tool/area'); function categoryaxis(ectheme, messagecenter, zr, option, mychart, axisbase) { if (option.data.length < 1) { console.error('option.data.length < 1.'); return; } base.call(this, ectheme, messagecenter, zr, option, mychart); this.grid = this.component.grid; for (var method in axisbase) { this[method] = axisbase[method]; } this.refresh(option); } categoryaxis.prototype = { type: ecconfig.component_type_axis_category, _getreformedlabel: function (idx) { var data = this.getdatafromoption(this.option.data[idx]); var formatter = this.option.data[idx].formatter || this.option.axislabel.formatter; if (formatter) { if (typeof formatter == 'function') { data = formatter.call(this.mychart, data); } else if (typeof formatter == 'string') { data = formatter.replace('{value}', data); } } return data; }, _getinterval: function () { var interval = this.option.axislabel.interval; if (interval == 'auto') { var fontsize = this.option.axislabel.textstyle.fontsize; var data = this.option.data; var datalength = this.option.data.length; if (this.ishorizontal()) { if (datalength > 3) { var gap = this.getgap(); var isenough = false; var labelspace; var labelsize; var step = math.floor(0.5 / gap); step = step < 1 ? 1 : step; interval = math.floor(15 / gap); while (!isenough && interval < datalength) { interval += step; isenough = true; labelspace = math.floor(gap * interval); for (var i = math.floor((datalength - 1) / interval) * interval; i >= 0; i -= interval) { if (this.option.axislabel.rotate !== 0) { labelsize = fontsize; } else if (data[i].textstyle) { labelsize = zrarea.gettextwidth(this._getreformedlabel(i), this.getfont(zrutil.merge(data[i].textstyle, this.option.axislabel.textstyle))); } else { var label = this._getreformedlabel(i) + ''; var wlen = (label.match(/\w/g) || '').length; var olen = label.length - wlen; labelsize = wlen * fontsize * 2 / 3 + olen * fontsize; } if (labelspace < labelsize) { isenough = false; break; } } } } else { interval = 1; } } else { if (datalength > 3) { var gap = this.getgap(); interval = math.floor(11 / gap); while (gap * interval - 6 < fontsize && interval < datalength) { interval++; } } else { interval = 1; } } } else { interval = typeof interval == 'function' ? 1 : interval - 0 + 1; } return interval; }, _buildshape: function () { this._interval = this._getinterval(); if (!this.option.show) { return; } this.option.splitarea.show && this._buildsplitarea(); this.option.splitline.show && this._buildsplitline(); this.option.axisline.show && this._buildaxisline(); this.option.axistick.show && this._buildaxistick(); this.option.axislabel.show && this._buildaxislabel(); for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } }, _buildaxistick: function () { var axshape; var data = this.option.data; var datalength = this.option.data.length; var tickoption = this.option.axistick; var length = tickoption.length; var color = tickoption.linestyle.color; var linewidth = tickoption.linestyle.width; var intervalfunction = typeof tickoption.interval == 'function' ? tickoption.interval : tickoption.interval == 'auto' ? typeof this.option.axislabel.interval == 'function' ? this.option.axislabel.interval : false : false; var interval = intervalfunction ? 1 : tickoption.interval == 'auto' ? this._interval : tickoption.interval - 0 + 1; var ongap = tickoption.ongap; var optgap = ongap ? this.getgap() / 2 : typeof ongap == 'undefined' ? this.option.boundarygap ? this.getgap() / 2 : 0 : 0; var startindex = optgap > 0 ? -interval : 0; if (this.ishorizontal()) { var yposition = this.option.position == 'bottom' ? tickoption.inside ? this.grid.getyend() - length - 1 : this.grid.getyend() + 1 : tickoption.inside ? this.grid.gety() + 1 : this.grid.gety() - length - 1; var x; for (var i = startindex; i < datalength; i += interval) { if (intervalfunction && !intervalfunction(i, data[i])) { continue; } x = this.subpixeloptimize(this.getcoordbyindex(i) + (i >= 0 ? optgap : 0), linewidth); axshape = { _axisshape: 'axistick', zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: x, ystart: yposition, xend: x, yend: yposition + length, strokecolor: color, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } else { var xposition = this.option.position == 'left' ? tickoption.inside ? this.grid.getx() + 1 : this.grid.getx() - length - 1 : tickoption.inside ? this.grid.getxend() - length - 1 : this.grid.getxend() + 1; var y; for (var i = startindex; i < datalength; i += interval) { if (intervalfunction && !intervalfunction(i, data[i])) { continue; } y = this.subpixeloptimize(this.getcoordbyindex(i) - (i >= 0 ? optgap : 0), linewidth); axshape = { _axisshape: 'axistick', zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: xposition, ystart: y, xend: xposition + length, yend: y, strokecolor: color, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } }, _buildaxislabel: function () { var axshape; var data = this.option.data; var datalength = this.option.data.length; var labeloption = this.option.axislabel; var rotate = labeloption.rotate; var margin = labeloption.margin; var clickable = labeloption.clickable; var textstyle = labeloption.textstyle; var intervalfunction = typeof labeloption.interval == 'function' ? labeloption.interval : false; var datatextstyle; if (this.ishorizontal()) { var yposition; var baseline; if (this.option.position == 'bottom') { yposition = this.grid.getyend() + margin; baseline = 'top'; } else { yposition = this.grid.gety() - margin; baseline = 'bottom'; } for (var i = 0; i < datalength; i += this._interval) { if (intervalfunction && !intervalfunction(i, data[i]) || this._getreformedlabel(i) === '') { continue; } datatextstyle = zrutil.merge(data[i].textstyle || {}, textstyle); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase() + 3, hoverable: false, style: { x: this.getcoordbyindex(i), y: yposition, color: datatextstyle.color, text: this._getreformedlabel(i), textfont: this.getfont(datatextstyle), textalign: datatextstyle.align || 'center', textbaseline: datatextstyle.baseline || baseline } }; if (rotate) { axshape.style.textalign = rotate > 0 ? this.option.position == 'bottom' ? 'right' : 'left' : this.option.position == 'bottom' ? 'left' : 'right'; axshape.rotation = [ rotate * math.pi / 180, axshape.style.x, axshape.style.y ]; } this.shapelist.push(new textshape(this._axislabelclickable(clickable, axshape))); } } else { var xposition; var align; if (this.option.position == 'left') { xposition = this.grid.getx() - margin; align = 'right'; } else { xposition = this.grid.getxend() + margin; align = 'left'; } for (var i = 0; i < datalength; i += this._interval) { if (intervalfunction && !intervalfunction(i, data[i]) || this._getreformedlabel(i) === '') { continue; } datatextstyle = zrutil.merge(data[i].textstyle || {}, textstyle); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase() + 3, hoverable: false, style: { x: xposition, y: this.getcoordbyindex(i), color: datatextstyle.color, text: this._getreformedlabel(i), textfont: this.getfont(datatextstyle), textalign: datatextstyle.align || align, textbaseline: datatextstyle.baseline || i === 0 && this.option.name !== '' ? 'bottom' : i == datalength - 1 && this.option.name !== '' ? 'top' : 'middle' } }; if (rotate) { axshape.rotation = [ rotate * math.pi / 180, axshape.style.x, axshape.style.y ]; } this.shapelist.push(new textshape(this._axislabelclickable(clickable, axshape))); } } }, _buildsplitline: function () { var axshape; var data = this.option.data; var datalength = this.option.data.length; var slineoption = this.option.splitline; var linetype = slineoption.linestyle.type; var linewidth = slineoption.linestyle.width; var color = slineoption.linestyle.color; color = color instanceof array ? color : [color]; var colorlength = color.length; var intervalfunction = typeof this.option.axislabel.interval == 'function' ? this.option.axislabel.interval : false; var ongap = slineoption.ongap; var optgap = ongap ? this.getgap() / 2 : typeof ongap == 'undefined' ? this.option.boundarygap ? this.getgap() / 2 : 0 : 0; datalength -= ongap || typeof ongap == 'undefined' && this.option.boundarygap ? 1 : 0; if (this.ishorizontal()) { var sy = this.grid.gety(); var ey = this.grid.getyend(); var x; for (var i = 0; i < datalength; i += this._interval) { if (intervalfunction && !intervalfunction(i, data[i])) { continue; } x = this.subpixeloptimize(this.getcoordbyindex(i) + optgap, linewidth); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: x, ystart: sy, xend: x, yend: ey, strokecolor: color[i / this._interval % colorlength], linetype: linetype, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } else { var sx = this.grid.getx(); var ex = this.grid.getxend(); var y; for (var i = 0; i < datalength; i += this._interval) { if (intervalfunction && !intervalfunction(i, data[i])) { continue; } y = this.subpixeloptimize(this.getcoordbyindex(i) - optgap, linewidth); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: sx, ystart: y, xend: ex, yend: y, strokecolor: color[i / this._interval % colorlength], linetype: linetype, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } }, _buildsplitarea: function () { var axshape; var data = this.option.data; var sareaoption = this.option.splitarea; var color = sareaoption.areastyle.color; if (!(color instanceof array)) { axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this.grid.getx(), y: this.grid.gety(), width: this.grid.getwidth(), height: this.grid.getheight(), color: color } }; this.shapelist.push(new rectangleshape(axshape)); } else { var colorlength = color.length; var datalength = this.option.data.length; var intervalfunction = typeof this.option.axislabel.interval == 'function' ? this.option.axislabel.interval : false; var ongap = sareaoption.ongap; var optgap = ongap ? this.getgap() / 2 : typeof ongap == 'undefined' ? this.option.boundarygap ? this.getgap() / 2 : 0 : 0; if (this.ishorizontal()) { var y = this.grid.gety(); var height = this.grid.getheight(); var lastx = this.grid.getx(); var curx; for (var i = 0; i <= datalength; i += this._interval) { if (intervalfunction && !intervalfunction(i, data[i]) && i < datalength) { continue; } curx = i < datalength ? this.getcoordbyindex(i) + optgap : this.grid.getxend(); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: lastx, y: y, width: curx - lastx, height: height, color: color[i / this._interval % colorlength] } }; this.shapelist.push(new rectangleshape(axshape)); lastx = curx; } } else { var x = this.grid.getx(); var width = this.grid.getwidth(); var lastyend = this.grid.getyend(); var cury; for (var i = 0; i <= datalength; i += this._interval) { if (intervalfunction && !intervalfunction(i, data[i]) && i < datalength) { continue; } cury = i < datalength ? this.getcoordbyindex(i) - optgap : this.grid.gety(); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: x, y: cury, width: width, height: lastyend - cury, color: color[i / this._interval % colorlength] } }; this.shapelist.push(new rectangleshape(axshape)); lastyend = cury; } } } }, refresh: function (newoption) { if (newoption) { this.option = this.reformoption(newoption); this.option.axislabel.textstyle = this.gettextstyle(this.option.axislabel.textstyle); } this.clear(); this._buildshape(); }, getgap: function () { var datalength = this.option.data.length; var total = this.ishorizontal() ? this.grid.getwidth() : this.grid.getheight(); if (this.option.boundarygap) { return total / datalength; } else { return total / (datalength > 1 ? datalength - 1 : 1); } }, getcoord: function (value) { var data = this.option.data; var datalength = data.length; var gap = this.getgap(); var position = this.option.boundarygap ? gap / 2 : 0; for (var i = 0; i < datalength; i++) { if (this.getdatafromoption(data[i]) == value) { if (this.ishorizontal()) { position = this.grid.getx() + position; } else { position = this.grid.getyend() - position; } return position; } position += gap; } }, getcoordbyindex: function (dataindex) { if (dataindex < 0) { if (this.ishorizontal()) { return this.grid.getx(); } else { return this.grid.getyend(); } } else if (dataindex > this.option.data.length - 1) { if (this.ishorizontal()) { return this.grid.getxend(); } else { return this.grid.gety(); } } else { var gap = this.getgap(); var position = this.option.boundarygap ? gap / 2 : 0; position += dataindex * gap; if (this.ishorizontal()) { position = this.grid.getx() + position; } else { position = this.grid.getyend() - position; } return position; } }, getnamebyindex: function (dataindex) { return this.getdatafromoption(this.option.data[dataindex]); }, getindexbyname: function (name) { var data = this.option.data; var datalength = data.length; for (var i = 0; i < datalength; i++) { if (this.getdatafromoption(data[i]) == name) { return i; } } return -1; }, getvaluefromcoord: function () { return ''; }, ismainaxis: function (dataindex) { return dataindex % this._interval === 0; } }; zrutil.inherits(categoryaxis, base); require('../component').define('categoryaxis', categoryaxis); return categoryaxis; });define('echarts/component/valueaxis', [ 'require', './base', 'zrender/shape/text', 'zrender/shape/line', 'zrender/shape/rectangle', '../config', '../util/date', 'zrender/tool/util', '../util/smartsteps', '../util/accmath', '../util/smartlogsteps', '../component' ], function (require) { var base = require('./base'); var textshape = require('zrender/shape/text'); var lineshape = require('zrender/shape/line'); var rectangleshape = require('zrender/shape/rectangle'); var ecconfig = require('../config'); ecconfig.valueaxis = { zlevel: 0, z: 0, show: true, position: 'left', name: '', namelocation: 'end', nametextstyle: {}, boundarygap: [ 0, 0 ], axisline: { show: true, onzero: true, linestyle: { color: '#48b', width: 2, type: 'solid' } }, axistick: { show: false, inside: false, length: 5, linestyle: { color: '#333', width: 1 } }, axislabel: { show: true, rotate: 0, margin: 8, textstyle: { color: '#333' } }, splitline: { show: true, linestyle: { color: ['#ccc'], width: 1, type: 'solid' } }, splitarea: { show: false, areastyle: { color: [ 'rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)' ] } } }; var ecdate = require('../util/date'); var zrutil = require('zrender/tool/util'); function valueaxis(ectheme, messagecenter, zr, option, mychart, axisbase, series) { if (!series || series.length === 0) { console.err('option.series.length == 0.'); return; } base.call(this, ectheme, messagecenter, zr, option, mychart); this.series = series; this.grid = this.component.grid; for (var method in axisbase) { this[method] = axisbase[method]; } this.refresh(option, series); } valueaxis.prototype = { type: ecconfig.component_type_axis_value, _buildshape: function () { this._hasdata = false; this._calculatevalue(); if (!this._hasdata || !this.option.show) { return; } this.option.splitarea.show && this._buildsplitarea(); this.option.splitline.show && this._buildsplitline(); this.option.axisline.show && this._buildaxisline(); this.option.axistick.show && this._buildaxistick(); this.option.axislabel.show && this._buildaxislabel(); for (var i = 0, l = this.shapelist.length; i < l; i++) { this.zr.addshape(this.shapelist[i]); } }, _buildaxistick: function () { var axshape; var data = this._valuelist; var datalength = this._valuelist.length; var tickoption = this.option.axistick; var length = tickoption.length; var color = tickoption.linestyle.color; var linewidth = tickoption.linestyle.width; if (this.ishorizontal()) { var yposition = this.option.position === 'bottom' ? tickoption.inside ? this.grid.getyend() - length - 1 : this.grid.getyend() + 1 : tickoption.inside ? this.grid.gety() + 1 : this.grid.gety() - length - 1; var x; for (var i = 0; i < datalength; i++) { x = this.subpixeloptimize(this.getcoord(data[i]), linewidth); axshape = { _axisshape: 'axistick', zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: x, ystart: yposition, xend: x, yend: yposition + length, strokecolor: color, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } else { var xposition = this.option.position === 'left' ? tickoption.inside ? this.grid.getx() + 1 : this.grid.getx() - length - 1 : tickoption.inside ? this.grid.getxend() - length - 1 : this.grid.getxend() + 1; var y; for (var i = 0; i < datalength; i++) { y = this.subpixeloptimize(this.getcoord(data[i]), linewidth); axshape = { _axisshape: 'axistick', zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: xposition, ystart: y, xend: xposition + length, yend: y, strokecolor: color, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } }, _buildaxislabel: function () { var axshape; var data = this._valuelist; var datalength = this._valuelist.length; var rotate = this.option.axislabel.rotate; var margin = this.option.axislabel.margin; var clickable = this.option.axislabel.clickable; var textstyle = this.option.axislabel.textstyle; if (this.ishorizontal()) { var yposition; var baseline; if (this.option.position === 'bottom') { yposition = this.grid.getyend() + margin; baseline = 'top'; } else { yposition = this.grid.gety() - margin; baseline = 'bottom'; } for (var i = 0; i < datalength; i++) { axshape = { zlevel: this.getzlevelbase(), z: this.getzbase() + 3, hoverable: false, style: { x: this.getcoord(data[i]), y: yposition, color: typeof textstyle.color === 'function' ? textstyle.color(data[i]) : textstyle.color, text: this._valuelabel[i], textfont: this.getfont(textstyle), textalign: textstyle.align || 'center', textbaseline: textstyle.baseline || baseline } }; if (rotate) { axshape.style.textalign = rotate > 0 ? this.option.position === 'bottom' ? 'right' : 'left' : this.option.position === 'bottom' ? 'left' : 'right'; axshape.rotation = [ rotate * math.pi / 180, axshape.style.x, axshape.style.y ]; } this.shapelist.push(new textshape(this._axislabelclickable(clickable, axshape))); } } else { var xposition; var align; if (this.option.position === 'left') { xposition = this.grid.getx() - margin; align = 'right'; } else { xposition = this.grid.getxend() + margin; align = 'left'; } for (var i = 0; i < datalength; i++) { axshape = { zlevel: this.getzlevelbase(), z: this.getzbase() + 3, hoverable: false, style: { x: xposition, y: this.getcoord(data[i]), color: typeof textstyle.color === 'function' ? textstyle.color(data[i]) : textstyle.color, text: this._valuelabel[i], textfont: this.getfont(textstyle), textalign: textstyle.align || align, textbaseline: textstyle.baseline || (i === 0 && this.option.name !== '' ? 'bottom' : i === datalength - 1 && this.option.name !== '' ? 'top' : 'middle') } }; if (rotate) { axshape.rotation = [ rotate * math.pi / 180, axshape.style.x, axshape.style.y ]; } this.shapelist.push(new textshape(this._axislabelclickable(clickable, axshape))); } } }, _buildsplitline: function () { var axshape; var data = this._valuelist; var datalength = this._valuelist.length; var slineoption = this.option.splitline; var linetype = slineoption.linestyle.type; var linewidth = slineoption.linestyle.width; var color = slineoption.linestyle.color; color = color instanceof array ? color : [color]; var colorlength = color.length; if (this.ishorizontal()) { var sy = this.grid.gety(); var ey = this.grid.getyend(); var x; for (var i = 0; i < datalength; i++) { x = this.subpixeloptimize(this.getcoord(data[i]), linewidth); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: x, ystart: sy, xend: x, yend: ey, strokecolor: color[i % colorlength], linetype: linetype, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } else { var sx = this.grid.getx(); var ex = this.grid.getxend(); var y; for (var i = 0; i < datalength; i++) { y = this.subpixeloptimize(this.getcoord(data[i]), linewidth); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { xstart: sx, ystart: y, xend: ex, yend: y, strokecolor: color[i % colorlength], linetype: linetype, linewidth: linewidth } }; this.shapelist.push(new lineshape(axshape)); } } }, _buildsplitarea: function () { var axshape; var color = this.option.splitarea.areastyle.color; if (!(color instanceof array)) { axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: this.grid.getx(), y: this.grid.gety(), width: this.grid.getwidth(), height: this.grid.getheight(), color: color } }; this.shapelist.push(new rectangleshape(axshape)); } else { var colorlength = color.length; var data = this._valuelist; var datalength = this._valuelist.length; if (this.ishorizontal()) { var y = this.grid.gety(); var height = this.grid.getheight(); var lastx = this.grid.getx(); var curx; for (var i = 0; i <= datalength; i++) { curx = i < datalength ? this.getcoord(data[i]) : this.grid.getxend(); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: lastx, y: y, width: curx - lastx, height: height, color: color[i % colorlength] } }; this.shapelist.push(new rectangleshape(axshape)); lastx = curx; } } else { var x = this.grid.getx(); var width = this.grid.getwidth(); var lastyend = this.grid.getyend(); var cury; for (var i = 0; i <= datalength; i++) { cury = i < datalength ? this.getcoord(data[i]) : this.grid.gety(); axshape = { zlevel: this.getzlevelbase(), z: this.getzbase(), hoverable: false, style: { x: x, y: cury, width: width, height: lastyend - cury, color: color[i % colorlength] } }; this.shapelist.push(new rectangleshape(axshape)); lastyend = cury; } } } }, _calculatevalue: function () { if (isnan(this.option.min - 0) || isnan(this.option.max - 0)) { var data = {}; var xidx; var yidx; var legend = this.component.legend; for (var i = 0, l = this.series.length; i < l; i++) { if (this.series[i].type != ecconfig.chart_type_line && this.series[i].type != ecconfig.chart_type_bar && this.series[i].type != ecconfig.chart_type_scatter && this.series[i].type != ecconfig.chart_type_k && this.series[i].type != ecconfig.chart_type_eventriver) { continue; } if (legend && !legend.isselected(this.series[i].name)) { continue; } xidx = this.series[i].xaxisindex || 0; yidx = this.series[i].yaxisindex || 0; if (this.option.xaxisindex != xidx && this.option.yaxisindex != yidx) { continue; } this._calculsum(data, i); } var oridata; for (var i in data) { oridata = data[i]; for (var j = 0, k = oridata.length; j < k; j++) { if (!isnan(oridata[j])) { this._hasdata = true; this._min = oridata[j]; this._max = oridata[j]; break; } } if (this._hasdata) { break; } } for (var i in data) { oridata = data[i]; for (var j = 0, k = oridata.length; j < k; j++) { if (!isnan(oridata[j])) { this._min = math.min(this._min, oridata[j]); this._max = math.max(this._max, oridata[j]); } } } var boundarygap = this.option.type !== 'log' ? this.option.boundarygap : [ 0, 0 ]; var gap = math.abs(this._max - this._min); this._min = isnan(this.option.min - 0) ? this._min - math.abs(gap * boundarygap[0]) : this.option.min - 0; this._max = isnan(this.option.max - 0) ? this._max + math.abs(gap * boundarygap[1]) : this.option.max - 0; if (this._min === this._max) { if (this._max === 0) { this._max = 1; } else if (this._max > 0) { this._min = this._max / this.option.splitnumber != null ? this.option.splitnumber : 5; } else { this._max = this._max / this.option.splitnumber != null ? this.option.splitnumber : 5; } } if (this.option.type === 'time') { this._reformtimevalue(); } else if (this.option.type === 'log') { this._reformlogvalue(); } else { this._reformvalue(this.option.scale); } } else { this._hasdata = true; this._min = this.option.min - 0; this._max = this.option.max - 0; if (this.option.type === 'time') { this._reformtimevalue(); } else if (this.option.type === 'log') { this._reformlogvalue(); } else { this._customervalue(); } } }, _calculsum: function (data, i) { var key = this.series[i].name || 'kener'; var value; var oridata; if (!this.series[i].stack) { data[key] = data[key] || []; if (this.series[i].type != ecconfig.chart_type_eventriver) { oridata = this.series[i].data; for (var j = 0, k = oridata.length; j < k; j++) { value = this.getdatafromoption(oridata[j]); if (this.series[i].type === ecconfig.chart_type_k) { data[key].push(value[0]); data[key].push(value[1]); data[key].push(value[2]); data[key].push(value[3]); } else if (value instanceof array) { if (this.option.xaxisindex != -1) { data[key].push(this.option.type != 'time' ? value[0] : ecdate.getnewdate(value[0])); } if (this.option.yaxisindex != -1) { data[key].push(this.option.type != 'time' ? value[1] : ecdate.getnewdate(value[1])); } } else { data[key].push(value); } } } else { oridata = this.series[i].data; for (var j = 0, k = oridata.length; j < k; j++) { var evolution = oridata[j].evolution; for (var m = 0, n = evolution.length; m < n; m++) { data[key].push(ecdate.getnewdate(evolution[m].time)); } } } } else { var keyp = '__magic_key_positive__' + this.series[i].stack; var keyn = '__magic_key_negative__' + this.series[i].stack; data[keyp] = data[keyp] || []; data[keyn] = data[keyn] || []; data[key] = data[key] || []; oridata = this.series[i].data; for (var j = 0, k = oridata.length; j < k; j++) { value = this.getdatafromoption(oridata[j]); if (value === '-') { continue; } value = value - 0; if (value >= 0) { if (data[keyp][j] != null) { data[keyp][j] += value; } else { data[keyp][j] = value; } } else { if (data[keyn][j] != null) { data[keyn][j] += value; } else { data[keyn][j] = value; } } if (this.option.scale) { data[key].push(value); } } } }, _reformvalue: function (scale) { var smartsteps = require('../util/smartsteps'); var splitnumber = this.option.splitnumber; if (!scale && this._min >= 0 && this._max >= 0) { this._min = 0; } if (!scale && this._min <= 0 && this._max <= 0) { this._max = 0; } var stepopt = smartsteps(this._min, this._max, splitnumber); splitnumber = splitnumber != null ? splitnumber : stepopt.secs; this._min = stepopt.min; this._max = stepopt.max; this._valuelist = stepopt.pnts; this._reformlabeldata(); }, _reformtimevalue: function () { var splitnumber = this.option.splitnumber != null ? this.option.splitnumber : 5; var curvalue = ecdate.getautoformatter(this._min, this._max, splitnumber); var formatter = curvalue.formatter; var gapvalue = curvalue.gapvalue; this._valuelist = [ecdate.getnewdate(this._min)]; var startgap; switch (formatter) { case 'week': startgap = ecdate.nextmonday(this._min); break; case 'month': startgap = ecdate.nextnthonmonth(this._min, 1); break; case 'quarter': startgap = ecdate.nextnthonquarteryear(this._min, 1); break; case 'half-year': startgap = ecdate.nextnthonhalfyear(this._min, 1); break; case 'year': startgap = ecdate.nextnthonyear(this._min, 1); break; default: if (gapvalue <= 3600000 * 2) { startgap = (math.floor(this._min / gapvalue) + 1) * gapvalue; } else { startgap = ecdate.getnewdate(this._min - -gapvalue); startgap.sethours(math.round(startgap.gethours() / 6) * 6); startgap.setminutes(0); startgap.setseconds(0); } break; } if (startgap - this._min < gapvalue / 2) { startgap -= -gapvalue; } curvalue = ecdate.getnewdate(startgap); splitnumber *= 1.5; while (splitnumber-- >= 0) { if (formatter == 'month' || formatter == 'quarter' || formatter == 'half-year' || formatter == 'year') { curvalue.setdate(1); } if (this._max - curvalue < gapvalue / 2) { break; } this._valuelist.push(curvalue); curvalue = ecdate.getnewdate(curvalue - -gapvalue); } this._valuelist.push(ecdate.getnewdate(this._max)); this._reformlabeldata(function (formatterstr) { return function (value) { return ecdate.format(formatterstr, value); }; }(formatter)); }, _customervalue: function () { var accmath = require('../util/accmath'); var splitnumber = this.option.splitnumber != null ? this.option.splitnumber : 5; var splitgap = (this._max - this._min) / splitnumber; this._valuelist = []; for (var i = 0; i <= splitnumber; i++) { this._valuelist.push(accmath.accadd(this._min, accmath.accmul(splitgap, i))); } this._reformlabeldata(); }, _reformlogvalue: function () { var thisoption = this.option; var result = require('../util/smartlogsteps')({ datamin: this._min, datamax: this._max, logpositive: thisoption.logpositive, loglabelbase: thisoption.loglabelbase, splitnumber: thisoption.splitnumber }); this._min = result.datamin; this._max = result.datamax; this._valuelist = result.ticklist; this._datamappingmethods = result.datamappingmethods; this._reformlabeldata(result.labelformatter); }, _reformlabeldata: function (innerformatter) { this._valuelabel = []; var formatter = this.option.axislabel.formatter; if (formatter) { for (var i = 0, l = this._valuelist.length; i < l; i++) { if (typeof formatter === 'function') { this._valuelabel.push(innerformatter ? formatter.call(this.mychart, this._valuelist[i], innerformatter) : formatter.call(this.mychart, this._valuelist[i])); } else if (typeof formatter === 'string') { this._valuelabel.push(innerformatter ? ecdate.format(formatter, this._valuelist[i]) : formatter.replace('{value}', this._valuelist[i])); } } } else { for (var i = 0, l = this._valuelist.length; i < l; i++) { this._valuelabel.push(innerformatter ? innerformatter(this._valuelist[i]) : this.numaddcommas(this._valuelist[i])); } } }, getextremum: function () { this._calculatevalue(); var datamappingmethods = this._datamappingmethods; return { min: this._min, max: this._max, datamappingmethods: datamappingmethods ? zrutil.merge({}, datamappingmethods) : null }; }, refresh: function (newoption, newseries) { if (newoption) { this.option = this.reformoption(newoption); this.option.axislabel.textstyle = zrutil.merge(this.option.axislabel.textstyle || {}, this.ectheme.textstyle); this.series = newseries; } if (this.zr) { this.clear(); this._buildshape(); } }, getcoord: function (value) { if (this._datamappingmethods) { value = this._datamappingmethods.value2coord(value); } value = value < this._min ? this._min : value; value = value > this._max ? this._max : value; var result; if (!this.ishorizontal()) { result = this.grid.getyend() - (value - this._min) / (this._max - this._min) * this.grid.getheight(); } else { result = this.grid.getx() + (value - this._min) / (this._max - this._min) * this.grid.getwidth(); } return result; }, getcoordsize: function (value) { if (!this.ishorizontal()) { return math.abs(value / (this._max - this._min) * this.grid.getheight()); } else { return math.abs(value / (this._max - this._min) * this.grid.getwidth()); } }, getvaluefromcoord: function (coord) { var result; if (!this.ishorizontal()) { coord = coord < this.grid.gety() ? this.grid.gety() : coord; coord = coord > this.grid.getyend() ? this.grid.getyend() : coord; result = this._max - (coord - this.grid.gety()) / this.grid.getheight() * (this._max - this._min); } else { coord = coord < this.grid.getx() ? this.grid.getx() : coord; coord = coord > this.grid.getxend() ? this.grid.getxend() : coord; result = this._min + (coord - this.grid.getx()) / this.grid.getwidth() * (this._max - this._min); } if (this._datamappingmethods) { result = this._datamappingmethods.coord2value(result); } return result.tofixed(2) - 0; }, ismaindaxis: function (value) { for (var i = 0, l = this._valuelist.length; i < l; i++) { if (this._valuelist[i] === value) { return true; } } return false; } }; zrutil.inherits(valueaxis, base); require('../component').define('valueaxis', valueaxis); return valueaxis; });define('echarts/util/date', [], function () { var _timegap = [ { formatter: 'hh : mm : ss', value: 1000 }, { formatter: 'hh : mm : ss', value: 1000 * 5 }, { formatter: 'hh : mm : ss', value: 1000 * 10 }, { formatter: 'hh : mm : ss', value: 1000 * 15 }, { formatter: 'hh : mm : ss', value: 1000 * 30 }, { formatter: 'hh : mm\nmm - dd', value: 60000 }, { formatter: 'hh : mm\nmm - dd', value: 60000 * 5 }, { formatter: 'hh : mm\nmm - dd', value: 60000 * 10 }, { formatter: 'hh : mm\nmm - dd', value: 60000 * 15 }, { formatter: 'hh : mm\nmm - dd', value: 60000 * 30 }, { formatter: 'hh : mm\nmm - dd', value: 3600000 }, { formatter: 'hh : mm\nmm - dd', value: 3600000 * 2 }, { formatter: 'hh : mm\nmm - dd', value: 3600000 * 6 }, { formatter: 'hh : mm\nmm - dd', value: 3600000 * 12 }, { formatter: 'mm - dd\nyyyy', value: 3600000 * 24 }, { formatter: 'week', value: 3600000 * 24 * 7 }, { formatter: 'month', value: 3600000 * 24 * 31 }, { formatter: 'quarter', value: 3600000 * 24 * 380 / 4 }, { formatter: 'half-year', value: 3600000 * 24 * 380 / 2 }, { formatter: 'year', value: 3600000 * 24 * 380 } ]; function getautoformatter(min, max, splitnumber) { splitnumber = splitnumber > 1 ? splitnumber : 2; var curvalue; var totalgap; var formatter; var gapvalue; for (var i = 0, l = _timegap.length; i < l; i++) { curvalue = _timegap[i].value; totalgap = math.ceil(max / curvalue) * curvalue - math.floor(min / curvalue) * curvalue; if (math.round(totalgap / curvalue) <= splitnumber * 1.2) { formatter = _timegap[i].formatter; gapvalue = _timegap[i].value; break; } } if (formatter == null) { formatter = 'year'; curvalue = 3600000 * 24 * 367; totalgap = math.ceil(max / curvalue) * curvalue - math.floor(min / curvalue) * curvalue; gapvalue = math.round(totalgap / (splitnumber - 1) / curvalue) * curvalue; } return { formatter: formatter, gapvalue: gapvalue }; } function s2d(v) { return v < 10 ? '0' + v : v; } function format(formatter, value) { if (formatter == 'week' || formatter == 'month' || formatter == 'quarter' || formatter == 'half-year' || formatter == 'year') { formatter = 'mm - dd\nyyyy'; } var date = getnewdate(value); var y = date.getfullyear(); var m = date.getmonth() + 1; var d = date.getdate(); var h = date.gethours(); var m = date.getminutes(); var s = date.getseconds(); formatter = formatter.replace('mm', s2d(m)); formatter = formatter.tolowercase(); formatter = formatter.replace('yyyy', y); formatter = formatter.replace('yy', y % 100); formatter = formatter.replace('dd', s2d(d)); formatter = formatter.replace('d', d); formatter = formatter.replace('hh', s2d(h)); formatter = formatter.replace('h', h); formatter = formatter.replace('mm', s2d(m)); formatter = formatter.replace('m', m); formatter = formatter.replace('ss', s2d(s)); formatter = formatter.replace('s', s); return formatter; } function nextmonday(value) { value = getnewdate(value); value.setdate(value.getdate() + 8 - value.getday()); return value; } function nextnthpernmonth(value, nth, nmon) { value = getnewdate(value); value.setmonth(math.ceil((value.getmonth() + 1) / nmon) * nmon); value.setdate(nth); return value; } function nextnthonmonth(value, nth) { return nextnthpernmonth(value, nth, 1); } function nextnthonquarteryear(value, nth) { return nextnthpernmonth(value, nth, 3); } function nextnthonhalfyear(value, nth) { return nextnthpernmonth(value, nth, 6); } function nextnthonyear(value, nth) { return nextnthpernmonth(value, nth, 12); } function getnewdate(value) { return value instanceof date ? value : new date(typeof value == 'string' ? value.replace(/-/g, '/') : value); } return { getautoformatter: getautoformatter, getnewdate: getnewdate, format: format, nextmonday: nextmonday, nextnthpernmonth: nextnthpernmonth, nextnthonmonth: nextnthonmonth, nextnthonquarteryear: nextnthonquarteryear, nextnthonhalfyear: nextnthonhalfyear, nextnthonyear: nextnthonyear }; });define('echarts/util/smartsteps', [], function () { var mysteps = [ 10, 20, 25, 50 ]; var mysections = [ 4, 5, 6 ]; var custopts; var custsteps; var custsecs; var minlocked; var maxlocked; var mt = math; var math_round = mt.round; var math_floor = mt.floor; var math_ceil = mt.ceil; var math_abs = mt.abs; function math_log(n) { return mt.log(math_abs(n)) / mt.ln10; } function math_pow(n) { return mt.pow(10, n); } function math_isint(n) { return n === math_floor(n); } function smartsteps(min, max, section, opts) { custopts = opts || {}; custsteps = custopts.steps || mysteps; custsecs = custopts.secs || mysections; section = math_round(+section || 0) % 99; min = +min || 0; max = +max || 0; minlocked = maxlocked = 0; if ('min' in custopts) { min = +custopts.min || 0; minlocked = 1; } if ('max' in custopts) { max = +custopts.max || 0; maxlocked = 1; } if (min > max) { max = [ min, min = max ][0]; } var span = max - min; if (minlocked && maxlocked) { return bothlocked(min, max, section); } if (span < (section || 5)) { if (math_isint(min) && math_isint(max)) { return forinteger(min, max, section); } else if (span === 0) { return forspan0(min, max, section); } } return corecalc(min, max, section); } function makeresult(newmin, newmax, section, expon) { expon = expon || 0; var expstep = expnum((newmax - newmin) / section, -1); var expmin = expnum(newmin, -1, 1); var expmax = expnum(newmax, -1); var minexp = mt.min(expstep.e, expmin.e, expmax.e); if (expmin.c === 0) { minexp = mt.min(expstep.e, expmax.e); } else if (expmax.c === 0) { minexp = mt.min(expstep.e, expmin.e); } expfixto(expstep, { c: 0, e: minexp }); expfixto(expmin, expstep, 1); expfixto(expmax, expstep); expon += minexp; newmin = expmin.c; newmax = expmax.c; var step = (newmax - newmin) / section; var zoom = math_pow(expon); var fixto = 0; var points = []; for (var i = section + 1; i--;) { points[i] = (newmin + step * i) * zoom; } if (expon < 0) { fixto = decimals(zoom); step = +(step * zoom).tofixed(fixto); newmin = +(newmin * zoom).tofixed(fixto); newmax = +(newmax * zoom).tofixed(fixto); for (var i = points.length; i--;) { points[i] = points[i].tofixed(fixto); +points[i] === 0 && (points[i] = '0'); } } else { newmin *= zoom; newmax *= zoom; step *= zoom; } custsecs = 0; custsteps = 0; custopts = 0; return { min: newmin, max: newmax, secs: section, step: step, fix: fixto, exp: expon, pnts: points }; } function expnum(num, digit, byfloor) { digit = math_round(digit % 10) || 2; if (digit < 0) { if (math_isint(num)) { digit = ('' + math_abs(num)).replace(/0+$/, '').length || 1; } else { num = num.tofixed(15).replace(/0+$/, ''); digit = num.replace('.', '').replace(/^[-0]+/, '').length; num = +num; } } var expon = math_floor(math_log(num)) - digit + 1; var cnum = +(num * math_pow(-expon)).tofixed(15) || 0; cnum = byfloor ? math_floor(cnum) : math_ceil(cnum); !cnum && (expon = 0); if (('' + math_abs(cnum)).length > digit) { expon += 1; cnum /= 10; } return { c: cnum, e: expon }; } function expfixto(expnum1, expnum2, byfloor) { var deltaexp = expnum2.e - expnum1.e; if (deltaexp) { expnum1.e += deltaexp; expnum1.c *= math_pow(-deltaexp); expnum1.c = byfloor ? math_floor(expnum1.c) : math_ceil(expnum1.c); } } function expfixmin(expnum1, expnum2, byfloor) { if (expnum1.e < expnum2.e) { expfixto(expnum2, expnum1, byfloor); } else { expfixto(expnum1, expnum2, byfloor); } } function getceil(num, rounds) { rounds = rounds || mysteps; num = expnum(num); var cnum = num.c; var i = 0; while (cnum > rounds[i]) { i++; } if (!rounds[i]) { cnum /= 10; num.e += 1; i = 0; while (cnum > rounds[i]) { i++; } } num.c = rounds[i]; return num; } function corecalc(min, max, section) { var step; var secs = section || +custsecs.slice(-1); var expstep = getceil((max - min) / secs, custsteps); var expspan = expnum(max - min); var expmin = expnum(min, -1, 1); var expmax = expnum(max, -1); expfixto(expspan, expstep); expfixto(expmin, expstep, 1); expfixto(expmax, expstep); if (!section) { secs = look4sections(expmin, expmax); } else { step = look4step(expmin, expmax, secs); } if (math_isint(min) && math_isint(max) && min * max >= 0) { if (max - min < secs) { return forinteger(min, max, secs); } secs = tryforint(min, max, section, expmin, expmax, secs); } var arrmm = cross0(min, max, expmin.c, expmax.c); expmin.c = arrmm[0]; expmax.c = arrmm[1]; if (minlocked || maxlocked) { singlelocked(min, max, expmin, expmax); } return makeresult(expmin.c, expmax.c, secs, expmax.e); } function look4sections(expmin, expmax) { var section; var tmpstep, tmpmin, tmpmax; var reference = []; for (var i = custsecs.length; i--;) { section = custsecs[i]; tmpstep = getceil((expmax.c - expmin.c) / section, custsteps); tmpstep = tmpstep.c * math_pow(tmpstep.e); tmpmin = math_floor(expmin.c / tmpstep) * tmpstep; tmpmax = math_ceil(expmax.c / tmpstep) * tmpstep; reference[i] = { min: tmpmin, max: tmpmax, step: tmpstep, span: tmpmax - tmpmin }; } reference.sort(function (a, b) { var delta = a.span - b.span; if (delta === 0) { delta = a.step - b.step; } return delta; }); reference = reference[0]; section = reference.span / reference.step; expmin.c = reference.min; expmax.c = reference.max; return section < 3 ? section * 2 : section; } function look4step(expmin, expmax, secs) { var span; var tmpmax; var tmpmin = expmax.c; var tmpstep = (expmax.c - expmin.c) / secs - 1; while (tmpmin > expmin.c) { tmpstep = getceil(tmpstep + 1, custsteps); tmpstep = tmpstep.c * math_pow(tmpstep.e); span = tmpstep * secs; tmpmax = math_ceil(expmax.c / tmpstep) * tmpstep; tmpmin = tmpmax - span; } var deltamin = expmin.c - tmpmin; var deltamax = tmpmax - expmax.c; var deltadelta = deltamin - deltamax; if (deltadelta > tmpstep * 1.1) { deltadelta = math_round(deltadelta / tmpstep / 2) * tmpstep; tmpmin += deltadelta; tmpmax += deltadelta; } expmin.c = tmpmin; expmax.c = tmpmax; return tmpstep; } function tryforint(min, max, section, expmin, expmax, secs) { var span = expmax.c - expmin.c; var step = span / secs * math_pow(expmax.e); if (!math_isint(step)) { step = math_floor(step); span = step * secs; if (span < max - min) { step += 1; span = step * secs; if (!section && step * (secs - 1) >= max - min) { secs -= 1; span = step * secs; } } if (span >= max - min) { var delta = span - (max - min); expmin.c = math_round(min - delta / 2); expmax.c = math_round(max + delta / 2); expmin.e = 0; expmax.e = 0; } } return secs; } function forinteger(min, max, section) { section = section || 5; if (minlocked) { max = min + section; } else if (maxlocked) { min = max - section; } else { var delta = section - (max - min); var newmin = math_round(min - delta / 2); var newmax = math_round(max + delta / 2); var arrmm = cross0(min, max, newmin, newmax); min = arrmm[0]; max = arrmm[1]; } return makeresult(min, max, section); } function forspan0(min, max, section) { section = section || 5; var delta = mt.min(math_abs(max / section), section) / 2.1; if (minlocked) { max = min + delta; } else if (maxlocked) { min = max - delta; } else { min = min - delta; max = max + delta; } return corecalc(min, max, section); } function cross0(min, max, newmin, newmax) { if (min >= 0 && newmin < 0) { newmax -= newmin; newmin = 0; } else if (max <= 0 && newmax > 0) { newmin -= newmax; newmax = 0; } return [ newmin, newmax ]; } function decimals(num) { num = (+num).tofixed(15).split('.'); return num.pop().replace(/0+$/, '').length; } function singlelocked(min, max, emin, emax) { if (minlocked) { var expmin = expnum(min, 4, 1); if (emin.e - expmin.e > 6) { expmin = { c: 0, e: emin.e }; } expfixmin(emin, expmin); expfixmin(emax, expmin); emax.c += expmin.c - emin.c; emin.c = expmin.c; } else if (maxlocked) { var expmax = expnum(max, 4); if (emax.e - expmax.e > 6) { expmax = { c: 0, e: emax.e }; } expfixmin(emin, expmax); expfixmin(emax, expmax); emin.c += expmax.c - emax.c; emax.c = expmax.c; } } function bothlocked(min, max, section) { var trysecs = section ? [section] : custsecs; var span = max - min; if (span === 0) { max = expnum(max, 3); section = trysecs[0]; max.c = math_round(max.c + section / 2); return makeresult(max.c - section, max.c, section, max.e); } if (math_abs(max / span) < 0.000001) { max = 0; } if (math_abs(min / span) < 0.000001) { min = 0; } var step, deltaspan, score; var scores = [ [ 5, 10 ], [ 10, 2 ], [ 50, 10 ], [ 100, 2 ] ]; var reference = []; var debuglog = []; var expspan = expnum(max - min, 3); var expmin = expnum(min, -1, 1); var expmax = expnum(max, -1); expfixto(expmin, expspan, 1); expfixto(expmax, expspan); span = expmax.c - expmin.c; expspan.c = span; for (var i = trysecs.length; i--;) { section = trysecs[i]; step = math_ceil(span / section); deltaspan = step * section - span; score = (deltaspan + 3) * 3; score += (section - trysecs[0] + 2) * 2; if (section % 5 === 0) { score -= 10; } for (var j = scores.length; j--;) { if (step % scores[j][0] === 0) { score /= scores[j][1]; } } debuglog[i] = [ section, step, deltaspan, score ].join(); reference[i] = { secs: section, step: step, delta: deltaspan, score: score }; } reference.sort(function (a, b) { return a.score - b.score; }); reference = reference[0]; expmin.c = math_round(expmin.c - reference.delta / 2); expmax.c = math_round(expmax.c + reference.delta / 2); return makeresult(expmin.c, expmax.c, reference.secs, expspan.e); } return smartsteps; });define('echarts/util/smartlogsteps', [ 'require', './number' ], function (require) { var number = require('./number'); var mt = math; var mathlog = mt.log; var mathpow = mt.pow; var mathabs = mt.abs; var mathceil = mt.ceil; var mathfloor = mt.floor; var log_base = mt.e; var ln10 = mt.ln10; var ln2 = mt.ln2; var ln2d10 = ln2 / ln10; var epsilon = 1e-9; var default_split_number = 5; var min_base_10_split_number = 2; var superscripts = { '0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹', '-': '⁻' }; var logpositive; var loglabelbase; var loglabelmode; var lnbase; var custopts; var splitnumber; var logmappingoffset; var absmin; var absmax; var ticklist; function smartlogsteps(opts) { clearstaticvariables(); custopts = opts || {}; reformsetting(); maketickslist(); return [ makeresult(), clearstaticvariables() ][0]; } function clearstaticvariables() { logpositive = custopts = logmappingoffset = lnbase = absmin = absmax = splitnumber = ticklist = loglabelbase = loglabelmode = null; } function reformsetting() { loglabelbase = custopts.loglabelbase; if (loglabelbase == null) { loglabelmode = 'plain'; loglabelbase = 10; lnbase = ln10; } else { loglabelbase = +loglabelbase; if (loglabelbase < 1) { loglabelbase = 10; } loglabelmode = 'exponent'; lnbase = mathlog(loglabelbase); } splitnumber = custopts.splitnumber; splitnumber == null && (splitnumber = default_split_number); var datamin = parsefloat(custopts.datamin); var datamax = parsefloat(custopts.datamax); if (!isfinite(datamin) && !isfinite(datamax)) { datamin = datamax = 1; } else if (!isfinite(datamin)) { datamin = datamax; } else if (!isfinite(datamax)) { datamax = datamin; } else if (datamin > datamax) { datamax = [ datamin, datamin = datamax ][0]; } logpositive = custopts.logpositive; if (logpositive == null) { logpositive = datamax > 0 || datamin === 0; } absmin = logpositive ? datamin : -datamax; absmax = logpositive ? datamax : -datamin; absmin < epsilon && (absmin = epsilon); absmax < epsilon && (absmax = epsilon); } function maketickslist() { ticklist = []; var maxdatalog = fixaccurate(mathlog(absmax) / lnbase); var mindatalog = fixaccurate(mathlog(absmin) / lnbase); var maxexpon = mathceil(maxdatalog); var minexpon = mathfloor(mindatalog); var spanexpon = maxexpon - minexpon; var spandatalog = maxdatalog - mindatalog; if (loglabelmode === 'exponent') { baseanalysis(); } else { !(spanexpon <= min_base_10_split_number && splitnumber > min_base_10_split_number) ? baseanalysis() : detailanalysis(); } function baseanalysis() { if (spanexpon < splitnumber) { splitnumber = spanexpon; } var stepexpon = mathfloor(fixaccurate(spanexpon / splitnumber)); var splitnumberadjust = mathceil(fixaccurate(spanexpon / stepexpon)); var spanexponadjust = stepexpon * splitnumberadjust; var halfdiff = (spanexponadjust - spandatalog) / 2; var minexponadjust = mathfloor(fixaccurate(mindatalog - halfdiff)); if (aroundzero(minexponadjust - mindatalog)) { minexponadjust -= 1; } logmappingoffset = -minexponadjust * lnbase; for (var n = minexponadjust; n - stepexpon <= maxdatalog; n += stepexpon) { ticklist.push(mathpow(loglabelbase, n)); } } function detailanalysis() { var mindecimal = todecimalfrom4hex(minexpon, 0); var enddecimal = mindecimal + 2; while (mindecimal < enddecimal && toh(mindecimal + 1) + tok(mindecimal + 1) * ln2d10 < mindatalog) { mindecimal++; } var maxdecimal = todecimalfrom4hex(maxexpon, 0); var enddecimal = maxdecimal - 2; while (maxdecimal > enddecimal && toh(maxdecimal - 1) + tok(maxdecimal - 1) * ln2d10 > maxdatalog) { maxdecimal--; } logmappingoffset = -(toh(mindecimal) * ln10 + tok(mindecimal) * ln2); for (var i = mindecimal; i <= maxdecimal; i++) { var h = toh(i); var k = tok(i); ticklist.push(mathpow(10, h) * mathpow(2, k)); } } function todecimalfrom4hex(h, k) { return h * 3 + k; } function tok(decimal) { return decimal - toh(decimal) * 3; } function toh(decimal) { return mathfloor(fixaccurate(decimal / 3)); } } function makeresult() { var resultticklist = []; for (var i = 0, len = ticklist.length; i < len; i++) { resultticklist[i] = (logpositive ? 1 : -1) * ticklist[i]; } !logpositive && resultticklist.reverse(); var datamappingmethods = makedatamappingmethods(); var value2coord = datamappingmethods.value2coord; var newdatamin = value2coord(resultticklist[0]); var newdatamax = value2coord(resultticklist[resultticklist.length - 1]); if (newdatamin === newdatamax) { newdatamin -= 1; newdatamax += 1; } return { datamin: newdatamin, datamax: newdatamax, ticklist: resultticklist, logpositive: logpositive, labelformatter: makelabelformatter(), datamappingmethods: datamappingmethods }; } function makelabelformatter() { if (loglabelmode === 'exponent') { var myloglabelbase = loglabelbase; var mylnbase = lnbase; return function (value) { if (!isfinite(parsefloat(value))) { return ''; } var sign = ''; if (value < 0) { value = -value; sign = '-'; } return sign + myloglabelbase + makesuperscriptexponent(mathlog(value) / mylnbase); }; } else { return function (value) { if (!isfinite(parsefloat(value))) { return ''; } return number.addcommas(formatnumber(value)); }; } } function makedatamappingmethods() { var mylogpositive = logpositive; var mylogmappingoffset = logmappingoffset; return { value2coord: function (x) { if (x == null || isnan(x) || !isfinite(x)) { return x; } x = parsefloat(x); if (!isfinite(x)) { x = epsilon; } else if (mylogpositive && x < epsilon) { x = epsilon; } else if (!mylogpositive && x > -epsilon) { x = -epsilon; } x = mathabs(x); return (mylogpositive ? 1 : -1) * (mathlog(x) + mylogmappingoffset); }, coord2value: function (x) { if (x == null || isnan(x) || !isfinite(x)) { return x; } x = parsefloat(x); if (!isfinite(x)) { x = epsilon; } return mylogpositive ? mathpow(log_base, x - mylogmappingoffset) : -mathpow(log_base, -x + mylogmappingoffset); } }; } function fixaccurate(result) { return +number(+result).tofixed(14); } function formatnumber(num) { return number(num).tofixed(15).replace(/\.?0*$/, ''); } function makesuperscriptexponent(exponent) { exponent = formatnumber(math.round(exponent)); var result = []; for (var i = 0, len = exponent.length; i < len; i++) { var cha = exponent.charat(i); result.push(superscripts[cha] || ''); } return result.join(''); } function aroundzero(val) { return val > -epsilon && val < epsilon; } return smartlogsteps; });