Skip to content

Commit

Permalink
feat(plugin-chart-cartodiagram): add support for dashboard filters
Browse files Browse the repository at this point in the history
  • Loading branch information
jansule committed Oct 17, 2024
1 parent bdbf207 commit 51b6e82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ import { QueryFormData, getChartBuildQueryRegistry } from '@superset-ui/core';
* if a viz needs multiple different result sets.
*/
export default function buildQuery(formData: QueryFormData) {
const { selected_chart: selectedChartString, geom_column: geometryColumn } =
formData;
const {
selected_chart: selectedChartString,
geom_column: geometryColumn,
extra_form_data: extraFormData,
} = formData;
const selectedChart = JSON.parse(selectedChartString);
const vizType = selectedChart.viz_type;
const chartFormData = JSON.parse(selectedChart.params);
// Pass extra_form_data to chartFormData so that
// dashboard filters will also be applied to the charts
// on the map.
chartFormData.extra_form_data = {
...chartFormData.extra_form_data,
...extraFormData,
};

// adapt groupby property to ensure geometry column always exists
// and is always at first position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import buildQuery from '../../src/plugin/buildQuery';

describe('CartodiagramPlugin buildQuery', () => {
const selectedChartParams = {
extra_form_data: {},
groupby: [],
};

Expand Down

0 comments on commit 51b6e82

Please sign in to comment.