[英]AmCharts5: How to change the x axis label and tooltip using a DateAxis?
使用 amcharts4,我使用 CategoryAxis 為 x 軸的更改工具提示和標簽文本做這樣的事情......
// change tooltip
this.xAxis.adapter.add("getTooltipText", (text, target) => {
const value = text ? parseInt(text) : -1;
return this.getAxisToolTipText(value);
});
// change label
this.xAxis.renderer.labels.template.adapter.add("text", (text, target) => {
const value = target.dataItem && target.dataItem.category ? parseInt(target.dataItem.category) : -1;
return this.getAxisText(value, text);
});
但是現在,如何對帶有 DateAxis 的 Amcharts5 做同樣的事情?
我將不勝感激任何建議。
使用適配器動態修改其目標元素的設置值。
xAxis.get("renderer").labels.template.adapters.add("html", function(html, target) {
return "<div style=\"text-align: center; font-weight: bold;\">{value.formatDate('d MMM')}</div><div style=\"text-align: center;\">{value.formatDate('EEE')}</div>";
});
xAxis.get("tooltip").adapters.add("labelText", function(text, target) {
return "Custom text";
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.