const getPiePosition = (indx, total) => {
var p = {
radius: '',
center: ['', '']
};
if (total === 1) {
p.radius = '75%';
p.center = ['50%', '50%'];
}
else if (total === 2) {
p.radius = '50%';
if (indx === 0) {
p.center = ['25%', '50%'];
}
else {
p.center = ['75%', '50%'];
}
}
else if (total === 3) {
p.radius = '45%';
if (indx === 0) {
p.center = ['25%', '33%'];
}
else if (indx === 1) {
p.center = ['75%', '33%'];
}
else {
p.center = ['50%', '75%'];
}
}
else if (total === 4) {
var inx = indx % 2;
var ix = Math.floor(indx / 2);
p.radius = '40%';
p.center[0] = inx === 0 ? '25%' : '75%';
p.center[1] = ix === 0 ? '30%' : '75%';
}
else {
var inx = indx % 3;
var ix = Math.floor((indx + 1) / 3);
p.radius = '35%';
if (ix === 0) {
p.center[1] = '25%';
}
else {
p.center[1] = '75%';
}
if (inx === 0) {
p.center[0] = '25%';
}
else if (inx === 1) {
p.center[0] = '75%';
}
else {
p.center = ['50%', '50%'];
}
}
return p;
}
var d = getPiePosition(4, 5);
console.log(d)
console