DamianC
03-01-2023Cloud Apps
Y Axis sorting
Hi All,
Can anyone help with sorting the Y axis on this scatter. I can see why it's building this way but I need it to be more readable for the end user.
Additionally is there anyway to hid...
Hi DamianC ,
Take a look at this post by intapiuser .
Regarding your question about hiding an empty tooltip, try the script suggested in this post.
Hi Benji,
Thanks for the info, I've added in the scripts and tooltip is gone as requested, and sorting on the y axis has been achieved however, this has now re ordered the x axis.
I've tried to incorporate another script I found but it's not working. Can you provide further assistance please?
widget.on('beforeviewloaded',function(se,ev){
ev.options.chart.type='heatmap'
})
var xOrder = 'desc' //also, this value can be desc
var yOrder = 'asc'
widget.on('beforeviewloaded', function(scope, args) {
var shouldBeExecuted = (order === 'desc' || order === 'asc' )
if (args.widget.type !== 'chart/scatter' || !shouldBeExecuted) {
return
}
var daysOrder = args.options.xAxis.categories.sort();
if (xOrder === 'desc') {
daysOrder.reverse()
}
if (daysOrder.length === args.options.xAxis.categories.length) {
args.options.xAxis.categories = daysOrder
for (i=0; i<daysOrder.length; i++) {
for (k=0; k<args.options.series.length; k++) {
for (j=0; j<args.options.series[k].data.length; j++) {
if (args.options.series[k].data[j].selectionData[0] === daysOrder[i]) {
args.options.series[k].data[j].x = i;
}
}
}
}
}
})
widget.on('beforequery', function(se, ev) {
ev.query.metadata.forEach(function(m) {
if (m.wpanel && m.wpanel === 'y-axis') {
m.jaql.sort = yOrder
}
})
})
var categories= ['00:00','01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00',];
widget.on('queryend',function(se,ev){
ev.rawResult.values.sort(function(a, b){
var aIndex = categories.indexOf(a[0].data.trim());
var bIndex = categories.indexOf(b[0].data.trim());
if (aIndex < bIndex)
return -1;
if (aIndex > bIndex)
return 1;
return 0;
})
})
widget.on("beforedatapointtooltip", function (se, args){
args.cancel=true;
});