add configuration property per shape to prevent user edits
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 18.3k
- フォーク
- 2k
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 28
説明
Hello,
I've been looking for a means to easily configure shape definitions such that any user edits (e.g. repositioning the shape) to them are blocked.
At this time of writing, the figure reference for shapes doesn't appear to have a property where one can achieve the above (e.g. an editable property). In case I've missed something in the API that makes this effortless, I'd appreciate any pointers.
In the meanwhile, I guess there are workarounds, such as my following example below which makes use of mouse event handlers:
import Plotly from 'plotly.js';
const data = [
{
x: [1, 2, 3, 4],
y: [2, 4, 8, 16],
type: 'scatter',
mode: 'lines'
}
];
const layout = {
shapes: [
{
type: 'rect',
x0: 2,
x1: 3,
y0: 5,
y1: 10
}
]
};
const config = {
editable: true
};
const plot = document.getElementById('plot');
Plotly.newPlot(plot, data, layout, config);
let blockMoveEvents = false;
plot.addEventListener('mousedown', e => {
if (e.target.closest('.shapelayer') == null) {
return;
}
blockMoveEvents = true;
});
document.addEventListener('mousemove', e => {
if (blockMoveEvents) {
e.stopImmediatePropagation();
}
});
document.addEventListener('mouseup', e => {
blockMoveEvents = false;
});
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、レポートに示されている layout shapes のリファレンスと Plotly.newPlot の設定を確認します。これには config.editable と、リンクされている CodeSandbox の回避策も含まれます。shape の操作がどのように処理されているかを追跡し、shape ごとの編集可能性をどこに設定すべきかを判断します。保護された shape を再配置できない一方で、その他の編集可能な plot 操作が引き続き機能すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- data-visualization
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100