Justin Unverricht
12/09/2021, 5:42 AMLubomir Slivka
12/09/2021, 8:05 AM@alpha
level with stabilization pending until next year.
anyway, to give a more precise answer, I will need further detail of what are you trying to achieve.
are you trying to:
a) render an existing insight in an arbitrary way? e.g. an insight that was created in AD and drag-dropped onto a dashboard?
b) render a custom widget that gets some data to render them in arbitrary way?Lubomir Slivka
12/09/2021, 8:19 AMLubomir Slivka
12/09/2021, 8:24 AMselectFilterContextDateFilter
selector (exported from the dashboard package normally)
in your React component you can do:
const dateFilter = useDashboardSelector(selectFilterContextDateFilter);
Justin Unverricht
12/09/2021, 6:24 PMLubomir Slivka
12/09/2021, 7:23 PMconst dateFilter = useDashboardSelector(selectFilterContextDateFilter);
Justin Unverricht
12/09/2021, 7:24 PMLubomir Slivka
12/09/2021, 7:28 PMLubomir Slivka
12/09/2021, 7:29 PMJustin Unverricht
12/09/2021, 7:48 PMreact_devtools_backend.js:2540 Tiger does not support this filter. The filter will be ignored
Here is my code for reference
const filters = useDashboardSelector(selectFilterContextFilters);
<Execute
seriesBy={ [bphfSum, lfdhSum] }
slicesBy={ [newAttribute('d_region.region_name')] }
filters={[filters[2]]}
>
Is this the correct way to apply the filters to this component in 8.7.0?Lubomir Slivka
12/09/2021, 9:22 PMJustin Unverricht
12/09/2021, 9:30 PMLubomir Slivka
12/09/2021, 9:33 PMfilterContextDateFilterToDateFilter
is the function we use to convert dashboard-specific filter to one that can be used in execution.
the signature alludes to what I was mentioning before.. the date filter from dashboard does not have the info about date dataset to use for filtering. that dataset can be set on per-widget base. that’s why the convertor takes both the dashboard filter & the widget (from where it grabs the dataset).
so.. you can repurpose this into your own small conversion function.
first param being the date filter that you retrieve using the selector. the second param being the reference to date dataset.Lubomir Slivka
12/09/2021, 9:34 PMLubomir Slivka
12/09/2021, 9:34 PMexport function toExecutionFilter(
filter: IDashboardDateFilter,
dateDatasetRef: ObjRef,
): IDateFilter {
if (filter.dateFilter.type === "relative") {
return newRelativeDateFilter(
dateDatasetRef,
filter.dateFilter.granularity,
numberOrStringToNumber(filter.dateFilter.from!),
numberOrStringToNumber(<http://filter.dateFilter.to|filter.dateFilter.to>!),
);
} else {
return newAbsoluteDateFilter(
dateDatasetRef,
filter.dateFilter.from!.toString(),
<http://filter.dateFilter.to|filter.dateFilter.to>!.toString(),
);
}
}
Lubomir Slivka
12/09/2021, 9:35 PMconst filterForExecution = toExecutionFilter(filterYouGetViaSelector, idRef("<http://id.of.your.date.dataset.to|id.of.your.date.dataset.to>.filter.on", 'dataset'))
Lubomir Slivka
12/09/2021, 9:36 PMLubomir Slivka
12/09/2021, 9:37 PMLubomir Slivka
12/09/2021, 9:41 PMJustin Unverricht
12/09/2021, 9:48 PM