From e0cd95fe5ca0ea9c758cf535b6e218c2e6168592 Mon Sep 17 00:00:00 2001 From: Conor Barnes Date: Tue, 6 Sep 2022 14:52:57 -0300 Subject: [PATCH] remove unnecessary mapping of sample array to array of objects --- .../components/src/components/DistributionChart.tsx | 10 +++++----- packages/components/src/lib/distributionSpecBuilder.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/components/src/components/DistributionChart.tsx b/packages/components/src/components/DistributionChart.tsx index fb0ff95c..d423b197 100644 --- a/packages/components/src/components/DistributionChart.tsx +++ b/packages/components/src/components/DistributionChart.tsx @@ -66,7 +66,8 @@ export const DistributionChart: React.FC = (props) => { // color: x.color, // not supported yet continuous: shape.continuous, discrete: shape.discrete, - samples: [] as point[], + samples: [] as number[], + // samples: [] as point[], })) ) ); @@ -86,14 +87,13 @@ export const DistributionChart: React.FC = (props) => { if (sampleSets.length) { for (const set of sampleSets) { if (set.distribution.t.tag === "SampleSet") { - // this must be duplicated to please typescript, more elegant solution probably exists - shapes.value[0].samples.push( - ...set.distribution.t.value.map((v) => ({ x: v, y: 0 })) - ); + // this conditional must be duplicated to please typescript, more elegant solution probably exists + shapes.value[0].samples.push(...set.distribution.t.value); } } } + console.log(shapes.value); const spec = buildVegaSpec(props); let widthProp = width ? width : size.width; diff --git a/packages/components/src/lib/distributionSpecBuilder.ts b/packages/components/src/lib/distributionSpecBuilder.ts index 261545b5..2880aa4b 100644 --- a/packages/components/src/lib/distributionSpecBuilder.ts +++ b/packages/components/src/lib/distributionSpecBuilder.ts @@ -316,7 +316,7 @@ export function buildVegaSpec( from: { data: "sample_facet" }, encode: { enter: { - x: { scale: "xscale", field: "x" }, + x: { scale: "xscale", field: "data"}, width: { value: 0.1 }, y: { value: 25, offset: { signal: "height" } },