• echart 两个柱状图并列,共用一个y轴的label


    echart 两个柱状图并列,共用一个y轴的label

    效果图如下:

    代码如下:

    1. let option = {
    2. tooltip: {
    3. trigger: 'axis',
    4. axisPointer: { // 坐标轴指示器,坐标轴触发有效
    5. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
    6. }
    7. },
    8. axisPointer: {
    9. link: { xAxisIndex: 'all' }
    10. },
    11. grid: [{
    12. top: 20,
    13. bottoom: 60,
    14. left: 10,
    15. height: '65%',
    16. //right: '40%',
    17. width: '39%'
    18. }, {
    19. top: 20,
    20. bottoom: 60,
    21. //left: '60%',
    22. height: '65%',
    23. right: 10,
    24. width: '39%'
    25. }],
    26. xAxis: [
    27. {
    28. type: 'value',
    29. boundaryGap: false,
    30. inverse: true,
    31. position: 'right',
    32. axisLine: { onZero: true },
    33. axisTick: {
    34. show: false
    35. },
    36. splitLine: { show: false },
    37. axisLine: {
    38. lineStyle: {
    39. color: '#fff',
    40. width: 1, //这里是为了突出显示加上的
    41. }
    42. },
    43. },
    44. {
    45. type: 'value',
    46. gridIndex: 1,
    47. boundaryGap: false,
    48. axisLine: { onZero: true },
    49. axisTick: {
    50. show: false
    51. },
    52. splitLine: { show: false },
    53. axisLine: {
    54. lineStyle: {
    55. color: '#fff',
    56. width: 1, //这里是为了突出显示加上的
    57. }
    58. },
    59. }
    60. ],
    61. yAxis: [
    62. {
    63. type: 'category',
    64. position: 'right',
    65. axisTick: {
    66. show: false
    67. },
    68. axisLabel: {
    69. show: false,
    70. fontSize: 10
    71. },
    72. axisLine: {
    73. lineStyle: {
    74. color: '#fff',
    75. width: 1, //这里是为了突出显示加上的
    76. }
    77. },
    78. data: ['A区', 'B区', 'C区', 'D区',]
    79. },
    80. {
    81. type: 'category',
    82. gridIndex: 1,
    83. inverse: true,
    84. axisTick: {
    85. show: false
    86. },
    87. axisLabel: {
    88. fontSize: 16,
    89. fontSize: 10
    90. },
    91. axisLine: {
    92. lineStyle: {
    93. color: '#fff',
    94. width: 1, //这里是为了突出显示加上的
    95. }
    96. },
    97. data: ['A区', 'B区', 'C区', 'D区',]
    98. }
    99. ],
    100. series: [
    101. {
    102. name: '收入',
    103. type: 'bar',
    104. label: {
    105. show: true
    106. },
    107. hoverAnimation: false,
    108. itemStyle: {
    109. normal: {
    110. show: true,
    111. color: new echarts.graphic.LinearGradient(0, 0, 1, 0,
    112. [
    113. {
    114. offset: 0,
    115. color: "#05FF10"
    116. },
    117. {
    118. offset: 1,
    119. color: "#fff"
    120. }
    121. ],
    122. false
    123. )
    124. }
    125. },
    126. data: [12, 4, 35, 17]
    127. },
    128. {
    129. name: '支出',
    130. type: 'bar',
    131. label: {
    132. show: true,
    133. //position: 'left'
    134. },
    135. xAxisIndex: 1,
    136. yAxisIndex: 1,
    137. hoverAnimation: false,
    138. itemStyle: {
    139. normal: {
    140. show: true,
    141. color: new echarts.graphic.LinearGradient(0, 0, 1, 0,
    142. [
    143. {
    144. offset: 0,
    145. color: "#fff"
    146. },
    147. {
    148. offset: 1,
    149. color: "#FF8C03"
    150. }
    151. ],
    152. false
    153. )
    154. }
    155. },
    156. data: [6, 21, 15, 18]
    157. }
    158. ]
    159. }

     

  • 相关阅读:
    在HBuilderX的git上导入github项目/把项目传到github
    Java类加载机制
    第二章 智能家居子系统——C51单片机 配置波特率115200
    什么是Web组件(Web Components)?它们的主要部分有哪些?
    在线神器 / 一键生成文字抖动表情 / 文字动态gif
    Windows OpenGL 图像色调
    栈浅谈(上)
    MFC Windows 程序设计[140]之多样消息对话框属性页(附源码)
    算法通关村第一关|青铜|链表笔记
    IM6ULL学习第18章Linux 系统对中断的处理
  • 原文地址:https://blog.csdn.net/baicai_123/article/details/126545227