首页 > 解决方案 > amCharts 标签字体设置

问题描述

我的应用程序上有一个样式表,用于设置基线字体。它工作正常,我很满意。

* {
    font-family: Roboto, sans-serif;
    font-size: 13px;
}

我在饼图的中心添加了一个标签。标签添加正确,但 fontSize 无效。我认为如此明确会覆盖任何其他样式,但事实并非如此?

chartOverviewAnimatedCenterLabel = chartOverviewAnimated.seriesContainer.createChild(am4core.Label);
chartOverviewAnimatedCenterLabel.text = "";
chartOverviewAnimatedCenterLabel.horizontalCenter = "middle";
chartOverviewAnimatedCenterLabel.verticalCenter = "middle";
chartOverviewAnimatedCenterLabel.fontSize = 50;
chartOverviewAnimatedCenterLabel.id = "center";

标签: labelamcharts

解决方案


您必须在轴上定义字体大小。像这样的东西

let categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.renderer.labels.template.fontSize = 8;

推荐阅读