E-Profit.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class="container">
  3. <!-- E-Profit 利润-->
  4. <div id="EGiveBirth" style="height:400px;"></div>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. name: "EGiveBirth",
  10. data() {
  11. return {};
  12. },
  13. mounted() {
  14. this.drawChart();
  15. },
  16. methods: {
  17. drawChart() {
  18. // 基于准备好的dom,初始化echarts实例
  19. let myChart = this.$echarts.init(
  20. document.getElementById("EGiveBirth")
  21. );
  22. // 指定图表的配置项和数据
  23. let option = {
  24. title: {
  25. text: "利润分析",
  26. left: "center",
  27. bottom: 0
  28. },
  29. color: ["#5bf0b2", "#FFB2FF", "#3ABAFF", "#FF6A01", "#ff8295"],
  30. tooltip: {
  31. trigger: "axis",
  32. axisPointer: {
  33. // 坐标轴指示器,坐标轴触发有效
  34. type: "shadow" // 默认为直线,可选为:'line' | 'shadow'
  35. }
  36. },
  37. grid: {
  38. left: "8%",
  39. right: "4%",
  40. bottom: "10%",
  41. containLabel: true
  42. },
  43. xAxis: [
  44. {
  45. type: "category",
  46. data: ["销售总额", "总成本", "利润"],
  47. axisTick: {
  48. alignWithLabel: true
  49. }
  50. }
  51. ],
  52. yAxis: [
  53. {
  54. type: "value"
  55. }
  56. ],
  57. series: [
  58. {
  59. name: "数量",
  60. type: "bar",
  61. barWidth: "30%",
  62. data: [100, 36, 33],
  63. itemStyle: {
  64. normal: {
  65. color: function(params) {
  66. var colorList = [
  67. "#FF9900",
  68. "#999966",
  69. "#0099FF"
  70. ];
  71. return colorList[params.dataIndex];
  72. }
  73. }
  74. }
  75. }
  76. ]
  77. };
  78. // 使用刚指定的配置项和数据显示图表。
  79. myChart.setOption(option);
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. </style>