如何动态更改dc.js可视化的数据URL?

时间:2018-02-12 16:21:27

标签: dc.js

我想根据选定的日期获取一些数据。我通过烧瓶应用程序中的资源路径发送日期。因此,我想在每次更改日期范围时更改数据网址。

1 个答案:

答案 0 :(得分:0)

function setOneYearRefiner(searchParam) {
if (document.URL.indexOf("Default") == -1){
var nu = new Date();
nu.setFullYear(nu.getFullYear()-1);
nu.setMonth(nu.getMonth());
nu.setDate(nu.getDate()-1);
var lastyear = nu.getUTCFullYear();

var thisMonth = nu.getMonth()+1;
if (thisMonth < 10) {thisMonth = "0" + thisMonth;}

var thisDay = nu.getUTCDate();
if (thisDay < 10) {thisDay = "0" + thisDay;}

location.hash='Default={"k":"'+searchParam+'","r":[{"n":"LastModifiedTime","t":["range('+lastyear+'-'+thisMonth+'-'+ thisDay+'T22:00:00Z, max, to=\\"le\\")"],"o":"and","k":false,"m":null}]}'
}