Skip to content

Commit 2853fd3

Browse files
committed
trying to solve gaps between bar graphs
1 parent 7a047e7 commit 2853fd3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/app/components/BarGraph.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const BarGraph = props => {
9595
let i = 0;
9696
// let barWidth = (xMax / (Object.keys(data.barStack[0]).length) + 5);
9797
const barWidth = (xMax * (2 / 3) / (Object.keys(data.barStack[0]).length - 2));
98+
console.log(barWidth, '<-- barWidth')
9899
console.log(data, '<-- data from snapshot');
99100
// function colorGen() {
100101
// const r = Math.floor(Math.random() * 256);
@@ -103,6 +104,8 @@ const BarGraph = props => {
103104
// return "rgb(" + r + "," + g + "," + b + ", " + .5 + ")"
104105
// }
105106
const rgb = ['rgba(50, 100, 241, .5)', 'rgba(90, 150, 217, .5)', 'rgba(200, 30, 7, .5)', 'rgba(23, 233, 217, .5)', 'rgba(150, 227, 19, .5)'];
107+
const gap = xMax / (Object.keys(data.barStack[0]).length);
108+
console.log(gap, i, '<-- gap , i');
106109
for (const [key, value] of Object.entries(data.barStack[0])) {
107110
const toolTipData = {key: key, value: value}
108111
console.log(xMax, '<-- xmax');
@@ -114,9 +117,9 @@ const BarGraph = props => {
114117
min="outer min"
115118
max="first if"
116119
// x={100}
117-
x={xMax / (Object.keys(data.barStack[0]).length)}
118-
y={yMax - value}
119-
height={value}
120+
x={gap}
121+
y={yMax - value * 25}
122+
height={value * 25}
120123
key={key}
121124
width={barWidth}
122125
fill="#62d6fb"
@@ -135,7 +138,8 @@ const BarGraph = props => {
135138
dispatch(onHover(data.componentData[key].rtid));
136139
if (tooltipTimeout) clearTimeout(tooltipTimeout);
137140
const top = event.clientY - margin.top - value * 25;
138-
const left = 10 + 10 * i + barWidth * i + barWidth / 2;
141+
// const left = 10 + 10 * i + barWidth * i + barWidth / 2;
142+
const left = gap + barWidth / 2;
139143
showTooltip({
140144
tooltipData: toolTipData,
141145
tooltipTop: top,
@@ -147,10 +151,10 @@ const BarGraph = props => {
147151
BarArray.push(<Bar
148152
min="outer min"
149153
max="else here"
150-
x={(xMax / (Object.keys(data.barStack[0]).length)) * (i + 1)}
154+
x={gap * (i + 1)}
151155
// x={(xMax / (Object.keys(data.barStack[0]).length - 2)) + barWidth * i}
152-
y={yMax - value * 20}
153-
height={value * 20}
156+
y={yMax - value * 25}
157+
height={value * 25}
154158
key={key}
155159
width={barWidth}
156160
fill="#62d6fb"
@@ -169,7 +173,8 @@ const BarGraph = props => {
169173
dispatch(onHover(data.componentData[key].rtid));
170174
if (tooltipTimeout) clearTimeout(tooltipTimeout);
171175
const top = event.clientY - margin.top - value * 25;
172-
const left = 10 + 10 * i + barWidth * i + barWidth / 2;
176+
// const left = 10 + 10 * i + barWidth * i + barWidth / 2;
177+
const left = gap * (i + 1) + barWidth / 2;
173178
showTooltip({
174179
tooltipData: toolTipData,
175180
tooltipTop: top,
@@ -555,11 +560,13 @@ const BarGraph = props => {
555560
style={tooltipStyles}
556561
>
557562
{console.log(tooltipData, '<------tooltipData')}
563+
{console.log(data.componentData, '<------data.componentData')}
558564
<div style={{ color: colorScale(tooltipData.key) }}>
559565
{' '}
560566
<strong>{tooltipData.key}</strong>
561567
{' '}
562568
</div>
569+
<div>{data.componentData[tooltipData.key].stateType}</div>
563570
<div>
564571
{' '}
565572
{formatRenderTime(tooltipData.value)}

0 commit comments

Comments
 (0)