1、折线 zoom缩放 time
    image.png

    1. if (this.echartsLeftDome != null) {
    2. this.echartsLeftDome.dispose();
    3. }
    4. this.echartsLeftDome = this.$echarts.init(
    5. document.getElementById('echartsLeft')
    6. );
    7. todayget().then((res) => {
    8. // res.data
    9. let title = [];
    10. let val = [];
    11. res.data.forEach((item) => {
    12. title.push(item[0]);
    13. val.push(item[1]);
    14. });
    15. let option = {
    16. tooltip: {
    17. trigger: 'axis',
    18. },
    19. xAxis: [{
    20. type: 'category',
    21. data: title,
    22. axisLine: {
    23. lineStyle: {
    24. color: '#999',
    25. },
    26. },
    27. }, ],
    28. yAxis: [{
    29. type: 'value',
    30. // splitNumber: 1,
    31. splitLine: {
    32. lineStyle: {
    33. color: '#DDD',
    34. },
    35. },
    36. axisLine: {
    37. show: false,
    38. lineStyle: {
    39. color: '#333',
    40. },
    41. },
    42. nameTextStyle: {
    43. color: '#999',
    44. },
    45. }, ],
    46. dataZoom: [{
    47. type: 'inside',
    48. show: false,
    49. start: 0,
    50. end: 100
    51. }, ],
    52. series: [{
    53. name: '请求数',
    54. type: 'line',
    55. data: val,
    56. color: 'red', // 100% 处的颜色
    57. lineStyle: {
    58. normal: {
    59. width: 2,
    60. },
    61. },
    62. symbol: 'none',
    63. smooth: true,
    64. }, ],
    65. };
    66. this.echartsLeftDome.setOption(option);
    67. });

    2、折线 time zoom缩放 面积
    image.png

    1. if (this.echartsLeftBottomDome != null) {
    2. this.echartsLeftBottomDome.dispose();
    3. }
    4. this.echartsLeftBottomDome = this.$echarts.init(
    5. document.getElementById('echartsLeftBottom')
    6. );
    7. let option = {
    8. tooltip: {
    9. trigger: "axis",
    10. formatter: function (parms) {
    11. var str =
    12. parms[0].data[0] +
    13. "</br>" +
    14. parms[0].marker +
    15. "内存" + '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp' +
    16. parms[0].data[1] + "%"
    17. "</br>"
    18. return str;
    19. },
    20. },
    21. title: {
    22. top: "bottom",
    23. left: "center",
    24. text: "内存",
    25. },
    26. grid: [{
    27. top: '8%',
    28. }, ],
    29. xAxis: {
    30. type: "time",
    31. boundaryGap: false,
    32. axisLabel: {
    33. formatter: '{HH}:{mm}'
    34. }
    35. },
    36. yAxis: {
    37. type: "value",
    38. max: 100,
    39. },
    40. dataZoom: [{
    41. type: 'inside',
    42. show: false,
    43. start: 1,
    44. end: 100
    45. }, ],
    46. series: [{
    47. name: "内存",
    48. type: "line",
    49. smooth: true,
    50. symbol: "none",
    51. sampling: "average",
    52. itemStyle: {
    53. normal: {
    54. color: "#82B9ED",
    55. },
    56. },
    57. areaStyle: {
    58. normal: {
    59. color: this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
    60. offset: 0,
    61. color: "#82B9ED",
    62. },
    63. {
    64. offset: 1,
    65. color: "#F8FBFE",
    66. },
    67. ]),
    68. },
    69. },
    70. data: this.CpData,
    71. }, ],
    72. };
    73. this.echartsLeftBottomDome.setOption(option)