Javascript 如何在动画图表饼图中显示月份?
我正在制作amchart时间轴饼图的动画,目前正试图让它显示月份和天数,而不仅仅是天数,因为我有很多数据,“132天”并不是最好的说明方式 有没有一种简单的方法可以通过amcharts本身或者仅仅是js来实现呢?Javascript 如何在动画图表饼图中显示月份?,javascript,html,animation,charts,amcharts,Javascript,Html,Animation,Charts,Amcharts,我正在制作amchart时间轴饼图的动画,目前正试图让它显示月份和天数,而不仅仅是天数,因为我有很多数据,“132天”并不是最好的说明方式 有没有一种简单的方法可以通过amcharts本身或者仅仅是js来实现呢? 我试着列出了一个“如果currentDay>=32&¤tDayAmCharts没有针对这种情况的内置解决方案,尤其是在饼图中,那么您必须自己想出一些解决方案。根据您的需要/准确性,您可以将当前日期划分/修改为月/日,而不是像您建议的那样列出ifs,或者您可以使用类似的方法将
我试着列出了一个“如果currentDay>=32&¤tDayAmCharts没有针对这种情况的内置解决方案,尤其是在饼图中,那么您必须自己想出一些解决方案。根据您的需要/准确性,您可以将当前日期划分/修改为月/日,而不是像您建议的那样列出ifs,或者您可以使用类似的方法将您的年中日期值转换为实际日期,以获取月份和日期,例如:
function loop() {
formatText(chart, currentYear); //consider renaming the currentYear variable since it refers to days.
// ... omitted ...
}
function formatText(chart, day) {
var date = moment(day, "DDD");//turn day of year into a date
chart.allLabels[1].text = date.format("MMMM"); //get the full month name and set it to the top label
chart.allLabels[0].text = date.format("Do"); //get date with ordinal and set it to the bottom
}