From 6301b266be71f4fb869b405a86337ea9431bf3cc Mon Sep 17 00:00:00 2001 From: Julian Kingman Date: Tue, 10 Oct 2017 13:25:34 -0400 Subject: [PATCH 1/3] added axis line position --- src/Axis.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Axis.js b/src/Axis.js index 5fcdbb3..ec04b52 100644 --- a/src/Axis.js +++ b/src/Axis.js @@ -111,6 +111,12 @@ export default class Axis extends Component { render() { const { chartArea, options, scale } = this.props const horizontal = options.orient ==='top' || options.orient ==='bottom' + const positionMargin = {x: 0, y: 0}; + + if (options.position) { + if (options.position === 'right') positionMargin.x += chartArea.x.max; + if (options.position === 'top') positionMargin.y += chartArea.y.max; + } const axis = new AxisStruct(scale,options,chartArea,horizontal).axis() @@ -155,7 +161,7 @@ export default class Axis extends Component { let returnValue if (label !== undefined && label !== null) { returnValue = - + {options.showTicks && } @@ -176,8 +182,8 @@ export default class Axis extends Component { }) let offset = { - x: chartArea.margin.left * -1, - y: chartArea.margin.top * -1 + x: chartArea.margin.left * -1 + positionMargin.x, + y: chartArea.margin.top * -1 + positionMargin.y // x: 0, // y: 0 } From b639be9b36e56baff18ed41891308a69774ca942 Mon Sep 17 00:00:00 2001 From: Julian Kingman Date: Tue, 10 Oct 2017 13:41:42 -0400 Subject: [PATCH 2/3] fix for position:top --- src/Axis.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Axis.js b/src/Axis.js index ec04b52..c93c408 100644 --- a/src/Axis.js +++ b/src/Axis.js @@ -111,12 +111,6 @@ export default class Axis extends Component { render() { const { chartArea, options, scale } = this.props const horizontal = options.orient ==='top' || options.orient ==='bottom' - const positionMargin = {x: 0, y: 0}; - - if (options.position) { - if (options.position === 'right') positionMargin.x += chartArea.x.max; - if (options.position === 'top') positionMargin.y += chartArea.y.max; - } const axis = new AxisStruct(scale,options,chartArea,horizontal).axis() @@ -131,6 +125,13 @@ export default class Axis extends Component { if (options.orient === 'left') xy = [-5,-10] if (options.orient === 'right') xy = [5,5] + const positionMargin = {x: 0, y: 0}; + + if (options.position) { + if (options.position === 'right') positionMargin.x += (chartArea.x.max); + if (options.position === 'top') positionMargin.y -= (chartArea.y.min + xy[1]); + } + if (typeof options.color !== 'string') { options.color = '#3E90F0' } From f03e1981c63aa9526689bcacf080eb65f725b041 Mon Sep 17 00:00:00 2001 From: Julian Kingman Date: Tue, 10 Oct 2017 13:46:45 -0400 Subject: [PATCH 3/3] added to options in docs --- docs/scatterplot/index.md | 2 ++ docs/smoothline/index.md | 2 ++ docs/stockline/index.md | 2 ++ 3 files changed, 6 insertions(+) diff --git a/docs/scatterplot/index.md b/docs/scatterplot/index.md index f9c4c08..45dea70 100644 --- a/docs/scatterplot/index.md +++ b/docs/scatterplot/index.md @@ -212,6 +212,7 @@ render() { showTicks: true, zeroAxis: false, orient: 'bottom', + position: 'top', //optional label: { fontFamily: 'Arial', fontSize: 8, @@ -226,6 +227,7 @@ render() { showTicks: true, zeroAxis: false, orient: 'left', + position: 'right', //optional label: { fontFamily: 'Arial', fontSize: 8, diff --git a/docs/smoothline/index.md b/docs/smoothline/index.md index d357d39..953e276 100644 --- a/docs/smoothline/index.md +++ b/docs/smoothline/index.md @@ -155,6 +155,7 @@ render() { showTicks: true, zeroAxis: false, orient: 'bottom', + position: 'top', //optional label: { fontFamily: 'Arial', fontSize: 14, @@ -169,6 +170,7 @@ render() { showTicks: true, zeroAxis: false, orient: 'left', + position: 'right', //optional label: { fontFamily: 'Arial', fontSize: 14, diff --git a/docs/stockline/index.md b/docs/stockline/index.md index 683fa47..d381489 100644 --- a/docs/stockline/index.md +++ b/docs/stockline/index.md @@ -200,6 +200,7 @@ render() { showTicks: true, zeroAxis: false, orient: 'bottom', + position: 'top', //optional tickValues: [], label: { fontFamily: 'Arial', @@ -215,6 +216,7 @@ render() { showTicks: true, zeroAxis: false, orient: 'left', + position: 'right', //optional tickValues: [], label: { fontFamily: 'Arial',