ECharts 折线图改变title lenendX轴Y轴字体颜色,大小改变(vue引用)

古城微笑少年丶 2022-02-20 03:06 1374阅读 0赞

改变背景,字体,折线颜色,x,y轴颜色,title字体颜色,lenend字体颜色,y轴添加单位后的效果图在这里插入图片描述
原图
在这里插入图片描述
代码
js

  1. mounted(){
  2. this.powerChart = this.$echarts.init(document.getElementById("Echart"));
  3. this.electricChart = this.$echarts.init(document.getElementById("Pchart"));
  4. // 调用方法
  5. this.drawChart();
  6. },
  7. // 折线图
  8. methods:{
  9. drawChart(){
  10. let option = {
  11. // 背景图颜色
  12. backgroundColor:"#0E1F31",
  13. title: {
  14. text: '水 燃气费走势图',
  15. textStyle: {
  16. fontWeight: 'normal',
  17. color: '#A3FFFC' //标题颜色
  18. },
  19. },
  20. tooltip: {
  21. trigger: 'axis'
  22. },
  23. legend: {
  24. data:['水费','燃气费'],
  25. top:'9%',
  26. textStyle: {
  27. fontWeight: 'normal',
  28. color: '#62B4BB' //legend颜色
  29. },
  30. },
  31. grid: {
  32. // top:'1%',
  33. left: '5%',
  34. right: '5%',
  35. bottom: '3%',
  36. containLabel: true
  37. },
  38. toolbox: {
  39. feature: {
  40. saveAsImage: {}
  41. }
  42. },
  43. xAxis: [{
  44. type: 'category',
  45. boundaryGap: false,
  46. data: ['1月','2月','3月','4月','5月','6月','7月'],
  47. // 改变x轴颜色
  48. axisLine:{
  49. lineStyle:{
  50. color:'#2A5D75',
  51. }
  52. },
  53. // 改变x轴字体颜色和大小
  54. axisLabel: {
  55. textStyle: {
  56. color: '#62B4BB',
  57. fontSize:'16'
  58. },
  59. },
  60. }],
  61. yAxis: [{
  62. type: 'value',
  63. // 改变y轴颜色
  64. axisLine:{
  65. lineStyle:{
  66. color:'#2A5D75',
  67. }
  68. },
  69. // 改变y轴字体颜色和大小
  70. axisLabel: {
  71. formatter: '{value} m³ ', // 给y轴添加单位
  72. textStyle: {
  73. color: '#62B4BB',
  74. fontSize:'16',
  75. },
  76. },
  77. }],
  78. series: [
  79. {
  80. name:'水费',
  81. type:'line',
  82. stack: '总量',
  83. data:[120, 132, 101, 134, 90, 230, 210],
  84. itemStyle:{
  85. normal:{
  86. color:'#4e76b5' // 给折线添加颜色
  87. },
  88. },
  89. },
  90. {
  91. name:'燃气费',
  92. type:'line',
  93. stack: '总量',
  94. data:[220, 182, 191, 234, 290, 330, 310]
  95. }
  96. ]
  97. };
  98. //展示图
  99. this.electricChart.setOption(option_power);
  100. }
  101. }

html

  1. <template>
  2. <div style="height: 100%;">
  3. <div id="Echart" class="Echar" :style="{width: '100%', height: '30%'}"></div>
  4. </div>
  5. </template>

发表评论

表情:
评论列表 (有 0 条评论,1374人围观)

还没有评论,来说两句吧...

相关阅读