top of page

Button to Show/Hide value labels

Sometime the widget looks messy when we enable value labels. At the same time it would be good to enable it to analyze the chart easily. So let the end user enable to disable value labels as they required. Here is a script to add button to chart to show/hide value labels.





Steps:

  1. Create new widget - (line/bar/column/pie/area chart)

  2. Add below script to widget

  3. Save the script and refresh widget


displayValue = false

widget.on('processresult', function(se, ev){	
	ev.result.chart.marginTop= 60
	ev.result.plotOptions.series.dataLabels.enabled = displayValue
	ev.result.plotOptions.bar.dataLabels.enabled = displayValue
});

widget.on("domready", function(w, args){
	
	chart = w.chart[0][Object.keys(w.chart[0])[0]].hc
	chart.renderer.button(
		displayValue == true?'Hide Values':'Show Values', 
		10, 
		10)
		.on('click', function () {
			displayValue = !displayValue
			widget.refresh();
		})
	.add();
	
});


It is possible to change style of buttons by adding 'style' property in the script

233 views0 comments

Comentarios

Obtuvo 0 de 5 estrellas.
Aún no hay calificaciones

Agrega una calificación
bottom of page