use in multiple plots
This commit is contained in:
parent
bc64d2882f
commit
2087a30b6b
|
@ -80,11 +80,19 @@ export const DistributionChart: React.FC<DistributionChartProps> = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this is a sample set, include the samples
|
// if this is a sample set, include the samples
|
||||||
const t = plot?.distributions[0]?.distribution?.t;
|
const sampleSets = plot?.distributions.filter(
|
||||||
if (t.tag === "SampleSet") {
|
(dist) => dist.distribution.t.tag === "SampleSet"
|
||||||
shapes.value[0].samples = t.value.map((v) => ({ x: v, y: 0 }));
|
);
|
||||||
|
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 }))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const spec = buildVegaSpec(props);
|
const spec = buildVegaSpec(props);
|
||||||
|
|
||||||
let widthProp = width ? width : size.width;
|
let widthProp = width ? width : size.width;
|
||||||
|
|
|
@ -75,14 +75,7 @@ const width = 500;
|
||||||
export function buildVegaSpec(
|
export function buildVegaSpec(
|
||||||
specOptions: DistributionChartSpecOptions
|
specOptions: DistributionChartSpecOptions
|
||||||
): VisualizationSpec {
|
): VisualizationSpec {
|
||||||
const {
|
const { title, minX, maxX, logX, expY, xAxis = "number" } = specOptions;
|
||||||
title,
|
|
||||||
minX,
|
|
||||||
maxX,
|
|
||||||
logX,
|
|
||||||
expY,
|
|
||||||
xAxis = "number",
|
|
||||||
} = specOptions;
|
|
||||||
|
|
||||||
const dateTime = xAxis === "dateTime";
|
const dateTime = xAxis === "dateTime";
|
||||||
|
|
||||||
|
@ -319,7 +312,10 @@ export function buildVegaSpec(
|
||||||
|
|
||||||
y: { value: 25, offset: { signal: "height" } },
|
y: { value: 25, offset: { signal: "height" } },
|
||||||
height: { value: 5 },
|
height: { value: 5 },
|
||||||
fill: { value: "steelblue" },
|
fill: {
|
||||||
|
scale: "color",
|
||||||
|
field: { parent: "name" },
|
||||||
|
},
|
||||||
fillOpacity: { value: 1 },
|
fillOpacity: { value: 1 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user