Forum Discussion
Hi :)
Please try this approach suggested by OleksiiDemianyk. On the client you need to:
- Add 6 days to each date returned by Sisense;
- Change category from the default one to the ${startWeekDate} - ${startWeekDate + 7 days}
This can be done on the event beforeviewloaded. Here is the sample where we have week as the only category:
const months = { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec' }; widget.on('beforeviewloaded', (scope, args) => { const [ seria ] = args.options.series; seria.data.forEach((point, index) => { const startDate = formatDate(point.selectionData[0]); const endDate = formatDate(new Date( new Date(point.selectionData[0]).getTime() + 6 * 24 * 60 * 60000), true); args.options.xAxis.categories[index] = `${startDate} - ${endDate}`; }) }) function formatDate( dateItem, returnYear = false ) { const [ year, monthIndex, date ] = dateItem.toISOString().substr(0, 10).split('-'); const monthString = months[parseInt(monthIndex)]; return returnYear ? `${date} ${monthString} ${year}` : `${date} ${monthString}`; }
Hope that helps!
Hi Liliia_DevX ,
Is there a way to do this without a widget edit script? As Compose SDK by Widget ID does not allow widget edit scripts to be render the changes when embedding.