Using expression’s color to show more information

In this post I show how can use the color expression’s in a chart to show information to the user in a single glance and maintaining the graph in a simple and easily readable format.

The idea is that each bar (in the case of a bar chart) can be assigned to a particular color using RGB () function with some kind of calculation based on the model’s data.

For example suppose you have a table of receivables with the following information:

load * inline [
CustomerID, Name, Debt, Days_Old, Credit_Qualification
1,   Pedro , 100, 50, 2-Good
2,   Maria , 140, 20, 1-Very Good
3,   Susana, 180, 90, 3-Poor
4,   John, 50, 35, 4-Bad
5,   Carlos, 70, 70, 5-Very Bad
6,  Sofia, 250, 10, 2-Good

And we want to show debtors in a bar chart where the expression is the amount owed, the dimension the debtor’s name, but we also want to show the age of the debt as follows: the oldest debt we will highlight with intense red color and vice versa, getting something like this:



Because Sofia has a quite new debt (10 days, low risk) will use a dimmed color, in contrast with a 90 days Susana’s debt showed with deep red.

To achieve this we will use the RGB function RGB(255, X, X) where 255 represents the red component and X is a function: while X is closest to 230 (maximum value) more faint result the color, and the more close to 0 (zero) more intense.

To do this add the following code to the script:

min(Days_Old) as minDaysOld,
max(Days_Old) as maxDaysOld
RESIDENT Receivables;

LET V_minDaysOld = Peek(‘minDaysOld’,0);
LET V_maxDaysOld = Peek(‘maxDaysOld’,0);

Drop Table MinMax;

 Finally we create an expression and use it in the “Background Color” from the main expression:


 Of course you can create color expression that is required, with more or less levels of complexity or assigning colors to age ranges, etc..

The important thing to remember here is another resource, the color, which can be used to display user’s valuable information.


Acerca de pparnisari
Casi 44 vueltas al sol. Licenciado en sistemas. Curioso, investigador, excelente para resolver problemas prácticos. Casado, 2 hijos, cada vez con mas preguntas y respuestas mas en duda. Almost 44 laps to the sun. System engineer. Curious, researcher, great for solving practical problems. Married, 2 children, each time with more questions and more answers in doubt.

Deja un comentario

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s

A %d blogueros les gusta esto: