]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix for chart title not updating 2696/head
authorNoel <noeloconnell88@gmail.com>
Fri, 3 Jun 2016 08:07:14 +0000 (09:07 +0100)
committerNoel <noeloconnell88@gmail.com>
Fri, 3 Jun 2016 08:07:14 +0000 (09:07 +0100)
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

index ab969d461c31e3ed1d21e225476f999029c40c5c..08d8a16bd44a9765603c0291cbc1adc719a20fdd 100644 (file)
@@ -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
+};