cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
When toggling the "value labels" switch of a widget's design pane, the labels are enabled or disabled for the entire chart.
In case you have multiple series and you want to disable just one of them (typical when it gets too crowded on the plot), it is possible to do by adding the following code to the widget's script:
/******* user configuration **********/
var seriesName = "MySeries";
/*************************************/
widget.on('processresult', function(sender, ev){
var data = _.find(ev.result.series, function (ser) {return ser.name == seriesName}).data
_.each(data, function(value){ 

      value.dataLabels = {enabled:false}
      })
})
Just replace the series name with the desired measure you want  to remove the labels from.
For hiding the value labels of multiple series, use the following script:
/******* user configuration **********/
var seriesNames = ["MySeries1", "MySeries2"];
/*************************************/
widget.on('processresult', function(sender, ev){
 seriesNames.forEach(function(e, i, a){
 var data = _.find(ev.result.series, function (ser) {return ser.name == e}).data
 _.each(data, function(value){ 
 value.dataLabels = {enabled:false}
 }) 
 })
})

BREAK-BY

In case your measure is "Broken By" some field, each series name will be as the specific value of that field. See this example, where only the "orange" labels are shown:
We enabled 'value labels' and configured in the script:
var seriesName = "apple";
The result:
 If you are using Markers signs which you would like to remove you can use the following script:
widget.on("beforeviewloaded",function(w,args){ 
var seriesToRemoveMarkerFrom = ["seriesName"]; 

var seriesWithoutMarkers = _.filter(args.options.series,function(ser){ 
return (seriesToRemoveMarkerFrom.indexOf(ser.name) > -1); 
}) 

if(seriesWithoutMarkers.length > 0){ 
seriesWithoutMarkers.forEach(function(s){ 
s.marker = {enabled : false}; 
}) 
}
Enjoy!
Rate this article:
Comments
karengonzalez
8 - Cloud Apps
8 - Cloud Apps

Worked amazing! Thanks for sharing

Julia_WK
7 - Data Storage
7 - Data Storage

Unfortunately this code doesn't work for L2023.11

After any iteration with the widget (resize, print or whatever), widget's layout gets broken. 

@intapiuser do you have updated code by any chance? 

DRay
Community Team Member
Community Team Member

@JeremyFriedel, Can you provide updated code for this, or know who can?

JeremyFriedel
Sisense Team Member
Sisense Team Member

No problem @DRay 

The below updated code works in newer versions of Sisense can be used as a template to hide the labels of specific series in a line chart widget:

 

 

/******* user configuration **********/
// Change to name of series which labels should be hidden
var seriesName = "TestName";
/*************************************/
widget.on('processresult', function (sender, ev) {

	var matchingSeries = _.find(ev.result.series, function (ser) { return ser.name == seriesName })

	matchingSeries.dataLabels = {
		enabled: false,
	}
})

 

 

A screenshot of hiding one series labels in a line chart while other series are enabled:

Screen Shot 2024-06-22 at 11.13.02 PM.png

This can be modified as needed to work with specific scenarios such as hiding multiple series.

@Julia_WK 

Version history
Last update:
‎03-02-2023 09:12 AM
Updated by:
Contributors