Horizontal Stacked Bar Labels Cut Off
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 encountering some behavior with labelling on stacked horizontal bar charts that I feel is somewhat strange.
Basically, when I try to add a label to each section of the stacked bar, everything works fine until I adjust the range of the x-axis to get rid of the grey space to the right of the bars. It looks like if the sum of any of the bars goes even slightly over the range of the x-axis, it causes some labels to not show up. What confuses me, and makes me unsure if this is intended or not, is that it appears as if the labels are correctly appearing in the JSON, but don't actually show up on the graph.
Here's an example:
import pandas as pd
import plotly.graph_objects as go
summary_figure = go.Figure()
summary_figure.add_trace(go.Bar(
name="Women",
text=["Women"]*4,
y = ["A","B","C","D"],
x = [50,60,70,85],
orientation = 'h',
textfont_color="white",
textangle=0,
textposition="inside",
insidetextanchor= "start",
cliponaxis=False,
))
summary_figure.add_trace(go.Bar(
name="Men",
text=["Men"]*4,
y = ["A","B","C","D"],
x = [50.001,40.001,30,15],
orientation = 'h',
textfont_color="white",
textangle=0,
textposition="inside",
insidetextanchor= "start",
cliponaxis=False,
))
summary_figure.update_layout(
barmode='stack',)
summary_figure.update_xaxes(range=[0, 100])
summary_figure.show()
In this example, "Men" appears in the JSON four times, but only gets displayed twice.
Because of tiny rounding discrepancies in our data, this behavior has led to a lot of confusion for my team. If it's intended, I'd love if there was some sort of warning to make it known that the bar is being truncated.
Thanks!
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
Không có tệp nguồn, bài kiểm thử hoặc điểm vào nào được nêu. Hãy bắt đầu bằng cách tái hiện ví dụ biểu đồ thanh xếp chồng ngang được cung cấp trong plotly.js với phạm vi của trục x được đặt thành [0, 100], sau đó theo dõi cách các nhãn được kết xuất khi tổng của các thanh hơi vượt quá phạm vi. Công việc được xem là hoàn tất khi đã quyết định hành vi dự kiến và ghi lại hoặc kiểm thử cách xử lý kết quả.
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100