diff --git a/src/components/Axis/Axis.tsx b/src/components/Axis/Axis.tsx index 6ff5e781..edf55360 100644 --- a/src/components/Axis/Axis.tsx +++ b/src/components/Axis/Axis.tsx @@ -78,7 +78,7 @@ export function Axis({ labelStyle, hidden = false, tickLabelStyle, - tickLabelFormat = scale === 'time' ? undefined : (value) => String(value), + tickLabelFormat, hiddenLine = false, lineStyle, primaryGridLineStyle, diff --git a/src/components/Axis/LinearAxis.tsx b/src/components/Axis/LinearAxis.tsx index 15770b39..e0fd449d 100644 --- a/src/components/Axis/LinearAxis.tsx +++ b/src/components/Axis/LinearAxis.tsx @@ -11,7 +11,12 @@ interface LinearAxisProps extends AxisChildProps { } export default function LinearAxis(props: LinearAxisProps) { - const { position, tickLabelFormat, scale, ...otherProps } = props; + const { + position, + tickLabelFormat = (value) => String(value), + scale, + ...otherProps + } = props; const axisRef = useRef(null); diff --git a/src/components/Axis/LogAxis.tsx b/src/components/Axis/LogAxis.tsx index 19a57c2b..76055fd2 100644 --- a/src/components/Axis/LogAxis.tsx +++ b/src/components/Axis/LogAxis.tsx @@ -11,7 +11,12 @@ interface LogAxisProps extends AxisChildProps { } export default function LinearAxis(props: LogAxisProps) { - const { position, tickLabelFormat, scale, ...otherProps } = props; + const { + position, + scale, + tickLabelFormat = scale.tickFormat(), + ...otherProps + } = props; const axisRef = useRef(null); diff --git a/stories/control/logaxis.stories.tsx b/stories/control/logaxis.stories.tsx index dee7eae2..0ef457da 100644 --- a/stories/control/logaxis.stories.tsx +++ b/stories/control/logaxis.stories.tsx @@ -26,10 +26,36 @@ const data = [ { x: 0.01, y: 10000 }, { x: 0.1, y: 100000 }, ]; +const dataB = [ + { x: 0.0000000001, y: 10000000000 }, + { x: 0.000000001, y: 1000000000 }, + { x: 0.00000001, y: 100000000 }, + { x: 0.0000001, y: 10000000 }, + { x: 0.000001, y: 1000000 }, + { x: 0.00001, y: 100000 }, + { x: 0.0001, y: 10000 }, + { x: 0.001, y: 1000 }, + { x: 0.01, y: 100 }, + { x: 0.1, y: 10 }, + { x: 1, y: 1 }, + { x: 10, y: 0.1 }, + { x: 100, y: 0.01 }, + { x: 1000, y: 0.001 }, + { x: 10000, y: 0.0001 }, + { x: 100000, y: 0.00001 }, + { x: 1000000, y: 0.000001 }, + { x: 10000000, y: 0.0000001 }, + { x: 100000000, y: 0.00000001 }, + { x: 1000000000, y: 0.000000001 }, + { x: 10000000000, y: 0.0000000001 }, +]; const logSeries = ( ); +const logSeriesB = ( + +); export function AxisLeftLogControl(props: AxisControlProps) { return ( @@ -40,7 +66,15 @@ export function AxisLeftLogControl(props: AxisControlProps) { ); } - +export function AxisLeftLogControlB(props: AxisControlProps) { + return ( + + {logSeriesB} + + + + ); +} export function AxisBottomLogControl(props: AxisControlProps) { return ( @@ -50,7 +84,15 @@ export function AxisBottomLogControl(props: AxisControlProps) { ); } - +export function AxisBottomLogControlB(props: AxisControlProps) { + return ( + + {logSeriesB} + + + + ); +} export function AxisRightLogControl(props: AxisControlProps) { return (