Skip to content

Commit ae24394

Browse files
authored
Merge pull request #47 from data-exp-lab/fe-gexf
Fix Explore Config
2 parents 5af185c + 00eb141 commit ae24394

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

src/lib/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ export function getFilterableFields(
576576
{ filterable, colorable, sizeable }: Pick<NavState, "filterable" | "colorable" | "sizeable">,
577577
): Field[] {
578578
const { fields, fieldsIndex } = data;
579-
const filterableSet = new Set<string>([...(filterable || []), ...(colorable || []), ...(sizeable || [])]);
579+
const filterableSet = new Set<string>(filterable || []);
580580

581581
return fields.filter((f) => filterableSet.has(f)).map((f) => fieldsIndex[f]);
582582
}

src/lib/navState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export function cleanNavState(state: NavState, data: Data): NavState {
156156
const cleanedColorable = uniq((colorable || []).filter((f) => fieldsIndex[f]));
157157
const cleanedSizeable = uniq((sizeable || []).filter((f) => fieldsIndex[f]?.type === "quanti"));
158158
const cleanedFilterable = uniq(
159-
(filterable || []).filter((f) => fieldsIndex[f] && !cleanedSizeable.includes(f) && !cleanedColorable.includes(f)),
159+
(filterable || []).filter((f) => fieldsIndex[f]),
160160
);
161161
const cleanedSizeableIndex = keyBy(cleanedSizeable);
162162
const cleanedColorableIndex = keyBy(cleanedColorable);

src/views/EditionPanel.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,9 @@ const EditionPanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
200200
{["filterable", "colorable", "sizeable"].map((key) => {
201201
const colorOrSize = sizeableSet.has(f) || colorableSet.has(f);
202202
const disabled =
203-
(key === "filterable" && colorOrSize) ||
204203
(key === "sizeable" && field.type !== "quanti") ||
205204
(key === "colorable" && field.type !== "quali" && field.type !== "quanti");
206-
const checked = sets[key].has(f) || (key === "filterable" && colorOrSize);
205+
const checked = sets[key].has(f);
207206
const keyToUpdate = {
208207
sizeable: "size",
209208
colorable: "color",
@@ -265,7 +264,7 @@ const EditionPanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
265264
</td>
266265
);
267266
})}
268-
<td className="line-height-1 text-muted">Allow using default graph file colors and/or sizes</td>
267+
<td className="line-height-1 text-white">Allow using default graph file colors and/or sizes</td>
269268
</tr>
270269
</tbody>
271270
</table>

src/views/GraphView.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,22 @@ const GraphView: FC<{ embed?: boolean }> = ({ embed = false }) => {
248248
const { filterable, sizeable } = navState;
249249
// Filter out createdAt_year from sizeable fields
250250
const sizeableFields = allFields.filter(field => field !== 'createdAt_year');
251-
if (
252-
!filterable || filterable.length !== allFields.length ||
253-
!sizeable || sizeable.length !== sizeableFields.length
254-
) {
251+
252+
// Set default values only if they haven't been initialized yet
253+
const updates: Partial<NavState> = {};
254+
255+
if (!filterable || filterable.length === 0) {
256+
updates.filterable = allFields;
257+
}
258+
259+
if (!sizeable || sizeable.length === 0) {
260+
updates.sizeable = sizeableFields;
261+
}
262+
263+
if (Object.keys(updates).length > 0) {
255264
setNavState({
256265
...navState,
257-
filterable: allFields,
258-
sizeable: sizeableFields,
266+
...updates,
259267
});
260268
}
261269
}, [data, navState, setNavState]);

0 commit comments

Comments
 (0)