【发布时间】:2015-07-16 04:11:46
【问题描述】:
我的图表对象中有这个事件:
load: function(){
var text = this.renderer.label(percentage + '%').css({
color: 'white',
fontSize: fontSize + 'px',
fontFamily: "'Raleway', sans-serif",
fontWeight: 100
}).add();
var textBBox = text.getBBox();
this.chartHeight = this.chartWidth;
this.redraw();
var x = ((this.renderer.width - textBBox.width) / 2) + 10;
var y = ((this.renderer.height - textBBox.height) / 2) - (fontSize / 5);
text.attr({x: x, y: y});
}
我想要做的是将图表的高度设置为与图表的宽度相同。看起来它有点工作,因为图表中的项目放置在正确的位置,但图表默认为 400px 高度。
所以当我的图表是 200px 宽时,高度应该调整为 200px 高。正在发生的事情是将图表移动到正确的位置,但图表本身仍然是 400 像素高。
我缺少什么来解决这个问题?我将css中的图表设置为100%,所以我希望它与该百分比的高度相同。我能做什么?
这是一个有效的小提琴:http://jsfiddle.net/epuqj6wy/
你可以看到图表是 400px,它应该是一个完美的正方形
【问题讨论】:
标签: javascript highcharts