Skip to content

Commit

Permalink
fix: improper title settings for ChartJS #1133
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoreMihai committed May 9, 2024
1 parent 48ab589 commit 2a896db
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/render-chartjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
data = chart.data;
settings = chart.settings;

console.log(settings);
container = document.getElementById(id);
if (container == null) {
return;
Expand Down Expand Up @@ -199,10 +200,6 @@
settings['animation']['duration'] = 1000;
}

if(typeof settings['title'] !== 'undefined' && settings['title']['text'] !== ''){
settings['title']['display'] = true;
}

if(typeof settings['tooltip'] !== 'undefined' && typeof settings['tooltip']['intersect'] !== 'undefined'){
// jshint ignore:line
settings['tooltip']['intersect'] = settings['tooltip']['intersect'] == true || parseInt(settings['tooltip']['intersect']) === 1; // jshint ignore:line
Expand Down Expand Up @@ -231,6 +228,12 @@
legend: settings.legend,
};

if(typeof settings['title'] !== 'undefined' && settings['title']['text'] !== ''){
settings.plugins['title'] = {};
settings.plugins['title']['display'] = true;
settings.plugins['title']['text'] = settings['title']['text'];
}

handleAxes(settings, chart);

override(settings, chart);
Expand Down Expand Up @@ -272,7 +275,7 @@
if(Array.isArray(settings[axis][i]) || typeof settings[axis][i] === 'object'){
for(var j in settings[axis][i]){
var $val = '';
if(j === 'labelString'){
if(j === 'labelString'){
$o['display'] = true;
$val = settings[axis][i][j];
}else if(i === 'ticks'){
Expand Down

0 comments on commit 2a896db

Please sign in to comment.