Skip to content

Commit 2c9c7eb

Browse files
committed
feat: Interactive filters are always defined
1 parent 01495c7 commit 2c9c7eb

33 files changed

Lines changed: 245 additions & 115 deletions

app/charts/area/areas-state.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ const useAreasState = (
333333
// When the user can toggle between absolute and relative values, we use the
334334
// absolute values to calculate the yScale domain, so that the yScale doesn't
335335
// change when the user toggles between absolute and relative values.
336-
if (interactiveFiltersConfig?.calculation.active) {
336+
if (interactiveFiltersConfig.calculation.active) {
337337
const scale = getStackedYScale(paddingData, {
338338
normalize: false,
339339
getX: getXAsString,
@@ -359,7 +359,7 @@ const useAreasState = (
359359
customDomain: y.customDomain,
360360
});
361361
}, [
362-
interactiveFiltersConfig?.calculation.active,
362+
interactiveFiltersConfig.calculation.active,
363363
paddingData,
364364
normalize,
365365
getXAsString,

app/charts/area/chart-area.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const ChartAreas = memo((props: ChartProps<AreaConfig>) => {
4848
<AxisTimeDomain />
4949
<VerticalLimits {...limits} />
5050
<InteractionHorizontal />
51-
{interactiveFiltersConfig?.timeRange.active === true && <BrushTime />}
51+
{interactiveFiltersConfig.timeRange.active && <BrushTime />}
5252
</ChartSvg>
5353
<Tooltip type={fields.segment ? "multiple" : "single"} />
5454
<Ruler />
@@ -58,7 +58,7 @@ const ChartAreas = memo((props: ChartProps<AreaConfig>) => {
5858
<LegendColor
5959
chartConfig={chartConfig}
6060
symbol="square"
61-
interactive={interactiveFiltersConfig?.legend.active}
61+
interactive={interactiveFiltersConfig.legend.active}
6262
showTitle={fields.segment?.showTitle}
6363
dimensionsById={dimensionsById}
6464
limits={limits}

app/charts/bar/bars-stacked-state.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ const useBarsStackedState = (
358358
// When the user can toggle between absolute and relative values, we use the
359359
// absolute values to calculate the xScale domain, so that the xScale doesn't
360360
// change when the user toggles between absolute and relative values.
361-
if (interactiveFiltersConfig?.calculation.active) {
361+
if (interactiveFiltersConfig.calculation.active) {
362362
const scale = getStackedXScale(paddingData, {
363363
normalize: false,
364364
getX,
@@ -382,7 +382,7 @@ const useBarsStackedState = (
382382
customDomain: x.customDomain,
383383
});
384384
}, [
385-
interactiveFiltersConfig?.calculation.active,
385+
interactiveFiltersConfig.calculation.active,
386386
paddingData,
387387
normalize,
388388
getX,

app/charts/bar/chart-bar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const ChartBars = memo((props: ChartProps<BarConfig>) => {
8383
dimensionsById={dimensionsById}
8484
chartConfig={chartConfig}
8585
symbol="square"
86-
interactive={interactiveFiltersConfig?.legend.active}
86+
interactive={interactiveFiltersConfig.legend.active}
8787
showTitle={fields.segment.showTitle}
8888
/>
8989
</ChartControlsContainer>
@@ -115,7 +115,7 @@ const ChartBars = memo((props: ChartProps<BarConfig>) => {
115115
dimensionsById={dimensionsById}
116116
chartConfig={chartConfig}
117117
symbol="square"
118-
interactive={interactiveFiltersConfig?.legend.active}
118+
interactive={interactiveFiltersConfig.legend.active}
119119
showTitle={fields.segment.showTitle}
120120
/>
121121
</ChartControlsContainer>

app/charts/chart-config-ui-options.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ const chartConfigOptionsUISpec: ChartSpecs = {
655655
if (segment) {
656656
const yScale = getStackedYScale(observations, {
657657
normalize:
658-
chartConfig.interactiveFiltersConfig?.calculation.type ===
658+
chartConfig.interactiveFiltersConfig.calculation.type ===
659659
"percent",
660660
getX,
661661
getY,
@@ -758,7 +758,7 @@ const chartConfigOptionsUISpec: ChartSpecs = {
758758
if (disableStacked(yMeasure)) {
759759
setWith(chartConfig, "fields.segment.type", "grouped", Object);
760760

761-
if (chartConfig.interactiveFiltersConfig?.calculation) {
761+
if (chartConfig.interactiveFiltersConfig.calculation) {
762762
setWith(
763763
chartConfig,
764764
"interactiveFiltersConfig.calculation",
@@ -799,7 +799,7 @@ const chartConfigOptionsUISpec: ChartSpecs = {
799799
if (segment && segment.type === "stacked") {
800800
const yScale = getStackedYScale(observations, {
801801
normalize:
802-
chartConfig.interactiveFiltersConfig?.calculation.type ===
802+
chartConfig.interactiveFiltersConfig.calculation.type ===
803803
"percent",
804804
getX,
805805
getY,
@@ -959,7 +959,7 @@ const chartConfigOptionsUISpec: ChartSpecs = {
959959
if (disableStacked(xMeasure)) {
960960
setWith(chartConfig, "fields.segment.type", "grouped", Object);
961961

962-
if (chartConfig.interactiveFiltersConfig?.calculation) {
962+
if (chartConfig.interactiveFiltersConfig.calculation) {
963963
setWith(
964964
chartConfig,
965965
"interactiveFiltersConfig.calculation",
@@ -1000,7 +1000,7 @@ const chartConfigOptionsUISpec: ChartSpecs = {
10001000
if (segment && segment.type === "stacked") {
10011001
const xScale = getStackedXScale(observations, {
10021002
normalize:
1003-
chartConfig.interactiveFiltersConfig?.calculation.type ===
1003+
chartConfig.interactiveFiltersConfig.calculation.type ===
10041004
"percent",
10051005
getX,
10061006
getY,

app/charts/column/chart-column.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const ChartColumns = memo((props: ChartProps<ColumnConfig>) => {
8383
dimensionsById={dimensionsById}
8484
chartConfig={chartConfig}
8585
symbol="square"
86-
interactive={interactiveFiltersConfig?.legend.active}
86+
interactive={interactiveFiltersConfig.legend.active}
8787
showTitle={fields.segment.showTitle}
8888
/>
8989
</ChartControlsContainer>
@@ -115,7 +115,7 @@ const ChartColumns = memo((props: ChartProps<ColumnConfig>) => {
115115
dimensionsById={dimensionsById}
116116
chartConfig={chartConfig}
117117
symbol="square"
118-
interactive={interactiveFiltersConfig?.legend.active}
118+
interactive={interactiveFiltersConfig.legend.active}
119119
showTitle={fields.segment.showTitle}
120120
/>
121121
</ChartControlsContainer>

app/charts/column/columns-stacked-state.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ const useColumnsStackedState = (
356356
// When the user can toggle between absolute and relative values, we use the
357357
// absolute values to calculate the yScale domain, so that the yScale doesn't
358358
// change when the user toggles between absolute and relative values.
359-
if (interactiveFiltersConfig?.calculation.active) {
359+
if (interactiveFiltersConfig.calculation.active) {
360360
const scale = getStackedYScale(paddingData, {
361361
normalize: false,
362362
getX,
@@ -380,7 +380,7 @@ const useColumnsStackedState = (
380380
customDomain: y.customDomain,
381381
});
382382
}, [
383-
interactiveFiltersConfig?.calculation.active,
383+
interactiveFiltersConfig.calculation.active,
384384
paddingData,
385385
normalize,
386386
getX,

app/charts/index.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ describe("chart type switch", () => {
329329
measures: bathingWaterData.data.dataCubeByIri.measures as Measure[],
330330
});
331331

332-
expect(newConfig.interactiveFiltersConfig?.dataFilters.active).toEqual(
332+
expect(newConfig.interactiveFiltersConfig.dataFilters.active).toEqual(
333333
false
334334
);
335-
expect(
336-
newConfig.interactiveFiltersConfig?.dataFilters.componentIds
337-
).toEqual([]);
335+
expect(newConfig.interactiveFiltersConfig.dataFilters.componentIds).toEqual(
336+
[]
337+
);
338338
});
339339

340340
it("should not carry over not-allowed segment", () => {

app/charts/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ export const getInitialConfig = (
386386
};
387387
}
388388
}),
389+
interactiveFiltersConfig: getInitialInteractiveFiltersConfig(),
389390
limits: {},
390391
conversionUnitsByComponentId: {},
391392
activeField: undefined,
@@ -507,7 +508,6 @@ export const getInitialConfig = (
507508
return {
508509
...getGenericConfig(makeInitialFiltersForArea(areaDimension)),
509510
chartType,
510-
interactiveFiltersConfig: getInitialInteractiveFiltersConfig(),
511511
baseLayer: {
512512
show: true,
513513
locked: false,
@@ -542,7 +542,6 @@ export const getInitialConfig = (
542542
return {
543543
...getGenericConfig(),
544544
chartType,
545-
interactiveFiltersConfig: getInitialInteractiveFiltersConfig(),
546545
fields: {
547546
y: { componentId: numericalMeasures[0].id },
548547
segment: {
@@ -571,7 +570,6 @@ export const getInitialConfig = (
571570
return {
572571
...getGenericConfig(),
573572
chartType: "scatterplot",
574-
interactiveFiltersConfig: getInitialInteractiveFiltersConfig(),
575573
fields: {
576574
x: { componentId: numericalMeasures[0].id },
577575
y: {
@@ -612,7 +610,6 @@ export const getInitialConfig = (
612610
return {
613611
...getGenericConfig(),
614612
chartType,
615-
interactiveFiltersConfig: undefined,
616613
settings: {
617614
showSearch: true,
618615
showAllRows: false,

app/charts/line/chart-lines.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const ChartLines = memo((props: ChartProps<LineConfig>) => {
7575
dimensionsById={dimensionsById}
7676
chartConfig={chartConfig}
7777
symbol="line"
78-
interactive={interactiveFiltersConfig?.legend.active}
78+
interactive={interactiveFiltersConfig.legend.active}
7979
showTitle={fields.segment?.showTitle}
8080
limits={limits}
8181
/>

0 commit comments

Comments
 (0)