How to dynamically modify the default group by field of multiple visualizations at the same time


#1

Hello, I have a dashboard with several visualizations (Bars, Bubbles, Donut, Word Cloud, Floating bubbles, etc.) that shows the behavior of electronic product sales, grouped by a specific attribute, which in this case is the product brand, for example Samsung.

Recently, the company’s management requested that the default attribute be dynamically changed in order to visualize how sales based on the new attribute behave.

I know that creating new visualizations with the new attributes changed manually can show me the sales behavior for that new attribute but it would be an inefficient solution since I would have to duplicate the visualizations to show the groups for each attribute.

I also tried doing some hacks, but couldn’t get it right.

Any suggestions on this?
Thanks.


#2

Hi @emma, I think that what you are needing is very simple to achieve, for this specific case the best thing would be to use the Field Selector visualization, which allows you to select several fields and modify the first group in all the visualizations that you choose. With the following simple piece of code you can achieve your goal, take a look:

let provider = cf.provider("Elastic Demo");
let source = provider.source('chicago_taxi_trips');

let charts = [getId("Bars"), getId("Bubbles"), getId("Donut"), getId("WordCloud"), getId("FloatingBubbles")]

let myChart = source.graph("Field Selector")
		.set("type", ["ATTRIBUTE"])
		.set("group", 1)
		.set("extend", {"limit": 10})
		.set("charts", charts)
		.set("field", "company")
		.execute();

Adding something like the code above, the result would be something like this:

In any case, I recommend that you take a look at this post in which the same topic is discussed, perhaps the second alternative, which is using the Interaction Maganer with the drill hierarchy, can also serve you.


#3

Ohh incredible visualization :heart_eyes:, it is very sure that this will help me, I will try adding the Field Selector to accomplish that.

Thanks!