I have a chart being created using chart.js version 2.8 running on an Angular application. I need the tooltips to always be visible on the chart by default and not just when the mouse is hovering over the points (the chart is a scatter plot). I have looked into how to set this up and most sources seem to recommend using the pluginService to register a fix to enable the possibility. However chart.config.options.showAllTooltips needs to already exist whereas it just doesn't seem to in chart.js v2.8 anymore.
this.LQChart = new Chart(this.myChart, {
type: 'bubble',
data: {
labels:['Jobs']
}, options: {
plugins:{
colorschemes: {
scheme: 'brewer.YlOrBr9'
},
zoom:{
pan: {
enabled: true,
mode: 'xy',
rangeMin: {
x: null,
y: null
},
rangeMax:{
x: null,
y: null
}
},
zoom:{
enabled: true,
drag: false,
mode:'xy',
rangeMin: {
x: null,
y: null
},
rangeMax:{
x: null,
y: null
},
speed:0.1
}
},
// datalabels: {
// color: 'white',
// font: {
// weight:'bold'
// },
// display: function (context) {
// console.log("Algo: "+context);
// return context.dataset.data[context.dataIndex] > 15;
// },
// formatter: function(value, context) {
// console.log("Forma: "+value+" : "+context);
// return context.dataIndex + ':' + Math.round(value*100) + '%';
// }
// }
}, tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var label = data.datasets[tooltipItem.datasetIndex].label || '';
return label
}
}
},legend: {
display: false
}, title: {
display: true,
text: 'Location Quotient of Jobs in Region'
}, scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: "# of Jobs"
},
id:'y-axis-0',
type:'linear',
gridLines: {
display:true
},
ticks: {
callback: function(value, index, values) {
return Number(value.toString());
}
},
position:'left'
}],
xAxes: [{
scaleLabel: {
display: true,
labelString: "LQ"
},
id: 'x-axis-0',
type: 'linear',
position: 'bottom',
}]
}, annotation: {
annotations: [{
borderColor: 'black',
//borderDash: [2, 2],
borderWidth: 2,
mode: 'vertical',
type: 'line',
value: 1.0,
scaleID: 'x-axis-0'
}]
}
}
});
This is the code I am using to create my chart, I just need to know how to set chart tooltips to always visible.