taek_onvi
01-27-2022Cloud Apps
Lines on scatter chart
This seems like a very trivial question, but I couldn't seem to find an answer. If I have a scatter chart, I would also like to show the calculated average of the x- and y-axis spanning across the ...
- 01-27-2022
Hello taek_onvi ,
Please check if this widget script works for you:
widget.on('processresult', function(se, ev){ xaxisCount = 0 xAxisSum = 0 yaxisCount = 0 yAxisSum = 0 $.each(ev.rawResult.values, function(index, value){ if(typeof(value[0].data) == 'number') { xaxisCount += 1 xAxisSum += value[0].data } if(typeof(value[1].data) == 'number') { yaxisCount += 1 yAxisSum += value[1].data } }) avgxAxis = xAxisSum/xaxisCount avgyAxis = yAxisSum/yaxisCount //Reference : https://www.binextlevel.com/post/add-target-benchmark-line-to-a-chart-in-sisense ev.result.xAxis.plotLines = [{ color: 'blue', dashStyle: 'ShortDash', width: 2, value: avgxAxis, zIndex: 5, label : { text : 'Avg X-Axis' } }] ev.result.yAxis[0].plotLines = [{ color: 'green', dashStyle: 'ShortDash', width: 2, value: avgyAxis, zIndex: 5, label : { text : 'Avg Y-Axis' } }] })
-Hari