0
我有一個primefaces/Java應用程序,可以獲取我放入圖表的最近12個月的數據。將Google Analytics(分析)中的數據轉換爲過去12個月
我已經得到了數據以月即1,2,3,4,5,6,7,8,9,10,11,12
我想顯示此作爲最後12月,也就是說現在是六月 -
七月,八月,九月,十月,十一月,十二月,一月,二月,三月,四月,五月,六月。
我假設我需要轉換圖表系列數據並使用它,任何想法如何?
下面是當前功能:
public List<VisitByPath2> getVisitsChartData() throws Exception {
DataQuery query = gaService.newQuery(startDate, endDate, 100);
query.setDimensions("ga:month");
query.setMetrics("ga:visits,ga:visitsWithEvent");
query.setFilters(getGuideFilter());
query.setSort("ga:month");
List<DataEntry> data = gaService.executeQuery(query);
List<VisitByPath2> visits = new ArrayList<VisitByPath2>();
visitChart = new CartesianChartModel();
ChartSeries visitorsData = new ChartSeries();
ChartSeries activeVisitorsData = new ChartSeries();
visitorsData.setLabel("Inactive Visitors");
activeVisitorsData.setLabel("Active Visitors");
for (DataEntry visit : data) {
VisitByPath2 visitChartData = new VisitByPath2(visit);
visits.add(new VisitByPath2(visit));
visitorsData.set(visitChartData.getMonth(),visitChartData.getVisitsWithOutEvents());
activeVisitorsData.set(visitChartData.getMonth(),visitChartData.getVisitsWithEvent());
}
visitChart.addSeries(activeVisitorsData);
visitChart.addSeries(visitorsData);
return visits;
}