英文:
Amcharts tooltip - how to manipulate the tooltipText?
问题
我有一个日期图表,我想要在每个工具提示中添加词语“今天”,如果它的日期是当前日期,但我不确定如何使用{valueY}关键字,因为它是一个引用....
假设我正在创建一个名为checkForCurrentDate()的函数,我应该如何在.tooltipText关键字中使用它?
series.tooltipText = "{dateX}: [b]{valueY}[/] this.checkForCurrentDate(???)";
英文:
I have a chart of dates and i want to add the word "Today" to each tooltip that it's day is the current day, but i'm not sure how to use the {valueY} key since it's a reference....
Suppose i'm creating a function called checkForCurrentDate(), how can i use it in the .tooltipText key?
series.tooltipText = "{dateX}: [b]{valueY}[/] this.checkForCurrentDate(???)";
答案1
得分: 1
我认为你应该在创建数据时调用该函数,像这样:
chart.data = [{
"date": new Date(2023, 0, 16),
"value": 450,
"value2": 362,
"value3": 699,
"isToday": checkForCurrentDate(new Date(2023, 0, 16)),
}]
然后,你可以在你的工具提示中使用它:
series.tooltipText = "{dateX}: [b]{valueY}[/] {isToday}";
通过在创建数据对象时直接传递checkForCurrentDate函数的结果,你可以确保isToday属性基于日期包含了正确的值。
英文:
I think you should call the function when you create the data, like this:
chart.data = [{
"date": new Date(2023, 0, 16),
"value": 450,
"value2": 362,
"value3": 699,
"isToday": checkForCurrentDate(new Date(2023, 0, 16)),
}]
Then, you can use it in your tooltip:
series.tooltipText = "{dateX}: [b]{valueY}[/] {isToday}";
By passing the result of the checkForCurrentDate function directly when creating the data object, you ensure that the isToday property contains the correct value based on the date.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论