From 54d1e49bb7dd27aa940e00c24261cc0144c8d1e4 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 3 Jun 2016 09:07:14 +0100 Subject: [PATCH] Fix for chart title not updating https://github.com/chartjs/Chart.js/issues/2686 Chart options were using a cache value from initialize function. Now updating values in the beforeUpdate lifecycle. --- src/core/core.title.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/core.title.js b/src/core/core.title.js index ab969d461..08d8a16bd 100644 --- a/src/core/core.title.js +++ b/src/core/core.title.js @@ -29,10 +29,15 @@ module.exports = function(Chart) { // These methods are ordered by lifecyle. Utilities then follow. - beforeUpdate: noop, + beforeUpdate: function () { + var chartOpts = this.chart.options; + if (chartOpts && chartOpts.title) { + this.options = helpers.configMerge(Chart.defaults.global.title, chartOpts.title); + } + }, update: function(maxWidth, maxHeight, margins) { - // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;) + // Update Lifecycle this.beforeUpdate(); // Absorb the master measurements @@ -195,4 +200,4 @@ module.exports = function(Chart) { } } }); -}; \ No newline at end of file +}; -- 2.47.2