Simple d3 fixes
This commit is contained in:
parent
5a11ebfb03
commit
4735b9703c
|
@ -158,19 +158,21 @@ module DistPlusChart = {
|
||||||
distPlus |> Distributions.DistPlus.T.toDiscreteProbabilityMass;
|
distPlus |> Distributions.DistPlus.T.toDiscreteProbabilityMass;
|
||||||
let (yMaxDiscreteDomainFactor, yMaxContinuousDomainFactor) =
|
let (yMaxDiscreteDomainFactor, yMaxContinuousDomainFactor) =
|
||||||
adjustBoth(toDiscreteProbabilityMass);
|
adjustBoth(toDiscreteProbabilityMass);
|
||||||
<DistributionPlot
|
<div className=Css.(style([minHeight(`px(state.height))]))>
|
||||||
scale={state.log ? "log" : "linear"}
|
<DistributionPlot
|
||||||
minX
|
scale={state.log ? "log" : "linear"}
|
||||||
maxX
|
minX
|
||||||
yMaxDiscreteDomainFactor
|
maxX
|
||||||
yMaxContinuousDomainFactor
|
yMaxDiscreteDomainFactor
|
||||||
height={state.height}
|
yMaxContinuousDomainFactor
|
||||||
?discrete
|
height={state.height}
|
||||||
?continuous
|
?discrete
|
||||||
color={`hex("5f6b7e")}
|
?continuous
|
||||||
onHover
|
color={`hex("5f6b7e")}
|
||||||
timeScale
|
onHover
|
||||||
/>;
|
timeScale
|
||||||
|
/>
|
||||||
|
</div>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -216,7 +218,7 @@ let make = (~distPlus: DistTypes.distPlus) => {
|
||||||
| CHANGE_HEIGHT(height) => {...state, height}
|
| CHANGE_HEIGHT(height) => {...state, height}
|
||||||
| CHANGE_SHOW_STATS => {...state, showStats: !state.showStats}
|
| CHANGE_SHOW_STATS => {...state, showStats: !state.showStats}
|
||||||
},
|
},
|
||||||
{log: true, height: 120, showStats: false},
|
{log: false, height: 80, showStats: false},
|
||||||
);
|
);
|
||||||
let chart =
|
let chart =
|
||||||
React.useMemo2(
|
React.useMemo2(
|
||||||
|
@ -238,7 +240,12 @@ let make = (~distPlus: DistTypes.distPlus) => {
|
||||||
<div onClick={_ => dispatch(CHANGE_HEIGHT(state.height + 40))}>
|
<div onClick={_ => dispatch(CHANGE_HEIGHT(state.height + 40))}>
|
||||||
{"HightPlus" |> ReasonReact.string}
|
{"HightPlus" |> ReasonReact.string}
|
||||||
</div>
|
</div>
|
||||||
<div onClick={_ => dispatch(CHANGE_HEIGHT(state.height - 40))}>
|
<div
|
||||||
|
onClick={_ =>
|
||||||
|
dispatch(
|
||||||
|
CHANGE_HEIGHT(state.height < 81 ? state.height : state.height - 40),
|
||||||
|
)
|
||||||
|
}>
|
||||||
{"HightMinus" |> ReasonReact.string}
|
{"HightMinus" |> ReasonReact.string}
|
||||||
</div>
|
</div>
|
||||||
chart
|
chart
|
||||||
|
|
|
@ -407,7 +407,7 @@ export class CdfChartD3 {
|
||||||
.attr('r', 6);
|
.attr('r', 6);
|
||||||
tooltip.transition()
|
tooltip.transition()
|
||||||
.style('opacity', .9);
|
.style('opacity', .9);
|
||||||
tooltip.html(`X: ${d.x}, Y: ${d.y}`)
|
tooltip.html(`x: ${d.x}, y: ${(d.y * 100).toFixed(1)}%`)
|
||||||
.style('left', (common.xScale(d.x) + 60) + 'px')
|
.style('left', (common.xScale(d.x) + 60) + 'px')
|
||||||
.style('top', yScale(d.y) + 'px');
|
.style('top', yScale(d.y) + 'px');
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ function CdfChartReact(props) {
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
try {
|
||||||
new CdfChartD3()
|
new CdfChartD3()
|
||||||
.set('svgWidth', width)
|
.set('svgWidth', width)
|
||||||
.set('svgHeight', props.height)
|
.set('svgHeight', props.height)
|
||||||
|
@ -58,6 +59,10 @@ function CdfChartReact(props) {
|
||||||
discrete: props.discrete,
|
discrete: props.discrete,
|
||||||
})
|
})
|
||||||
.render();
|
.render();
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
console.error("distPlotD3 Error: ", e)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return React.createElement("div", {
|
return React.createElement("div", {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user