ObjectProfile / Roassal3

The Roassal Visualization Engine
MIT License
95 stars 52 forks source link

Adding proper heatmaps #562

Closed Inao0 closed 1 year ago

Inao0 commented 1 year ago

An example of heatmap :

image

What is already existing :

In Roassal there is the RSDSM (Dependency structural matrix) which is the closest thing to a heatmap. There is also, in a package not loaded, RSHeatmap which is outdated and inherits directly from Object (Still works though). For now, the RSDSM name is quite cryptic and for someone looking for a heatmap, this is going to be hard to find.

Differences in APIs :

Expected APIs are different. This is the second example for RSDSM:

example02Numbers
        | dsm |
    dsm := RSDSM new.
    dsm objectsX: (1 to: 10).
    dsm objectsY: (1 to: 10 by: 2).
    dsm dependency: [ :aValue | aValue // 2 ].
    ^ dsm

Here we can see here that DSM takes objects, either one list for both axis or two different lists, and a dependency bloc that given an object will return which objects it depends on (either one object or a list of objects). Cells that are at the intersection of rows and columns will be colored. The colors can be altered by giving a block able to compute the color of a cell from a the tuple of the row object and column object.

In a heatmap, the expected API would be something like this:

example
    | h |
    h := RSHeatmap new.
    h objectsX: #('A' 'B' 'C').
    h objectsY: #('tomato' 'pumpkin').
        h dataMatrix:  #(#(1 2 5) #(3 4 6)).
        ^ h dataMatrice

The objects on the axis could be only labels if it's simpler. We do not need the objects to compute dependencies, the color of a scale is a number inside the matrix and the position is already determined. Maybe the heatmap could take a block to calculate the value matrix, in this case, labels would not be enough, and objects would be required.

Default values

Some more examples of heatmaps : https://chartio.com/learn/charts/heatmap-complete-guide/

akevalion commented 1 year ago

Hi, I have added class RSHeatmap in package Roassal3-DSM There are 3 new examples about this:

| builder |
builder := RSHeatmap new.
builder objectsX: #('A' 'B' 'C').
builder objectsY: #('tomato' 'pumpkin').
builder dataMatrix: #(#(1 2 5) #(3 4 6)).
^ builder
image

Example with months

image

And with vegetables

image

About these points

akevalion commented 1 year ago

@Inao0 can we close this issue?

Inao0 commented 1 year ago

Yes, perfect, thanks :)