Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
First, I want to apologize for this sort of question. I don’t have much respect for the pie charts in general, and even less for the 2-dimensional pies. But this is what our client has already, and they insist on keeping it. The problem is with the colors.
The color pallet is the same for the “internal” and “external” pies. Client wants the pies to have different colors. For example, internal pie (first dimension) using colors 1, 2, 3, and 4, and the external pie (second dimension) – colors 5, 6, and 7:
I tried a variety of approaches in the background color expression, but with no much success. The internal pie gets all same colors, or the external color repeats the first color of the internal pie.
Appreciate any ideas.
Thanks you,
Michael
PS: I can do it using combined “object” with overlapping pies, but looking for a cleaner solution, one object.
Starting from the second dimension you have to set personalized colours in the expression:
if you have for example
Country (first dim)
City (second dim)
you have to wtite in the expression:
If(City='new york', rgb(x,y,z),
...
if Country='France', rgb(a,b,c),
...
)
)
Hope it helps
Thanks for trying Alex,
I wish it were that's simple... First, your expression guarantees the same color for internal, and for at least the first external. Test, and see how it looks. Second, there is a logical gap - where do you insert conditions for the next city? Well, I can handle the second one, but it doesn't help. Besides, we have the same values of the 2nd dimesion within each value of the first dimension.
I'm attaching an example, in case anyone wants to test. It contains the exact number of values in my dimensions - 4 in Dim1, and 3 in Dim2.
Thanks,
Michael
Edit: Using the previously attched example. Expression starting with Dim2
if(Dim2='X',
if(Dim1='A', color(1),
if(Dim1='B', color(2),
if(Dim1='C', color(3),
if(Dim1='D', color(4), color(5))))),
if(Dim2='Y',
if(Dim1='A', color(1),
if(Dim1='B', color(2),
if(Dim1='C', color(3),
if(Dim1='D', color(4), color(6))))),
if(Dim2='Z',
if(Dim1='A', color(1),
if(Dim1='B', color(2),
if(Dim1='C', color(3),
if(Dim1='D', color(4), color(7)))))
)))
Results is this, using only colors 1 to 4:
An opposit approach:
if(Dim1='A',
if(Dim2='X', color(5),
if(Dim2='Y', color(6),
if(Dim2='Z', color(7), color(1)))),
if(Dim1='B',
if(Dim2='X', color(5),
if(Dim2='Y', color(6),
if(Dim2='Z', color(7), color(2)))),
if(Dim1='C',
if(Dim2='X', color(5),
if(Dim2='Y', color(6),
if(Dim2='Z', color(7), color(3)))),
if(Dim1='D',
if(Dim2='X', color(5),
if(Dim2='Y', color(6),
if(Dim2='Z', color(7), color(4))))
))))
Gives this, using colors 5 to 7:
Both worse than no expression at all.
This one is the closest to the desired result. The remaining problem - the first value of the second dimension takes color from the first dimension. Interestingly, the colors in legend are correct:
if(aggr(count(distinct Dim2),Dim1)>1,
if(Dim1='A', color(4),
if(Dim1='B', color(5),
if(Dim1='C', color(6),
if(Dim1='D', color(7)))))
,
if(Dim2='X', color(1), // this part doesn't work
if(Dim2='Y', color(2),
if(Dim2='Z', color(3))))
)
Moving up...