From ee85aa044ad2ad8f032d220ab2d7f0f3d442eb51 Mon Sep 17 00:00:00 2001 From: GrigoreMihai <40674950+GrigoreMihai@users.noreply.github.com> Date: Fri, 10 May 2024 18:58:32 +0300 Subject: [PATCH] fix: improper title settings for ChartJS #1133 (#1142) * fix: improper title settings for ChartJS #1133 * chore: removed test logs --- js/render-chartjs.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/render-chartjs.js b/js/render-chartjs.js index 96a3b849..251f92e4 100644 --- a/js/render-chartjs.js +++ b/js/render-chartjs.js @@ -199,10 +199,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 @@ -231,6 +227,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); @@ -272,7 +274,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'){