From 829d58edad28a2bd6f956c3e02002da8ab8711d1 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Wed, 10 Jan 2024 13:05:27 -0800 Subject: [PATCH] Bring variableName to sidebar --- .../components/views/ListView/index.tsx | 1 + .../components/views/ListView/sidebar.tsx | 18 ++++++++++++------ .../relative-values/values/ModelEvaluator.ts | 8 +++++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/hub/src/relative-values/components/views/ListView/index.tsx b/packages/hub/src/relative-values/components/views/ListView/index.tsx index 54e9cd6886..1826edff78 100644 --- a/packages/hub/src/relative-values/components/views/ListView/index.tsx +++ b/packages/hub/src/relative-values/components/views/ListView/index.tsx @@ -250,6 +250,7 @@ export const ListView: FC = () => {
diff --git a/packages/hub/src/relative-values/components/views/ListView/sidebar.tsx b/packages/hub/src/relative-values/components/views/ListView/sidebar.tsx index cea66fcecd..a7526a20fd 100644 --- a/packages/hub/src/relative-values/components/views/ListView/sidebar.tsx +++ b/packages/hub/src/relative-values/components/views/ListView/sidebar.tsx @@ -33,14 +33,15 @@ const TableRow: React.FC = ({ label, number }) => ( let buildurl = ( model: ModelEvaluator, numeratorItem: Item, - denominatorItem: Item + denominatorItem: Item, + variableName: string ) => { const toVarName = (id: string) => id.replace(/-/g, "_"); const numeratorItemName = toVarName(numeratorItem.id); const denominatorItemName = toVarName(denominatorItem.id); return `${model.modelCode} // ------- AUTOGENERATED CODE ------- -dists = fn("${numeratorItem.id}", "${denominatorItem.id}") +dists = ${variableName}("${numeratorItem.id}", "${denominatorItem.id}") value_${numeratorItemName} = Dist(dists[0]) value_${denominatorItemName} = Dist(dists[1]) valueRatio = value_${numeratorItemName} / value_${denominatorItemName} @@ -84,9 +85,7 @@ debug = [ ratio = Plot.dist( { dist: valueRatio, - xScale: Scale.symlog( - { tickFormatObj } - ), + xScale: Scale.symlog(tickFormatObj), yScale: Scale.symlog(tickFormatObj), showSummary: false, } @@ -100,11 +99,13 @@ type Props = { model: ModelEvaluator; numeratorItem: Item; denominatorItem: Item; + variableName: string; }; export const ItemSideBar: FC = ({ model, numeratorItem, + variableName, denominatorItem, }) => { const result = model.compare(numeratorItem.id, denominatorItem.id); @@ -112,7 +113,12 @@ export const ItemSideBar: FC = ({ return
Result not found
; } else { let item = result.value; - const squggleCode = buildurl(model, numeratorItem, denominatorItem); + const squggleCode = buildurl( + model, + numeratorItem, + denominatorItem, + variableName + ); // It would be better to not load SquiggleChart, but rather, a lower-level compontent. That can be refactored later. return ( diff --git a/packages/hub/src/relative-values/values/ModelEvaluator.ts b/packages/hub/src/relative-values/values/ModelEvaluator.ts index f8b575fe6b..013ef14b4f 100644 --- a/packages/hub/src/relative-values/values/ModelEvaluator.ts +++ b/packages/hub/src/relative-values/values/ModelEvaluator.ts @@ -94,6 +94,7 @@ function buildRelativeValue({ export class ModelEvaluator { private constructor( public modelCode: string, + public variableName: string, private fn: SqLambda, private cache?: RelativeValuesCacheRecord ) {} @@ -154,7 +155,12 @@ export class ModelEvaluator { return { ok: true, - value: new ModelEvaluator(modelCode, result.value.value, cacheRecord), + value: new ModelEvaluator( + modelCode, + variableName, + result.value.value, + cacheRecord + ), }; }