[英]create a tag "<text>" part of the word is cut. c3.js - d3.js
[英]move position labels of bar, to maximize / minimize the screen, the text unsettle ( in C3.js - D3.js)
首先移动所有d3活动,将文本移动到调整大小函数,如下所示:
function resize() {
d3.selectAll('.c3-axis-x .tick')
.each(function(d, i) {
// clear tick contents and replace with image
var self = d3.select(this);
// self.selectAll("*").remove();
self.append('image')
.attr("xlink:href", arrayOfPics[i])
.attr("x", -40)
.attr("y", -20)
.attr("width", 25)
.attr("height", 25);
});
d3.selectAll('.c3-axis-x .tick')
.each(function(d, i) {
// clear tick contents and replace with image
var self = d3.select(this);
// self.selectAll("*").remove();
self.append('text')
.attr("x", 50)
.attr("y", -110)
.style("text-anchor", "middle")
.text("this text is a indicator");
});
d3.select('.c3-axis-x').attr("clip-path", null);
d3.selectAll('.c3-text')
.each(function(d) {
var self = d3.select(this);
self.attr('x', '5');
});
}
现在在图表调整大小调用此函数如下:
var chart = c3.generate({
bindto: '#chart',
size: {
height: 500,
}
....
onresized: function() {//callback called on resize of a chart
resize()
}
});
在这里工作代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.