Version:0.9 StartHTML:0000000105 EndHTML:0000021649 StartFragment:0000001053 EndFragment:0000021633 mXScriptasHTML
program CovidStatistic_Plot_Validation;
//{$APPTYPE CONSOLE}
// Basescript for maXbox_starter85.pdf - Tutorial 85
//www.softwareschule.ch/download/maxbox_starter85.pdf

Const
   JSONUrl = 'https://pomber.github.io/covid19/timeseries.json';
   COUNTRY1 = 'Afghanistan';  //first: Afghanistan 'Sweden'; Germany Afghanistan     
   COUNTRY2 = 'Zimbabwe';    //last: Zimbabwe
   COUNTRY3 = 'Brazil';      //delete filter
  

procedure JSONPlot(form1: TForm);
var  XMLhttp: OleVariant; // AsObject
     ajt: TJson; JObj: TJsonObject2; JArr: TJsonArray2; 
     chart1: TChart; Ser1: TFastLineSeries; //TPieSeries;    
     response, clb: string; 
     cnt,cnt2,itmp,sumup, startC,stopC: integer;
begin
  XMLhttp:= CreateOleObject('msxml2.xmlhttp')
  XMLhttp.Open ('GET', JSONUrl, False)
  XMLhttp.setrequestHeader('Content-Type','application/x-www-form-urlencoded');
  XMLhttp.Send();
  response:=  XMLhttp.responseText; 
  writeln('http status: '+vartostr(XMLhttp.status)); 
  
  //slice func like python
  startC:= pos('"'+COUNTRY1+'"',response);  
  stopC:= pos('"'+COUNTRY2+'"',response);  
  //AnsiDelete(response, startC, stopC-startC);
  (*response:= Copy(response, startC, stopC-startC);
  response:= '{'+response+'}'; *)
  ajt:= TJson.create();
  try
    ajt.parse(response);
  except
     writeln( 'Exception: <TJson>"" parse error: {'+
     exceptiontostring(exceptiontype, exceptionparam)) 
  end;  
 
  JObj:= ajt.JsonObject;
  chart1:= TChart.create(form1) 
  chart1.parent:= form1;
  chart1.align:= alClient;
  chart1.Title.Text.add('SciplotSerie: '+'Worldwide Covid21 Ø');
  chart1.LeftAxis.Title.Caption:= 'Covid D Amount';
  chart1.Title.font.size:= 20;
  clb:=''; sumup:= 0;
  Ser1:= TFastLineSeries.create(chart1); //  TPieSeries
  ser1.parentchart:= chart1
  Ser1.Marks.Visible:= true;
             
  for cnt:= 0 to jobj.count-1 do begin
    clb:= Jobj.items[cnt].name
    JArr:= ajt.values[clb].asarray;
    for cnt2:= jarr.count-1 to jarr.count-1 do begin
      PrintF(' %d: %s ',
         [cnt,jarr.items[cnt2].asObject.values['confirmed'].asstring+' '+clb]);
      itmp:=jarr.items[cnt2].asObject.values['deaths'].asinteger;
      sumup:= sumup+itmp
      chart1.Series[0].Addxy(cnt,itmp,itoa(itmp div 1000)+' '+clb,clgreen);
    end; 
  end;
 writeln('Worldwide: '+itoa(ajt.count)+' Covid Countries D: '+itoa(sumup));
 XMLhttp:= unassigned;
 ajt.Clear;
 ajt.Free;
 //Chart1.Free;
end; 
      
begin //@main  
  //ValidateBitcoinAddress('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i');
  //ValidateBitcoinAddress('1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9');
  
     JSONPlot(getForm2(1200, 600, clGreen, 'Sciplot4'));  
End.

ref: http://www.teechart.net/docs/teechart/vcl/TChart.0Methods.html 

https://www.buybitcoinworldwide.com/how-many-bitcoins-are-there/

 mX4 executed: 15/03/2021 20:43:46  Runtime: 0:0:4.531  Memload: 63% use
 mX4 executed: 07/05/2021 13:02:28  Runtime: 0:0:15.610  Memload: 72% use
 mX4 executed: 07/05/2021 13:04:10  Runtime: 0:0:14.329  Memload: 67% use