Table Colorizer
feature is a grid parameterization for colorizing grid cells depending on its content, generally to emphasize the importance of a cell amoung a group of cells.1 Introduction
1.1 What is it?
Table Colorizer
is a tool to make grids easier to analyze at a glance.
Let's see an example of a simple grid with a table colorizer definition assigned:
As it looks, due to the colors of the grid, it becomes very easy to see which values ara bigger and which ones are not.
In addition, depending on the dataset that we want to deal with, there are different algorithms to deal with this data, and thus color the grid in the best possible way.
1.2 What can I do?
Table Colorizer
are mainly focused on the colorization of grids, such as those containing SQL Tables
or grids contained in Channels
.
Its use is interesting when:
- The dataset contains numeric values to be classified
- The dataset contains discrete values (numbers or strings) from which we want to obtain the frequency of appearance
The best thing of Color Palette is that it's very easy to colorize the grid, just by indicating a palette of colors and one of the defined algorithms we have enough. At the same time, it can be added complexity to the colorizer with the use of ranges.
1.3 What do I need?
In first place, Table Colorizer
requires the basic Axional Studio infrastructure, which includes:
- Axional Studio Server, properly set up.
- Dictionary database
- A target database
In second place, as they can be applied to SQL Tables
in Axional Studio Form Object
, it is required to have any object that uses an SQL Table with at least one column for which
a table colorizer is defined. And the same to Channels
.
2 Architecture
2.1 Structure
2.2 Dictionary tables
Table Colorizer
implementation involves four parametrization tables:
- Table colorizer definition (wic_jdic_color_rule_def)
- Color palette (wic_jdic_color_palette)
- Table colorizer ranges (wic_jdic_color_rule_range)
- Labels (wic_jdic_lbldata)
As it is explained below, Table Colorizer
functionalities only requires always the table wic_jdic_color_rule_def; It will be explained when is necessary to use the other tables below.
2.2.1 Table colorizer definition
2.2.2 Color palette
If the method defined in a color rule definition is 'Simple distribution', 'Quartiles distribution' or 'Repetitions', another table to obtain the color palette will be needed:
wic_jdic_color_palette | |
---|---|
Label | Description |
Code | Identifier code of palette |
Name | Name of palette |
Colors | Colors of palette |
2.2.3 Table colorizer ranges
If the method defined in a color rule definition is 'By rank', another table to define the ranges will be needed:
wic_jdic_color_rule_range | |
---|---|
Label | Description |
seqno | Order |
Id | Join with wic_jdic_color_rule.rule_code |
Order | Indicate the order to execute the range expressions. |
Bg color |
|
Text color | Secondary color to be applied to the cell, in case the expression returns true. It should be a contrast color in relation to the main color, to guarantee a correct visibility. Generally, corresponds to the text color. It should contain a value such as #00FF00
|
Expression | UEL Expression which determine whether apply the current color or not. It must return a boolean value:
In order to give the maximum means for create versatil expressions, the system provides the following variables to the expression evaluator:
|
Label | Label describing the color functional meaning. It might be used in palette legend. It's value validates with wic_jdic_lbldata.label_code |
2.2.4 Labels
When the table colorizer has ranges defined, it is possible to set a label to the ranges with information about the range expression, to be shown on the tooltip legend.
wic_jdic_lbldata | |
---|---|
Label | Description |
Language | Language in which the descriptions referring to the labels are expressed. When the connection users to the system are defined through the configuration database ( wic_conf ), among other data, it is defined the language in which the application will be used and managed. Depending on the user and language indicated, you will use the description of the labels corresponding to that language.
|
Verified | It specifies if the text has been checked by an expert or translator. Never mind the current status, automatic processes will not affect it.
|
Code | Tag code that will be used to reference it from the form definition. |
Description | Description of the label in the indicated language. This description will be the one that is presented, dynamically and automatically, in the definition and construction of system forms. |
Information | Generally, the documentation implemented here is shown by a floating component or a large fixed component, so that the information can become very extensive, even in the form of a document with sections. |
Created by |
|
Date created |
|
Modified by |
|
Date updated |
|
3 Implementation
The implementation of Table Colorizer
is achieved by adding some color rule definitions to the desired columns in a table.
The implementation of Table Colorizer
is defined by one entity:
- Table colorizer definition (wic_jdic_color_rule_def)
The former defines the colorizer rule, and according to this rule involve another entities like table colorizer ranges (wic_jdic_color_rule_range) or color palettes (wic_jdic_color_palette).
3.1 Table colorizer definition
The Table colorizer definition contains all the necessary information to colorize a column of a table. Each colorizer definition is identified by a unique code, that can be use by more than one column in a table.
3.1.1 Defining a table colorizer
To start defining our colorizer, the following values will be indicated:
- Description (not required)
- Consider all columns
- Show histogram
- Method
- Palette
- Gradient
Description
The Description contains the functional description of the color rule definition. It is not required.
Consider all columns
The Consider all columns flag indicates which columns the colorizer considers for calculating the limit values like max, min, average, etc.
It can contain two values:
- 0 (false): It considers a single column.
- 1 (true): It considers all the columns of the grid with the same color rule definition.
If the flag is activated and all the columns of the table have the same color rule definition, the resulting grid will be the following:
Otherwise, if the flag is not activated, the resulting grid will be the following:
Show histogram
The Show histogram flag indicates if the header of the column will have a frequency histogram with a tooltip caption.
If the flag is activated in all the columns of the table, the following histograms will appear below the header:
Also, if we go over the histogram, a tooltip with the caption will appear:
The implementation of Table Colorizer
is achieved by adding some color rule definitions to the desired columns in a table. According to this configuration, the system handles two ways to colorize:
- By algorithm method: The user indicates a method to colorize automatically the grid.
- By ranges: The user indicates some ranges to colorize the grid according to the validation of certain expressions that can involve limit values, for example.
By algorithm method
The Color rule definitions contain the following automatic grid colorization algorithms:
- For continuous values:
- Simple distribution
- Quantiles distribution
- For discrete values:
- Repetitions
Simple distribution
Simple distribution algorithm distributes the data of the dataset by ranges with an amplitude determined by the following formula:
$$Amplitude = {max - min \over groups}$$This algorithm calculates the groups considering the range of the dataset, giving very good results when a large part of the data tend to be close to the arithmetic mean. Otherwise, it does not plow a good distinction when the are extreme data in out dataset.
This is a dataset with the following values:
- Max: 8000
- Min: 0
- Groups: 10
- Amplitude = 800
This is the resulting grid when it is applied the simple distribution algorithm to this dataset:
The distribution of the values by groups will be the following:
- 0 - 800: 90,83 %
- 801 - 1600: 8,33 %
- 7201 - 8000: 0,83 %
In conclusion, for this dataset is it not appropaite to apply this distribution algorithm.
Quantiles distribution
Quantiles distribution distributes the data of the dataset in groups of equal size. Its use is recommended when our dataset contains many extreme values (very far from the arithmetic mean).
This is the resulting grid when it is applied the quantiles distribution algorithm to the same dataset as the previous example:
In this case, when creating groups with the same number of data, the interpretetion of data is better than with the simple distribution algorithm.
Repetitions
Repetitions algorithm distributes the data of the dataset according to the absoute frequency of each discrete value. Its use is indicated when it is important to know what values are repeated more or less.
This dataset contains the most polluted cities in Europe for the last 20 years* (each row contains 6 cities, the most polluted cities every 2 months in that year).
This is the resulting grid when it is applied the repetitions algorithm to this dataset:
With this example is easy to see what cities were the most and the least polluted cities for the last 20 years.
*The data shown is not real
When one of these algorithms is being applied, there are two more values of the color rule definition that have to consider:
- Color palette
- Gradient
Color palette
The Color palette defines the list of colors to be applied on the grid. This code validates to pal_code in table wic_jdic_color_palette.
Only available in working dictionary
The available colors palettes are those of the current dictionary. This is not a multidictionary option.Gradient
The Gradient flag determines if consider the palette colors as final values, or use them to create a gradient. It will also determine the number of groups in which the dataset will be divided.
This palette contains the following colors:
Color | Hex |
---|---|
#55ff55 | |
#ff5555 |
In the case that gradient flag is not actived, only the two colors indicated on the palette will be applied, an therefore the number of groups will be 2.
Otherwise, if gradient flag is activated, the system will calculate the number of groups with a mathematical formula.
Imagine that in this case the result is 10. Then, the groups will have the following colors:
Color | Hex |
---|---|
#55ff55 | |
#68ec55 | |
#7bd955 | |
#8ec655 | |
#a1b355 | |
#b3a155 | |
#c68e55 | |
#d97b55 | |
#ec6855 | |
#ff5555 |
By ranges
When the goal is to colorize the dataset in our own way, it is best to use the By rank method.
The Color rule ranges contains the necessary fields to indicate how to manually colorize a grid. Each colorizer range is identified by the unique code of its parent wic_jdic_color_rule_def.
To define the ranges, the following values will be indicated:
- Order (not required)
- Main color
- Secondary color
- Expression
- Label (not required)
Order
Order indicates the order to execute the range expressions. The first ordered expression that is fulfilled will be the one that will be applied to the data. It is not required.
Main color
Main color to be applied to the cell, in case the expression returns true. It shoud contain this types of colors:
- HTML Colors (RED, BLUE, WHITE, etc.)
- Hexadecimal Colors (#FF0000, #54AB19, #000, etc.)
- RGB Colors (rgb(255,255,255), rgba(0, 120, 120, 1), etc.)
Secondary color
Secondary color to be applied to the cell, in case the expression returns true. Corresponds to the text color. It should contain a type of color like the main color.
Expression
The UEL Expression will determine whether apply the current color or not. It must return a boolean value:
- If true, the current color is applied.
- Otherwise, it is expected to applu the color of another item.
- In case of any item for the given palette is applicable, it is not set any color.
In order to give the maximum means for create versatil expressions, the system provides the following variables to the expression evaluator:
Variable | Definition |
---|---|
value | Correspond to the value of the cell the color might be applied. |
totalitems | The number of items available for the current dataset. |
Continuous values | |
max | The maximum value of the dataset. |
min | The minimum value of the dataset. |
avg | The mathematical mean of the dataset. |
med | The median value of the dataset. |
Discrete values | |
repeat_value | Is the number of repetitions of the current value. |
repeat_max | Is the maximum number of repetitions of the dataset. |
repeat_min | Is the minimum number of repetitions of the dataset. |
Label
Label describing the color functional meaning. It will be used in tooltip caption. Its value validates with label_code in wic_jdic_lbldata. It is not required.
If the Show histogram flag is activated and almost a label is applied to a range of the color rule, the label will appear on the tooltip caption.
3.2 Table colorizer applications
3.2.1 Applying a colorizer to a SQL table
Once having the necessary color rule definitions to colorize our tables is the time of telling each column what color rule definition will use.
To do this, indicate the color rule definition rule_code in the out_palette field of the SQL table columns.
Only available in working dictionary
The available color rule definitions are those of the current dictionary. This is not a multidictionary option.3.2.2 Applying a colorizer to channels
Once having the necessary color rule definitions to colorize our tables is the time of telling each column what color rule definition will use.
To do this, indicate the color rule definition rule_code in the out_palette field of the SQL table columns.
Only available in working dictionary
The available color rule definitions are those of the current dictionary. This is not a multidictionary option.4 Samples
The following section presents a set of samples with the most interesting cases of uses of Axional Studio Table Colorizer
implementations:
4.1 Heat map of a CPU usage per hour
4.1.1 Introduction
This sample shows how to implement a defined Table Colorizer
in a SQL Table.
The current sample is based on the following data structure:
As observed, a table with a date and information per hour about the CPU usage of a server contains our dataset.
The following SQL Table shows the content of the table:
After seeing this table, it is apparent that with colors in this table it would be much easier to see when the server is in a critical state of work. That is why it is important to apply a colorizer to the table.
4.1.2 Defining a table colorizer
The color rule definition parametrization for that case consists of:
Column | Value |
---|---|
Code | CPU |
Description | Color rule to colorize the CPU usage of a server |
Consider all columns | true |
Show histogram | true |
Method | Simple distribution |
Palette | cpu_1 |
Gradient | true |
And the color palette assigned to this color rule definition have these colors:
Color | Hexadecimal color |
---|---|
#70b58a | |
#fec444 | |
#fbb050 | |
#f89d5b | |
#f48967 | |
#f17572 |
4.1.3 Applying a colorizer to a SQL table
Once color rule definition is defined, this definition is assigned to the necessary columns of the SQL Table.
4.1.4 Execution
Once color rule definition is defined and assigned to the columns of the SQL Table, the grid will be automatically colorized every time it is generated, and in this case it will be shown as: