From ccb98eb058c48d73dd5abd32ac2bbad3ef3c1cab Mon Sep 17 00:00:00 2001 From: wadjih-bencheikh18 Date: Wed, 26 Jan 2022 22:17:31 +0100 Subject: [PATCH 1/2] docs: create log axisb --- package.json | 4 +-- stories/control/logaxis.stories.tsx | 46 +++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index bf70b3a2..4f03fff6 100644 --- a/package.json +++ b/package.json @@ -64,11 +64,11 @@ "@types/react": "^17.0.38", "@zakodium/eslint-config": "^5.1.0", "eslint": "^8.7.0", - "mass-tools": "^0.60.23", + "mass-tools": "^0.60.25", "ml-dataset-iris": "^1.2.1", "ml-pca": "^4.0.2", "ml-regression-simple-linear": "^2.0.3", - "ml-spectra-processing": "^8.1.0", + "ml-spectra-processing": "^8.3.1", "prettier": "^2.5.1", "react": "^17.0.2", "react-dom": "^17.0.2", 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 ( From f215a8661919e64a934090784895d739c0de0ef6 Mon Sep 17 00:00:00 2001 From: wadjih-bencheikh18 Date: Sat, 29 Jan 2022 12:40:45 +0100 Subject: [PATCH 2/2] feat: default d3 tick format in logscale --- src/components/Axis/Axis.tsx | 2 +- src/components/Axis/LinearAxis.tsx | 7 ++++++- src/components/Axis/LogAxis.tsx | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/Axis/Axis.tsx b/src/components/Axis/Axis.tsx index f2a92f92..c349d237 100644 --- a/src/components/Axis/Axis.tsx +++ b/src/components/Axis/Axis.tsx @@ -73,7 +73,7 @@ export function Axis({ labelStyle, hidden = false, tickLabelStyle, - tickLabelFormat = (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);