我正在使用 dash-svg(下图)开发一个 plotly dash 应用程序, https://github.com/stevej2608/dash-svg
我在使用 dash-svg 为 svg 图形制作 htmltag 时遇到问题。 我找不到在 svg 图表中建立链接,例如“https://www.google.com”。
如果有人知道“Clickable svg circle”的答案,请帮助我...
import dash
from dash import html
from dash_svg import Svg, G, Path, Circle
app = dash.Dash(__name__)
app.layout = html.Div([
html.Header([
Svg([
G([
Path(d='...'),
Circle(cx="420.9", cy="296.5", r='45.7'),
Path(d='M520.5 78.1z')
], fill='#61DAFB')
], viewBox='0 0 841.9 595.3', className="App-logo", alt="logo"),
html.P(["Edit ", html.Code("usage.py"), " and save to reload."]),
html.A("Learn Dash", className="App-link", href="https://dash.plotly.com/", target="_blank", rel="noopener noreferrer")
], className="App-header")
], className="App")
if __name__ == '__main__':
app.run_server(debug=True)
最佳答案
您可以尝试将 Svg 组件设置为 html.A 组件的子组件,如下所示:
html.A(
[
Svg([
G([
Path(d='...'),
Circle(cx="420.9", cy="296.5", r='45.7'),
Path(d='M520.5 78.1z')
], fill='#61DAFB')
], viewBox='0 0 841.9 595.3', className="App-logo", alt="logo"),
],
target="_blank",href="https://google.com"
),
关于html - plotly dash-svg 的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74037213/