From 5c23aa12eccb332c46238fce3c9cc22b2cf72116 Mon Sep 17 00:00:00 2001 From: Sam Nolan Date: Wed, 12 Oct 2022 14:57:35 +1100 Subject: [PATCH] Add setting to editor and playground --- .../src/components/SquiggleEditor.tsx | 2 ++ .../src/components/SquigglePlayground.tsx | 2 ++ .../SquiggleViewer/ItemSettingsMenu.tsx | 1 + .../components/src/components/ViewSettings.tsx | 17 +++++++++++++++++ 4 files changed, 22 insertions(+) diff --git a/packages/components/src/components/SquiggleEditor.tsx b/packages/components/src/components/SquiggleEditor.tsx index 23765f38..4f64e416 100644 --- a/packages/components/src/components/SquiggleEditor.tsx +++ b/packages/components/src/components/SquiggleEditor.tsx @@ -53,6 +53,7 @@ export const SquiggleEditor: React.FC = (props) => { executionId = 0, width, height = 200, + numberPrecision, enableLocalSettings = false, } = props; @@ -86,6 +87,7 @@ export const SquiggleEditor: React.FC = (props) => { result={valueToRender} width={width} height={height} + numberPrecision={numberPrecision} distributionPlotSettings={distributionPlotSettings} chartSettings={chartSettings} environment={environment ?? defaultEnvironment} diff --git a/packages/components/src/components/SquigglePlayground.tsx b/packages/components/src/components/SquigglePlayground.tsx index 59898d6b..95bf672c 100644 --- a/packages/components/src/components/SquigglePlayground.tsx +++ b/packages/components/src/components/SquigglePlayground.tsx @@ -278,6 +278,7 @@ export const SquigglePlayground: FC = ({ diagramStart: 0, diagramStop: 10, diagramCount: 20, + numberPrecision: 3, }, }); const vars = useWatch({ @@ -332,6 +333,7 @@ export const SquigglePlayground: FC = ({ result={valueToRender} environment={environment} height={vars.chartHeight || 150} + numberPrecision={vars.numberPrecision} distributionPlotSettings={{ showSummary: vars.showSummary ?? false, logX: vars.logX ?? false, diff --git a/packages/components/src/components/SquiggleViewer/ItemSettingsMenu.tsx b/packages/components/src/components/SquiggleViewer/ItemSettingsMenu.tsx index 50f8e5ba..f305b4fe 100644 --- a/packages/components/src/components/SquiggleViewer/ItemSettingsMenu.tsx +++ b/packages/components/src/components/SquiggleViewer/ItemSettingsMenu.tsx @@ -38,6 +38,7 @@ const ItemSettingsModal: React.FC< // this is a mess and should be fixed showEditor: true, // doesn't matter chartHeight: mergedSettings.height, + numberPrecision: mergedSettings.numberPrecision, showSummary: mergedSettings.distributionPlotSettings.showSummary, logX: mergedSettings.distributionPlotSettings.logX, expY: mergedSettings.distributionPlotSettings.expY, diff --git a/packages/components/src/components/ViewSettings.tsx b/packages/components/src/components/ViewSettings.tsx index 7d70bfc8..73ec2c9a 100644 --- a/packages/components/src/components/ViewSettings.tsx +++ b/packages/components/src/components/ViewSettings.tsx @@ -21,6 +21,13 @@ export const viewSettingsSchema = yup.object({}).shape({ diagramStart: yup.number().required().positive().integer().default(0).min(0), diagramStop: yup.number().required().positive().integer().default(10).min(0), diagramCount: yup.number().required().positive().integer().default(20).min(2), + numberPrecision: yup + .number() + .required() + .integer() + .positive() + .default(3) + .min(0), }); type FormFields = yup.InferType; @@ -57,6 +64,16 @@ export const ViewSettings: React.FC<{ +
+ + + +