The MongoDB charts SDK allows you to filter a chart on whitelisted fields. In the dashboard itself, you can add more than one filter to a chart but as soon as you embed the chart using the Javascript SDK you can only use one filter. This is what the code looks like for a filter, is it possible to add another filter on 1 chart using clever javascript?
import 'regenerator-runtime/runtime';
import ChartsEmbedSDK from '@mongodb-js/charts-embed-dom';
const sdk = new ChartsEmbedSDK({
baseUrl: 'https://charts.mongodb.com/charts-project-0-bhitm',
});
const chart = sdk.createChart({
chartId: 'd1be814a-7ff2-4f3d-bd61-521589279fd9',
background: 'transparent',
height: '1200px',
showAttribution: false,
});
async function renderChart() {
await chart.render(document.getElementById('Box1'));
document
.getElementById('game-filter')
.addEventListener('change', async (e) => {
const game = e.target.value;
const currentFilterDOM = document.getElementById('currentFilter');
if (game) {
await chart.setFilter({ _id: game });
const filter = await chart.getFilter();
currentFilterDOM.innerText = JSON.stringify(filter);
} else {
await chart.setFilter({});
const filter = await chart.getFilter();
currentFilterDOM.innerText = JSON.stringify(filter);
}
});
}
renderChart().catch((e) => window.alert(e.message));
any help will be appreciable thanks in advance