plotly / plotly/plotly.js

Choropleth: can't add/remove from current selection after zoom

未关闭
#7,391 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

I don't know if this is a bug or a missing feature, but i'd like to select polygons on a choropleth, zoom, then add/ remove from the current selection via shift+click.
This is especially useful when i want to remove a few central polygons from a big selection small polygons and need to select then zoom in to better see which few to remove.
This is already possible in (non-geographic) scatter plots: click to select, zoom, then shift-click to remove from selection, e.g.

import plotly.express as px

df = px.data.iris()
fig = px.scatter(df.iloc[:20], x="sepal_width", y="sepal_length")
fig.update_layout(clickmode="event+select")
fig.show()

And it's already possible in choropleths without zooming between selecting and shift-clicking.

Here's a code snippet to reproduce the bug (or missing feature).

import plotly.graph_objects as go

import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv')

fig = go.Figure(data=go.Choropleth(
    locations=df['code'], # Spatial coordinates
    z = df['total exports'].astype(float), # Data to be color-coded
    locationmode = 'USA-states', # set of locations match entries in `locations`
    colorscale = 'Reds',
    colorbar_title = "Millions USD",
))

fig.update_layout(
    title_text = '2011 US Agriculture Exports by State',
    geo_scope='usa', # limite map scope to USA
    clickmode="event+select",
)

fig.show()

Now box-select some polygons, then remove a polygon from the selection by shift-clicking it.
Works nicely.
Box-select some polygons again, zoom in, then try to remove a polygon from the selection by shift-clicking it.
No can do!

贡献指南

打开贡献指南

从这里开始

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

调研方向

先从提供的 Plotly Express scatter 和 plotly.graph_objects Choropleth 复现开始,然后在 repository 中追踪 choropleth 选择和地理缩放交互的入口点。确认现有的无缩放 shift-click 行为,并使缩放后的情况保留并更新当前选择;完成的标准是,提供的复现可以在缩放后移除一个多边形,并且该操作序列有 coverage。

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

评估

技术栈
javascript
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

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