The type of matrix graph is designed to represent relationships between pairs of variables.

1 Example

This example shows the total sales per employee according to gender and mediatype

Parameterization of the box:

  1. Selector type of Matrix graph.
  2. SQL statement to execute, in this case:
Copy
<select>
   <columns>
       genre.name <alias name='x_name'/>, 
       customer.country <alias name='y_name'/>, 
       'x' <alias name='x_group'/>,
       SUM(invoiceline.unitprice * invoiceline.quantity) <alias name='value'/>
   </columns>    
   <from table='invoice'>
       <join table='invoiceline'>
           <on>invoice.invoiceid = invoiceline.invoiceid</on>
           <join table='track'>
               <on>track.trackid = invoiceline.trackid</on>
               <join table='genre'>
                   <on>track.genreid = genre.genreid</on>	
               </join>
           </join>	
       </join>                    
       <join table='customer'>
           <on>invoice.customerid = customer.customerid</on>
       </join>	
   </from>
   <group>1,2,3</group>      
</select>

* Starting from the table of invoices and grouping gender and country.

INPUTS:

  • x_name: Name of the elements that make up the X axis in the chart.
  • x_group: Group name of the elements (Elements of the same group are painted the same color).
  • y_name: Name of the elements that make up the Y axis in the graph.
  • value: Value of the relationship between each element of the X axis with each element of the Y axis.

2 Interaction

In this type of graph the user can interact to order the values and to show tooltips with each value.


  • (1) Sort by combo, can be ordered according to: Name, Value i Family Group.

Name Value Family Group

In this case the field 'x_group' of the select comes hardcoded, so it loses sense to sort by group.


  • (2) When you move the cursor over the matrix, a tooltip will appear indicating each exact value according to the position of the cursor.

3 Group

In the previous example all the genres appear with the same color.

If the genres are classified into groups they can be visualized in different colors.

The structure of the genre table will be modified and a classification field will be added.

Copy
ALTER TABLE genre ADD clasif SMALLINT DEFAULT 0 NOT NULL;

The column is updated with the values:

Copy
UPDATE genre SET clasif = 0 WHERE genreid = 1;	
UPDATE genre SET clasif = 0 WHERE genreid = 2;	
UPDATE genre SET clasif = 0 WHERE genreid = 3;	
UPDATE genre SET clasif = 0 WHERE genreid = 4;	
UPDATE genre SET clasif = 0 WHERE genreid = 5;	
UPDATE genre SET clasif = 0 WHERE genreid = 6;	
UPDATE genre SET clasif = 0 WHERE genreid = 7;	
UPDATE genre SET clasif = 1 WHERE genreid = 8;	
UPDATE genre SET clasif = 1 WHERE genreid = 9;	
UPDATE genre SET clasif = 1 WHERE genreid = 10;	
UPDATE genre SET clasif = 1 WHERE genreid = 11;	
UPDATE genre SET clasif = 1 WHERE genreid = 12;	
UPDATE genre SET clasif = 1 WHERE genreid = 13;	
UPDATE genre SET clasif = 2 WHERE genreid = 14;	
UPDATE genre SET clasif = 2 WHERE genreid = 15;	
UPDATE genre SET clasif = 2 WHERE genreid = 16;	
UPDATE genre SET clasif = 2 WHERE genreid = 17;	
UPDATE genre SET clasif = 2 WHERE genreid = 18;	
UPDATE genre SET clasif = 2 WHERE genreid = 19;	
UPDATE genre SET clasif = 3 WHERE genreid = 20;	
UPDATE genre SET clasif = 3 WHERE genreid = 21;	
UPDATE genre SET clasif = 3 WHERE genreid = 22;	
UPDATE genre SET clasif = 3 WHERE genreid = 23;	
UPDATE genre SET clasif = 3 WHERE genreid = 24;	
UPDATE genre SET clasif = 3 WHERE genreid = 25;

The data in the table is as follows:



The parameterization of the box is modified and the SQL statement is added to the classification column.

The result:

The filter is used per group: