https://echarts.apache.org/examples/zh/editor.html?c=line-stack

  • icon: ‘circle’ 自定义 Legend形状
  • symbol: “none” 去掉折线图上的小圆点

image.png

  1. option = {
  2. tooltip: {
  3. trigger: 'axis'
  4. },
  5. legend: {
  6. type: 'scroll',
  7. icon: 'circle',
  8. data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
  9. },
  10. grid: {
  11. left: '3%',
  12. right: '4%',
  13. bottom: '3%',
  14. containLabel: true
  15. },
  16. xAxis: {
  17. type: 'category',
  18. boundaryGap: false,
  19. data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  20. },
  21. yAxis: {
  22. type: 'value'
  23. },
  24. series: [
  25. {
  26. name: 'Email',
  27. type: 'line',
  28. stack: 'Total',
  29. symbol: "none", // 去掉折线上面的小圆点
  30. data: [120, 132, 101, 134, 90, 230, 210]
  31. },
  32. {
  33. name: 'Union Ads',
  34. type: 'line',
  35. stack: 'Total',
  36. symbol: "none",
  37. data: [220, 182, 191, 234, 290, 330, 310]
  38. },
  39. {
  40. name: 'Video Ads',
  41. type: 'line',
  42. stack: 'Total',
  43. symbol: "none",
  44. data: [150, 232, 201, 154, 190, 330, 410]
  45. },
  46. {
  47. name: 'Direct',
  48. type: 'line',
  49. stack: 'Total',
  50. symbol: "none",
  51. data: [320, 332, 301, 334, 390, 330, 320]
  52. },
  53. {
  54. name: 'Search Engine',
  55. type: 'line',
  56. stack: 'Total',
  57. symbol: "none",
  58. data: [820, 932, 901, 934, 1290, 1330, 1320]
  59. }
  60. ]
  61. };

自定义Legend

image.png

正方形

  1. {
  2. legend: {
  3. // icon: 'rect',
  4. // itemWidth: 20,
  5. // itemHeight: 10,
  6. // itemGap: 10, 以上都是默认值
  7. itemHeight: 24,
  8. itemWidth: 24,
  9. data: [
  10. {
  11. name: '修边比例',
  12. icon: 'rect',
  13. },
  14. {
  15. name: '平均门幅',
  16. icon: 'rect',
  17. }
  18. ],
  19. right: '4%',
  20. textStyle: {
  21. fontSize: 12,
  22. color: '#F1F1F3'
  23. },
  24. }
  25. }