[英]Add a div inside the text tag
I have a text tag <text></text>
, which is getting from c3 donut chart title. 我有一个文本标签
<text></text>
,它是从c3甜甜圈图标题中获取的。 i want to change the content of that text tag. 我想更改该文本标签的内容。 So I tried like this way:
所以我尝试这样:
$handlerdiv.find(".c3-chart-arcs-title").append("<div style='background:green;'>"+skbl+"</div>");
but it is not working, because it is not possible to append to a text tag. 但它不起作用,因为无法附加到文本标签。
What I want is to display donut chart title inside the chart circle and this title content should be in two lines. 我想要的是在图表圆内显示甜甜圈图表标题,并且此标题内容应为两行。
Chart is generated this way: 图表是通过以下方式生成的:
var chart = c3.generate({
bindto : bindto,
data : {
columns : [],
type : 'donut',
colors : colors,
order : order
},
donut : {
title : title,
label : {
show : label
},
width : width,
},
});
You can use d3.js to add elements to chart, for example a second line to title in a donut chart: 您可以使用d3.js在图表中添加元素,例如在甜甜圈图中添加第二行标题:
d3.select(".c3-chart-arcs-title")
.append("tspan")
.attr("dy", 16)
.attr("x", 0)
.text("Second title");
Here is a fiddle: https://jsfiddle.net/beaver71/20s6sw4L/ 这是一个小提琴: https : //jsfiddle.net/beaver71/20s6sw4L/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.