echaerts图例自动滚动并隐藏翻页按钮

效果图

 

代码

    legend: {
      itemHeight: 14,
      itemWidth: 14,
      height: "300", //决定显示多少个
      // 通过 CSS 完全隐藏翻页按钮
      pageButtonItemGap: 0,
      pageButtonPosition: 'end',
      pageIconColor: 'transparent', // 隐藏翻页按钮
      pageIconInactiveColor: 'transparent', // 隐藏翻页按钮
      pageIconSize: 0, // 隐藏翻页按钮
      pageTextStyle: {
        color: 'transparent' // 隐藏翻页按钮的文字
      } ,
      icon: "rect",
      orient: 'vertical',
      type: 'scroll',  //必须
      top: 'center',
      right: 0,
      data: legend
    },

 

  // 获取图例的总页数
  var totalPage = myChart.getOption().legend[0].pageIconInactiveColor;

  var currentPage = 0;

  function autoScroll() {
    myChart.dispatchAction({
      type: 'legendScroll',
      scrollDataIndex: currentPage * 5   //一下滚动几个
    });
    currentPage++;
    if (currentPage * 5 >= option.legend.data.length) {
      currentPage = 0;
    }
  }
  clearInterval(timer)
    
  timer = setInterval(autoScroll, 3000);

  myChart.on('click', function () {
    clearInterval(timer);
    timer = setInterval(autoScroll, 3000);
  });

最近更新

  1. TCP协议是安全的吗?

    2024-06-06 22:12:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-06 22:12:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-06 22:12:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-06 22:12:03       18 阅读

热门阅读

  1. Springboot+WebSocket实现消息推送

    2024-06-06 22:12:03       9 阅读
  2. 嵌入式学习——网络编程(UDP)——day30

    2024-06-06 22:12:03       8 阅读
  3. iPhone 语言编程:深入探索与无限可能

    2024-06-06 22:12:03       11 阅读
  4. iOS swift5 加载网络图片的第三方框架

    2024-06-06 22:12:03       8 阅读
  5. C++ 智能指针

    2024-06-06 22:12:03       10 阅读