_Chart_Cmd.cshtml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. @using WeApp.Helpers
  2. <div class="area" id="chart-cmd"></div>
  3. @using (Html.BeginScripts())
  4. {
  5. <script>
  6. //指令
  7. var cmdChart = echarts.init(document.getElementById('chart-cmd'));
  8. function CmdChart(data, category) {
  9. if (data && data.length > 0) {
  10. //console.log("=====>CMD", data);
  11. } else {
  12. console.log("CMD-Null");
  13. return;
  14. }
  15. window.titleOpt.text = "处置指令统计示意图";
  16. var series = [], nData = [], titleOpts = [window.titleOpt];
  17. for (var i = 0; i < data.length; i++) {
  18. var item = data[i];
  19. for (var ii = 0; ii < item.data.length; ii++) {
  20. if (i == 0) {
  21. nData.push([]);
  22. }
  23. nData[ii].push({
  24. name: item.name,
  25. value: item.data[ii],
  26. itemStyle:{
  27. color: roundColor[i % 3],
  28. }
  29. })
  30. }
  31. }
  32. for (var i = 0; i < 3; i++) {
  33. var item = nData[i];
  34. titleOpts.push({
  35. subtext: "第" + (i + 1) + "组",
  36. left: i == 0 ? '16.66%' : i == 1 ? "50%" : i == 2 ? "83.33%" : "",
  37. top: '75%',
  38. subtextStyle: {
  39. color: textColor[1],
  40. },
  41. textAlign: 'center'
  42. });
  43. series.push({
  44. //name: "第"+i+"组",
  45. type: "pie",
  46. radius: '80%',
  47. center: ['50%', '50%'],
  48. data: item,
  49. left: i * 33.3333 + '%',
  50. right: (2 - i) * 33.3333 + '%',
  51. top: 0,
  52. bottom: 0,
  53. label: {
  54. position: 'inside',
  55. formatter: ' {c} 条'
  56. },
  57. });
  58. }
  59. //series.push({
  60. // name: item.name,
  61. // type: "pie",
  62. // data: item.data,
  63. // stack: "cmd",
  64. // label: {
  65. // normal: {
  66. // show: true,
  67. // //formatter: '{a} : {c} 条',
  68. // formatter: ' {a} ',
  69. // color: "#eee"
  70. // }
  71. // },
  72. // barMaxWidth: 50,
  73. // barMinHeight: 20,
  74. // itemStyle: {
  75. // color: {
  76. // type: 'linear',
  77. // x: 0,
  78. // y: 0,
  79. // x2: 1,
  80. // y2: 0,
  81. // colorStops: [
  82. // {
  83. // offset: 0,
  84. // color: roundColor[i % 3] // 0% 处的颜色
  85. // }, {
  86. // offset: 1,
  87. // color: '#27303f' // 100% 处的颜色
  88. // }
  89. // ]
  90. // }
  91. // }
  92. // //itemStyle: {
  93. // // color: {
  94. // // type: 'linear',
  95. // // x: 0,
  96. // // y: 0,
  97. // // x2: 0,
  98. // // y2: 1,
  99. // // colorStops: [
  100. // // {
  101. // // offset: 0,
  102. // // color: roundColor[i % 3] // 0% 处的颜色
  103. // // }, {
  104. // // offset: 1,
  105. // // color: '#27303f' // 100% 处的颜色
  106. // // }
  107. // // ]
  108. // // },
  109. // // barBorderRadius: [50, 50, 0, 0]
  110. // //}
  111. //});
  112. var option = {
  113. grid: {
  114. top: 40,
  115. bottom: 20,
  116. left: 30,
  117. right: 10,
  118. borderColor: textColor[1]
  119. },
  120. legend: {
  121. right: 20,
  122. textStyle: {
  123. color: textColor[1]
  124. },
  125. icon: 'circle'
  126. },
  127. title: titleOpts,
  128. series: series
  129. };
  130. //console.log(option);
  131. cmdChart.setOption(option);
  132. }
  133. </script>
  134. }