echarts-liquidfill.js 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("echarts"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["echarts"], factory);
  6. else if(typeof exports === 'object')
  7. exports["echarts-liquidfill"] = factory(require("echarts"));
  8. else
  9. root["echarts-liquidfill"] = factory(root["echarts"]);
  10. })(self, function(__WEBPACK_EXTERNAL_MODULE_echarts_lib_echarts__) {
  11. return /******/ (() => { // webpackBootstrap
  12. /******/ "use strict";
  13. /******/ var __webpack_modules__ = ({
  14. /***/ "./index.js":
  15. /*!******************************!*\
  16. !*** ./index.js + 6 modules ***!
  17. \******************************/
  18. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  19. // ESM COMPAT FLAG
  20. __webpack_require__.r(__webpack_exports__);
  21. // EXTERNAL MODULE: external "echarts"
  22. var external_echarts_ = __webpack_require__("echarts/lib/echarts");
  23. ;// CONCATENATED MODULE: ./src/liquidFillSeries.js
  24. external_echarts_.extendSeriesModel({
  25. type: 'series.liquidFill',
  26. optionUpdated: function () {
  27. var option = this.option;
  28. option.gridSize = Math.max(Math.floor(option.gridSize), 4);
  29. },
  30. getInitialData: function (option, ecModel) {
  31. var dimensions = external_echarts_.helper.createDimensions(option.data, {
  32. coordDimensions: ['value']
  33. });
  34. var list = new external_echarts_.List(dimensions, this);
  35. list.initData(option.data);
  36. return list;
  37. },
  38. defaultOption: {
  39. color: ['#294D99', '#156ACF', '#1598ED', '#45BDFF'],
  40. center: ['50%', '50%'],
  41. radius: '50%',
  42. amplitude: '8%',
  43. waveLength: '80%',
  44. phase: 'auto',
  45. period: 'auto',
  46. direction: 'right',
  47. shape: 'circle',
  48. waveAnimation: true,
  49. animationEasing: 'linear',
  50. animationEasingUpdate: 'linear',
  51. animationDuration: 2000,
  52. animationDurationUpdate: 1000,
  53. outline: {
  54. show: true,
  55. borderDistance: 8,
  56. itemStyle: {
  57. color: 'none',
  58. borderColor: '#294D99',
  59. borderWidth: 8,
  60. shadowBlur: 20,
  61. shadowColor: 'rgba(0, 0, 0, 0.25)'
  62. }
  63. },
  64. backgroundStyle: {
  65. color: '#E3F7FF'
  66. },
  67. itemStyle: {
  68. opacity: 0.95,
  69. shadowBlur: 50,
  70. shadowColor: 'rgba(0, 0, 0, 0.4)'
  71. },
  72. label: {
  73. show: true,
  74. color: '#294D99',
  75. insideColor: '#fff',
  76. fontSize: 50,
  77. fontWeight: 'bold',
  78. align: 'center',
  79. baseline: 'middle',
  80. position: 'inside'
  81. },
  82. emphasis: {
  83. itemStyle: {
  84. opacity: 0.8
  85. }
  86. }
  87. }
  88. });
  89. ;// CONCATENATED MODULE: ./node_modules/zrender/lib/core/util.js
  90. var BUILTIN_OBJECT = {
  91. '[object Function]': true,
  92. '[object RegExp]': true,
  93. '[object Date]': true,
  94. '[object Error]': true,
  95. '[object CanvasGradient]': true,
  96. '[object CanvasPattern]': true,
  97. '[object Image]': true,
  98. '[object Canvas]': true
  99. };
  100. var TYPED_ARRAY = {
  101. '[object Int8Array]': true,
  102. '[object Uint8Array]': true,
  103. '[object Uint8ClampedArray]': true,
  104. '[object Int16Array]': true,
  105. '[object Uint16Array]': true,
  106. '[object Int32Array]': true,
  107. '[object Uint32Array]': true,
  108. '[object Float32Array]': true,
  109. '[object Float64Array]': true
  110. };
  111. var objToString = Object.prototype.toString;
  112. var arrayProto = Array.prototype;
  113. var nativeForEach = arrayProto.forEach;
  114. var nativeFilter = arrayProto.filter;
  115. var nativeSlice = arrayProto.slice;
  116. var nativeMap = arrayProto.map;
  117. var ctorFunction = function () { }.constructor;
  118. var protoFunction = ctorFunction ? ctorFunction.prototype : null;
  119. var methods = {};
  120. function $override(name, fn) {
  121. methods[name] = fn;
  122. }
  123. var idStart = 0x0907;
  124. function guid() {
  125. return idStart++;
  126. }
  127. function logError() {
  128. var args = [];
  129. for (var _i = 0; _i < arguments.length; _i++) {
  130. args[_i] = arguments[_i];
  131. }
  132. if (typeof console !== 'undefined') {
  133. console.error.apply(console, args);
  134. }
  135. }
  136. function clone(source) {
  137. if (source == null || typeof source !== 'object') {
  138. return source;
  139. }
  140. var result = source;
  141. var typeStr = objToString.call(source);
  142. if (typeStr === '[object Array]') {
  143. if (!isPrimitive(source)) {
  144. result = [];
  145. for (var i = 0, len = source.length; i < len; i++) {
  146. result[i] = clone(source[i]);
  147. }
  148. }
  149. }
  150. else if (TYPED_ARRAY[typeStr]) {
  151. if (!isPrimitive(source)) {
  152. var Ctor = source.constructor;
  153. if (Ctor.from) {
  154. result = Ctor.from(source);
  155. }
  156. else {
  157. result = new Ctor(source.length);
  158. for (var i = 0, len = source.length; i < len; i++) {
  159. result[i] = clone(source[i]);
  160. }
  161. }
  162. }
  163. }
  164. else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
  165. result = {};
  166. for (var key in source) {
  167. if (source.hasOwnProperty(key)) {
  168. result[key] = clone(source[key]);
  169. }
  170. }
  171. }
  172. return result;
  173. }
  174. function merge(target, source, overwrite) {
  175. if (!isObject(source) || !isObject(target)) {
  176. return overwrite ? clone(source) : target;
  177. }
  178. for (var key in source) {
  179. if (source.hasOwnProperty(key)) {
  180. var targetProp = target[key];
  181. var sourceProp = source[key];
  182. if (isObject(sourceProp)
  183. && isObject(targetProp)
  184. && !isArray(sourceProp)
  185. && !isArray(targetProp)
  186. && !isDom(sourceProp)
  187. && !isDom(targetProp)
  188. && !isBuiltInObject(sourceProp)
  189. && !isBuiltInObject(targetProp)
  190. && !isPrimitive(sourceProp)
  191. && !isPrimitive(targetProp)) {
  192. merge(targetProp, sourceProp, overwrite);
  193. }
  194. else if (overwrite || !(key in target)) {
  195. target[key] = clone(source[key]);
  196. }
  197. }
  198. }
  199. return target;
  200. }
  201. function mergeAll(targetAndSources, overwrite) {
  202. var result = targetAndSources[0];
  203. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  204. result = merge(result, targetAndSources[i], overwrite);
  205. }
  206. return result;
  207. }
  208. function extend(target, source) {
  209. if (Object.assign) {
  210. Object.assign(target, source);
  211. }
  212. else {
  213. for (var key in source) {
  214. if (source.hasOwnProperty(key)) {
  215. target[key] = source[key];
  216. }
  217. }
  218. }
  219. return target;
  220. }
  221. function defaults(target, source, overlay) {
  222. var keysArr = keys(source);
  223. for (var i = 0; i < keysArr.length; i++) {
  224. var key = keysArr[i];
  225. if ((overlay ? source[key] != null : target[key] == null)) {
  226. target[key] = source[key];
  227. }
  228. }
  229. return target;
  230. }
  231. var createCanvas = function () {
  232. return methods.createCanvas();
  233. };
  234. methods.createCanvas = function () {
  235. return document.createElement('canvas');
  236. };
  237. function indexOf(array, value) {
  238. if (array) {
  239. if (array.indexOf) {
  240. return array.indexOf(value);
  241. }
  242. for (var i = 0, len = array.length; i < len; i++) {
  243. if (array[i] === value) {
  244. return i;
  245. }
  246. }
  247. }
  248. return -1;
  249. }
  250. function inherits(clazz, baseClazz) {
  251. var clazzPrototype = clazz.prototype;
  252. function F() { }
  253. F.prototype = baseClazz.prototype;
  254. clazz.prototype = new F();
  255. for (var prop in clazzPrototype) {
  256. if (clazzPrototype.hasOwnProperty(prop)) {
  257. clazz.prototype[prop] = clazzPrototype[prop];
  258. }
  259. }
  260. clazz.prototype.constructor = clazz;
  261. clazz.superClass = baseClazz;
  262. }
  263. function mixin(target, source, override) {
  264. target = 'prototype' in target ? target.prototype : target;
  265. source = 'prototype' in source ? source.prototype : source;
  266. if (Object.getOwnPropertyNames) {
  267. var keyList = Object.getOwnPropertyNames(source);
  268. for (var i = 0; i < keyList.length; i++) {
  269. var key = keyList[i];
  270. if (key !== 'constructor') {
  271. if ((override ? source[key] != null : target[key] == null)) {
  272. target[key] = source[key];
  273. }
  274. }
  275. }
  276. }
  277. else {
  278. defaults(target, source, override);
  279. }
  280. }
  281. function isArrayLike(data) {
  282. if (!data) {
  283. return false;
  284. }
  285. if (typeof data === 'string') {
  286. return false;
  287. }
  288. return typeof data.length === 'number';
  289. }
  290. function each(arr, cb, context) {
  291. if (!(arr && cb)) {
  292. return;
  293. }
  294. if (arr.forEach && arr.forEach === nativeForEach) {
  295. arr.forEach(cb, context);
  296. }
  297. else if (arr.length === +arr.length) {
  298. for (var i = 0, len = arr.length; i < len; i++) {
  299. cb.call(context, arr[i], i, arr);
  300. }
  301. }
  302. else {
  303. for (var key in arr) {
  304. if (arr.hasOwnProperty(key)) {
  305. cb.call(context, arr[key], key, arr);
  306. }
  307. }
  308. }
  309. }
  310. function map(arr, cb, context) {
  311. if (!arr) {
  312. return [];
  313. }
  314. if (!cb) {
  315. return slice(arr);
  316. }
  317. if (arr.map && arr.map === nativeMap) {
  318. return arr.map(cb, context);
  319. }
  320. else {
  321. var result = [];
  322. for (var i = 0, len = arr.length; i < len; i++) {
  323. result.push(cb.call(context, arr[i], i, arr));
  324. }
  325. return result;
  326. }
  327. }
  328. function reduce(arr, cb, memo, context) {
  329. if (!(arr && cb)) {
  330. return;
  331. }
  332. for (var i = 0, len = arr.length; i < len; i++) {
  333. memo = cb.call(context, memo, arr[i], i, arr);
  334. }
  335. return memo;
  336. }
  337. function filter(arr, cb, context) {
  338. if (!arr) {
  339. return [];
  340. }
  341. if (!cb) {
  342. return slice(arr);
  343. }
  344. if (arr.filter && arr.filter === nativeFilter) {
  345. return arr.filter(cb, context);
  346. }
  347. else {
  348. var result = [];
  349. for (var i = 0, len = arr.length; i < len; i++) {
  350. if (cb.call(context, arr[i], i, arr)) {
  351. result.push(arr[i]);
  352. }
  353. }
  354. return result;
  355. }
  356. }
  357. function find(arr, cb, context) {
  358. if (!(arr && cb)) {
  359. return;
  360. }
  361. for (var i = 0, len = arr.length; i < len; i++) {
  362. if (cb.call(context, arr[i], i, arr)) {
  363. return arr[i];
  364. }
  365. }
  366. }
  367. function keys(obj) {
  368. if (!obj) {
  369. return [];
  370. }
  371. if (Object.keys) {
  372. return Object.keys(obj);
  373. }
  374. var keyList = [];
  375. for (var key in obj) {
  376. if (obj.hasOwnProperty(key)) {
  377. keyList.push(key);
  378. }
  379. }
  380. return keyList;
  381. }
  382. function bindPolyfill(func, context) {
  383. var args = [];
  384. for (var _i = 2; _i < arguments.length; _i++) {
  385. args[_i - 2] = arguments[_i];
  386. }
  387. return function () {
  388. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  389. };
  390. }
  391. var bind = (protoFunction && isFunction(protoFunction.bind))
  392. ? protoFunction.call.bind(protoFunction.bind)
  393. : bindPolyfill;
  394. function curry(func) {
  395. var args = [];
  396. for (var _i = 1; _i < arguments.length; _i++) {
  397. args[_i - 1] = arguments[_i];
  398. }
  399. return function () {
  400. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  401. };
  402. }
  403. function isArray(value) {
  404. if (Array.isArray) {
  405. return Array.isArray(value);
  406. }
  407. return objToString.call(value) === '[object Array]';
  408. }
  409. function isFunction(value) {
  410. return typeof value === 'function';
  411. }
  412. function isString(value) {
  413. return typeof value === 'string';
  414. }
  415. function isStringSafe(value) {
  416. return objToString.call(value) === '[object String]';
  417. }
  418. function isNumber(value) {
  419. return typeof value === 'number';
  420. }
  421. function isObject(value) {
  422. var type = typeof value;
  423. return type === 'function' || (!!value && type === 'object');
  424. }
  425. function isBuiltInObject(value) {
  426. return !!BUILTIN_OBJECT[objToString.call(value)];
  427. }
  428. function isTypedArray(value) {
  429. return !!TYPED_ARRAY[objToString.call(value)];
  430. }
  431. function isDom(value) {
  432. return typeof value === 'object'
  433. && typeof value.nodeType === 'number'
  434. && typeof value.ownerDocument === 'object';
  435. }
  436. function isGradientObject(value) {
  437. return value.colorStops != null;
  438. }
  439. function isPatternObject(value) {
  440. return value.image != null;
  441. }
  442. function isRegExp(value) {
  443. return objToString.call(value) === '[object RegExp]';
  444. }
  445. function eqNaN(value) {
  446. return value !== value;
  447. }
  448. function retrieve() {
  449. var args = [];
  450. for (var _i = 0; _i < arguments.length; _i++) {
  451. args[_i] = arguments[_i];
  452. }
  453. for (var i = 0, len = args.length; i < len; i++) {
  454. if (args[i] != null) {
  455. return args[i];
  456. }
  457. }
  458. }
  459. function retrieve2(value0, value1) {
  460. return value0 != null
  461. ? value0
  462. : value1;
  463. }
  464. function retrieve3(value0, value1, value2) {
  465. return value0 != null
  466. ? value0
  467. : value1 != null
  468. ? value1
  469. : value2;
  470. }
  471. function slice(arr) {
  472. var args = [];
  473. for (var _i = 1; _i < arguments.length; _i++) {
  474. args[_i - 1] = arguments[_i];
  475. }
  476. return nativeSlice.apply(arr, args);
  477. }
  478. function normalizeCssArray(val) {
  479. if (typeof (val) === 'number') {
  480. return [val, val, val, val];
  481. }
  482. var len = val.length;
  483. if (len === 2) {
  484. return [val[0], val[1], val[0], val[1]];
  485. }
  486. else if (len === 3) {
  487. return [val[0], val[1], val[2], val[1]];
  488. }
  489. return val;
  490. }
  491. function assert(condition, message) {
  492. if (!condition) {
  493. throw new Error(message);
  494. }
  495. }
  496. function trim(str) {
  497. if (str == null) {
  498. return null;
  499. }
  500. else if (typeof str.trim === 'function') {
  501. return str.trim();
  502. }
  503. else {
  504. return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  505. }
  506. }
  507. var primitiveKey = '__ec_primitive__';
  508. function setAsPrimitive(obj) {
  509. obj[primitiveKey] = true;
  510. }
  511. function isPrimitive(obj) {
  512. return obj[primitiveKey];
  513. }
  514. var HashMap = (function () {
  515. function HashMap(obj) {
  516. this.data = {};
  517. var isArr = isArray(obj);
  518. this.data = {};
  519. var thisMap = this;
  520. (obj instanceof HashMap)
  521. ? obj.each(visit)
  522. : (obj && each(obj, visit));
  523. function visit(value, key) {
  524. isArr ? thisMap.set(value, key) : thisMap.set(key, value);
  525. }
  526. }
  527. HashMap.prototype.get = function (key) {
  528. return this.data.hasOwnProperty(key) ? this.data[key] : null;
  529. };
  530. HashMap.prototype.set = function (key, value) {
  531. return (this.data[key] = value);
  532. };
  533. HashMap.prototype.each = function (cb, context) {
  534. for (var key in this.data) {
  535. if (this.data.hasOwnProperty(key)) {
  536. cb.call(context, this.data[key], key);
  537. }
  538. }
  539. };
  540. HashMap.prototype.keys = function () {
  541. return keys(this.data);
  542. };
  543. HashMap.prototype.removeKey = function (key) {
  544. delete this.data[key];
  545. };
  546. return HashMap;
  547. }());
  548. function createHashMap(obj) {
  549. return new HashMap(obj);
  550. }
  551. function concatArray(a, b) {
  552. var newArray = new a.constructor(a.length + b.length);
  553. for (var i = 0; i < a.length; i++) {
  554. newArray[i] = a[i];
  555. }
  556. var offset = a.length;
  557. for (var i = 0; i < b.length; i++) {
  558. newArray[i + offset] = b[i];
  559. }
  560. return newArray;
  561. }
  562. function createObject(proto, properties) {
  563. var obj;
  564. if (Object.create) {
  565. obj = Object.create(proto);
  566. }
  567. else {
  568. var StyleCtor = function () { };
  569. StyleCtor.prototype = proto;
  570. obj = new StyleCtor();
  571. }
  572. if (properties) {
  573. extend(obj, properties);
  574. }
  575. return obj;
  576. }
  577. function hasOwn(own, prop) {
  578. return own.hasOwnProperty(prop);
  579. }
  580. function noop() { }
  581. ;// CONCATENATED MODULE: ./node_modules/echarts/lib/util/number.js
  582. /*
  583. * Licensed to the Apache Software Foundation (ASF) under one
  584. * or more contributor license agreements. See the NOTICE file
  585. * distributed with this work for additional information
  586. * regarding copyright ownership. The ASF licenses this file
  587. * to you under the Apache License, Version 2.0 (the
  588. * "License"); you may not use this file except in compliance
  589. * with the License. You may obtain a copy of the License at
  590. *
  591. * http://www.apache.org/licenses/LICENSE-2.0
  592. *
  593. * Unless required by applicable law or agreed to in writing,
  594. * software distributed under the License is distributed on an
  595. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  596. * KIND, either express or implied. See the License for the
  597. * specific language governing permissions and limitations
  598. * under the License.
  599. */
  600. /**
  601. * AUTO-GENERATED FILE. DO NOT MODIFY.
  602. */
  603. var RADIAN_EPSILON = 1e-4;
  604. function _trim(str) {
  605. return str.replace(/^\s+|\s+$/g, '');
  606. }
  607. function linearMap(val, domain, range, clamp) {
  608. var subDomain = domain[1] - domain[0];
  609. var subRange = range[1] - range[0];
  610. if (subDomain === 0) {
  611. return subRange === 0 ? range[0] : (range[0] + range[1]) / 2;
  612. }
  613. if (clamp) {
  614. if (subDomain > 0) {
  615. if (val <= domain[0]) {
  616. return range[0];
  617. } else if (val >= domain[1]) {
  618. return range[1];
  619. }
  620. } else {
  621. if (val >= domain[0]) {
  622. return range[0];
  623. } else if (val <= domain[1]) {
  624. return range[1];
  625. }
  626. }
  627. } else {
  628. if (val === domain[0]) {
  629. return range[0];
  630. }
  631. if (val === domain[1]) {
  632. return range[1];
  633. }
  634. }
  635. return (val - domain[0]) / subDomain * subRange + range[0];
  636. }
  637. function parsePercent(percent, all) {
  638. switch (percent) {
  639. case 'center':
  640. case 'middle':
  641. percent = '50%';
  642. break;
  643. case 'left':
  644. case 'top':
  645. percent = '0%';
  646. break;
  647. case 'right':
  648. case 'bottom':
  649. percent = '100%';
  650. break;
  651. }
  652. if (typeof percent === 'string') {
  653. if (_trim(percent).match(/%$/)) {
  654. return parseFloat(percent) / 100 * all;
  655. }
  656. return parseFloat(percent);
  657. }
  658. return percent == null ? NaN : +percent;
  659. }
  660. function round(x, precision, returnStr) {
  661. if (precision == null) {
  662. precision = 10;
  663. }
  664. precision = Math.min(Math.max(0, precision), 20);
  665. x = (+x).toFixed(precision);
  666. return returnStr ? x : +x;
  667. }
  668. function asc(arr) {
  669. arr.sort(function (a, b) {
  670. return a - b;
  671. });
  672. return arr;
  673. }
  674. function getPrecision(val) {
  675. val = +val;
  676. if (isNaN(val)) {
  677. return 0;
  678. }
  679. var e = 1;
  680. var count = 0;
  681. while (Math.round(val * e) / e !== val) {
  682. e *= 10;
  683. count++;
  684. }
  685. return count;
  686. }
  687. function getPrecisionSafe(val) {
  688. var str = val.toString();
  689. var eIndex = str.indexOf('e');
  690. if (eIndex > 0) {
  691. var precision = +str.slice(eIndex + 1);
  692. return precision < 0 ? -precision : 0;
  693. } else {
  694. var dotIndex = str.indexOf('.');
  695. return dotIndex < 0 ? 0 : str.length - 1 - dotIndex;
  696. }
  697. }
  698. function getPixelPrecision(dataExtent, pixelExtent) {
  699. var log = Math.log;
  700. var LN10 = Math.LN10;
  701. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  702. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
  703. var precision = Math.min(Math.max(-dataQuantity + sizeQuantity, 0), 20);
  704. return !isFinite(precision) ? 20 : precision;
  705. }
  706. function getPercentWithPrecision(valueList, idx, precision) {
  707. if (!valueList[idx]) {
  708. return 0;
  709. }
  710. var sum = reduce(valueList, function (acc, val) {
  711. return acc + (isNaN(val) ? 0 : val);
  712. }, 0);
  713. if (sum === 0) {
  714. return 0;
  715. }
  716. var digits = Math.pow(10, precision);
  717. var votesPerQuota = map(valueList, function (val) {
  718. return (isNaN(val) ? 0 : val) / sum * digits * 100;
  719. });
  720. var targetSeats = digits * 100;
  721. var seats = map(votesPerQuota, function (votes) {
  722. return Math.floor(votes);
  723. });
  724. var currentSum = reduce(seats, function (acc, val) {
  725. return acc + val;
  726. }, 0);
  727. var remainder = map(votesPerQuota, function (votes, idx) {
  728. return votes - seats[idx];
  729. });
  730. while (currentSum < targetSeats) {
  731. var max = Number.NEGATIVE_INFINITY;
  732. var maxId = null;
  733. for (var i = 0, len = remainder.length; i < len; ++i) {
  734. if (remainder[i] > max) {
  735. max = remainder[i];
  736. maxId = i;
  737. }
  738. }
  739. ++seats[maxId];
  740. remainder[maxId] = 0;
  741. ++currentSum;
  742. }
  743. return seats[idx] / digits;
  744. }
  745. var MAX_SAFE_INTEGER = 9007199254740991;
  746. function remRadian(radian) {
  747. var pi2 = Math.PI * 2;
  748. return (radian % pi2 + pi2) % pi2;
  749. }
  750. function isRadianAroundZero(val) {
  751. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  752. }
  753. var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;
  754. function parseDate(value) {
  755. if (value instanceof Date) {
  756. return value;
  757. } else if (typeof value === 'string') {
  758. var match = TIME_REG.exec(value);
  759. if (!match) {
  760. return new Date(NaN);
  761. }
  762. if (!match[8]) {
  763. return new Date(+match[1], +(match[2] || 1) - 1, +match[3] || 1, +match[4] || 0, +(match[5] || 0), +match[6] || 0, +match[7] || 0);
  764. } else {
  765. var hour = +match[4] || 0;
  766. if (match[8].toUpperCase() !== 'Z') {
  767. hour -= +match[8].slice(0, 3);
  768. }
  769. return new Date(Date.UTC(+match[1], +(match[2] || 1) - 1, +match[3] || 1, hour, +(match[5] || 0), +match[6] || 0, +match[7] || 0));
  770. }
  771. } else if (value == null) {
  772. return new Date(NaN);
  773. }
  774. return new Date(Math.round(value));
  775. }
  776. function quantity(val) {
  777. return Math.pow(10, quantityExponent(val));
  778. }
  779. function quantityExponent(val) {
  780. if (val === 0) {
  781. return 0;
  782. }
  783. var exp = Math.floor(Math.log(val) / Math.LN10);
  784. if (val / Math.pow(10, exp) >= 10) {
  785. exp++;
  786. }
  787. return exp;
  788. }
  789. function nice(val, round) {
  790. var exponent = quantityExponent(val);
  791. var exp10 = Math.pow(10, exponent);
  792. var f = val / exp10;
  793. var nf;
  794. if (round) {
  795. if (f < 1.5) {
  796. nf = 1;
  797. } else if (f < 2.5) {
  798. nf = 2;
  799. } else if (f < 4) {
  800. nf = 3;
  801. } else if (f < 7) {
  802. nf = 5;
  803. } else {
  804. nf = 10;
  805. }
  806. } else {
  807. if (f < 1) {
  808. nf = 1;
  809. } else if (f < 2) {
  810. nf = 2;
  811. } else if (f < 3) {
  812. nf = 3;
  813. } else if (f < 5) {
  814. nf = 5;
  815. } else {
  816. nf = 10;
  817. }
  818. }
  819. val = nf * exp10;
  820. return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
  821. }
  822. function quantile(ascArr, p) {
  823. var H = (ascArr.length - 1) * p + 1;
  824. var h = Math.floor(H);
  825. var v = +ascArr[h - 1];
  826. var e = H - h;
  827. return e ? v + e * (ascArr[h] - v) : v;
  828. }
  829. function reformIntervals(list) {
  830. list.sort(function (a, b) {
  831. return littleThan(a, b, 0) ? -1 : 1;
  832. });
  833. var curr = -Infinity;
  834. var currClose = 1;
  835. for (var i = 0; i < list.length;) {
  836. var interval = list[i].interval;
  837. var close_1 = list[i].close;
  838. for (var lg = 0; lg < 2; lg++) {
  839. if (interval[lg] <= curr) {
  840. interval[lg] = curr;
  841. close_1[lg] = !lg ? 1 - currClose : 1;
  842. }
  843. curr = interval[lg];
  844. currClose = close_1[lg];
  845. }
  846. if (interval[0] === interval[1] && close_1[0] * close_1[1] !== 1) {
  847. list.splice(i, 1);
  848. } else {
  849. i++;
  850. }
  851. }
  852. return list;
  853. function littleThan(a, b, lg) {
  854. return a.interval[lg] < b.interval[lg] || a.interval[lg] === b.interval[lg] && (a.close[lg] - b.close[lg] === (!lg ? 1 : -1) || !lg && littleThan(a, b, 1));
  855. }
  856. }
  857. function numericToNumber(val) {
  858. var valFloat = parseFloat(val);
  859. return valFloat == val && (valFloat !== 0 || typeof val !== 'string' || val.indexOf('x') <= 0) ? valFloat : NaN;
  860. }
  861. function isNumeric(val) {
  862. return !isNaN(numericToNumber(val));
  863. }
  864. function getRandomIdBase() {
  865. return Math.round(Math.random() * 9);
  866. }
  867. function getGreatestCommonDividor(a, b) {
  868. if (b === 0) {
  869. return a;
  870. }
  871. return getGreatestCommonDividor(b, a % b);
  872. }
  873. function getLeastCommonMultiple(a, b) {
  874. if (a == null) {
  875. return b;
  876. }
  877. if (b == null) {
  878. return a;
  879. }
  880. return a * b / getGreatestCommonDividor(a, b);
  881. }
  882. ;// CONCATENATED MODULE: ./src/liquidFillShape.js
  883. /* harmony default export */ const liquidFillShape = (external_echarts_.graphic.extendShape({
  884. type: 'ec-liquid-fill',
  885. shape: {
  886. waveLength: 0,
  887. radius: 0,
  888. radiusY: 0,
  889. cx: 0,
  890. cy: 0,
  891. waterLevel: 0,
  892. amplitude: 0,
  893. phase: 0,
  894. inverse: false
  895. },
  896. buildPath: function (ctx, shape) {
  897. if (shape.radiusY == null) {
  898. shape.radiusY = shape.radius;
  899. }
  900. /**
  901. * We define a sine wave having 4 waves, and make sure at least 8 curves
  902. * is drawn. Otherwise, it may cause blank area for some waves when
  903. * wave length is large enough.
  904. */
  905. var curves = Math.max(
  906. Math.ceil(2 * shape.radius / shape.waveLength * 4) * 2,
  907. 8
  908. );
  909. // map phase to [-Math.PI * 2, 0]
  910. while (shape.phase < -Math.PI * 2) {
  911. shape.phase += Math.PI * 2;
  912. }
  913. while (shape.phase > 0) {
  914. shape.phase -= Math.PI * 2;
  915. }
  916. var phase = shape.phase / Math.PI / 2 * shape.waveLength;
  917. var left = shape.cx - shape.radius + phase - shape.radius * 2;
  918. /**
  919. * top-left corner as start point
  920. *
  921. * draws this point
  922. * |
  923. * \|/
  924. * ~~~~~~~~
  925. * | |
  926. * +------+
  927. */
  928. ctx.moveTo(left, shape.waterLevel);
  929. /**
  930. * top wave
  931. *
  932. * ~~~~~~~~ <- draws this sine wave
  933. * | |
  934. * +------+
  935. */
  936. var waveRight = 0;
  937. for (var c = 0; c < curves; ++c) {
  938. var stage = c % 4;
  939. var pos = getWaterPositions(c * shape.waveLength / 4, stage,
  940. shape.waveLength, shape.amplitude);
  941. ctx.bezierCurveTo(pos[0][0] + left, -pos[0][1] + shape.waterLevel,
  942. pos[1][0] + left, -pos[1][1] + shape.waterLevel,
  943. pos[2][0] + left, -pos[2][1] + shape.waterLevel);
  944. if (c === curves - 1) {
  945. waveRight = pos[2][0];
  946. }
  947. }
  948. if (shape.inverse) {
  949. /**
  950. * top-right corner
  951. * 2. draws this line
  952. * |
  953. * +------+
  954. * 3. draws this line -> | | <- 1. draws this line
  955. * ~~~~~~~~
  956. */
  957. ctx.lineTo(waveRight + left, shape.cy - shape.radiusY);
  958. ctx.lineTo(left, shape.cy - shape.radiusY);
  959. ctx.lineTo(left, shape.waterLevel);
  960. }
  961. else {
  962. /**
  963. * top-right corner
  964. *
  965. * ~~~~~~~~
  966. * 3. draws this line -> | | <- 1. draws this line
  967. * +------+
  968. * ^
  969. * |
  970. * 2. draws this line
  971. */
  972. ctx.lineTo(waveRight + left, shape.cy + shape.radiusY);
  973. ctx.lineTo(left, shape.cy + shape.radiusY);
  974. ctx.lineTo(left, shape.waterLevel);
  975. }
  976. ctx.closePath();
  977. }
  978. }));
  979. /**
  980. * Using Bezier curves to fit sine wave.
  981. * There is 4 control points for each curve of wave,
  982. * which is at 1/4 wave length of the sine wave.
  983. *
  984. * The control points for a wave from (a) to (d) are a-b-c-d:
  985. * c *----* d
  986. * b *
  987. * |
  988. * ... a * ..................
  989. *
  990. * whose positions are a: (0, 0), b: (0.5, 0.5), c: (1, 1), d: (PI / 2, 1)
  991. *
  992. * @param {number} x x position of the left-most point (a)
  993. * @param {number} stage 0-3, stating which part of the wave it is
  994. * @param {number} waveLength wave length of the sine wave
  995. * @param {number} amplitude wave amplitude
  996. */
  997. function getWaterPositions(x, stage, waveLength, amplitude) {
  998. if (stage === 0) {
  999. return [
  1000. [x + 1 / 2 * waveLength / Math.PI / 2, amplitude / 2],
  1001. [x + 1 / 2 * waveLength / Math.PI, amplitude],
  1002. [x + waveLength / 4, amplitude]
  1003. ];
  1004. }
  1005. else if (stage === 1) {
  1006. return [
  1007. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2),
  1008. amplitude],
  1009. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1),
  1010. amplitude / 2],
  1011. [x + waveLength / 4, 0]
  1012. ]
  1013. }
  1014. else if (stage === 2) {
  1015. return [
  1016. [x + 1 / 2 * waveLength / Math.PI / 2, -amplitude / 2],
  1017. [x + 1 / 2 * waveLength / Math.PI, -amplitude],
  1018. [x + waveLength / 4, -amplitude]
  1019. ]
  1020. }
  1021. else {
  1022. return [
  1023. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2),
  1024. -amplitude],
  1025. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1),
  1026. -amplitude / 2],
  1027. [x + waveLength / 4, 0]
  1028. ]
  1029. }
  1030. }
  1031. ;// CONCATENATED MODULE: ./src/liquidFillView.js
  1032. const liquidFillView_parsePercent = parsePercent;
  1033. external_echarts_.extendChartView({
  1034. type: 'liquidFill',
  1035. render: function (seriesModel, ecModel, api) {
  1036. var group = this.group;
  1037. group.removeAll();
  1038. var data = seriesModel.getData();
  1039. var itemModel = data.getItemModel(0);
  1040. var center = itemModel.get('center');
  1041. var radius = itemModel.get('radius');
  1042. var width = api.getWidth();
  1043. var height = api.getHeight();
  1044. var size = Math.min(width, height);
  1045. // itemStyle
  1046. var outlineDistance = 0;
  1047. var outlineBorderWidth = 0;
  1048. var showOutline = seriesModel.get('outline.show');
  1049. if (showOutline) {
  1050. outlineDistance = seriesModel.get('outline.borderDistance');
  1051. outlineBorderWidth = liquidFillView_parsePercent(
  1052. seriesModel.get('outline.itemStyle.borderWidth'), size
  1053. );
  1054. }
  1055. var cx = liquidFillView_parsePercent(center[0], width);
  1056. var cy = liquidFillView_parsePercent(center[1], height);
  1057. var outterRadius;
  1058. var innerRadius;
  1059. var paddingRadius;
  1060. var isFillContainer = false;
  1061. var symbol = seriesModel.get('shape');
  1062. if (symbol === 'container') {
  1063. // a shape that fully fills the container
  1064. isFillContainer = true;
  1065. outterRadius = [
  1066. width / 2,
  1067. height / 2
  1068. ];
  1069. innerRadius = [
  1070. outterRadius[0] - outlineBorderWidth / 2,
  1071. outterRadius[1] - outlineBorderWidth / 2
  1072. ];
  1073. paddingRadius = [
  1074. liquidFillView_parsePercent(outlineDistance, width),
  1075. liquidFillView_parsePercent(outlineDistance, height)
  1076. ];
  1077. radius = [
  1078. Math.max(innerRadius[0] - paddingRadius[0], 0),
  1079. Math.max(innerRadius[1] - paddingRadius[1], 0)
  1080. ];
  1081. }
  1082. else {
  1083. outterRadius = liquidFillView_parsePercent(radius, size) / 2;
  1084. innerRadius = outterRadius - outlineBorderWidth / 2;
  1085. paddingRadius = liquidFillView_parsePercent(outlineDistance, size);
  1086. radius = Math.max(innerRadius - paddingRadius, 0);
  1087. }
  1088. if (showOutline) {
  1089. var outline = getOutline();
  1090. outline.style.lineWidth = outlineBorderWidth;
  1091. group.add(getOutline());
  1092. }
  1093. var left = isFillContainer ? 0 : cx - radius;
  1094. var top = isFillContainer ? 0 : cy - radius;
  1095. var wavePath = null;
  1096. group.add(getBackground());
  1097. // each data item for a wave
  1098. var oldData = this._data;
  1099. var waves = [];
  1100. data.diff(oldData)
  1101. .add(function (idx) {
  1102. var wave = getWave(idx, false);
  1103. var waterLevel = wave.shape.waterLevel;
  1104. wave.shape.waterLevel = isFillContainer ? height / 2 : radius;
  1105. external_echarts_.graphic.initProps(wave, {
  1106. shape: {
  1107. waterLevel: waterLevel
  1108. }
  1109. }, seriesModel);
  1110. wave.z2 = 2;
  1111. setWaveAnimation(idx, wave, null);
  1112. group.add(wave);
  1113. data.setItemGraphicEl(idx, wave);
  1114. waves.push(wave);
  1115. })
  1116. .update(function (newIdx, oldIdx) {
  1117. var waveElement = oldData.getItemGraphicEl(oldIdx);
  1118. // new wave is used to calculate position, but not added
  1119. var newWave = getWave(newIdx, false, waveElement);
  1120. // changes with animation
  1121. var shape = {};
  1122. var shapeAttrs = ['amplitude', 'cx', 'cy', 'phase', 'radius', 'radiusY', 'waterLevel', 'waveLength'];
  1123. for (var i = 0; i < shapeAttrs.length; ++i) {
  1124. var attr = shapeAttrs[i];
  1125. if (newWave.shape.hasOwnProperty(attr)) {
  1126. shape[attr] = newWave.shape[attr];
  1127. }
  1128. }
  1129. var style = {};
  1130. var styleAttrs = ['fill', 'opacity', 'shadowBlur', 'shadowColor'];
  1131. for (var i = 0; i < styleAttrs.length; ++i) {
  1132. var attr = styleAttrs[i];
  1133. if (newWave.style.hasOwnProperty(attr)) {
  1134. style[attr] = newWave.style[attr];
  1135. }
  1136. }
  1137. if (isFillContainer) {
  1138. shape.radiusY = height / 2;
  1139. }
  1140. // changes with animation
  1141. external_echarts_.graphic.updateProps(waveElement, {
  1142. shape: shape
  1143. }, seriesModel);
  1144. waveElement.useStyle(style);
  1145. // instant changes
  1146. waveElement.position = newWave.position;
  1147. waveElement.setClipPath(newWave.getClipPath());
  1148. waveElement.shape.inverse = newWave.inverse;
  1149. setWaveAnimation(newIdx, waveElement, waveElement);
  1150. group.add(waveElement);
  1151. data.setItemGraphicEl(newIdx, waveElement);
  1152. waves.push(waveElement);
  1153. })
  1154. .remove(function (idx) {
  1155. var wave = oldData.getItemGraphicEl(idx);
  1156. group.remove(wave);
  1157. })
  1158. .execute();
  1159. if (itemModel.get('label.show')) {
  1160. group.add(getText(waves));
  1161. }
  1162. this._data = data;
  1163. /**
  1164. * Get path for outline, background and clipping
  1165. *
  1166. * @param {number} r outter radius of shape
  1167. * @param {boolean|undefined} isForClipping if the shape is used
  1168. * for clipping
  1169. */
  1170. function getPath(r, isForClipping) {
  1171. if (symbol) {
  1172. // customed symbol path
  1173. if (symbol.indexOf('path://') === 0) {
  1174. var path = external_echarts_.graphic.makePath(symbol.slice(7), {});
  1175. var bouding = path.getBoundingRect();
  1176. var w = bouding.width;
  1177. var h = bouding.height;
  1178. if (w > h) {
  1179. h = r * 2 / w * h;
  1180. w = r * 2;
  1181. }
  1182. else {
  1183. w = r * 2 / h * w;
  1184. h = r * 2;
  1185. }
  1186. var left = isForClipping ? 0 : cx - w / 2;
  1187. var top = isForClipping ? 0 : cy - h / 2;
  1188. path = external_echarts_.graphic.makePath(
  1189. symbol.slice(7),
  1190. {},
  1191. new external_echarts_.graphic.BoundingRect(left, top, w, h)
  1192. );
  1193. if (isForClipping) {
  1194. path.position = [-w / 2, -h / 2];
  1195. }
  1196. return path;
  1197. }
  1198. else if (isFillContainer) {
  1199. // fully fill the container
  1200. var x = isForClipping ? -r[0] : cx - r[0];
  1201. var y = isForClipping ? -r[1] : cy - r[1];
  1202. return external_echarts_.helper.createSymbol(
  1203. 'rect', x, y, r[0] * 2, r[1] * 2
  1204. );
  1205. }
  1206. else {
  1207. var x = isForClipping ? -r : cx - r;
  1208. var y = isForClipping ? -r : cy - r;
  1209. if (symbol === 'pin') {
  1210. y += r;
  1211. }
  1212. else if (symbol === 'arrow') {
  1213. y -= r;
  1214. }
  1215. return external_echarts_.helper.createSymbol(symbol, x, y, r * 2, r * 2);
  1216. }
  1217. }
  1218. return new external_echarts_.graphic.Circle({
  1219. shape: {
  1220. cx: isForClipping ? 0 : cx,
  1221. cy: isForClipping ? 0 : cy,
  1222. r: r
  1223. }
  1224. });
  1225. }
  1226. /**
  1227. * Create outline
  1228. */
  1229. function getOutline() {
  1230. var outlinePath = getPath(outterRadius);
  1231. outlinePath.style.fill = null;
  1232. outlinePath.setStyle(seriesModel.getModel('outline.itemStyle')
  1233. .getItemStyle());
  1234. return outlinePath;
  1235. }
  1236. /**
  1237. * Create background
  1238. */
  1239. function getBackground() {
  1240. // Seperate stroke and fill, so we can use stroke to cover the alias of clipping.
  1241. var strokePath = getPath(radius);
  1242. strokePath.setStyle(seriesModel.getModel('backgroundStyle')
  1243. .getItemStyle());
  1244. strokePath.style.fill = null;
  1245. // Stroke is front of wave
  1246. strokePath.z2 = 5;
  1247. var fillPath = getPath(radius);
  1248. fillPath.setStyle(seriesModel.getModel('backgroundStyle')
  1249. .getItemStyle());
  1250. fillPath.style.stroke = null;
  1251. var group = new external_echarts_.graphic.Group();
  1252. group.add(strokePath);
  1253. group.add(fillPath);
  1254. return group;
  1255. }
  1256. /**
  1257. * wave shape
  1258. */
  1259. function getWave(idx, isInverse, oldWave) {
  1260. var radiusX = isFillContainer ? radius[0] : radius;
  1261. var radiusY = isFillContainer ? height / 2 : radius;
  1262. var itemModel = data.getItemModel(idx);
  1263. var itemStyleModel = itemModel.getModel('itemStyle');
  1264. var phase = itemModel.get('phase');
  1265. var amplitude = liquidFillView_parsePercent(itemModel.get('amplitude'),
  1266. radiusY * 2);
  1267. var waveLength = liquidFillView_parsePercent(itemModel.get('waveLength'),
  1268. radiusX * 2);
  1269. var value = data.get('value', idx);
  1270. var waterLevel = radiusY - value * radiusY * 2;
  1271. phase = oldWave ? oldWave.shape.phase
  1272. : (phase === 'auto' ? idx * Math.PI / 4 : phase);
  1273. var normalStyle = itemStyleModel.getItemStyle();
  1274. if (!normalStyle.fill) {
  1275. var seriesColor = seriesModel.get('color');
  1276. var id = idx % seriesColor.length;
  1277. normalStyle.fill = seriesColor[id];
  1278. }
  1279. var x = radiusX * 2;
  1280. var wave = new liquidFillShape({
  1281. shape: {
  1282. waveLength: waveLength,
  1283. radius: radiusX,
  1284. radiusY: radiusY,
  1285. cx: x,
  1286. cy: 0,
  1287. waterLevel: waterLevel,
  1288. amplitude: amplitude,
  1289. phase: phase,
  1290. inverse: isInverse
  1291. },
  1292. style: normalStyle,
  1293. position: [cx, cy]
  1294. });
  1295. wave.shape._waterLevel = waterLevel;
  1296. var hoverStyle = itemModel.getModel('emphasis.itemStyle')
  1297. .getItemStyle();
  1298. hoverStyle.lineWidth = 0;
  1299. wave.ensureState('emphasis').style = hoverStyle;
  1300. external_echarts_.helper.enableHoverEmphasis(wave);
  1301. // clip out the part outside the circle
  1302. var clip = getPath(radius, true);
  1303. // set fill for clipPath, otherwise it will not trigger hover event
  1304. clip.setStyle({
  1305. fill: 'white'
  1306. });
  1307. wave.setClipPath(clip);
  1308. return wave;
  1309. }
  1310. function setWaveAnimation(idx, wave, oldWave) {
  1311. var itemModel = data.getItemModel(idx);
  1312. var maxSpeed = itemModel.get('period');
  1313. var direction = itemModel.get('direction');
  1314. var value = data.get('value', idx);
  1315. var phase = itemModel.get('phase');
  1316. phase = oldWave ? oldWave.shape.phase
  1317. : (phase === 'auto' ? idx * Math.PI / 4 : phase);
  1318. var defaultSpeed = function (maxSpeed) {
  1319. var cnt = data.count();
  1320. return cnt === 0 ? maxSpeed : maxSpeed *
  1321. (0.2 + (cnt - idx) / cnt * 0.8);
  1322. };
  1323. var speed = 0;
  1324. if (maxSpeed === 'auto') {
  1325. speed = defaultSpeed(5000);
  1326. }
  1327. else {
  1328. speed = typeof maxSpeed === 'function'
  1329. ? maxSpeed(value, idx) : maxSpeed;
  1330. }
  1331. // phase for moving left/right
  1332. var phaseOffset = 0;
  1333. if (direction === 'right' || direction == null) {
  1334. phaseOffset = Math.PI;
  1335. }
  1336. else if (direction === 'left') {
  1337. phaseOffset = -Math.PI;
  1338. }
  1339. else if (direction === 'none') {
  1340. phaseOffset = 0;
  1341. }
  1342. else {
  1343. console.error('Illegal direction value for liquid fill.');
  1344. }
  1345. // wave animation of moving left/right
  1346. if (direction !== 'none' && itemModel.get('waveAnimation')) {
  1347. wave
  1348. .animate('shape', true)
  1349. .when(0, {
  1350. phase: phase
  1351. })
  1352. .when(speed / 2, {
  1353. phase: phaseOffset + phase
  1354. })
  1355. .when(speed, {
  1356. phase: phaseOffset * 2 + phase
  1357. })
  1358. .during(function () {
  1359. if (wavePath) {
  1360. wavePath.dirty(true);
  1361. }
  1362. })
  1363. .start();
  1364. }
  1365. }
  1366. /**
  1367. * text on wave
  1368. */
  1369. function getText(waves) {
  1370. var labelModel = itemModel.getModel('label');
  1371. function formatLabel() {
  1372. var formatted = seriesModel.getFormattedLabel(0, 'normal');
  1373. var defaultVal = (data.get('value', 0) * 100);
  1374. var defaultLabel = data.getName(0) || seriesModel.name;
  1375. if (!isNaN(defaultVal)) {
  1376. defaultLabel = defaultVal.toFixed(0) + '%';
  1377. }
  1378. return formatted == null ? defaultLabel : formatted;
  1379. }
  1380. var textRectOption = {
  1381. z2: 10,
  1382. shape: {
  1383. x: left,
  1384. y: top,
  1385. width: (isFillContainer ? radius[0] : radius) * 2,
  1386. height: (isFillContainer ? radius[1] : radius) * 2
  1387. },
  1388. style: {
  1389. fill: 'transparent'
  1390. },
  1391. textConfig: {
  1392. position: labelModel.get('position') || 'inside'
  1393. },
  1394. silent: true
  1395. };
  1396. var textOption = {
  1397. style: {
  1398. text: formatLabel(),
  1399. textAlign: labelModel.get('align'),
  1400. textVerticalAlign: labelModel.get('baseline')
  1401. }
  1402. };
  1403. Object.assign(textOption.style, external_echarts_.helper.createTextStyle(labelModel));
  1404. var outsideTextRect = new external_echarts_.graphic.Rect(textRectOption);
  1405. var insideTextRect = new external_echarts_.graphic.Rect(textRectOption);
  1406. insideTextRect.disableLabelAnimation = true;
  1407. outsideTextRect.disableLabelAnimation = true;
  1408. var outsideText = new external_echarts_.graphic.Text(textOption);
  1409. var insideText = new external_echarts_.graphic.Text(textOption);
  1410. outsideTextRect.setTextContent(outsideText);
  1411. insideTextRect.setTextContent(insideText);
  1412. var insColor = labelModel.get('insideColor');
  1413. insideText.style.fill = insColor;
  1414. var group = new external_echarts_.graphic.Group();
  1415. group.add(outsideTextRect);
  1416. group.add(insideTextRect);
  1417. // clip out waves for insideText
  1418. var boundingCircle = getPath(radius, true);
  1419. wavePath = new external_echarts_.graphic.CompoundPath({
  1420. shape: {
  1421. paths: waves
  1422. },
  1423. position: [cx, cy]
  1424. });
  1425. wavePath.setClipPath(boundingCircle);
  1426. insideTextRect.setClipPath(wavePath);
  1427. return group;
  1428. }
  1429. },
  1430. dispose: function () {
  1431. // dispose nothing here
  1432. }
  1433. });
  1434. ;// CONCATENATED MODULE: ./src/liquidFill.js
  1435. ;// CONCATENATED MODULE: ./index.js
  1436. /***/ }),
  1437. /***/ "echarts/lib/echarts":
  1438. /*!**************************!*\
  1439. !*** external "echarts" ***!
  1440. \**************************/
  1441. /***/ ((module) => {
  1442. module.exports = __WEBPACK_EXTERNAL_MODULE_echarts_lib_echarts__;
  1443. /***/ })
  1444. /******/ });
  1445. /************************************************************************/
  1446. /******/ // The module cache
  1447. /******/ var __webpack_module_cache__ = {};
  1448. /******/
  1449. /******/ // The require function
  1450. /******/ function __webpack_require__(moduleId) {
  1451. /******/ // Check if module is in cache
  1452. /******/ if(__webpack_module_cache__[moduleId]) {
  1453. /******/ return __webpack_module_cache__[moduleId].exports;
  1454. /******/ }
  1455. /******/ // Create a new module (and put it into the cache)
  1456. /******/ var module = __webpack_module_cache__[moduleId] = {
  1457. /******/ // no module.id needed
  1458. /******/ // no module.loaded needed
  1459. /******/ exports: {}
  1460. /******/ };
  1461. /******/
  1462. /******/ // Execute the module function
  1463. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  1464. /******/
  1465. /******/ // Return the exports of the module
  1466. /******/ return module.exports;
  1467. /******/ }
  1468. /******/
  1469. /************************************************************************/
  1470. /******/ /* webpack/runtime/make namespace object */
  1471. /******/ (() => {
  1472. /******/ // define __esModule on exports
  1473. /******/ __webpack_require__.r = (exports) => {
  1474. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  1475. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  1476. /******/ }
  1477. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  1478. /******/ };
  1479. /******/ })();
  1480. /******/
  1481. /************************************************************************/
  1482. /******/ // module exports must be returned from runtime so entry inlining is disabled
  1483. /******/ // startup
  1484. /******/ // Load entry module and return exports
  1485. /******/ return __webpack_require__("./index.js");
  1486. /******/ })()
  1487. ;
  1488. });
  1489. //# sourceMappingURL=echarts-liquidfill.js.map