_Chart_Cmd2.cshtml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. var series = [];
  16. for (var i = 0; i < data.length; i++) {
  17. var item = data[i];
  18. series.push({
  19. name: item.name,
  20. type: "bar",
  21. data: item.data,
  22. stack: "cmd",
  23. label: {
  24. normal: {
  25. show: true,
  26. //formatter: '{a} : {c} 条',
  27. formatter: ' {c} ',
  28. color: "#eee"
  29. }
  30. },
  31. barMaxWidth: 50,
  32. barMinHeight: 20,
  33. itemStyle: {
  34. color: {
  35. type: 'linear',
  36. x: 0,
  37. y: 0,
  38. x2: 1,
  39. y2: 0,
  40. colorStops: [
  41. {
  42. offset: 0,
  43. color: roundColor[i % 3] // 0% 处的颜色
  44. }, {
  45. offset: 1,
  46. color: '#27303f' // 100% 处的颜色
  47. }
  48. ]
  49. }
  50. }
  51. //itemStyle: {
  52. // color: {
  53. // type: 'linear',
  54. // x: 0,
  55. // y: 0,
  56. // x2: 0,
  57. // y2: 1,
  58. // colorStops: [
  59. // {
  60. // offset: 0,
  61. // color: roundColor[i % 3] // 0% 处的颜色
  62. // }, {
  63. // offset: 1,
  64. // color: '#27303f' // 100% 处的颜色
  65. // }
  66. // ]
  67. // },
  68. // barBorderRadius: [50, 50, 0, 0]
  69. //}
  70. });
  71. }
  72. window.titleOpt.text = "处置指令统计示意图";
  73. var option = {
  74. grid: {
  75. top: 40,
  76. bottom: 20,
  77. left: 30,
  78. right: 10,
  79. borderColor: textColor[1]
  80. },
  81. legend: {
  82. right: 20,
  83. textStyle: {
  84. color: textColor[1]
  85. },
  86. icon: 'circle'
  87. },
  88. title: window.titleOpt,
  89. xAxis: {
  90. type: 'category',
  91. data: category,
  92. axisLabel: {
  93. color: textColor[1]
  94. },
  95. axisLine: {
  96. show: true,
  97. lineStyle: {
  98. color: textColor[0]
  99. }
  100. }
  101. },
  102. yAxis: {
  103. type: 'value',
  104. splitNumber: 4,
  105. axisLabel: {
  106. color: textColor[1]
  107. },
  108. axisLine: {
  109. show: false,
  110. lineStyle: {
  111. color: textColor[0]
  112. }
  113. },
  114. splitLine: {
  115. show: true,
  116. lineStyle: {
  117. color: textColor[0]
  118. }
  119. }
  120. },
  121. series: series
  122. };
  123. //console.log(option);
  124. cmdChart.setOption(option);
  125. }
  126. </script>
  127. }