Skip to content

Allow changing point labels using a callback function#1879

Merged
etimberg merged 2 commits intov2.0-devfrom
fix/1110
Jan 9, 2016
Merged

Allow changing point labels using a callback function#1879
etimberg merged 2 commits intov2.0-devfrom
fix/1110

Conversation

@etimberg
Copy link
Member

@etimberg etimberg commented Jan 9, 2016

Fixes #1110

To change the point labels, modify the config option for the scale

scale: {
    pointLabels: {
        callback: function(pointLabel, index, labels) { 
            // Return string here. String must be defined
        }
    }
}

@etimberg etimberg added this to the Version 2.0 milestone Jan 9, 2016
etimberg added a commit that referenced this pull request Jan 9, 2016
@etimberg etimberg merged commit ff94a54 into v2.0-dev Jan 9, 2016
@etimberg etimberg changed the title Fix/1110 Allow changing point labels using a callback function Jan 9, 2016
@etimberg etimberg deleted the fix/1110 branch January 9, 2016 19:58
@Jesperskate
Copy link

Jesperskate commented Oct 4, 2018

Hi Etimberg,

Is this fix still working? For me it isn't. I am using chartjs 2.0 (https://atmospherejs.com/jmsalash/chartjs) in Meteor:

myBarChart = new Chart(ctx, {
	    type: 'radar',
	    data: {
	      labels: labelInput,
	      datasets: [{
	          label: "Your result",
	          fill: true,
	          backgroundColor: "rgba(242,105,33,0.8)",
	          borderColor: "rgba(242,105,33,1)",
	          borderWidth: 1,
	          pointBorderWidth: 0,
	          pointRadius: 0,
	          data: dataInput
        	}]
	    },
	   	options: {
	    	scale: {
		    	pointLabels: {
		    		fontSize: 15,
		            callback: function() {
		            	var string = 'hello'
		            	console.log('hello')
		                return string
		            } 
		        },
		        ticks: {
		        	display: false,
					beginAtZero: true,
					showLabelBackdrop: false,
					stepSize: 1,
					suggestedMin: 1,
		            suggestedMax: 4,
		        },
		        gridLines: {
		            lineWidth: 4,	
		        	color: "#efefef"
		  		} 
		    },
		    layout: {
		        padding: {
		            left: 50,
		            right: 20,
		            top: 20,
		            bottom: 0
		    	}
			},
			legend:{
				display: false,
			}
	   	}
	});
}

I can change all other options of pointLabels, such as fontsize, but not the callback...

Best,

Jesper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants