From 2a896db87ddcacad60bbfe334618b1c25c9fcda9 Mon Sep 17 00:00:00 2001 From: GrigoreMihai Date: Thu, 9 May 2024 11:09:23 +0300 Subject: [PATCH] fix: improper title settings for ChartJS #1133 --- js/render-chartjs.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/render-chartjs.js b/js/render-chartjs.js index 96a3b849..8e1b3f6f 100644 --- a/js/render-chartjs.js +++ b/js/render-chartjs.js @@ -25,6 +25,7 @@ data = chart.data; settings = chart.settings; + console.log(settings); container = document.getElementById(id); if (container == null) { return; @@ -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 @@ -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); @@ -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'){