Javascript 如何更改图表html轴标签的字体特征?
基于一位图表作者的帖子,我实现了将html锚元素放入Y轴标签的功能。正如建议的那样,我在Javascript源代码中添加了插件代码,如下所示:Javascript 如何更改图表html轴标签的字体特征?,javascript,html,css,chartist.js,Javascript,Html,Css,Chartist.js,基于一位图表作者的帖子,我实现了将html锚元素放入Y轴标签的功能。正如建议的那样,我在Javascript源代码中添加了插件代码,如下所示: // HTML Label plugin Chartist.plugins = Chartist.plugins || {}; Chartist.plugins.ctHtmlLabels = function(options) { return function(chart) { chart.on('draw', function(conte
// HTML Label plugin
Chartist.plugins = Chartist.plugins || {};
Chartist.plugins.ctHtmlLabels = function(options) {
return function(chart) {
chart.on('draw', function(context) {
if (context.type === 'label') {
// Best to combine with something like sanitize-html
context.element.empty()._node.innerHTML = context.text;
}
});
}
}
这将成功地将可导航元素设置到轴标签中。但是,我想将显示的文本链接的字体特征修改为默认的Times Roman 12 pt外观之外的内容。如何做到这一点?你不能给元素分配一个类,然后用css来设计类的样式吗?谢谢。很明显,我不知道为什么我没有想到。