use domain to feed sample for bottom band
This commit is contained in:
parent
865b01f48d
commit
f8e5396d57
|
@ -48,9 +48,8 @@ export function makePlot(record: {
|
||||||
export const DistributionChart: React.FC<DistributionChartProps> = (props) => {
|
export const DistributionChart: React.FC<DistributionChartProps> = (props) => {
|
||||||
const { plot, height, showSummary, width, logX, actions = false } = props;
|
const { plot, height, showSummary, width, logX, actions = false } = props;
|
||||||
// const [xAxis, setXAxis] = React.useState<"dateAndTime" | "numbers">("dateAndTime")
|
// const [xAxis, setXAxis] = React.useState<"dateAndTime" | "numbers">("dateAndTime")
|
||||||
|
|
||||||
const [sized] = useSize((size) => {
|
const [sized] = useSize((size) => {
|
||||||
let shapes = flattenResult(
|
const shapes = flattenResult(
|
||||||
plot.distributions.map((x) =>
|
plot.distributions.map((x) =>
|
||||||
resultMap(x.distribution.pointSet(), (shape) => ({
|
resultMap(x.distribution.pointSet(), (shape) => ({
|
||||||
name: x.name,
|
name: x.name,
|
||||||
|
@ -60,6 +59,7 @@ export const DistributionChart: React.FC<DistributionChartProps> = (props) => {
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (shapes.tag === "Error") {
|
if (shapes.tag === "Error") {
|
||||||
return (
|
return (
|
||||||
<ErrorAlert heading="Distribution Error">
|
<ErrorAlert heading="Distribution Error">
|
||||||
|
@ -81,6 +81,7 @@ export const DistributionChart: React.FC<DistributionChartProps> = (props) => {
|
||||||
shape.discrete.concat(shape.continuous)
|
shape.discrete.concat(shape.continuous)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log({domain, data: shapes.value})
|
||||||
return (
|
return (
|
||||||
<div style={{ width: widthProp }}>
|
<div style={{ width: widthProp }}>
|
||||||
{logX && shapes.value.some(hasMassBelowZero) ? (
|
{logX && shapes.value.some(hasMassBelowZero) ? (
|
||||||
|
|
|
@ -145,7 +145,35 @@ export function buildVegaSpec(
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
marks: [
|
marks: [
|
||||||
|
{
|
||||||
|
name: "sample_distributions",
|
||||||
|
"type": "group",
|
||||||
|
from: {
|
||||||
|
facet: {
|
||||||
|
name: "distribution_facet",
|
||||||
|
data: "domain",
|
||||||
|
groupby: ["name"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
marks: [
|
||||||
|
{
|
||||||
|
"name": "samples",
|
||||||
|
"type": "rect",
|
||||||
|
"from": {"data": "distribution_facet"},
|
||||||
|
"encode": {
|
||||||
|
"enter": {
|
||||||
|
"x": {"scale": "xscale", "field":"x"},
|
||||||
|
"width": {"value": 0.5},
|
||||||
|
|
||||||
|
"y": {"value": 25, "offset": {"signal": "height"}},
|
||||||
|
"height": {"value": 5},
|
||||||
|
"fill": {"value": "steelblue"},
|
||||||
|
"fillOpacity": {"value": 0.8}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "all_distributions",
|
name: "all_distributions",
|
||||||
type: "group",
|
type: "group",
|
||||||
|
@ -216,22 +244,7 @@ export function buildVegaSpec(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
marks: [
|
marks: [
|
||||||
{
|
|
||||||
"name": "samples",
|
|
||||||
"type": "rect",
|
|
||||||
"from": {"data": "discrete_facet"},
|
|
||||||
"encode": {
|
|
||||||
"enter": {
|
|
||||||
"x": {"scale": "xscale", "field":"x"},
|
|
||||||
"width": {"value": 1},
|
|
||||||
|
|
||||||
"y": {"value": 25, "offset": {"signal": "height"}},
|
|
||||||
"height": {"value": 5},
|
|
||||||
"fill": {"value": "steelblue"},
|
|
||||||
"fillOpacity": {"value": 0.8}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
type: "rect",
|
type: "rect",
|
||||||
from: {
|
from: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user