Skip to content

Commit cdf50b7

Browse files
authored
Merge pull request #626 from neo4j-labs/fix/BarColorAssignment
Fix Bar Colors assignment
2 parents 26194d7 + 59fb394 commit cdf50b7

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</head>
3131

3232
<body>
33+
<div id="overlay"></div>
3334
<div id="root"></div>
3435
<noscript>Please enable JavaScript to view this site.</noscript>
3536
<script src="bundle.js"></script>

public/style.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,11 @@
228228
transform: scale(0.95);
229229
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
230230
}
231-
}
231+
}
232+
233+
/* Workaround for Needle not handling menu placement of dropdowns on modals */
234+
#overlay {
235+
z-index: 99 !important;
236+
position: absolute;
237+
}
238+
/* End workaround */

src/card/settings/CardSettingsContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const NeoCardSettingsContent = ({
111111
label: report?.label || '',
112112
value: report?.label || '',
113113
},
114-
menuPortalTarget: document.querySelector('body'),
114+
menuPortalTarget: document.querySelector('#overlay'),
115115
}}
116116
fluid
117117
style={{ marginLeft: '0px', marginRight: '10px', width: '47%', maxWidth: '200px', display: 'inline-block' }}
@@ -133,7 +133,7 @@ const NeoCardSettingsContent = ({
133133
value: database,
134134
})),
135135
value: { label: databaseText, value: databaseText },
136-
menuPortalTarget: document.querySelector('body'),
136+
menuPortalTarget: document.querySelector('#overlay'),
137137
}}
138138
fluid
139139
style={{ marginLeft: '0px', marginRight: '10px', width: '47%', maxWidth: '200px', display: 'inline-block' }}

src/card/view/CardViewFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const NeoCardViewFooter = ({
121121
: { label: selection[selectable], value: selection[selectable] },
122122
isMulti: selectableFields[selectable].multiple,
123123
isClearable: false,
124-
menuPortalTarget: document.querySelector('body'),
124+
menuPortalTarget: document.querySelector('#overlay'),
125125
}}
126126
fluid
127127
style={{

src/chart/bar/BarChart.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const NeoBarChart = (props: ChartProps) => {
2828

2929
const { records, selection } = props;
3030

31-
const [keys, setKeys] = React.useState({});
31+
const [keys, setKeys] = React.useState<string[]>([]);
3232
const [data, setData] = React.useState<Record<string, any>[]>([]);
3333

3434
useEffect(() => {
@@ -72,7 +72,7 @@ const NeoBarChart = (props: ChartProps) => {
7272
return row;
7373
});
7474

75-
setKeys(newKeys);
75+
setKeys(Object.keys(newKeys));
7676
setData(newData);
7777
}, [selection]);
7878

@@ -114,8 +114,8 @@ const NeoBarChart = (props: ChartProps) => {
114114
const chartColorsByScheme = getD3ColorsByScheme(colorScheme);
115115
// Compute bar color based on rules - overrides default color scheme completely.
116116
const getBarColor = (bar) => {
117-
let { data, id } = bar;
118-
let colorIndex = Object.keys(data).indexOf(id);
117+
let { id } = bar;
118+
let colorIndex = keys.indexOf(id);
119119
if (colorIndex >= chartColorsByScheme.length) {
120120
colorIndex %= chartColorsByScheme.length;
121121
}
@@ -218,7 +218,7 @@ const NeoBarChart = (props: ChartProps) => {
218218
layout={layout}
219219
groupMode={groupMode == 'stacked' ? 'stacked' : 'grouped'}
220220
enableLabel={enableLabel}
221-
keys={Object.keys(keys)}
221+
keys={keys}
222222
indexBy='index'
223223
margin={{
224224
top: marginTop,

0 commit comments

Comments
 (0)