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', diff --git a/src/Axis.js b/src/Axis.js index 5fcdbb3..c93c408 100644 --- a/src/Axis.js +++ b/src/Axis.js @@ -125,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' } @@ -155,7 +162,7 @@ export default class Axis extends Component { let returnValue if (label !== undefined && label !== null) { returnValue = - + {options.showTicks && } @@ -176,8 +183,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 }