From: Simon Brunel Date: Sun, 23 Apr 2017 17:58:11 +0000 (+0200) Subject: Fix legend and title layout options update X-Git-Tag: v2.6.0~2^2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f0c6b3f8342e2406c250329336037a7f7004284e;p=thirdparty%2FChart.js.git Fix legend and title layout options update --- diff --git a/src/core/core.layoutService.js b/src/core/core.layoutService.js index 045a74901..8d50db80a 100644 --- a/src/core/core.layoutService.js +++ b/src/core/core.layoutService.js @@ -54,18 +54,19 @@ module.exports = function(Chart) { * Register a box to a chart. * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title. * @param {Chart} chart - the chart to use - * @param {ILayoutItem} layoutItem - the item to add to be layed out + * @param {ILayoutItem} item - the item to add to be layed out */ - addBox: function(chart, layoutItem) { + addBox: function(chart, item) { if (!chart.boxes) { chart.boxes = []; } - // Ensure that all layout items have a weight - if (!layoutItem.weight) { - layoutItem.weight = 0; - } - chart.boxes.push(layoutItem); + // initialize item with default values + item.fullWidth = item.fullWidth || false; + item.position = item.position || 'top'; + item.weight = item.weight || 0; + + chart.boxes.push(item); }, /** @@ -80,6 +81,26 @@ module.exports = function(Chart) { } }, + /** + * Sets (or updates) options on the given `item`. + * @param {Chart} chart - the chart in which the item lives (or will be added to) + * @param {Object} item - the item to configure with the given options + * @param {Object} options - the new item options. + */ + configure: function(chart, item, options) { + var props = ['fullWidth', 'position', 'weight']; + var ilen = props.length; + var i = 0; + var prop; + + for (; i