Skip to content

Commit b1c2a60

Browse files
(updated) centered x axis, bar stack group position, default margins
1 parent 26e9597 commit b1c2a60

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type BarStackProps = {
3737
/* DEFAULT STYLING */
3838
const axisColor = '#679DCA';
3939
const background = "#242529";
40-
const defaultMargin = { top: 40, right: 0, bottom: 0, left: 0 };
40+
const defaultMargin = { top: 40, right: 30, bottom: 0, left: 35 };
4141
const tooltipStyles = {
4242
...defaultStyles,
4343
minWidth: 60,
@@ -136,7 +136,7 @@ const colorScale = scaleOrdinal<CityName, string>({
136136

137137
// setting max dimensions and scale ranges
138138
if (width < 10) return null;
139-
const xMax = width;
139+
const xMax = width - margin.left - margin.right
140140
const yMax = height - margin.top - 100;
141141
snapshotIdScale.rangeRound([0, xMax]);
142142
renderingScale.range([yMax, 0]);
@@ -165,7 +165,7 @@ renderingScale.range([yMax, 0]);
165165
strokeOpacity={0.1}
166166
xOffset={snapshotIdScale.bandwidth() / 2}
167167
/>
168-
<Group top={margin.top}>
168+
<Group top={margin.top} left={margin.left}>
169169
<BarStack <snapshot, CityName>
170170
data={data}
171171
keys={keys}
@@ -182,6 +182,7 @@ renderingScale.range([yMax, 0]);
182182
height={bar.height}
183183
width={bar.width}
184184
fill={bar.color}
185+
/* TIP TOOL EVENT HANDLERS */
185186
onClick={() => {
186187
if (events) alert(`clicked: ${JSON.stringify(bar)}`);
187188
}}
@@ -208,6 +209,7 @@ renderingScale.range([yMax, 0]);
208209
</Group>
209210
<AxisBottom
210211
top={yMax + margin.top}
212+
left={margin.left}
211213
scale={snapshotIdScale}
212214
stroke={axisColor}
213215
tickStroke={axisColor}

0 commit comments

Comments
 (0)