index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div >
  3. <div ref="testLine" style="height: 170px; width: 300px"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. currentChartId: 1,
  11. xData: new Array(30).fill("-"),
  12. y1Data: new Array(30).fill("-"),
  13. y2Data: new Array(30).fill("-"),
  14. count: 0,
  15. myChart: null,
  16. option: {
  17. title: {
  18. text: "各煤仓占比",
  19. // 标题内边距 上下边距 左右边距
  20. padding: [10, 10, 0, 110],
  21. textStyle: {
  22. fontWeight: "bolder", //标题颜色
  23. color: "white",
  24. fontSize: 18,
  25. },
  26. },
  27. tooltip: {
  28. trigger: "item",
  29. },
  30. grid: {
  31. top: "22%",
  32. left: "41%",
  33. right: "4%",
  34. bottom: "3%",
  35. containLabel: true,
  36. },
  37. // legend: {
  38. // align: "left",
  39. // left: "44%",
  40. // top: "17%",
  41. // type: "plain",
  42. // textStyle: {
  43. // color: "#7ec7ff",
  44. // fontSize: 11,
  45. // },
  46. // data: ["原煤仓", "块煤仓","末煤仓","成品煤"],
  47. // },
  48. series: [
  49. {
  50. name: "煤仓占比",
  51. type: "pie",
  52. radius: "50%",
  53. data: [
  54. { value: 1048, name: "原煤仓" },
  55. { value: 735, name: "块煤仓" },
  56. { value: 580, name: "末煤仓" },
  57. { value: 484, name: "成品煤" },
  58. ],
  59. emphasis: {
  60. itemStyle: {
  61. shadowBlur: 10,
  62. shadowOffsetX: 0,
  63. shadowColor: "rgba(0, 0, 0, 0.5)",
  64. },
  65. },
  66. },
  67. ],
  68. },
  69. };
  70. },
  71. methods: {},
  72. mounted() {
  73. this.myChart = this.$echarts.init(this.$refs.testLine);
  74. // 获取数据
  75. this.myChart.setOption(this.option);
  76. },
  77. };
  78. </script>
  79. <style scoped lang="less">
  80. </style>