Add Stacked Bar Graph component (Closes #3) #37
Loading…
Reference in New Issue
No description provided.
Delete Branch "stackedbar-component"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Notes:
BarStack
component from Visx.Staging: https://stackedbar-component-csc-class-profile-staging-snedadah.k8s.csclub.cloud/playground/
A few visual nitpicks:
@ -0,0 +9,4 @@
.legend {
position: absolute;
display: flex;
font-size: 16px;
NIT:
calc(16rem / 16)
instead ofpx
in this file@ -0,0 +15,4 @@
interface StackedBarData {
category: string;
[key: string]: number | string;
Have we considered
?
This would allow for a key called "category", at the expense of more nesting.
Also is there a reason why the value can beEDIT: nvm, it's to make TS stop complainingnumber | string
and not justnumber
?https://stackoverflow.com/questions/54460029/typescript-inteface-where-id-must-be-number-and-other-properties-must-be-strin
I have considered the above, but it doesn't work since the format of the data doesn't match what is expected in the props
data
taken by the<BarStack>
component:It specifically needs
category
to be a key indata
and all the other keys to be directly nested inside ofdata
(cannot be nested inside ofvalues
).@ -0,0 +62,4 @@
const tooltipStyles = {
...defaultStyles,
minWidth: 60,
backgroundColor: Color.primaryAccentLighter,
NIT: background should be
Color.label
@ -0,0 +120,4 @@
showTooltip,
} = useTooltip<TooltipData>();
const { containerRef, TooltipInPortal } = useTooltipInPortal({
Any reason why we're using the TooltipInPortal here instead of the regular Tooltip we're using everywhere else?
@ -0,0 +126,4 @@
scroll: true,
});
if (width < 10) return null;
NIT: redundant if we have
return width < 10 ? null : ...
down below@ -0,0 +129,4 @@
if (width < 10) return null;
// bounds
const xMax = width;
const yMax = height - margin.top - 50;
Just curious, why 50?
@ -0,0 +211,4 @@
<AxisBottom
top={yMax}
scale={xScale}
left={valueAxisLeftOffset / 5}
Why divide by 5?
Also is there the possibility of being able to support a horizontal stacked bar graph as well?
Horizontal Stacked Bar Graph looks like this:
Note: I was unable to center the labels of the value axis (x-axis)
Just left one last comment.
I'm going to approve this so we can merge it for now, but I'd like for us to come back later to fix some visual nitpicks (eg. axis lines sticking out, axis tick label centering - could possibly check out the BarGraph to see how the alignment is done) and maybe clean up the code since there is quite a bit of repetition between the vertical and horizontal graphs.
EDIT: #51
@ -0,0 +324,4 @@
const xMax = width;
const yMax = height - margin.top - axisBottomOffset;
categoryScale.rangeRound([yMax, 0]);
Please change the range to
[0, yMax]
- it makes it so the order of the categories is the same top-to-bottom when the graph has horizontal bars vs. left-to-right when the graph has vertical bars.