Missing Text Elements (e.g. Title, and Legends) when exporting as HTML
Describe the bug
Title, text, and label elements are not visible when exporting to HTML, either from the server or using pyvista.Plotter.export_html. The same issue occurs with vtksz, from which as far as I understood the HTML is generated.
To Reproduce
Steps to reproduce the behavior:
- Run the provided script.
- Open Served app (text elements will be present).
- Export as HTML.
- Observe that the title, text, and legend labels are missing.
⚠️ Can also be reproduces with pyvista.Plotter.export_html.
Code
"""Script to report bug - text elements not showing on HTML exports."""
import pyvista as pv
from pyvista import examples
from pyvista.trame.ui import plotter_ui
from trame.app import get_server
from trame.ui.vuetify3 import SinglePageLayout
pv.OFF_SCREEN = True
server = get_server()
state, ctrl = server.state, server.controller
mesh = examples.load_random_hills()
pl = pv.Plotter()
pl.add_mesh(mesh, label="mesh")
pl.add_text("My Sphere Plot", position="upper_edge", font_size=24, color="black")
pl.add_legend()
with SinglePageLayout(server) as layout:
with layout.content:
view = plotter_ui(pl)
if __name__ == "__main__":
server.start()
Expected behavior
The exported HTML should include all text elements, including the title, text annotations, and legend labels.
Screenshots
Served app (or pyvista.Plotter.show():
Exported HTML:
** Environment **
--------------------------------------------------------------------------------
Date: Fri Feb 07 11:42:30 2025 CET
OS : Darwin (macOS 15.2)
CPU(s) : 8
Machine : arm64
Architecture : 64bit
RAM : 16.0 GiB
Environment : Python
File system : apfs
Python 3.10.15 (main, Dec 5 2024, 12:36:43) [Clang 16.0.0
(clang-1600.0.26.4)]
pyvista : 0.44.2
vtk : 9.3.1
numpy : 1.24.4
matplotlib : 3.9.3
scooby : 0.10.0
pooch : 1.8.2
pillow : 11.0.0
IPython : 8.30.0
scipy : 1.14.1
tqdm : 4.67.1
trame : 3.8.0
trame_client : 3.5.2
trame_server : 3.3.0
trame_vtk : 2.8.14
trame_vuetify : 2.8.1
nest_asyncio : 1.6.0
--------------------------------------------------------------------------------
Platform:
Device:
- [x] Desktop
- [x] Mobile
OS:
- [ ] Windows
- [x] MacOS
- [ ] Linux
- [ ] Android
- [ ] iOS
Browsers Affected:
- [x] Chrome
- [x] Firefox
- [x] Microsoft Edge
- [x] Safari
- [x] Opera
- [x] Brave
- [x] IE 11
Thanks for the report, but that is a known limitation of vtk.js.
See https://github.com/Kitware/trame-vtk/issues/67