Custom Script for Blox Panel Name
We are currently using a Blox "text block" banner at the top of our dashboard. It is tied to a data table containing org names (aka customers) so that when our dashboard is filtered by that field, the top banner updates with the name of the selected org (Script: Items > Text > Panel > Data Field (org name).
This is working well, however, when the filter defaults to "all" and our dashboard is displaying aggregate data across all "orgs", the top banner displays the first name from the table, which is inaccurate from a data visualization standpoint.
Is there a way to tie a default filter (set to "all") so that instead of Blox just displaying the top name in from the data, it triggers a custom phrase instead (like "Aggregate")?
Any tips are greatly appreciated!
-
Here's a simple way to do something of the kind! Two steps:
(1) Give the TextBlock containing the customer name an id attribute - for example, see the bolded text:{"type": "TextBlock","text": "{panel:Fake Names}️","id": "custName","style": {"text-align": "center","font-weight": "bold","font-size": "24px","margin": "100px"}}(2) Open the widget's script and add this:
widget.on('ready', function(w, args) {
var custCount = w.queryResult.length;
if (custCount > 1) {
$("#custName").text("Aggregate data (" + custCount + " customers)") //insert your id in place of custName
}
});
Here are the results when 1 customer is filtered to vs. many.Additionally, if you want to, you can get rid of the carousel arrows like this in the BloX editor:
"showCarousel": true, "carouselAnimation": { "showButtons": false }
-
Gideon Jeffrey This worked beautifully! Thank you so much!
-
Hi Gideon,
I am trying to do something similar where i am trying to display from & to date selection made on the dashboard filter.
i am using this article to create a blox widget to accept from and to dates.
do you think this is possible?
Best,
Ani
Please sign in to leave a comment.
Comments
4 comments