plotly / plotly/plotly.js

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

オープン
#7,391 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
JavaScript
スター
18.3k
フォーク
2k
平均マージ
2日 12時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供されている Plotly Express の scatter と plotly.graph_objects の Choropleth の再現コードから始め、続いてリポジトリ内で choropleth の選択および地理的なズーム操作のエントリポイントを追跡します。既存のズームなしの shift-click の動作を確認し、ズームした場合に現在の選択を維持して更新できるようにします。完了の条件は、提供された再現コードでズーム後にポリゴンを削除でき、その一連の操作がカバレッジされていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。