Add BoxPlot component (Closes #6) #34
|
@ -11,6 +11,7 @@
|
|||
background-color: var(--label);
|
||||
color: var(--primary-background);
|
||||
padding: calc(10rem / 16);
|
||||
border-radius: calc(10rem / 16);
|
||||
}
|
||||
|
||||
.tooltip .category {
|
||||
|
@ -19,9 +20,9 @@
|
|||
}
|
||||
|
||||
.tooltip .toolTipData {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 16px;
|
||||
margin-top: calc(5rem / 16);
|
||||
margin-bottom: calc(10rem / 16);
|
||||
font-size: calc(16rem / 16);
|
||||
}
|
||||
|
||||
.tooltip .toolTipData p {
|
||||
|
|
|
@ -18,7 +18,7 @@ import { Color } from "utils/Color";
|
|||
import styles from "./Boxplot.module.css";
|
||||
|
||||
const DEFAULT_LABEL_SIZE = 16;
|
||||
const TICK_LABEL_FONT_SIZE = 800;
|
||||
const TICK_LABEL_FONT_WEIGHT = 800;
|
||||
|
||||
interface BoxPlotData {
|
||||
a258wang marked this conversation as resolved
|
||||
category: string;
|
||||
|
@ -222,7 +222,7 @@ export const BoxPlot = withTooltip<StatsPlotProps, TooltipData>(
|
|||
tickLabelProps={() => {
|
||||
return {
|
||||
fill: Color.label,
|
||||
fontWeight: TICK_LABEL_FONT_SIZE,
|
||||
fontWeight: TICK_LABEL_FONT_WEIGHT,
|
||||
};
|
||||
}}
|
||||
/>
|
||||
|
@ -238,7 +238,7 @@ export const BoxPlot = withTooltip<StatsPlotProps, TooltipData>(
|
|||
tickLabelProps={() => {
|
||||
return {
|
||||
fill: Color.label,
|
||||
fontWeight: TICK_LABEL_FONT_SIZE,
|
||||
fontWeight: TICK_LABEL_FONT_WEIGHT,
|
||||
};
|
||||
}}
|
||||
/>
|
||||
|
@ -273,11 +273,7 @@ export const BoxPlot = withTooltip<StatsPlotProps, TooltipData>(
|
|||
constrainedWidth +
|
||||
toolTipLeftOffset,
|
||||
tooltipData: {
|
||||
min: getMin(d),
|
||||
max: getMax(d),
|
||||
median: getMedian(d),
|
||||
firstQuartile: getFirstQuartile(d),
|
||||
thirdQuartile: getThirdQuartile(d),
|
||||
...d.boxPlot,
|
||||
category: getX(d),
|
||||
},
|
||||
});
|
||||
|
@ -296,11 +292,7 @@ export const BoxPlot = withTooltip<StatsPlotProps, TooltipData>(
|
|||
constrainedWidth +
|
||||
toolTipLeftOffset,
|
||||
tooltipData: {
|
||||
min: getMin(d),
|
||||
max: getMax(d),
|
||||
median: getMedian(d),
|
||||
firstQuartile: getFirstQuartile(d),
|
||||
thirdQuartile: getThirdQuartile(d),
|
||||
...d.boxPlot,
|
||||
category: getX(d),
|
||||
},
|
||||
});
|
||||
|
@ -324,6 +316,7 @@ export const BoxPlot = withTooltip<StatsPlotProps, TooltipData>(
|
|||
},
|
||||
});
|
||||
},
|
||||
strokeWidth: 0,
|
||||
onMouseLeave: () => {
|
||||
hideTooltip();
|
||||
},
|
||||
|
@ -341,11 +334,7 @@ export const BoxPlot = withTooltip<StatsPlotProps, TooltipData>(
|
|||
constrainedWidth +
|
||||
toolTipLeftOffset,
|
||||
tooltipData: {
|
||||
min: getMin(d),
|
||||
max: getMax(d),
|
||||
median: getMedian(d),
|
||||
firstQuartile: getFirstQuartile(d),
|
||||
thirdQuartile: getThirdQuartile(d),
|
||||
...d.boxPlot,
|
||||
category: getX(d),
|
||||
},
|
||||
});
|
||||
|
@ -370,15 +359,11 @@ export const BoxPlot = withTooltip<StatsPlotProps, TooltipData>(
|
|||
>
|
||||
<p className={styles.category}>{tooltipData.category}</p>
|
||||
<div className={styles.toolTipData}>
|
||||
{tooltipData.max ? <p>max: {tooltipData.max}</p> : null}
|
||||
{tooltipData.thirdQuartile ? (
|
||||
<p>third quartile: {tooltipData.thirdQuartile}</p>
|
||||
) : null}
|
||||
{tooltipData.median ? <p>median: {tooltipData.median}</p> : null}
|
||||
{tooltipData.firstQuartile ? (
|
||||
<p>first quartile: {tooltipData.firstQuartile}</p>
|
||||
) : null}
|
||||
{tooltipData.min ? <p>min: {tooltipData.min}</p> : null}
|
||||
<p>max: {tooltipData.max}</p>
|
||||
<p>third quartile: {tooltipData.thirdQuartile}</p>
|
||||
<p>median: {tooltipData.median}</p>
|
||||
<p>first quartile: {tooltipData.firstQuartile}</p>
|
||||
<p>min: {tooltipData.min}</p>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
|
Loading…
Reference in New Issue
NIT: maybe name this
label
orname
or something, just to be a bit more descriptive?The name was left as
x
since theboxPlot
property in theStats
object takes in a field namedx
. With the changes (of changingx
to a more descriptive name), inserting the boxplot data would look like this:since the
BoxPlotData
would have a different label name forx
. If we don't implement the changes, inserting boxplot data would look like this:I was wondering whether the name change was really necessary. We could add a comment next to the field
x
in theinterface BoxPlotData
to explain its purpose.We should be able to do
which is fairly concise, in my opinion. But ultimately it's up to you - a descriptive JSDoc comment in the interface would be a good idea either way. 🙂