add configuration property per shape to prevent user edits
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 18.3k
- Fork
- 2k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 28
Mô tả
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;
});
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với tài liệu tham chiếu về các shape của layout và cấu hình Plotly.newPlot được nêu trong báo cáo, bao gồm config.editable và workaround CodeSandbox được liên kết. Theo dõi cách các tương tác với shape được xử lý và xác định khả năng chỉnh sửa theo từng shape nên được đặt ở đâu. Được xem là hoàn thành khi các shape được bảo vệ không thể bị định vị lại, trong khi các tương tác có thể chỉnh sửa khác của plot vẫn tiếp tục hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- data-visualization
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100