Always wanted to show location based insights to your audience on a vector map of your own (and not Google maps)? With icCube’s custom “Widget Template” you can! Here is how….
In this blog post I will explain how to create a custom spatial dashboard from a vector map and link the images to the data in icCube. But before you continue, please do not overwhelm your audience with spatial dashboards, just because you can! Always be intentional in why you choose for a particular visualization. A spatial dashboard can be of enormous help in very specific situations, but it can be really annoying, to say the least, if you apply it to answer questions your audience is not interested in.
So far the “teacher” … now on to the fun part.
In the next steps, I will guide you how to create a spatial dashboard yourself, by using a simple example for a cinema. Below you will see the cinema map (one room only) on which the seats are plotted. The general idea here is that we will analyze sales per seat; seats will light up (green) if a ticket has been sold for that day (I admit, this is not really a “killer” business case).
ingredients for a spatial dashboards
- a vector map with objects that can be linked to data
- an svg editor to edit the map
- a text file editor
- a hierarchy in icCube that contains unique object IDs that can be linked to objects in the vector map (in this example we have the dimension “chair” and the metric “tickets sold”).
steps for making the dashboard
step 1 – create or update the vector map
This is the creative part. Create or import a map in a drawing tool that supports vectors.
For this tutorial I have created a floor plan for the cinema in Inkscape: each seat is a rectangle. The cinema has 5 rows (A – E) and 8 seats (1 – 8):

The colors of the seats are just for illustration purposes only as these will eventually be set by icCube, based on the underlying data.
step 2 – name all objects to corresponding IDs in data
This is the “magic trick”. To allow the seats (or vector objects) to be linked to the icCube data, each object must have a unique identifier (ID) that is also available in icCube. In Inkscape, this can be done by selecting the rectangle and then pressing ctrl + shift + o and adding the unique ID. In this case I use the seat code as unique ID:

step 3 – group the changeable objects
Group all the changeable objects and assign a unique id so it can be addressed using CSS. In this example we have provided a hover effect for each seat using CSS. This can be done by selecting and grouping all the seats and providing it with a recognizable ID, e.g. “chairs”:
#cinema1 g #chairs rect:hover { cursor: pointer; opacity: 0.5; } #cinema1 g #chairs rect.on { stroke: black; stroke-width: 1px; }
Save the file and close the svg editor. Note that each object that you want to be colored by icCube should have a unique distinct ID.
step 4 – prepare your icCube model
Ensure that you have a dimension in your schema that consists of elements that have the ID you provided to the objects in the previous step. I have created a schema using the “in memory” data source with a dimension called “chair”. In practice you would build a dimension based on the metadata in your ticketing system.
The “in-memory” data has the following columns:
[table] column,data type, example date ticket sold, date field, e.g. 1 Nov 2016 chair, alphanumeric, ID for the seat e.g. A4 or E1 ticket sold, integer, number of tickets sold [/table]Below the in-memory data source in the icCube Builder and its columns:

The dimension “Chair” has been set up as:
- key column = chair
- name column = chair
(In practice, the key column would be a unique number and the name a meaningful label that is readable to the end user).

That is a bit all there is for the model. The following MDX statement will provide the number of tickets per seat. Its result is going to be used in the dashboard:
[icCubeMdx]SELECT {[Measures].[tickets]} ON 0, [Chairs].[Chair].[chair].allmembers ON 1 FROM [Cube] CELL PROPERTIES VALUE, FORMATTED_VALUE, STYLE[/icCubeMdx]
step 5 – blend all together in the widget template
Now, it is finally time to do some “magic”. Let’s bind all ingredients into a dashboard. Please stay with me, as this might get a bit complicated ;-).
First, we start with a fresh dashboard on the cinema schema described in the previous step and add a “Widget Template” (more details on this functionality can be found here).
To enable you to see the result, paste the MDX statement from the previous step in the “data” section (press tab “MDX” to paste it).
Navigate to the “Data Render” tab and add the property “Background Color” so it can be referenced later:

Click on “Options” and fill the “After Render” and “HTML, data received” with the information further on in the blog post:

Then, open the svg file of the map you using a text editor. Select and copy the HTML code and paste it in the “HTML, data received” section:

