Knowledge Base Article

Adding additional dimensions to the area map widget tooltip [Linux]

Additional dimensions can be added to the Area Map widget on hover tooltip, extending the information shown beyond the default values (area name and color). Additional dimension data is integrated into the tooltip through the before query event to add additional dimension data for the hover tooltips and the widget render event for tooltip rendering. This method of query modification using the beforequery event can also be applied across other widget types. (Applicable to Sisense version 2023.11 and later | Cloud and On-Prem deployments.)

 

Step-by-Step Guide:

  1. Navigate to the specific Area Map widget on the Sisense dashboard.
  2. Open the widget's settings and access the script editor.
    // Add extra parameters to be used in tooltips by modifying query
    widget.on("beforequery", function (se, ev) {
    
        // Initial number of widget metadata panels excluding filter panel
        widget.initialPanelSizeExcludingFilterPanel = ev.query.metadata.filter(function (panel) {
            return panel.panel !== "scope";
        }).length;
    
        // Extra dimensions to show in tooltip, should return a single result, include as many as needed, just add to array
        // Jaql Objects can be copied from other widgets via prism.activeWidget.metadata.panels in the browser console
        // Modify JAQL as needed; the title of the JAQL is used in tooltip and can be customized to any string
        widget.extraDimensionJAQL = [
            {
                "jaql": {
                    "table": "Category",
                    "column": "Category ID",
                    "dim": "[Category.Category ID]",
                    "datatype": "numeric",
                    "merged": true,
                    "agg": "count",
                    "title": "Unique Category ID"
                }
            },
            {
                "jaql": {
                    "table": "Country",
                    "column": "Country ID",
                    "dim": "[Country.Country ID]",
                    "datatype": "numeric",
                    "merged": true,
                    "agg": "count",
                    "title": "Unique Country ID"
                }
            }
        ];
    
        // Add extra dimensions to the query
        widget.extraDimensionStartIndex = ev.query.metadata.length;
    
        for (var i = 0; i < widget.extraDimensionJAQL.length; i++) {
            ev.query.metadata.push(widget.extraDimensionJAQL[i]);
        }
    });
    
    
    // Append extra dimension values to tooltip label text in-place during widget render
    widget.on("render", function (se, args) {
    
        // Reference to query result rows
        var rows = args.widget.queryResult?.$$rows || [];
    
        // Column index to modify — typically the label or dimension used in tooltip
        var labelColumnIndex = 1;
    
        // Where extra dimensions start in the row array
        var extraStartIndex = widget.extraDimensionStartIndex || 2; // fallback
    
        // Human-readable labels for each added dimension
        var extraDimensionTitles = widget.extraDimensionJAQL.map(function (dim) {
            return dim.jaql.title;
        });
    
        // Loop through all data rows and append extra dimension values to the label
        rows.forEach(function (row) {
            var baseText = row[labelColumnIndex]?.text || "";
    
            var formattedExtras = [];
    
            for (var i = 0; i < extraDimensionTitles.length; i++) {
                var tooltip = row[extraStartIndex + i];
                var valueText = (tooltip && tooltip.text) ? tooltip.text : "-";
                formattedExtras.push("• " + extraDimensionTitles[i] + ": " + valueText);
            }
    
            // Append bullet-pointed extra info to label, separated by spaces
            if (formattedExtras.length > 0) {
                row[labelColumnIndex].text = baseText + " " + formattedExtras.join(" ");
            }
        });
    });
  3. Insert the following script into the widget script editor:
  4. Modify the JAQL variable to include the relevant additional dimensions as required by your specific use case.
  5. After completing the script edits, refresh the dashboard to apply the changes.
  6. The JAQL entries provided in the script can be replaced with any valid JAQL object, and the tooltip formatting can be further customized as needed.

    Tooltip Example Screenshot Description:

     

    The screenshot illustrates an enhanced tooltip on the Area Map widget, displaying the default area name followed by additional dimension values. Each dimension is presented clearly with a bullet point for easy readability, such as:

    • Unique Category ID: [numeric value]
    • Unique Country ID: [numeric value]

     

Conclusion:

Integrating additional dimensions into Area Map widget data hover tooltips provides users with immediate, detailed contextual information, enhancing data visibility and decision-making capabilities. This method is applicable to other Sisense widget types, enabling flexible, customized data presentations.

Disclaimer: This post outlines a potential custom workaround for a specific use case or provides instructions regarding a specific task. The solution may not work in all scenarios or Sisense versions, so we strongly recommend testing it in your environment before deployment. If you need further assistance with this, please let us know.

Published 07-21-2025
No CommentsBe the first to comment