Watermarking Sanctioned/Non-Sanctioned Data

Contents[Hide]

1. Overview

A requirement that is often associated with better data governance is the ability to watermark content based on approved/non-approved data. This is important if some of the power users are conducting their own self-service analysis with IT certified data as well as personal data files and end up sharing those with others. Dundas BI provides the ability to watermark datasets and content based on whether or not sanctioned data sources are used. This article provides a sample of how the visualizations in a dashboard can be watermarked to certify data using Javascript and CSS overrides.

2. Prerequisite

This sample requires basic familiarity with Javascript and CSS.

3. Organizing Sanctioned Data in Dundas BI

As a best practice, sanctioned or company approved data should reside in a repository that can be controlled by an administrator. Any metric set that is based on said data can then be watermarked when they are created using the certified data sources or data model in the repository.

Dundas BI provides users with a Global project where content that is meant to be shared across all projects would reside. Every project other than Global project has a Shared folder for project items such as data connectors, data cubes, metric sets etc. Any item created in the Global project will be accessible from the Shared folder of any other project. This ensures that the data is consistent and valid across all dashboards and reports built regardless of the projects.

The sample below has a dashboard for ad-hoc analysis created by a power user. Any metric sets the analyst uses from the Shared folders will be watermarked as certified official data, however any metric sets that the analyst creates on the fly for analysis will not be watermarked.

4. Dashboard Setup

Open a dashboard ready for sharing in Edit mode.

Add the following script to the Ready event of the dashboard. This script gets all the metric sets on the dashboard and adds a watermark to them.

Note
This script can be modified to change the watermark content, format etc.

//get the metric set service
var metricSetService = this.getService('MetricSetService');
//get the base view service
var baseViewService = this.getService('BaseViewService');
//get all the adapters of the dashboard
$E(baseViewService.currentView.control.adapters).forEach(function(adapter) {
  if (adapter.metricSetBindings) {
    $E(adapter.metricSetBindings).forEach(function(binding){   
      var metricSetDef = metricSetService.getMetricSetById(binding.metricSetId);
      $.when(metricSetDef).done(function(metricSetData) {
        //if the adapter belongs to the specified project
        if (metricSetData.projectId == 'a3a952c9-5092-444b-bc9a-28e1d013ffa4'){
          var rect = dundas.Utility.getAdapterBoundingClientRect(adapter.id);
          var watermark = document.createElement('div');
          $(watermark).text('Sanctioned Data');
          $(adapter.control.container).append(watermark);
          $(watermark).css('border', '#ff7f7f solid 2px');
          $(watermark).css('position', 'absolute');
          $(watermark).css('font-size', '13px');
          $(watermark).css('font-family', 'Arial');
          $(watermark).css('color', '#A9A9A9');
          $(watermark).css({left: (rect.width/3), top: (rect.height/3)});
          
          var watermarkBackground = document.createElement('div');
          $(watermarkBackground).css('background', '#FF0000');
          $(watermarkBackground).css('opacity', 0.50);
          $(watermark).append(watermarkBackground);
         $(watermark).css('z-Index', 99999999999999999);
        }
      })
      
    })
  }
});

To add the watermark on only specific visualizations regardless of which project they belong to, or to add different watermark comment on different visualizations, you can simply fetch a metric set by its ID instead of getting all the metric sets of the project as in the script above.

To get the ID of the metric set, click on the visualization and go to Properties Panel. From the Main tab of the properties, find ID under Actions. Copy and paste this ID in the script below.

Get the ID of the metricSet
Get the ID of the metricSet

//get the metric set service
var metricSetService = this.getService('MetricSetService');
//get the base view service
var baseViewService = this.getService('BaseViewService');
//get the metric set to be watermarked by its ID
var adapter = baseViewService.currentView.control.getAdapterById("60f85a18-8e65-c287-e813-ec311156ddd4");
    $E(adapter.metricSetBindings).forEach(function(binding){ 
      var metricSetDef = metricSetService.getMetricSetById(binding.metricSetId);
      $.when(metricSetDef).done(function(metricSetData) {
          var rect = dundas.Utility.getAdapterBoundingClientRect(adapter.id);
          var watermark = document.createElement('div');
          $(watermark).text('Non-Official Data');
          $(adapter.control.container).append(watermark);
          $(watermark).css('border', '#ff7f7f solid 2px');
          $(watermark).css('position', 'absolute');
          $(watermark).css('font-size', '13px');
          $(watermark).css('font-family', 'Arial');
          $(watermark).css('color', '#A9A9A9');
          $(watermark).css({left: (rect.width/3), top: (rect.height/3)});
          
          var watermarkBackground = document.createElement('div');
          $(watermarkBackground).css('background', '#FF0000');
          $(watermarkBackground).css('opacity', 0.50);
          $(watermark).append(watermarkBackground);
         $(watermark).css('z-Index', 99999999999999999);
        });      
    });

4.1. Watermarking all Dashboards in the Instance

The above script can also be added to the Javascript Override file so it fires across all the dashboards in that instance and not just a specific dashboard.

The following changes have be made to the script if you want to add it to the Override file:

$(document).ready(function(){
   this.ready(function(){
   ..
   ..
   ..
   //add the script from the section above
   ..
   ..
   ..
   });
});

5. Test the Dashboard

Open the dashboard in Sandbox View mode.

Note
Opening the dashboard in View mode to test will not trigger a script in dashboard's Ready event

The dashboard will have the watermarks on metric sets that have been used for the Shared folder (i.e. belong to the Global project) containing the IT developed and approved official data.

Dashboard with watermarks on the two metric sets on the right (sanctioned data) and no watermark on the left metric set (personal data)
Dashboard with watermarks on the two metric sets on the right (sanctioned data) and no watermark on the left metric set (personal data)

6. See Also

 

 

Dundas Data Visualization, Inc.
500-250 Ferrand Drive
Toronto, ON, Canada
M3C 3G8

North America: 1.800.463.1492
International: 1.416.467.5100

Dundas Support Hours: 7am-6pm, ET, Mon-Fri