• echarts折线图(其他图也是一样)设置tooltip自动滚动


    按顺序自动滚动效果

    1. class="leftComp-charts" id="chartsBox">
    2. chartsData: {
    3. roadNorm: [],
    4. time: []
    5. },
    6. eChartsTimer: null
    7. initChartsBox() {
    8. this.option = {
    9. tooltip: {
    10. trigger: "axis",
    11. axisPointer: {
    12. // 方法一
    13. type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
    14. shadowStyle: {
    15. color: "rgba(41, 95, 204, 0.2)",
    16. },
    17. },
    18. borderColor: "rgba(0, 170, 255)", // 边框颜色
    19. }, // 坐标轴指示器配置
    20. textStyle: {
    21. color: "#333", // xy轴的提示文字颜色,不包含背景刻度线
    22. },
    23. color: ["#1492FF"],
    24. grid: {
    25. top: "25px",
    26. left: "50px",
    27. right: "20px",
    28. bottom: "35px",
    29. },
    30. xAxis: [
    31. {
    32. type: "category",
    33. data: this.chartsData.time,
    34. axisLine: {
    35. show: true,
    36. lineStyle: {
    37. color: "#004080",
    38. // width: 0,
    39. type: "solid",
    40. }, // x轴线的颜色以及宽度
    41. },
    42. // axisLabel: {
    43. // show: true,
    44. // textStyle: {
    45. // color: "rgba(255, 255, 255, 0.3)",
    46. // }
    47. // }, // x轴文字的配置
    48. splitLine: {
    49. show: false,
    50. lineStyle: {}, // 分割线配置
    51. },
    52. axisTick: {
    53. show: false,
    54. }, // x轴的刻度线
    55. },
    56. ],
    57. yAxis: [
    58. {
    59. type: "value",
    60. splitLine: {
    61. show: true,
    62. lineStyle: {
    63. color: "#333",
    64. opacity: 0.1,
    65. }, // 设置横向的线的颜色
    66. },
    67. axisLabel: {
    68. show: true,
    69. margin: 20,
    70. // textStyle: {
    71. // color: "rgba(255, 255, 255, 0.3)",
    72. // }, // y轴的字体配置
    73. },
    74. },
    75. ],
    76. series: [
    77. {
    78. data: this.chartsData.roadNorm,
    79. type: "line",
    80. smooth: true,
    81. },
    82. ],
    83. };
    84. this.myChart = this.$echarts.init(document.getElementById("chartsBox")); // 图标初始化
    85. this.myChart.setOption(this.option); // 渲染页面
    86. var that = this;
    87. let index = 0;
    88. this.eChartsTimer = setInterval(function () {
    89. let len = that.chartsData.time.length;
    90. if (index >= len) {
    91. index = 0;
    92. }
    93. that.myChart.dispatchAction({
    94. type: "showTip", // 提示框
    95. seriesIndex: 0,
    96. dataIndex: index, // 第 lightIndex 柱子高亮
    97. });
    98. index += 1
    99. }, 1000);
    100. /* ECharts动态效果 */
    101. window.addEventListener("resize", () => {
    102. this.myChart.resize();
    103. });
    104. },
    105. mounted() {
    106. this.initChartsBox()
    107. },
    108. destroyed() {
    109. clearInterval(this.eChartsTimer)
    110. }
    111. .leftComp-charts {
    112. width: 600px;
    113. height: 220px;
    114. border: 1px solid red;
    115. }

    随机滚动请看这里

    1. var that = this;
    2. this.eChartTimer = setInterval(function () {
    3. var index = Math.round(Math.random() * that.yAxisData.length);
    4. if (index === 0) {
    5. index = 1;
    6. }
    7. that.myChart.dispatchAction({
    8. type: "showTip", // 提示框
    9. seriesIndex: 0,
    10. dataIndex: index, // 第 lightIndex 柱子高亮
    11. });
    12. }, 1000);

  • 相关阅读:
    使用mybatis-plus的saveOrUpdate的问题
    常用工具 | 使用API Monitor监测到目标程序对系统API函数的调用
    FL Studio21中文完整版升级下载
    将自定义RPM包加入YUM
    【Java基础】深入理解反射、反射的应用(工厂模式、代理模式)
    Android下的app性能测试应主要针对那些方面,如何开展?
    湖北省制造业高质量发展专项资金政策!2022年各大类申报条件以及奖励补贴标准汇总
    JS-(14)正则表达式
    volatile的用途和说明
    系统运维网络知识汇总
  • 原文地址:https://blog.csdn.net/m0_74149462/article/details/133767881