jmn3
08-02-2022Cloud Apps
Change Continuous Timeline on Charts to Show Date every 7 days instead of every day
Problem:
One of our teams uses Sunday as the calendar week start day, which is different than our other teams that use Monday as the week start day. I have created a special column in a date dimen...
- 08-05-2022
Hi jmn3 ,
Try below script. Don't use Continuous Timeline feature in Sisense
(I have done some basic testing with this script)
widget.on("processresult", function (se, ev) { max_date = new Date(ev.result.series[0].data[ev.result.series[0].data.length - 1].selectionData[0]) min_date = new Date(ev.result.series[0].data[0].selectionData[0]) day_interval = 7 //Update the interval here var new_date_list = []; var new_date_list_string = [] temp_date = min_date while (temp_date <= max_date) { new_date_list.push(new Date(temp_date)); new_date_list_string.push(moment(temp_date).format('ll')); temp_date.setDate(temp_date.getDate() + day_interval); } ev.result.series.forEach( function(bb) { newData= new Array(new_date_list.length); var blankcat; bb.data.forEach( function(cat) { if (cat.selectionData){ newData[new_date_list.map(Number).indexOf(+cat.selectionData[0])]=cat; } }) for (i=0; i<newData.length; i++) { blankcat = { "y": null, "color": null, "selected": false, "marker": { "fillColor": "white", "lineColor": null } } if (typeof newData[i] === 'undefined') { newData[i]=blankcat; } } bb.data=newData; }); ev.result.xAxis.categories = new_date_list_string })-Hari