amCharts 4 的导出菜单中添加平均数据选项

问题描述 投票:0回答:1

我正在尝试找到一种使用 amCharts 4 中的导出菜单快速平均每周或每月数据的方法。我做了这个 codePen 但它不起作用。

有人可以看看我做错了什么吗?

导出菜单部分如下所示:

chart.exporting.menu = new am4core.ExportMenu();
chart.exporting.menu.align = "right";
chart.exporting.menu.verticalAlign = "top";
chart.exporting.menu.items = [{
        "label": "<i class='fa fa-bars' ></i>",
        "menu": [
            { 
                "label": "Average",
                "menu": [
                    { "type": "custom", "label": "All", "options":
                        { "callback":
                            function() {
                                dateAxis.groupData = false;
                            }
                        }
                    },
                    { "type": "custom", "label": "Week", "options":
                        { "callback":
                            function() {
                                dateAxis.groupData = true;
                                lineSeries.groupFields.valueY = "average";
                                lineSeries.groupInterval = { timeUnit: "week", count: 1 };
                            }
                        }
                    },
                    { "type": "custom", "label": "Month", "options":
                        { "callback":
                            function() {
                                dateAxis.groupData = true;
                                lineSeries.groupFields.valueY = "average";
                                lineSeries.groupInterval = { timeUnit: "month", count: 1 };
                            }
                        }
                    }
                ]
            }

        ]
}];

非常感谢您的宝贵时间。

javascript amcharts
1个回答
0
投票

如果它可以帮助某人,我在另一个论坛上得到了@zeroin的答案:

功能应该是这样的...

lineSeries.groupFields.valueY = "average";  
dateAxis.groupInterval = { timeUnit: "week", count: 1 };
dateAxis.groupData = true;

干杯

© www.soinside.com 2019 - 2024. All rights reserved.