官网矩形:https://echarts.apache.org/zh/option.html#graphic.elements-rect

    1. const rectObj = {
    2. id: 'rect_id',
    3. type: 'rect',
    4. style: {
    5. fill: {
    6. type: 'linear',
    7. x: 0,
    8. y: 0,
    9. x2: 1,
    10. y2: 0,
    11. colorStops: [
    12. {
    13. offset: 0, color: 'yellow'
    14. },
    15. {
    16. offset: 1, color: 'pink'
    17. }
    18. ]
    19. }
    20. },
    21. shape: {
    22. x: 20,
    23. y: 20,
    24. width: 40,
    25. height: 60,
    26. r: 2
    27. },
    28. textContent: {
    29. style: {
    30. text: 'rect',
    31. fill: '#ffffff',
    32. fontSize: 12,
    33. font: 'Microsoft YaHei',
    34. fontWeight: 400,
    35. lineHeight: 32
    36. },
    37. z: 100
    38. },
    39. textConfig: {
    40. position: 'inside'
    41. },
    42. z: 100
    43. };