如何像列表一样显示SVG标题内容,而不是直线
我正在使用SVG创建离散的传奇,在该传说中,我将标题附加到rect上,以显示悬停的内容,但标题的内容以直线显示,我想一个又一个又一个类似的列表。例如:内容1第一行内容2,依此类推。
代码段的一部分:
//有一个我正在附加的div svg
<div id="legend" ref={divRef}></div>
const currentDiv = select(divRef.current);
// creating svg
currentDiv
.append("svg")
.attr("viewBox", `0 0 ${count} 1`)
.attr("preserveAspectRatio", "none")
g.selectAll("g.legendCells")
.data(data)
.enter()
.append("g")
.append("rect")
.append("title")
.append("span")
.text(legendValues) // this is title content (array items)
//i.sstatic.net/9Mygg.png“ alt =” inter taimy Description在此处“>
fiddle链接: https://jsfiddle.net/r4lafyjs/
基本上标题是阵列值,例如格式:
0: "Content_0"
1: "Content_1"
2: "Content_2"
3: "Content_3"
必须显示在悬停在rect cell上,索引:content:content
I am creating discrete legend using SVG, where I am appending title to the rect to show content on hover but the content of title is displayed in straight line, which I want to come one after the other like list. Ex: Content 1 first and next line Content 2 and so on.
Part of Code Snippet:
// Have a div for which I am appending the svg
<div id="legend" ref={divRef}></div>
const currentDiv = select(divRef.current);
// creating svg
currentDiv
.append("svg")
.attr("viewBox", `0 0 ${count} 1`)
.attr("preserveAspectRatio", "none")
g.selectAll("g.legendCells")
.data(data)
.enter()
.append("g")
.append("rect")
.append("title")
.append("span")
.text(legendValues) // this is title content (array items)
Fiddle link : https://jsfiddle.net/r4Lafyjs/
Basically the title is array values like in format :
0: "Content_0"
1: "Content_1"
2: "Content_2"
3: "Content_3"
Which must be shown on hover over the rect cells, index: content
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论