The Egg graph

So I wanted to generate a scatter chart in QLIKVIEW that visualized the outline of an egg... because it is Easter.

This is the result and how I did it....

 My first goal was to understand how to generate data that would make the grey pattern in the background.

That was easy by using the Rand() function in QLIKVIEW.

Set vRandA_Max = Rand() * (100-80) + 80;
Set vRandA_Min = Rand() * (50-20) + 20;
Set vRandB_Max = Rand() * (110-90) + 90;
Set vRandB_Min = Rand() * (30-5 ) + 5;

set fxGaussianRandomA = sqrt(-2*log(rand())) * cos(2* pi() * rand());
set fxGaussianRandomB = sqrt(-2*log(rand())) * cos(2* pi() * rand());

Data:
LOAD
     RowNo() as Id,
     Rand() * ($(vRandA_Max)-$(vRandA_Min) ) + $(vRandA_Min) + 40 AS A,
     Rand() * ($(vRandB_Max)-$(vRandB_Min) ) + $(vRandB_Min) + 40 AS B
AUTOGENERATE 100;
  
Concatenate(Data)
LOAD
  RowNo() as Id,
  FABS(($(fxGaussianRandomA) * $(vRandA_Max)) + $(vRandA_Min)) AS A,
    FABS(($(fxGaussianRandomB) * $(vRandB_Max)) + $(vRandB_Min)) AS B
AUTOGENERATE 1000;   

 

Next challenge was to create the circular data. To do this I had to dig back into my old Math skills from the school days.... but I came to this solution and it worked great:

Let vCircleCenterA = 120;
Let vCircleCenterB = 100;
Let vCircleRadius = 40;


for x=-$(vCircleRadius)+$(vCircleCenterA) to $(vCircleRadius)+$(vCircleCenterA)

 Concatenate(Data)
 LOAD
  RowNo() as Id,
  $(x) as A,  
  $(vCircleCenterB)+sqrt(sqr($(vCircleRadius)) - sqr(($(x)-$(vCircleCenterA)))) as B
 AutoGenerate 1;
Next x;

for x=-$(vCircleRadius)+$(vCircleCenterA) to $(vCircleRadius)+$(vCircleCenterA)

Concatenate(Data)
LOAD
   RowNo() as Id,
   $(x) as A,  
   $(vCircleCenterB)-sqrt(sqr($(vCircleRadius)) - sqr(($(x)-$(vCircleCenterA))))  as B
 AutoGenerate 1;
Next x;

 

That's all it takes. I added a field called "Type" in the Data table to be able to color the different "dots" in the scatterchart separately.

I wish you all a happy Easter!