add configuration property per shape to prevent user edits
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 18.3k
- Forks
- 2k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 28
Beschreibung
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;
});
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der Referenz zu den Layout-Shapes und der im Bericht gezeigten Plotly.newPlot-Konfiguration, einschließlich config.editable und der verlinkten CodeSandbox-Umgehungslösung. Verfolgen Sie, wie Shape-Interaktionen behandelt werden, und bestimmen Sie, wo die Bearbeitbarkeit einzelner Shapes hingehört. Als erledigt gilt die Aufgabe, wenn geschützte Shapes nicht neu positioniert werden können, während andere bearbeitbare Plot-Interaktionen weiterhin funktionieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- data-visualization
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100