Export to png ; Export to html/png requires explicit range specified for dates (pd.DateTimeIndex)
@ayjayt 已經在處理了。
開始於 2025年8月26日。
評估
這個 Issue 還沒有評估資料。
描述
kaleido==1.0.0
plotly==6.3.0
The Scatter plot below using pandas dates look fine on the Notebook, but
- When exporting to html and png, the range needs to be set explicitly
range=[dates.min(), dates.max()]. Otherwise the default starts from Jan 2000. - For png export, after the explicit fix above, the x-axis range is corrected, but the line disappeared.
There's a workaround which is to convert the dates to str for the x data values first x=dates.strftime("%Y-%m-%d") but this is a gotcha.
# Sample time series data
dates = pd.date_range(start="2024-01-01", periods=30, freq="D")
values = [20 + i + (i % 7) * 3 for i in range(30)] # Trending data with weekly pattern
# Create line chart with Graph Objects
fig = go.Figure()
fig.add_trace(
go.Scatter(
x=dates, # Plotly handles pandas DatetimeIndex directly
y=values,
mode="lines+markers",
name="Daily Values",
line=dict(color="blue", width=2),
marker=dict(size=4),
)
)
# Update layout with explicit date range
fig.update_layout(
title="Basic Line Chart - Graph Objects API",
xaxis_title="Date",
yaxis_title="Value",
width=800,
height=600,
showlegend=True,
xaxis=dict(
type="date",
# Explicitly set the date range for html and image export
range=[dates.min(), dates.max()]
),
)
# Save as HTML and PNG
fig.write_html(data_dir / "01_basic_line.html")
fig.write_image(data_dir / "01_basic_line.png")
- 主要語言
- Python
- 星號
- 504
- 分支
- 65
- 平均合併
- 6 天 9 小時
- 30 天內合併 PR
- 2
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
plotly/kaleido 的其他 Issue
-
Writing to an existing directory whose name has a dot fails with "Invalid format"可能已有人在做 @RaphaelFakhri 於 15 天前認領。 未關閉bug P3 size: 1
難度 2/5 1-3 小時 新手友好度 35/100
-
Deterministic Rendering Challenges可能重新可做 @camdecoster 於 69 天前認領,目前沒有進行中的 PR。 未關閉enhancement feature P2 size: 5
-
[FEATURE]: Embed custom fonts into vector exports (no system install)可能已有人在做 @camdecoster 於 126 天前認領。 未關閉enhancement P3 size: 3
-
enhancement feature P3 size: 5
難度 5/5 一週以上 新手友好度 25/100
-
GlobalKaleidoServer is not thread-safe可能已有人在做 @talleibman 於 251 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 48/100
相似的 Issue
-
area/test type/bug
難度 2/5 1-3 小時 新手友好度 76/100
Clodmony/starship-coop#70 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
punitarani/fli#270 ·
-
🐛 Bug 🔔 Pending processing
難度 2/5 1-3 小時 新手友好度 67/100
jumpserver/jumpserver#17980 ·
維護者通常 1 天內回覆
-
community enhancement good first issue
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
namespace
難度 2/5 1-3 小時 新手友好度 60/100
EclipseFdn/open-vsx.org#15341 ·
維護者通常 1 天內回覆