plotly / plotly/plotly.js

add trace option to make some data not selectable in order to speed up slow box select

未关闭
#6,822 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature P3
主要语言
JavaScript
星标
18.3k
派生
2k
平均合并
2 天 12 小时
30 天内合并 PR
28

描述

Hi,

When there are a lot of data traces displayed in the plot (>10,000), box select is slow and laggy when you click and drag to select data traces. I notice it is even slower in version plotly.js@2.27.1 than it is in plotly.js@2.5.1. A hypothetical solution for me would be if you added a feature to exclude some traces from being selectable, as in the example below.

Example of proposed feature:

import React from 'react';
import Plot from 'react-plotly.js';

class MyPlot extends React.Component {
  render() {
    return (
      <Plot
        data={[
          {
            x: [1, 2, 3, 4],
            y: [10, 15, 13, 17],
            type: 'scattergl',
            mode: 'lines+markers',
            name: 'Selectable Trace'
          },
          {
            x: [1, 2, 3, 4],
            y: [16, 5, 11, 9],
            type: 'scattergl',
            mode: 'lines+markers',
            name: 'Non-selectable Trace',
            selectable: false   //  <------ THIS IS THE NEW FEATURE THAT IS BEING REQUESTED
          }
        ]}
        layout={{ 
          title: 'Selectable vs Non-selectable Traces'
        }}
      />
    );
  }
}

I have a temporary fix to speed up selection. When I tested this naive change, box select's click and drag is no longer laggy:

// Change in file: plotly.js/src/traces/scattergl/select.js
 module.exports = function select(searchInfo, selectionTester) {
  return [];  // Changed to always return no selected traces, because my own onSelected handler can do all the work using only the selected x, y range coordinates.
 }

If you can tell me how to monkey patch this in, that would be very helpful!

Thanks!

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 src/traces/scattergl/select.js 开始,检查框选当前如何处理各个 trace,并使用报告中的 scattergl 示例作为行为参考。确定 trace 级别的 selectable 选项应如何影响选择,同时保留对其他 trace 的选择。完成的标准是排除不可选择的 trace,并且在大型数据集上框选仍具有良好的响应性。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, react
领域
data-visualization, frontend, performance
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。