i've following script:
gapi.analytics.ready(function() { viewselector.on('viewchange', function update (data) { var title = document.getelementbyid('view-name'); title.innerhtml = data.property.name + ' (' + data.view.name + ')'; activeusers.set(data).execute(); renderweekoverweekchart(data.ids); rendertopbrowserschart(data.ids); rendertopcountrieschart(data.ids); settimeout(function() { var list = document.getelementsbytagname("tr")[0]; list.getelementsbytagname("th")[0].innerhtml = "pagina's"; list.getelementsbytagname("th")[1].innerhtml = "paginaweergaven"; }, 500); }); });
and within following code re-run update(); function.
function datumwissel( datumbtn ) { if ( datumbtn.classname == 'maand' ) { datumbtn.classname = 'jaar'; dimensions1 = 'ga:month,ga:nthmonth'; start1 = moment(now).date(1).month(0).format('yyyy-mm-dd'); end1 = moment(now).format('yyyy-mm-dd'); start2 = moment(now).subtract(1, 'year').date(1).month(0).format('yyyy-mm-dd'); end2 = moment(now).date(1).month(0).subtract(1, 'day').format('yyyy-mm-dd'); format1 = 'm'; format2 = 'mmm'; update(); } else { datumbtn.classname = 'maand'; dimensions1 = 'ga:date,ga:nthweek'; start1 = moment(now).subtract(2, 'day').date(1).format('yyyy-mm-dd'); end1 = moment(now).format('yyyy-mm-dd'); start2 = moment(now).subtract(2, 'day').date(1).subtract(1, 'month').format('yyyy-mm-dd'); end2 = moment(now).subtract(2, 'day').date(1).subtract(1, 'day').format('yyyy-mm-dd'); format1 = 'yyyymmdd'; format2 = 'do'; update(); } }
but somehow doesn't work. tried in above script: window.update = function (data) {}
. doesn't work.
how can call update();
function situated inside gapi.analytics.ready(function() {}
?
important cannot make globally has situated inside gapi.analytics.ready().
it's simple matter of moving function declaration
function update (data) { // same existing code } gapi.analytics.ready(function() { viewselector.on('viewchange', update ); });
and passing in data needed when call in other function
function datumwissel( datumbtn ) { if ( datumbtn.classname == 'maand' ) { .......... update(datumbtn); }.......
Comments
Post a Comment