calcommon.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * @Author: Marte
  3. * @Date: 2017-09-26 14:33:29
  4. * @Last Modified by: Marte
  5. * @Last Modified time: 2018-03-26 16:37:34
  6. */
  7. 'use strict';
  8. /**
  9. * [公共的饼图方法]
  10. * @param {[type]} id [图形存放位置]
  11. * @param {[type]} arr [比例数组]
  12. */
  13. function echartMethod(id, arr) {
  14. // 基于准备好的dom,初始化echarts实例
  15. var myChart = echarts.init(document.getElementById(id));
  16. // 指定图表的配置项和数据
  17. var option = {
  18. series: [{
  19. type: 'pie',
  20. radius: ['50%', '70%'],
  21. avoidLabelOverlap: false,
  22. color: ["#fbae35","#608cfb", "#ff794f"],
  23. labelLine: {
  24. normal: {
  25. show: false
  26. }
  27. },
  28. data: arr
  29. }]
  30. };
  31. // 使用刚指定的配置项和数据显示图表。
  32. myChart.setOption(option);
  33. }
  34. /**
  35. * [公共的线形图方法]
  36. * @param {[type]} id [图形存放位置]
  37. * @param {[type]} arr [比例数组]
  38. */
  39. function echartlinear(id,tit,hour,dataTitle,dataColor,obj) {
  40. var myChart = echarts.init(document.getElementById(id));
  41. var option = {
  42. title: {
  43. text: dataTitle,
  44. left: 'center',
  45. top: '50',
  46. textStyle: {
  47. color: '#888',
  48. fontSize:'12',
  49. fontWeight:'normal'
  50. }
  51. },
  52. tooltip: {
  53. trigger: 'item',
  54. formatter: '{a} <br/>{b} : {c}'
  55. },
  56. color:dataColor,
  57. legend: {
  58. bottom: 'bottom',
  59. data: tit
  60. },
  61. xAxis: {
  62. type: 'category',
  63. splitLine: {show: false},
  64. data: hour
  65. },
  66. grid: {
  67. top: '30%',
  68. left: '6%',
  69. right: '6%',
  70. bottom: '15%',
  71. containLabel: true
  72. },
  73. yAxis: {
  74. type: 'log'
  75. },
  76. series: obj
  77. };
  78. myChart.setOption(option);
  79. }
  80. if(typeof lineData != 'undefined'){
  81. var dataTitle = lineData.dataTitle;
  82. var dataTit = lineData.nameList;
  83. var dataList = lineData.timeList;
  84. var dataArr = lineData.dataList;
  85. var dataColor = lineData.dataColor;
  86. var titleList = lineData.dataTitleList;
  87. var array = [];
  88. for (var i = 0; i < dataTit.length; i++) {
  89. array.push(
  90. {
  91. name: dataTit[i],
  92. type: 'line',
  93. data:dataArr[i]
  94. }
  95. );
  96. if(titleList[i] != ""){
  97. $(".trends_Box").append('<li style="border: 1px solid '+dataColor[i]+'">'+titleList[i]+'</li>');
  98. }
  99. };
  100. echartlinear("x_echart",dataTit,dataList,dataTitle,dataColor,array);
  101. }
  102. //贷款-计算结果切换
  103. $(".tabs-hd").on("click","li",function(){
  104. var _idx=$(this).index();
  105. $(this).addClass('active').siblings().removeClass("active");
  106. $(".bus_tab_box").eq(_idx).show().siblings(".bus_tab_box").hide();
  107. });
  108. /**
  109. * [下拉框赋值]
  110. * @param {[type]} ele [下拉框赋值]
  111. * @param {[type]} $this [下拉框]
  112. */
  113. function pullVal2($this,ele){
  114. var _txt=$.trim($this.text());
  115. var _id=$.trim($this.data("val"));
  116. $(ele).text(_txt);
  117. $(ele).attr("data-id",_id);
  118. $this.parent().hide();
  119. }