Highlight Max and Min values in Line chart
- BI Next Level
- Nov 25, 2022
- 1 min read
Sometimes line chart contains more value points and it wont be readable if we enable the value labels. But it would be a nice feature to highlight minimum and maximum value in the chart to get a better understanding of value range in it. Here is a script to achieve this.

Steps:
Create line chart and disable value label from design panel
Add below widget script
Save the script and refresh widget
widget.on('processresult', function(se, ev){
let maxItem = Math.max.apply(Math, ev.result.series[0].data.map(function(el) { return el.y; }))
let minItem = Math.min.apply(Math, ev.result.series[0].data.map(function(el) { return el.y; }))
let maxfilterItems = ev.result.series[0].data.filter(el=>el.y == maxItem)
let minfilterItems = ev.result.series[0].data.filter(el=>el.y == minItem)
$.each(maxfilterItems, function(index, value){
value.dataLabels = {
enabled:true,
borderColor: 'green',
backgroundColor:'green',
color: 'white',
borderWidth: 1,
borderRadius:3,
padding: 3,
style: {
fontWeight: 'bold'
}
}
})
$.each(minfilterItems, function(index, value){
value.dataLabels = {
enabled:true,
borderColor: 'red',
backgroundColor:'red',
color: 'white',
borderWidth: 1,
borderRadius:3,
padding: 3,
style: {
fontWeight: 'bold'
}
}
})
})
This would be really useful, but unfortunately, it no longer works for a line chart that uses a dimension changer for the x-axis. Do you have any suggestions on how I can make it work, especially if I want to integrate it into a line chart where the date aggregation changes?