Watermarking sanctioned/non-sanctioned data

Contents[Hide]

1. Overview

A requirement that may be associated with data governance is the ability to watermark content based on approved/non-approved data, for example when power users are doing self-service analysis with IT-certified data as well as personal data files, and sharing it with others.

With Dundas BI's open APIs, it is possible to use script 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 actions 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.

var metricSetService = this.getService('MetricSetService');
var baseViewService = this.getService('BaseViewService');

// Get all the adapters of the dashboard:
baseViewService.currentView.control.adapters.forEach(function (adapter) {
  if (adapter.metricSetBindings) {
    adapter.metricSetBindings.forEach(function (metricSetBinding) {   
      var metricSetDef = metricSetService.getMetricSetById(metricSetBinding.metricSetId);
      $.when(metricSetDef).done(function (metricSet) {
        // If the metric set belongs to the specified project:
        if (metricSet.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.5);
          $(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 fetch a metric set by its visualization ID instead of getting all the metric sets of the project as in the script above.

To get the ID of the visualization, click on it and go to the Properties window. In the Main tab, find ID under Actions. This is the visualization adapter ID (adapters plug controls such as visualizations into Dundas BI). Copy and paste this adapter ID into the script below:

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

var metricSetService = this.getService('MetricSetService');
var baseViewService = this.getService('BaseViewService');

// Get the metric set to be watermarked by its visualization adapter ID
var adapter = baseViewService.currentView.control.getAdapterById("60f85a18-8e65-c287-e813-ec311156ddd4");
adapter.metricSetBindings.forEach(function (metricSetBinding) { 
  var metricSetDef = metricSetService.getMetricSetById(metricSetBinding.metricSetId);
  $.when(metricSetDef).done(function (metricSet) {
    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.5);
    $(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 application styling so it runs for all the dashboards in that Dundas BI 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
Switching a dashboard that is already open from edit mode to view mode will not trigger a script added to the 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.
400-15 Gervais Drive
Toronto, ON, Canada
M3C 1Y8

North America: 1.800.463.1492
International: 1.416.467.5100

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