worlddata=Import["https://covid.ourworldindata.org/data/owid-covid-data.csv"];

font="Helvetica Neue";

(*names={"Japan","Taiwan","Australia","United States","United Kingdom","India","France","Germany","Italy","New Zealand","Brazil","South Korea","Sweden","Thailand","China"};*)
names={"Japan","Taiwan","Australia","United States","United Kingdom","India","Italy","New Zealand","South Korea","Sweden","China"};
names={"Japan","Taiwan","United States"};

namesLabel=names;

(*names={"Japan","Taiwan","Malaysia","Thailand","Vietnam","India","Indonesia","Mongolia","Singapore","Philippines","South Korea","China"};
namesLabel={"日本","台湾","マレーシア","タイ","ベトナム","インド","インドネシア","モンゴル","シンガポール","フィリピン","韓国","中国"};
namesLabel=names;*)

font="Helvetica Neue";
fontsize=12;

startdate={2020,3,20};
enddate={2021,8,30};

tagoff=0.5;
startdateObj=DateObject[startdate];
date=4;
newDeathsSmoothed=10;
newDeathsSmoothedPerMillion=16;
newCasesSmoothedPerMillion=13;
newCasesSmoothed=7;
newCases=6;
elm=newDeathsSmoothed;
title=worlddata[[1,elm]];
pos0={0,0};
radius=Log[10]/Pi;
tag={1,10,100,1000,10000};
tagtext={1,10,100,1000,10000};

tagoff=0.5;
zeropx=-0.5;
kmax=Length[names];
dataTmp=Table[Cases[worlddata,x_?(#1[[3]]==names[[k]]&)][[All,{date,elm,newCasesSmoothedPerMillion}]],{k,1,kmax}];
data=Table[DeleteCases[dataTmp[[k]],x_?(DateObject[#1[[1]]]<startdateObj&)],{k,1,kmax}];
colors=If[kmax==1,{Red},Table[ColorData["Rainbow"][(k-1)/(kmax-1)],{k,1,kmax}]];
minvalue=tag[[1]]/2;
maxvalue=2Last[tag];

title

slopepos[val_,h_]:=pos0+{Cos[slopeangle]*val+h*Sin[slopeangle],(-Sin[slopeangle])*val+h*Cos[slopeangle]}
line[x_,angle_]:=With[{},{{x[[1]]+radius*Cos[-angle+Pi/2-slopeangle],x[[2]]+radius*Sin[-angle+Pi/2-slopeangle]},{x[[1]]-radius*Cos[-angle+Pi/2-slopeangle],x[[2]]-radius*Sin[-angle+Pi/2-slopeangle]}}];

slope:=Show[Graphics[Table[Text[Style[tagtext[[i]],10,Black,FontFamily->font],slopepos[Log[tag[[i]]],-tagoff]],{i,1,Length[tag]}]],Graphics[Text[Style[0,10,Black,FontFamily->font],slopepos[Log[minvalue],0]+{zeropx,-0.2}]],Graphics[Line[{slopepos[Log[minvalue],0],slopepos[Log[maxvalue],0]}]],Graphics[Line[{slopepos[Log[minvalue],0],slopepos[Log[minvalue],0]-{10,0}}]],Graphics[Table[Line[{slopepos[Log[tag[[i]]],0],slopepos[Log[tag[[i]]],-0.2]}],{i,1,Length[tag]}]],Graphics[Table[Table[Line[{slopepos[Log[k*tag[[i]]],0],slopepos[Log[k*tag[[i]]],-0.1]}],{k,1,10}],{i,1,Length[tag]-1}]]];

dotstore=Table[0.98radius Cases[Table[{2Random[]-1,2Random[]-1},{i,1,100000}],x_?(Norm[#1]<1&)],{k,1,kmax}];

ball[val_,k_]:=Module[{pos,ang,tpos,dotnumber,dots,dn},
Show[
If[val≤minvalue,
cntzero++;
pos=slopepos[Log[minvalue],0]+{zeropx-cntzero*0.05,0}+{0,radius};
ang=-cntzero*0.05/radius-slopeangle ;
tpos=slopepos[Log[minvalue],0]+{-cntzero*0.6,2.3radius},
pos=slopepos[Log[val],radius];
ang=Log[val]/radius;
tpos=slopepos[Log[val],2.3*radius]];

dotnumber=Round[val];
dots={};
While[Length[dots]<dotnumber,
rpos={1,1};
While[Norm[rpos]>1,rpos={2Random[]-1,2Random[]-1}];
AppendTo[dots,rpos]];
Graphics[{colors[[k]],Opacity[0.1],EdgeForm[{colors[[k]],Thickness[Medium]}],Disk[pos,radius]}],
(*dots=Table[dotstore[[k,j]],{j,1,dotnumber}];*)
(*Graphics[Rotate[Table[{colors[[k]],Disk[pos+dots[[j]],0.03]},{j,1,dotnumber}],-ang,pos]],*)
Graphics[Table[{colors[[k]],Disk[pos+radius dots[[j]],0.02]},{j,1,dotnumber}]],
Graphics[{colors[[k]],Line[line[pos,ang]]}],
Graphics[Rotate[Text[Style[namesLabel[[k]],12,colors[[k]],FontFamily->font],tpos,Left],0,tpos]]]]

xmin=N[slopepos[Log[minvalue],0]][[1]]-2;
xmax=N[slopepos[Log[maxvalue],0]][[1]]+2;
ymin=N[slopepos[Log[maxvalue],0]][[2]]+1;
ymax=N[slopepos[Log[minvalue],0]][[2]]+2;
mainplotrange={{xmin,xmax},{ymin,ymax}}

slopeangle=Pi/4;
tskip=0.5;
posinset={xmin+2.5,ymin+1.8};
textpos={xmax-3,ymax-0.2};
pltalldeath=DateListLogPlot[data[[All,All,2]],startdate,FrameStyle->Directive[9,Black,FontFamily->font],Frame->True,PlotStyle->Table[{Thickness[0.005],colors[[k]]},{k,1,kmax}],PlotRange->{{startdate,enddate},{0.1,5000}},ImageSize->160];
output=
Table[cntzero=-1;plt=Show[pltalldeath,DateListLogPlot[{{DateObject[data[[1,i,1]]],(10^(-4))},{DateObject[data[[1,i,1]]],(10^8)}},startdate,PlotStyle->{{Black,Thickness[0.007]}},Joined->True]];
Show[slope,Table[ball[data[[k,i,2]],k],{k,1,kmax}],
Graphics[Inset[Graphics[plt],posinset]],Graphics[Text[Style[title,fontsize,Black,FontFamily->font],textpos]],Graphics[Text[Style[data[[1,i,1]],fontsize,Black,FontFamily->font],textpos-{0,tskip}]],Graphics[Text[Style["data: covid.ourworldindata.org",fontsize,Black,FontFamily->font],textpos-{0,2tskip}]],
PlotRange->mainplotrange],{i,1,Length[data[[1]]]}];
outputMovie=Join[output,Table[Last[output],{j,1,30}]];
Last[outputMovie]

Export["~/world_"<>title<>ToString[kmax]<>".mp4",outputMovie]

Export["~/world_death_per_M.mp4",outputMovie]

(*Export["~/asia_cases_per_M.mp4",outputMovie]*)

title