QIndex.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. var refreshGirdData;
  2. const CONFIG = {
  3. // 画布基准
  4. BASE_WIDTH: 1280,
  5. BASE_HEIGHT: 800,
  6. }
  7. let normalTableData = [
  8. {
  9. type: 'Card类型一',
  10. num: '66',
  11. rate: '40%',
  12. },
  13. {
  14. type: 'Card类型二',
  15. num: '22',
  16. rate: '30%',
  17. },
  18. {
  19. type: 'Card类型三',
  20. num: '11',
  21. rate: '20%',
  22. },
  23. {
  24. type: 'Card类型四',
  25. num: '11',
  26. rate: '20%',
  27. },
  28. {
  29. type: 'Card类型五',
  30. num: '11',
  31. rate: '20%',
  32. },
  33. {
  34. type: 'Card类型六',
  35. num: '11',
  36. rate: '20%',
  37. },
  38. ]
  39. let normalTableColumn = [
  40. {
  41. key: 'index',
  42. title: '排名',
  43. },
  44. {
  45. key: 'rate',
  46. title: '占比',
  47. render: (params) => {
  48. let width = genVH(14),
  49. height = genVH(14),
  50. pieRate = parseInt(params.rate) / 100 * 2,
  51. dataUrl,
  52. ctx,
  53. canvas = document.createElement('canvas')
  54. canvas.width = width
  55. canvas.height = height
  56. ctx = canvas.getContext('2d')
  57. ctx.moveTo(width / 2, height / 2)
  58. ctx.arc(width / 2, height / 2, width / 2, 0, Math.PI * pieRate, false)
  59. ctx.closePath()
  60. ctx.fillStyle = '#6ac8f1'
  61. ctx.fill()
  62. dataUrl = canvas.toDataURL('image/png')
  63. return `
  64. <div class="table-rate-wrap">
  65. <div class="table-pan-icon" style="background-image: url('${dataUrl}');
  66. width: ${width}px; height: ${height}px;"></div>
  67. <div class="table-rate-num">${params.rate}</div>
  68. </div>
  69. `
  70. },
  71. },
  72. {
  73. key: 'type',
  74. title: '类型',
  75. width: '40%',
  76. tooltip: true,
  77. align: 'center',
  78. },
  79. {
  80. key: 'num',
  81. title: '计数',
  82. align: 'right',
  83. class: 'normal-table-num',
  84. },
  85. ]
  86. const renderOtherModule = (config) => {
  87. let domMap = renderContentBasic(config)
  88. if (config.render) {
  89. config.render(domMap, config)
  90. }
  91. //if (config.onResize) {
  92. // window.addEventListener('resize', () => {
  93. // emptyAllDom(domMap)
  94. // config.onResize(domMap, config)
  95. // })
  96. //}
  97. }
  98. const genVH = (length) => {
  99. let clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  100. if (!clientHeight) return length
  101. return length * clientHeight / CONFIG.BASE_HEIGHT
  102. }
  103. const genVW = (length) => {
  104. let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  105. if (!clientWidth) return length
  106. return length * clientWidth / CONFIG.BASE_WIDTH
  107. }
  108. const renderContentBasic = (config) => {
  109. const { domHeight = 200, domId, renderBasic, renderTitle, name } = config
  110. if (renderBasic === false) return renderBasic
  111. const dom = document.getElementById(domId)
  112. dom.style.height = `${domHeight / CONFIG.BASE_HEIGHT * 100}vh`
  113. let innerHTML = '', titleDomHeight = 0
  114. if (renderTitle !== false) {
  115. // 添加标题容器
  116. innerHTML = `
  117. <div class="content-box-title-icon"></div>
  118. <div class="content-box-title-text fontSize14">${name}</div>
  119. `
  120. const titleDom = appendContentNode({
  121. dom,
  122. innerHTML,
  123. nodeWrapName: `${domId}-title`,
  124. className: `content-box-title-wrap ${domId}-title`,
  125. })
  126. titleDomHeight = titleDom.getBoundingClientRect().height
  127. }
  128. // 添加内容容器
  129. const style = {
  130. height: `calc(100% - ${titleDomHeight}px)`,
  131. }
  132. innerHTML = `
  133. <div class="before-${domId}"></div>
  134. <div class="chart-wrap _${domId}"></div>
  135. <div class="after-${domId}"></div>
  136. `
  137. appendContentNode({
  138. dom,
  139. innerHTML,
  140. nodeWrapName: `${domId}-inner-wrap`,
  141. className: `content-box-inner-wrap ${domId}-inner-wrap`,
  142. style,
  143. })
  144. return {
  145. beforeDomClass: `before-${domId}`,
  146. contentDomClass: `_${domId}`,
  147. afterDomClass: `after-${domId}`,
  148. titleClass: `${domId}-title`,
  149. }
  150. }
  151. const appendContentNode = (config) => {
  152. const { dom, innerHTML, nodeWrapName, className, style = {} } = config
  153. let contentNodeWrap = document.getElementsByClassName(nodeWrapName)
  154. if (contentNodeWrap.length) {
  155. contentNodeWrap.innerHTML = innerHTML
  156. } else {
  157. contentNodeWrap = document.createElement('div')
  158. contentNodeWrap.className = className
  159. contentNodeWrap.innerHTML = innerHTML
  160. Object.keys(style).forEach(key => {
  161. contentNodeWrap.style[key] = style[key]
  162. })
  163. dom.appendChild(contentNodeWrap)
  164. }
  165. return contentNodeWrap
  166. }
  167. const renderNormalTable = (classNameParams, config) => {
  168. const contentDom = document.getElementsByClassName(classNameParams.contentDomClass)
  169. let dom = ''
  170. let table = document.createElement('table')
  171. let tableHeader = document.createElement('table')
  172. let tableBodyWrap = document.createElement('div')
  173. table.className = 'normal-table fontSize12'
  174. tableHeader.className = 'normal-table fontSize12'
  175. tableBodyWrap.className = 'normal-table-wrap'
  176. // 表头
  177. if (!config.hideHeader) {
  178. dom += `<tr>`
  179. config.column.forEach(item => {
  180. const { width, align } = item
  181. let style = ' style="'
  182. if (width) style += `width: ${width};`
  183. if (align) style += `text-align: ${align};`
  184. style += `"`
  185. dom += `<th${style}><span>${item.title}</span></th>`
  186. })
  187. dom += `</tr>`
  188. }
  189. tableHeader.innerHTML = dom
  190. document.getElementsByClassName(classNameParams.beforeDomClass)[0].appendChild(tableHeader)
  191. // 表体
  192. dom = ''
  193. config.data.forEach((item, index) => {
  194. dom += `<tr>`
  195. config.column.forEach(cell => {
  196. const { render, key, width, align } = cell
  197. let { class: className = '' } = cell
  198. let style = ' style="'
  199. if (width) style += `width: ${width};`
  200. if (align) style += `text-align: ${align};`
  201. style += `"`
  202. if (cell.tooltip) className += ` ${config.domId}-table-overflow-text`
  203. if (render) {
  204. dom += `<td${style} class="${className}">${render(item)}</td>`
  205. } else if (key === 'index') {
  206. dom += `<td${style} class="${className}"><span>${index + 1}</span></td>`
  207. } else {
  208. dom += `<td${style} class="${className}"><span>${item[key]}</span></td>`
  209. }
  210. })
  211. dom += `</tr>`
  212. })
  213. if (!config.data.length) dom += `<tr><td colspan="${config.column.length}" style="text-align: center;height: 100%;">暂无数据</td></tr>`
  214. table.innerHTML = dom
  215. tableBodyWrap.appendChild(table)
  216. contentDom[0].appendChild(tableBodyWrap)
  217. contentDom[0].style.height = `calc(100% - ${tableHeader.getBoundingClientRect().height}px)`
  218. // scrollbar compensation
  219. if (tableBodyWrap.scrollHeight > tableBodyWrap.clientHeight) {
  220. document.getElementsByClassName(classNameParams.beforeDomClass)[0].classList.add('scrollbar-compensation')
  221. }
  222. // tooltips
  223. let tooltips = document.createElement('div')
  224. tooltips.className = 'table-tootips'
  225. tooltips.innerHTML = '<span class="tooltips-arrow"></span><span class="tooltips-text"></span>'
  226. contentDom[0].appendChild(tooltips)
  227. const tooltipsArrow = document.getElementsByClassName('tooltips-arrow')[0]
  228. const tooltipsText = document.getElementsByClassName('tooltips-text')[0]
  229. const tableOverflowTextDom = document.getElementsByClassName(`${config.domId}-table-overflow-text`)
  230. for (let i = 0; i < tableOverflowTextDom.length; i++) {
  231. if (tableOverflowTextDom[i].scrollWidth - tableOverflowTextDom[i].clientWidth > 1) {
  232. tableOverflowTextDom[i].addEventListener('mouseout', () => {
  233. tooltips.style.display = 'none'
  234. })
  235. tableOverflowTextDom[i].addEventListener('mouseover', () => {
  236. tooltips.style.display = 'block'
  237. const fontSize = '1.125vh'
  238. const padding = genVH(8)
  239. const size = getTextSize(tableOverflowTextDom[i].innerText, fontSize)
  240. tooltips.style.fontSize = fontSize
  241. tooltips.style.padding = `${padding}px`
  242. tooltips.style.left = `${tableOverflowTextDom[i].offsetLeft + (tableOverflowTextDom[i].clientWidth / 2 - size.width / 2 - padding)}px`
  243. tooltips.style.top = `${tableOverflowTextDom[i].offsetTop - tableBodyWrap.scrollTop - (size.height + padding * 2) - tooltipsArrow.clientHeight}px`
  244. tooltipsArrow.style.transform = `translate3d(${size.width / 2 + padding - tooltipsArrow.clientWidth / 2}px, 0, 0)`
  245. tooltipsText.innerHTML = tableOverflowTextDom[i].innerText
  246. })
  247. }
  248. }
  249. }
  250. var bootstrap = function ($, learun) {
  251. "use strict";
  252. const devices = ["SRM1", "SRM2", "SRM3"];
  253. var SrmRateData;
  254. var RobotRateData;
  255. var page = {
  256. init: function () {
  257. $("#beginTime").val(beginTime);
  258. $("#endTime").val(endTime);
  259. $("#robotbeginTime").val(beginTime);
  260. $("#robotendTime").val(endTime);
  261. page.GetSrmRateData();
  262. page.GetRobotRateData();
  263. page.initGird();
  264. page.bind();
  265. //page.GetSRMRate('SRM201');
  266. //page.GetSRMRate('SRM202');
  267. //page.GetSRMRate('SRM203');
  268. //page.GetSRMRate('SRM204');
  269. //page.GetSRMRate('SRM205');
  270. //page.GetSRMRate('SRM206');
  271. //page.GetSRMRate('SRM207');
  272. //page.GetSRMRate('SRM208');
  273. },
  274. bind: function () {
  275. // 查询
  276. $('#btn_Search').on('click', function () {
  277. page.GetSrmRateData();
  278. });
  279. $('#btn_robotSearch').on('click', function () {
  280. page.GetRobotRateData();
  281. });
  282. page.SpanFunction($("#SRMSpan").find('span'), page.ChangeFloor);
  283. },
  284. // 初始化列表
  285. initGird: function () {
  286. },
  287. search: function (param) {
  288. },
  289. SpanFunction: function (list, callBack) {
  290. $(list).on('click', function () {
  291. $(this).addClass('active').siblings('span').removeClass('active');
  292. var index = $(this).index();
  293. var text = $(this).text();
  294. //alert($(this).attr('queryValue'));
  295. if (!!callBack) {
  296. callBack();
  297. }
  298. })
  299. //for (var i = 0; i < list.length; i++) {
  300. // $(list[i]).on('click', function () {
  301. // var name = $(this).text();
  302. // list.each(function () {
  303. // if ($(this).text() == name) {
  304. // $(this).addClass('active');
  305. // if (!!callBack) {
  306. // callBack();
  307. // }
  308. // }
  309. // else {
  310. // $(this).removeClass('active');
  311. // }
  312. // });
  313. // });
  314. //}
  315. },
  316. GetSrmRateData: function () {
  317. learun.httpAsync('GET', top.$.rootUrl + '/SXManager/DeviceEffectives/GetSrmRateData', { queryJson: JSON.stringify({ beginTime: $("#beginTime").val(), endTime: $("#endTime").val(), floor: $("#SRMSpan span.active").attr('data-queryValue'), DevType:'2' }) }, function (res) {
  318. if (res.code > 0) {
  319. SrmRateData = res.data;
  320. let floor = $("#SRMSpan span.active").attr('data-queryValue');
  321. for (let i = 0; i < SrmRateData[floor].length; i++) {
  322. page.GetSRMRate(SrmRateData[floor][i].code, SrmRateData[floor][i]);
  323. } ;
  324. }
  325. });
  326. },
  327. GetRobotRateData: function () {
  328. learun.httpAsync('GET', top.$.rootUrl + '/SXManager/DeviceEffectives/GetRobotRateData', { queryJson: JSON.stringify({ beginTime: $("#robotbeginTime").val(), endTime: $("#robotendTime").val(), floor: $("#SRMSpan span.active").attr('data-queryValue'), DevType: '3' }) }, function (res) {
  329. if (res.code > 0) {
  330. RobotRateData = res.data;
  331. //RobotRateData['Robot1']
  332. page.GetSRMRate(RobotRateData['Robot1'][0].code, RobotRateData['Robot1'][0]);
  333. page.GetSRMRate(RobotRateData['Robot2'][0].code, RobotRateData['Robot2'][0]);
  334. }
  335. });
  336. },
  337. ChangeFloor: function () {
  338. let floor = $("#SRMSpan span.active").attr('data-queryValue');
  339. if (SrmRateData) {
  340. for (let i = 0; i < SrmRateData[floor].length; i++) {
  341. page.GetSRMRate(SrmRateData[floor][i].code, SrmRateData[floor][i]);
  342. };
  343. }
  344. },
  345. //
  346. GetSRMRate: function (id,srmdatas) {
  347. // var chartDom = document.getElementById('mainLastTaskCompletionRate');
  348. var chartDom;
  349. let isRobot = id.includes('Robot');
  350. if (isRobot) {
  351. $("#" + id).next().text(id);
  352. chartDom = document.getElementById(id);
  353. }
  354. else {
  355. let last = id.charAt(id.length - 1);
  356. $("#SRM0" + last).next().text(id);
  357. chartDom = document.getElementById("SRM0" + last);
  358. }
  359. var myChart = echarts.init(chartDom, 'shine');
  360. var option;
  361. let data = srmdatas.rates;
  362. option = {
  363. title: {
  364. text: ' ' + srmdatas.utilizationrate + ' ' ,//data.total
  365. textStyle: {
  366. color: '#1C3554',
  367. },
  368. subtext:' 利用率',
  369. subtextStyle: {
  370. color: '#5A5E66',
  371. },
  372. left: '26%',
  373. top: '42%'
  374. },
  375. tooltip: {
  376. trigger: 'item',
  377. borderColor: "#fff",
  378. formatter: function (params) {
  379. // console.log(params);
  380. // 计算百分比时,params.percent是图表自己计算的;
  381. // params.data.rate(在dimensions中定义的)是我们自己传的值
  382. let html =`<div style="height:auto;width: 135px;">
  383. <div style="font-size:14px;font-weight:bold;color:#333;margin-bottom:16px;display:flex;align-items:center;line-height:1;">
  384. <span style="display:inline-block;margin-right:8px;border-radius:6px;width:6px;height:6px;background-color:${params.color};"></span>
  385. ${params.name}
  386. </div>
  387. <div style="font-size:12px;color:#808080;margin-bottom:8px;display:flex;align-items:center;line-height:1;">
  388. <span>时长</span>
  389. <span style="flex:1;text-align:right;">${params.data.desc}</span>
  390. </div>
  391. <div style="font-size:12px;color:#808080;margin-bottom:8px;display:flex;align-items:center;line-height:1;">
  392. <span>占比</span>
  393. <span style="flex:1;text-align:right;">${(params.data.rate).toFixed(2)}%</span>
  394. </div>
  395. <div style="font-size:12px;color:#808080;margin-bottom:8px;display:flex;align-items:center;line-height:1;">
  396. <span>出库</span>
  397. <span style="flex:1;text-align:right;">${srmdatas.OutDepot}</span>
  398. </div>
  399. <div style="font-size:12px;color:#808080;margin-bottom:8px;display:flex;align-items:center;line-height:1;${isRobot ? 'display:none' : 'display:black'}">
  400. <span>入库</span>
  401. <span style="flex:1;text-align:right;">${srmdatas.EnterDepot }</span>
  402. </div>
  403. <div style="font-size:12px;color:#808080;margin-bottom:8px;display:flex;align-items:center;line-height:1;${isRobot ? 'display:none' : 'display:black'}">
  404. <span>移库</span>
  405. <span style="flex:1;text-align:right;">${srmdatas.TransferDepot}</span>
  406. </div>
  407. </div>`;
  408. return html;
  409. },
  410. },
  411. legend: {
  412. //itemWidth: 25, // 标志图形的长度
  413. //itemHeight: 25, // 标志图形的宽度
  414. orient: "vertical",
  415. //right: 60,
  416. left: '60%',//调整位置
  417. //y: "center",
  418. textStyle: {
  419. //图例文字的样式
  420. color: "black", //文字颜色
  421. fontSize: 10, //文字大小
  422. },
  423. // 回调函数 实现标志图形字体后边加上百分比
  424. formatter(name) {
  425. // console.log(option);
  426. let than = option.series[0].data; //获取series中的data
  427. let total = 0;
  428. let tarValue;
  429. for (let i = 0, l = than.length; i < l; i++) {
  430. total += than[i].value;
  431. if (than[i].name == name) {
  432. tarValue = than[i].rate;
  433. }
  434. }
  435. //let p = total>0? (tarValue / total) * 100 :0;
  436. return name + " " + " " + tarValue.toFixed(2) + "%";
  437. },
  438. //orient: 'vertical',
  439. //left: '76%',//调整位置
  440. top: '5%',
  441. //left: 'center'
  442. },
  443. series: [
  444. {
  445. name: 'Access From',
  446. type: 'pie',
  447. radius: ['39%', '70%'],
  448. center: ['37%', '50%'],
  449. avoidLabelOverlap: false,
  450. itemStyle: {
  451. borderRadius: 4
  452. },
  453. minAngle: 30, // 设置扇区最小角度
  454. label: {
  455. show: false,
  456. position: 'center',
  457. //normal: {
  458. // formatter: '{b}:{d}% ( {c} )'
  459. //}
  460. },
  461. //emphasis: {
  462. // label: {
  463. // show: true,
  464. // fontSize: 10,
  465. // fontWeight: 'bold'
  466. // }
  467. //},
  468. labelLine: {
  469. show: false
  470. },
  471. data:
  472. data
  473. //[
  474. // { value: 1048, name: 'Search Engine',desc:"ASED" },
  475. // { value: 735, name: 'Direct', desc: "dERDE" },
  476. // { value: 580, name: 'Email', desc: "EMAILSSS" },
  477. // { value: 484, name: 'Union Ads', desc: "UNIONS" },
  478. // { value: 300, name: 'Video Ads', desc: "VIDEO" }
  479. //]
  480. }
  481. ]
  482. };
  483. option && myChart.setOption(option);
  484. //option = {
  485. // series: [
  486. // {
  487. // type: 'gauge',
  488. // progress: {
  489. // show: true,
  490. // width: 12
  491. // },
  492. // axisLine: {
  493. // lineStyle: {
  494. // width: 12
  495. // }
  496. // },
  497. // axisTick: {
  498. // show: false
  499. // },
  500. // splitLine: {
  501. // length: 10,
  502. // lineStyle: {
  503. // width: 2,
  504. // color: '#999'
  505. // }
  506. // },
  507. // axisLabel: {
  508. // distance: 7,
  509. // color: '#999',
  510. // fontSize: 10
  511. // },
  512. // anchor: {
  513. // show: true,
  514. // showAbove: true,
  515. // size: 15,
  516. // itemStyle: {
  517. // borderWidth: 10
  518. // }
  519. // },
  520. // title: {
  521. // show: false
  522. // },
  523. // detail: {
  524. // valueAnimation: true,
  525. // fontSize: 20,
  526. // formatter: function (value) {
  527. // return value + '%';
  528. // },
  529. // offsetCenter: [0, '70%']
  530. // },
  531. // data: [
  532. // {
  533. // value: 78
  534. // }
  535. // ]
  536. // }
  537. // ]
  538. //};
  539. //option && myChart.setOption(option);
  540. },
  541. };
  542. refreshGirdData = function () {
  543. };
  544. page.init();
  545. }
  546. var app = {};
  547. var ROOT_PATH = 'https://echarts.apache.org/examples';
  548. var option;
  549. var _panelImageURL = ROOT_PATH + '/data/asset/img/custom-gauge-panel.png';
  550. var _animationDuration = 1000;
  551. var _animationDurationUpdate = 1000;
  552. var _animationEasingUpdate = 'quarticInOut';
  553. var _valOnRadianMax = 200;
  554. var _outerRadius = 200;
  555. var _innerRadius = 170;
  556. var _pointerInnerRadius = 40;
  557. var _insidePanelRadius = 140;
  558. var _currentDataIndex = 0;
  559. function renderItem(params, api) {
  560. var valOnRadian = api.value(1);
  561. var coords = api.coord([api.value(0), valOnRadian]);
  562. var polarEndRadian = coords[3];
  563. var imageStyle = {
  564. image: _panelImageURL,
  565. x: params.coordSys.cx - _outerRadius,
  566. y: params.coordSys.cy - _outerRadius,
  567. width: _outerRadius * 2,
  568. height: _outerRadius * 2
  569. };
  570. return {
  571. type: 'group',
  572. children: [
  573. {
  574. type: 'image',
  575. style: imageStyle,
  576. clipPath: {
  577. type: 'sector',
  578. shape: {
  579. cx: params.coordSys.cx,
  580. cy: params.coordSys.cy,
  581. r: _outerRadius,
  582. r0: _innerRadius,
  583. startAngle: 0,
  584. endAngle: -polarEndRadian,
  585. transition: 'endAngle',
  586. enterFrom: { endAngle: 0 }
  587. }
  588. }
  589. },
  590. {
  591. type: 'image',
  592. style: imageStyle,
  593. clipPath: {
  594. type: 'polygon',
  595. shape: {
  596. points: makePionterPoints(params, polarEndRadian)
  597. },
  598. extra: {
  599. polarEndRadian: polarEndRadian,
  600. transition: 'polarEndRadian',
  601. enterFrom: { polarEndRadian: 0 }
  602. },
  603. during: function (apiDuring) {
  604. apiDuring.setShape(
  605. 'points',
  606. makePionterPoints(params, apiDuring.getExtra('polarEndRadian'))
  607. );
  608. }
  609. }
  610. },
  611. {
  612. type: 'circle',
  613. shape: {
  614. cx: params.coordSys.cx,
  615. cy: params.coordSys.cy,
  616. r: _insidePanelRadius
  617. },
  618. style: {
  619. fill: '#fff',
  620. shadowBlur: 25,
  621. shadowOffsetX: 0,
  622. shadowOffsetY: 0,
  623. shadowColor: 'rgba(76,107,167,0.4)'
  624. }
  625. },
  626. {
  627. type: 'text',
  628. extra: {
  629. valOnRadian: valOnRadian,
  630. transition: 'valOnRadian',
  631. enterFrom: { valOnRadian: 0 }
  632. },
  633. style: {
  634. text: makeText(valOnRadian),
  635. fontSize: 50,
  636. fontWeight: 700,
  637. x: params.coordSys.cx,
  638. y: params.coordSys.cy,
  639. fill: 'rgb(0,50,190)',
  640. align: 'center',
  641. verticalAlign: 'middle',
  642. enterFrom: { opacity: 0 }
  643. },
  644. during: function (apiDuring) {
  645. apiDuring.setStyle(
  646. 'text',
  647. makeText(apiDuring.getExtra('valOnRadian'))
  648. );
  649. }
  650. }
  651. ]
  652. };
  653. }
  654. function convertToPolarPoint(renderItemParams, radius, radian) {
  655. return [
  656. Math.cos(radian) * radius + renderItemParams.coordSys.cx,
  657. -Math.sin(radian) * radius + renderItemParams.coordSys.cy
  658. ];
  659. }
  660. function makePionterPoints(renderItemParams, polarEndRadian) {
  661. return [
  662. convertToPolarPoint(renderItemParams, _outerRadius, polarEndRadian),
  663. convertToPolarPoint(
  664. renderItemParams,
  665. _outerRadius,
  666. polarEndRadian + Math.PI * 0.03
  667. ),
  668. convertToPolarPoint(renderItemParams, _pointerInnerRadius, polarEndRadian)
  669. ];
  670. }
  671. function makeText(valOnRadian) {
  672. // Validate additive animation calc.
  673. if (valOnRadian < -10) {
  674. alert('illegal during val: ' + valOnRadian);
  675. }
  676. return ((valOnRadian / _valOnRadianMax) * 100).toFixed(0) + '%';
  677. }
  678. option = {
  679. animationEasing: _animationEasingUpdate,
  680. animationDuration: _animationDuration,
  681. animationDurationUpdate: _animationDurationUpdate,
  682. animationEasingUpdate: _animationEasingUpdate,
  683. dataset: {
  684. source: [[1, 156]]
  685. },
  686. tooltip: {},
  687. angleAxis: {
  688. type: 'value',
  689. startAngle: 0,
  690. show: false,
  691. min: 0,
  692. max: _valOnRadianMax
  693. },
  694. radiusAxis: {
  695. type: 'value',
  696. show: false
  697. },
  698. polar: {},
  699. series: [
  700. {
  701. type: 'custom',
  702. coordinateSystem: 'polar',
  703. renderItem: renderItem,
  704. }
  705. ]
  706. };