Hi @oliver89, thanks for reaching out. ChartFactor allows us to achieve your goal in a very elegant way. At the visualization level it is possible to apply restrictions that allow you to specify when a visualization should be executed or not. Take a look at the following example:
const restrictions = [
{ filter: "community_areas" }
];
/* Configuration code for this widget */
let provider = cf.provider("Elasticsearch");
let source = provider.source("chicago_taxi_trips");
// Define metrics
let metric0 = cf.Metric("extras", "sum");
// Define attributes to group by
let group1 = cf.Attribute("company")
.limit(10000)
.sort("asc", "company");
// Add metrics and groups to data source
let myData = source.groupby(group1).metrics(metric0);
// --- Define chart options and static filters ---
let myChart = myData.graph("Slicer")
.onlyWithFilters(restrictions)
.execute();
As you can see in the piece of code above, in the restrictions
array we have defined the rule that will be applied to the visualization using the .onlyWithFilters(restrictions)
function. With this we are telling the visualization to run only when there is a filter applied to the community_areas
field.
You can go even further and specify what filter values you want the visualization to load with. For more information please take a look at the following documentation: https://chartfactor.com/doc/latest/visualizations/interaction_manager/#visualization-level
Let me know if this solved your problem.