From 24add2d3932e1d03123f0e1d699a44c0b23b839c Mon Sep 17 00:00:00 2001 From: Chris Barnes Date: Wed, 6 Sep 2017 12:07:17 -0400 Subject: [PATCH] Normalize the padding This changeset normalizes the chart padding before trying to access the object's properties since it is possible to pass in an integer and not an object as the padding option. --- src/scripts/chartist-plugin-axistitle.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/scripts/chartist-plugin-axistitle.js b/src/scripts/chartist-plugin-axistitle.js index 14ffe57..8b3010d 100644 --- a/src/scripts/chartist-plugin-axistitle.js +++ b/src/scripts/chartist-plugin-axistitle.js @@ -56,17 +56,18 @@ ); } - var xPos; - var yPos; - var title; + var xPos, + yPos, + title, + chartPadding = Chartist.normalizePadding(data.options.chartPadding); // normalize the padding in case the full padding object was not passed into the options //position axis X title if (options.axisX.axisTitle && data.axisX) { xPos = (data.axisX.axisLength / 2) + data.options.axisY.offset + - data.options.chartPadding.left; + chartPadding.left; - yPos = data.options.chartPadding.top; + yPos = chartPadding.top; if (data.options.axisY.position === 'end') { xPos -= data.options.axisY.offset; @@ -94,7 +95,7 @@ xPos = 0; - yPos = (data.axisY.axisLength / 2) + data.options.chartPadding + yPos = (data.axisY.axisLength / 2) + chartPadding .top; if (data.options.axisX.position === 'start') {