X-axis type lost after restyle
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ả
If i create a bar chart with a categorical x-axis, where the x-values are strings of digits, then restyle it with new y-values, the categoricality of the x-axis is lost, and it becomes linear, as if the type had been freshly inferred from the values.
Here is a self-contained example (i'm afraid i don't have a codepen account):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Restyle</title>
<script src="https://cdn.plot.ly/plotly-latest.js"></script>
<script>
addEventListener("DOMContentLoaded", () => {
const plot = document.getElementById("plot");
Plotly.newPlot(plot,
{
data: [{
type: "bar",
x: ["2", "5", "10", "30", "50"],
y: [1, 2, 3, 4, 5]
}],
layout: {
xaxis: {type: "category"}
},
config: {
responsive: true
}
});
document.getElementById("restyle").addEventListener("click", () => {
Plotly.restyle(plot, {y: [[5, 4, 3, 2, 1]]}, 0);
});
});
</script>
</head>
<body>
<div id="plot"></div>
<button id="restyle">Restyle</button>
</body>
</html>
When the page loads, the x-axis is correctly categorical, but when you click the button, it becomes incorrectly linear.
I believe this is the same problem as described in the forum post "X-axis “category” type not honored after Plotly.restyle".
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 bằng cách chạy ví dụ HTML tự chứa với Plotly.newPlot và Plotly.restyle, sau đó lần theo đường dẫn restyle cập nhật biểu đồ cột. Công việc được hoàn thành khi trục x vẫn là phân loại sau khi các giá trị y được thay thế, thay vì được suy luận lại là tuyến tính.
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
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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
- 45/100