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 chart. For example if the average of the points on the x-axis is 10, then there would be a dotted line that goes from bottom of the chart to the top of the chart at x=10 and this value would be dynamic based on the points on the chart.
Thanks in advance.
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