program CovidStatistic_Plot_Validation31; //{$APPTYPE CONSOLE} - Refactor Separation of Concerns // Basescript for maXbox_starter85.pdf - Tutorial 85 //www.softwareschule.ch/download/maxbox_starter85.pdf //https://www.bbc.com/news/world-51235105 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 From_CloseClick(Sender: TObject; var action: TCloseAction); begin //afrm.Close; action:= cafree; writeln('Plotform closed at: '+datetimetostr(now)); end; function ConnectJSON_API: string; var XMLhttp: OleVariant; // AsObject begin XMLhttp:= CreateOleObject('msxml2.xmlhttp') XMLhttp.Open('GET', JSONUrl, False) XMLhttp.setrequestHeader('Content-Type','application/x-www-form-urlencoded'); XMLhttp.Send(); result:= XMLhttp.responseText; writeln('http status: '+vartostr(XMLhttp.status)); XMLhttp:= unassigned; end; function ChartInjector(aform: Tform): TChart; var Ser1: TFastLineSeries; //TPieSeries; begin result:= TChart.create(aform) with result do begin parent:= aform; align:= alClient; Title.Text.add('SciplotSerie: '+'Worldwide Covid21 Ø'); LeftAxis.Title.Caption:= 'Covid D Amount'; Title.font.size:= 20; Ser1:= TFastLineSeries.create(result); // TPieSeries ser1.parentchart:= result; Ser1.Marks.Visible:= true; //Free; end; end; procedure JSONPlot(form1: TForm); var chart1: TChart; ajt: TJson; JObj: TJsonObject2; JArr: TJsonArray2; response, clb: string; cnt,cnt2,tmp,tmp2, tmp3, sumup,sumup2, startC,stopC: integer; tmp3d: double; begin response:= ConnectJSON_API; //slice func like python startC:= pos('"'+COUNTRY1+'"',response); stopC:= pos('"'+COUNTRY2+'"',response); (*response:= Copy(response, startC, stopC-startC); response:= '{'+response+'}'; *) ajt:= TJson.create(); try ajt.parse(response); except writeln( 'Exception: "" parse error: {'+ exceptiontostring(exceptiontype, exceptionparam)) end; form1.onclose:= @From_CloseClick; JObj:= ajt.JsonObject; chart1:= ChartInjector(form1); clb:=''; sumup:=0; sumup2:=0; 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 tmp:= jarr.items[cnt2].asObject.values['deaths'].asinteger; tmp2:= jarr.items[cnt2].asObject.values['confirmed'].asinteger; PrintF(' %d: %d %s',[cnt,tmp,clb]); PrintF(' %d: %d %s',[cnt,tmp2,clb]); tmp3d:= tmp / tmp2; PrintF(' %d: %.4f %% ',[cnt,tmp3d * 100]); sumup:= sumup+tmp; sumup2:= sumup2+tmp2; chart1.Series[0].Addxy(cnt,tmp,itoa(tmp div 1000)+' '+clb,clgreen); end; end; PrintF(' WorldWide %d: Confirmed: %d', [ajt.count, sumup2]); PrintF(' WorldWide %d: Deaths: %d', [ajt.count, sumup]); PrintF(' WorldWide %d: Deathrate: %.4f', [ajt.count, (sumup / sumup2) *100]); ajt.Clear; ajt.Free; end; begin //@main //ValidateBitcoinAddress('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i'); 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 WorldWide 193: Confirmed: 169296672 WorldWide 193: Deaths: 3519492 WorldWide 193: Deathrate: 2.0789  mX4 executed: 29/05/2021 11:04:50 Runtime: 0:0:15.707 Memload: 71% use  mX4 byte code executed: 29/05/2021 11:28:51 Runtime: 0:0:13.969 Memload: 74% use ByteCode Success Message of: C:\maXbox\mX47464\maxbox4\examples\covidapp31.psb WorldWide 193: Confirmed: 171184588 WorldWide 193: Deaths: 3565105 WorldWide 193: Deathrate: 2.0826  mX4 executed: 02/06/2021 21:31:29 Runtime: 0:0:25.905 Memload: 69% use