Here is a sample of the code. Note that there is a bit of HTML code at the end that must be added as well (between the <style> and </style>):
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" id="cinema1" version="1.1" inkscape:version="0.91 r13725" xml:space="preserve" ... etcetera d="m 404.94566,317.86248 0,-142.35466" style="fill:none;fill-rule:evenodd;stroke:#888888;stroke-width:1.84;stroke-linecap:butt;stroke-linejoin:miter;stroke-stroke-miterlimit:4;stroke-dasharray:none" /></g></svg> <style> #cinema1 g #chairs rect:hover { cursor: pointer; opacity: 0.5; } #cinema1 g #chairs rect.on { stroke: black; stroke-width: 1px; } </style> <script> var allObjects = $("#cinema1 #chairs rect"); allObjects.on("click", function() { allObjects.removeAttr("class"); $(this).attr("class", "on"); });
As a next step, add the javascript code to the “After Render” section:

This is the code:
/** * You can bind events to node and it's children */ function(context, node, props) { for (var row = 0; row < context.rowsCount; row++) { var idd = context.rowLabel(row); var color = context.cellValue(idd, 0,0); //var color = props.backColor(row,0) || '#ccc'; // Find object var $object = $(node).find("#" + idd); // Change color and add row click $object.attr('style', 'fill:' + color) .click(function(row) { context.fireRowClick(row, 0); context.fireCellClick(row, 0); }.bind(this, row)); // it's a bit special managing svg var titleElem = document.createElementNS("http://www.w3.org/2000/svg", "title"); titleElem.textContent = 'seat '+ idd + ', tickets sold: ' + context.cellValue(idd, 0,1) ; $object.append( titleElem ); } }
You are almost there…
Click on the property “Background Color” value “Pallete for Cell values” and select the following:

You should now be able to see the colored cinema seats.
If so, save the template so it can be used in any other dashboard:
In the “data render” tab, press [Save]:

step 6 – use the template in your dashboard
Create a new dashboard and add the filter widgets of your choice. To add the cinema template, just created, select “Charts” > “Widget Template”. Add your MDX (remember to have the chair in the row and the numeric data in the first column). On the “data render” tab, click on the “default” icon under “Preset”. Now all available saved custom templates will be displayed. Select the one just created “Inside Vision Spatial Dashboard”:

By changing the “Palette for Cell Values” for the property “Background color” you can tweak how the data is translated to colors.
This is my end-result:

This was the last step of the tutorial, if you copied my steps, you should have now a spatial BI map of your choice.
More applications of the vector map
This icCube functionality is not limited to maps only. Any vector based file can be linked in this way to icCube. We think to use this functionality for our clients for the following applications:
- interactive maps (hotels, flex workspace usage, holiday rentals, …)
- interactive flow charts
- custom sales funnels (not the standard boring pictures ;-))
- interactive diagrams (machines, in- and outflows, education)
May be you have some great idea’s how to apply this nice feature to your company’s or clients’ data. Please share with us, so we together can build and educate the icCube community to create killer dashboards that really turn data into value.
FAQ
- My svg doesn’t fit in the container, and it doesn’t adjust to the size of the container. The width and height of the svg are defined in the svg code itself. You can change these by changing the values of the width and height attribute. Preferably, set these to 100% (see the demo example).
- The hover effect doesn’t work Recheck if the grouped id and the CSS selector are the same. If this isn’t the case, maybe your items are not rectangles, but paths. You can check this in the svg code. Simply change the CSS selector to path instead of rect.Another possible cause could be that the opacity is hard-coded in the svg. Check the objects in the svg code. Ensure to remove the opacity or fill-opacity field in the styling attribute for all objects using a simple text search and replace.
- The click effect doesn’t work The click effect changes the stroke and the stroke-width. These attributes are probably hard-coded in your svg code. For each object in the svg code, remove these fields in the styling attribute. This can be done with a text search and replace.
- I would like to change another svg attribute, next to the color At present, this is not supported, but you can contact icCube services to see how your specific needs can be addressed shortly.
about the author
Arthur van den Berg, www.inside-vision.com
It’s a kind of magic … to transform loads of data into insight giving dashboard products that show your audience what step to take next, based on your data.
I work closely together with icCube being a Dutch reseller. I love their product that allows me and my clients to launch meaningful dashboard products and to embed analytical insights into their software.
By Arthur van den Berg