3a15b614ea97bfe17c8c8150946c6cf.png

    1. option = {
    2. tooltip: { //浮窗设置
    3. trigger: 'item',
    4. textStyle: {
    5. fontSize: 40
    6. },
    7. padding: [20, 20, 20, 20],
    8. borderWidth: 2,
    9. formatter: function (params) { //不知道params里面的参数可以打印出来看
    10. return (
    11. `${params.name}<br/>` +
    12. `<span style="display:inline-block;margin-right:10px;border-radius:50%;width:20px;height:20px;background-color:${params.color.colorStops[0].color};"></span>` +
    13. `${params.value}`
    14. );
    15. }
    16. },
    17. grid: { //设置图表内容范围
    18. left: '0',
    19. right: '0',
    20. bottom: '0',
    21. top: '10',
    22. containLabel: true
    23. },
    24. xAxis: { //x轴
    25. type: 'category',
    26. data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    27. axisLine: { //设置x坐标轴
    28. show: true,
    29. lineStyle: {
    30. color: '#333'
    31. }
    32. },
    33. axisLabel: { //设置x坐标轴标签
    34. show: true,
    35. textStyle: {
    36. fontSize: 24,
    37. color: '#f00'
    38. }
    39. },
    40. axisTick: { //坐标轴刻度设置
    41. show: false
    42. }
    43. },
    44. yAxis: { //y 轴
    45. type: 'value',
    46. axisLine: { //设置y坐标轴
    47. show: true,
    48. lineStyle: {
    49. color: '#333'
    50. }
    51. },
    52. axisTick: { //坐标轴刻度设置
    53. show: false
    54. },
    55. axisLabel: { //设置y坐标轴标签
    56. show: true,
    57. textStyle: {
    58. fontSize: 20,
    59. color: '#f00'
    60. }
    61. },
    62. splitLine: { //坐标轴在 grid 区域中的分隔线(中间的网格线)
    63. lineStyle: {
    64. color: '#333',
    65. width: 1,
    66. type: 'dashed'
    67. }
    68. }
    69. },
    70. series: [
    71. {
    72. data: [120, 200, 150, 80, 70, 110, 130],
    73. type: 'bar',
    74. barWidth: 72, //设置柱子宽度
    75. label: { //设置图形上的文本标签(不需要则不用设置)
    76. show: true,
    77. fontSize: '32',
    78. color: '#fff',
    79. position: 'insideTop', //top / left / right / bottom / inside / insideLeft / insideRight / insideTop / insideBottom / insideTopLeft / insideBottomLeft / insideTopRight / insideBottomRight
    80. formatter: function (params) {
    81. return params.value;
    82. }
    83. },
    84. itemStyle: {
    85. color: function (params) { //每条柱子设置渐变色
    86. var colorList = [
    87. ['rgba(73, 158, 251, 1)', 'rgba(73, 104, 251, 0)'],
    88. ['rgba(170, 135, 255, 1)', 'rgba(171, 106, 255, 0)'],
    89. ['rgba(163, 222, 36, 1)', 'rgba(134, 184, 28, 0)'],
    90. ['rgba(255, 155, 208, 1)', 'rgba(235, 129, 185, 0)'],
    91. ['rgba(255, 139, 0, 1)', 'rgba(255, 110, 0, 0)'],
    92. ['rgba(255, 0, 0, 1)', 'rgba(235, 0, 0, 0)'],
    93. ['rgba(0, 255, 0, 1)', 'rgba(0, 255, 0, 0)']
    94. ];
    95. var colorItem = colorList[params.dataIndex];
    96. return new echarts.graphic.LinearGradient(
    97. 0,
    98. 0,
    99. 0,
    100. 1,
    101. [
    102. {
    103. offset: 0,
    104. color: colorItem[0]
    105. },
    106. {
    107. offset: 1,
    108. color: colorItem[1]
    109. }
    110. ],
    111. false
    112. );
    113. }
    114. }
    115. }
    116. ]
    117. };