diff --git a/packages/vx-demo/components/tiles/axis.js b/packages/vx-demo/components/tiles/axis.js index c7eeac4ff..66390ca58 100644 --- a/packages/vx-demo/components/tiles/axis.js +++ b/packages/vx-demo/components/tiles/axis.js @@ -4,7 +4,7 @@ import { Group } from '@vx/group'; import { curveBasis } from '@vx/curve'; import { GradientOrangeRed } from '@vx/gradient'; import { genDateValue } from '@vx/mock-data'; -import { AxisLeft, AxisBottom } from '@vx/axis'; +import { AxisLeft, AxisRight, AxisBottom } from '@vx/axis'; import { AreaClosed, LinePath, Line } from '@vx/shape'; import { scaleTime, scaleLinear } from '@vx/scale'; import { extent, max } from 'd3-array'; @@ -88,71 +88,97 @@ export default ({ width, height, margin }) => { curve={curveBasis} /> - ({ - fill: '#8e205f', - textAnchor: 'end', - fontSize: 10, - fontFamily: 'Arial', - dx: '-0.25em', - dy: '0.25em' - })} - tickComponent={({ formattedValue, ...tickProps }) => ( - {formattedValue} - )} - /> - - {props => { - const tickLabelSize = 10; - const tickRotate = 45; - const tickColor = '#8e205f'; - const axisCenter = (props.axisToPoint.x - props.axisFromPoint.x) / 2; - return ( - - {props.ticks.map((tick, i) => { - const tickX = tick.to.x; - const tickY = tick.to.y + tickLabelSize + props.tickLength; - return ( - - - - {tick.formattedValue} - - - ); - })} - - {props.label} - - - ); - }} - + + ({ + fill: '#8e205f', + textAnchor: 'end', + fontSize: 10, + fontFamily: 'Arial', + dx: '-0.25em', + dy: '0.25em' + })} + tickComponent={({ formattedValue, ...tickProps }) => ( + {formattedValue} + )} + /> + ({ + fill: '#8e205f', + textAnchor: 'start', + fontSize: 10, + fontFamily: 'Arial', + dx: '0.25em', + dy: '0.25em' + })} + /> + + {props => { + const tickLabelSize = 10; + const tickRotate = 45; + const tickColor = '#8e205f'; + const axisCenter = (props.axisToPoint.x - props.axisFromPoint.x) / 2; + return ( + + {props.ticks.map((tick, i) => { + const tickX = tick.to.x; + const tickY = tick.to.y + tickLabelSize + props.tickLength; + return ( + + + + {tick.formattedValue} + + + ); + })} + + {props.label} + + + ); + }} + + ); }; diff --git a/packages/vx-demo/pages/axis.js b/packages/vx-demo/pages/axis.js index 9d93ac105..ce6b5aefa 100644 --- a/packages/vx-demo/pages/axis.js +++ b/packages/vx-demo/pages/axis.js @@ -9,8 +9,8 @@ export default () => { title="Axis" margin={{ top: 20, - left: 60, - right: 40, + left: 70, + right: 70, bottom: 60 }} > @@ -20,7 +20,7 @@ import { Group } from '@vx/group'; import { curveBasis } from '@vx/curve'; import { GradientOrangeRed } from '@vx/gradient'; import { genDateValue } from '@vx/mock-data'; -import { AxisLeft, AxisBottom } from '@vx/axis'; +import { AxisLeft, AxisRight, AxisBottom } from '@vx/axis'; import { AreaClosed, LinePath, Line } from '@vx/shape'; import { scaleTime, scaleLinear } from '@vx/scale'; import { extent, max } from 'd3-array'; @@ -54,12 +54,12 @@ export default ({ width, height, margin }) => { // scales const xScale = scaleTime({ range: [0, xMax], - domain: extent(data, x), + domain: extent(data, x) }); const yScale = scaleLinear({ range: [yMax, 0], domain: [0, max(data, y)], - nice: true, + nice: true }); // scale tick formats @@ -68,20 +68,8 @@ export default ({ width, height, margin }) => { return ( - - + + { curve={curveBasis} /> - ({ - fill: '#8e205f', - textAnchor: 'end', - fontSize: 10, - fontFamily: 'Arial', - dx: '-0.25em', - dy: '0.25em', - })} - tickComponent={({ formattedValue, ...tickProps}) => ( - {formattedValue} - )} - /> - - {props => { - const tickLabelSize = 10; - const tickRotate = 45; - const tickColor = '#8e205f'; - const axisCenter = - (props.axisToPoint.x - props.axisFromPoint.x) / 2; - return ( - - {props.ticks.map((tick, i) => { - const tickX = tick.to.x; - const tickY = - tick.to.y + tickLabelSize + props.tickLength; - return ( - - - - {tick.formattedValue} - - - ); - })} - - {props.label} - - - ); - }} - + + ({ + fill: '#8e205f', + textAnchor: 'end', + fontSize: 10, + fontFamily: 'Arial', + dx: '-0.25em', + dy: '0.25em' + })} + tickComponent={({ formattedValue, ...tickProps }) => ( + {formattedValue} + )} + /> + ({ + fill: '#8e205f', + textAnchor: 'start', + fontSize: 10, + fontFamily: 'Arial', + dx: '0.25em', + dy: '0.25em' + })} + /> + + {props => { + const tickLabelSize = 10; + const tickRotate = 45; + const tickColor = '#8e205f'; + const axisCenter = (props.axisToPoint.x - props.axisFromPoint.x) / 2; + return ( + + {props.ticks.map((tick, i) => { + const tickX = tick.to.x; + const tickY = tick.to.y + tickLabelSize + props.tickLength; + return ( + + + + {tick.formattedValue} + + + ); + })} + + {props.label} + + + ); + }} + + ); };`}