Lazarus

Announcements => Third party => Topic started by: wp on March 19, 2020, 06:04:53 pm

Title: Corona outbreak
Post by: wp on March 19, 2020, 06:04:53 pm
The Johns Hopkins University, Baltimore, publishes current counts of confirmed and recovered cases as well as deaths in the Corona outbreak for many countries. I wrote a little program which downloads the time-series values and displays them graphically in a TChart. I know that such programs can be found in the web at many places now, but having the data immediately available makes the program very agile. And there is an option to use a logarithmic scale for cumulative data which allows to detect when the currently exponential increase of cases begins to level out hopefully. And holding the CTRL key and left mouse button down, and dragging the mouse across data points allows to fit an exponential curve to the data points; the time for doubling the case counts as well as an estimage of the case count in 1 and 2 weeks are displayed in the status bar.

The attached screenshot compares the growth of confirmed cases for China/Hubei, South Korea, Iran, Italy and Germany. The line fitted to the exponential plot of Germany, extrapolated two weeks into the future, tells that there will be 400.000 confirmed cases then if the current measures fail (and if testing capacity will be sufficient to handle this).

The sources can be found on my github at https://github.com/wp-xyz/corona.git and can be compiled with Laz trunk or 2.0.6 and FPC trunk or 3.0.4 (others combinations not tested). I am developing on Windows, but I checked the program to run on Linux (Mint) and Mac (Mojave), too. For access to the Johns Hopkins server, the OpenSSL library must be available on the system; for Windows users, the libeay32.dll and ssleay32.dll must be available in the exe folder with the correct bitness.
Title: Re: Corona outbreak
Post by: Otto on March 19, 2020, 06:45:25 pm
Hello wp, thank you for sharing your work.

I wanted to ask whether the data on deaths also include age of previous diseases or additional parameters to better understand Covid-19's behaviour.

Otto.
Title: Re: Corona outbreak
Post by: wp on March 19, 2020, 07:08:33 pm
I am not a specialist here, but I am pretty sure that it is the total of persons who died due to Covid-19, no matter how old they were and which previous diseases they had. There are other documents on that site (https://github.com/CSSEGISandData/COVID-19) which you can study to get more detail, but probably you will also have to look at the main site of JHU or that of WHO. I only used this site because data are nicely accessible and can be downloaded easily.
Title: Re: Corona outbreak
Post by: BeanzMaster on March 19, 2020, 07:39:30 pm
Hi wp thanks for sharing

I've got some sigsev

Those lines are the problems:

Code: Pascal  [Select][+][-]
  1. sa[0] := AnsiDequotedStr(sa[0], '"');
  2. sa[1] := AnsiDequotedStr(sa[1], '"');

Solved by just comment

My configuration is W10 64 bits and Lazarus 2.0.6 SVN 62129 and FPC 3.0.4

Best regards

Title: Re: Corona outbreak
Post by: wp on March 19, 2020, 07:43:07 pm
Which country did you select?
Title: Re: Corona outbreak
Post by: BeanzMaster on March 19, 2020, 07:52:00 pm
Which country did you select?

None. The exception is thrown at the begining in TMainForm.LoadLocations and in TMainForm.GetDataString when selecting any country

After comment those line all work very well

[EDIT] I've checked the csv all are unquoted except some but not many
Title: Re: Corona outbreak
Post by: wp on March 19, 2020, 08:03:55 pm
Cannot reproduce... Your Laz/FPC versions? OS/Widgetset? 32/64 bit?
Title: Re: Corona outbreak
Post by: BeanzMaster on March 19, 2020, 08:04:20 pm
When the exception is raised i'm only see ASM windows, and point to  function AnsiDequotedStr(const S: string; AQuote: Char): string; 

By replacing with this quick function


Code: Pascal  [Select][+][-]
  1. Function MyDequotedStr(s: string) : String;
  2. var
  3.   i: integer;
  4. begin
  5.   Result :='';
  6.   for i:= 0 to length(s)-1 do
  7.   begin
  8.     if s[i]<>'"' then result := result + s[i];
  9.   end;
  10. end;  

All is fine
Title: Re: Corona outbreak
Post by: BeanzMaster on March 19, 2020, 08:05:35 pm
My OS Win10 64
Lazarus 2.0.6 SVN 62129
FPC 3.0.4
Title: Re: Corona outbreak
Post by: jwdietrich on March 19, 2020, 08:29:15 pm
The program compiles and runs well, even on the Mac, on both Carbon and Cocoa widgetsets.

This is a very interesting initiative that helps understanding the dynamics of COVID-19. Is it possible to display cumulative data for the whole planet? This would be especially instructive by revealing a more or less clear exponential relationship.
Title: Re: Corona outbreak
Post by: RAW on March 19, 2020, 08:43:33 pm
Sorry, I couldn't deny myself, so just ignore me, but there is no immune system (yeah, it's just a lie!). Free your mind and relax! Yes, this is an one post only ... (Truth is important, at least for me!) ... and now I'm calm again... enjoy the show...  :).
Title: Re: Corona outbreak
Post by: howardpc on March 19, 2020, 08:56:12 pm
Another good, well-researched site with reliable information is
https://healthmap.org/en/ (https://healthmap.org/en/)
Although it seems at first to be restricted to the UK, it also has up-to-date information from across the globe (see COVID-19 outbreak news).
The "Animate spread" button on the page
https://healthmap.org/covid-19/ (https://healthmap.org/covid-19/)

is particularly illuminating, showing the worldwide spread of the virus since its first appearance in China.
Title: Re: Corona outbreak
Post by: Otto on March 19, 2020, 09:28:32 pm
I am not a specialist here, but I am pretty sure that it is the total of persons who died due to Covid-19, no matter how old they were and which previous diseases they had. There are other documents on that site (https://github.com/CSSEGISandData/COVID-19) which you can study to get more detail, but probably you will also have to look at the main site of JHU or that of WHO. I only used this site because data are nicely accessible and can be downloaded easily.

Thank you wp for the answer.

I compiled the program and everything works regularly (Windows 10 64bit; FPC 3.0.4; Laz 2.0.6).
However, I've had problems with OpenSSL. Which version would you advise me to use?

Otto.
Title: Re: Corona outbreak
Post by: wp on March 19, 2020, 10:20:16 pm
The exception is thrown at the begining in TMainForm.LoadLocations and in TMainForm.GetDataString when selecting any country
OK, it happens on 64-bit Windows. Fixed.

I compiled the program and everything works regularly (Windows 10 64bit; FPC 3.0.4; Laz 2.0.6).
However, I've had problems with OpenSSL. Which version would you advise me to use?

https://forum.lazarus.freepascal.org/index.php/topic,46560.msg332387.html#msg332387 points to 32bit and 64 bit versions of the openssl dlls. You need the version which matches the bitness of your IDE (unless you are cross-compiling).

Is it possible to display cumulative data for the whole planet? This would be especially instructive by revealing a more or less clear exponential relationship.
It looks to me that the dataset used seems to contain both areas and sub-areas, I saw that US cities are contained together with their states which would count these cities twice. These cities are filtered out in my program, but I cannot guarantee that duplicates do not occur anywhere else.

I doubt that the global total sum is an exponential because the outbreaks sets in at different times and with different intensities, and in some countries (China, South Korea) the case count does not grow any more noticably.

See for example https://www.worldometers.info/coronavirus/ which can be switched to logarithmic scale.
Title: Re: Corona outbreak
Post by: Otto on March 19, 2020, 10:48:40 pm
https://forum.lazarus.freepascal.org/index.php/topic,46560.msg332387.html#msg332387 points to 32bit and 64 bit versions of the openssl dlls. You need the version which matches the bitness of your IDE (unless you are cross-compiling).

Perfect, It all works properly now.

I would suggest adding the link to the openssl dlls on your project's GitHub web page.

Thank you again for sharing your work.

Otto.
Title: Re: Corona outbreak
Post by: VTwin on March 19, 2020, 11:30:47 pm
Wow, very nice.
Title: Re: Corona outbreak
Post by: Dimitrios Chr. Ioannidis on March 19, 2020, 11:40:18 pm
I had to add opensslsockets to be able to download new data .

I'm using trunk

Lazarus version: 2.1.0
Lazarus svn revision: 62768
Lazarus build date: 2020/03/16
Lazarus was compiled for x86_64-win64

FPC executable:
CompilerDate=5/1/2020 20:00:02
RealCompilerDate=5/1/2020 19:55:44
RealTargetOS=win64
RealTargetCPU=x86_64
Version=3.3.1
Title: Re: Corona outbreak
Post by: wp on March 20, 2020, 12:04:59 am
I had to add opensslsockets to be able to download new data .
Thanks. Fixed.
Title: Re: Corona outbreak
Post by: circular on March 20, 2020, 11:26:05 am
Nice tool to follow the progression of the pandemic.
Title: Re: Corona outbreak
Post by: dbannon on March 20, 2020, 12:32:21 pm
but I checked the program to run on Linux (Mint) and Mac (Mojave), too. For access to the Johns Hopkins server, the OpenSSL library ...

I needed Getmem's tricks to get the downloader to work on FPC304 and Lazarus Fixes :

https://forum.lazarus.freepascal.org/index.php/topic,46560.15.html

But sadly, no data for the land of Oz....

Davo
Title: Re: Corona outbreak
Post by: zeljko on March 20, 2020, 01:19:48 pm
It works here out of the box. Lazarus trunk, fpc-3.0.4, Fedora 64bit, Qt5 widgetset.
Title: Re: Corona outbreak
Post by: wp on March 20, 2020, 02:29:20 pm
I needed Getmem's tricks to get the downloader to work on FPC304 and Lazarus Fixes :
https://forum.lazarus.freepascal.org/index.php/topic,46560.15.html
What was the issue? And how exactly did you fix it? What is your OS/widgetset? 32/64 bit? Do you use the latest revision from my github?
Title: Re: Corona outbreak
Post by: wp on March 20, 2020, 02:49:54 pm
no data for the land of Oz....
You mean the US? The JHU files do not contain the total, only the values of individual states. Look at US > New York with today's data: there is a doubling time of around 1 day! Mr. Trump will have a huge problem.
Title: Re: Corona outbreak
Post by: howardpc on March 20, 2020, 02:51:38 pm
I think he means Australia
Title: Re: Corona outbreak
Post by: wp on March 20, 2020, 03:16:16 pm
I think he means Australia
Oh. Like for the US, there is no total of Australia, only its states are listed. Being used to the numbers in Europe these numbers appear pretty low, but almost everywhere there is exponential growth with doubling times in the order of a few days. So, in a few weeks they will be at our levels if nothing happens.
Title: Re: Corona outbreak
Post by: dbannon on March 20, 2020, 11:32:03 pm
I needed Getmem's tricks to get the downloader to work on FPC304 and Lazarus Fixes :
https://forum.lazarus.freepascal.org/index.php/topic,46560.15.html
What was the issue? And how exactly did you fix it? What is your OS/widgetset? 32/64 bit? Do you use the latest revision from my github?

Add to interface Uses :
Code: Pascal  [Select][+][-]
  1. fpopenssl, ssockets, sslsockets;

Added this function :
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.GetSocketHandler(Sender: TObject; const UseSSL: Boolean; out
  2.   AHandler: TSocketHandler);
  3. begin
  4.   AHandler := TSSLSocketHandler.Create;
  5.   TSSLSocketHandler(AHandler).SSLType := stTLSv1_2;
  6. end;

Set the above proc as a new handler (and note DownloadFile() now a class method, easier) :
Code: Pascal  [Select][+][-]
  1. function TMainForm.DownloadFile(const Url: string; AStream: TStream): Boolean;
  2. .....
  3.   try
  4.     http.OnGetSocketHandler := @GetSocketHandler;                 <<  Add this line
  5.     http.AllowRedirect := true;
  6. .....

I think thats it.  I am on Linux, Ubuntu 18.04, using GTK2. Lazarus Fixes and unpatched FPC 304.  I use this approach in my app, been extensively tested on Linux and Windows. Windows still need the dlls of course.  Does not work on my relatively old Mac Sierra.

And, yes, I was interested in Australian data, sorry, it took me awhile to realize that it was a fully functional tree view !

Nice work. I hink we all feel just a little threatened if we can understand the process a little !

Davo
Davo
Title: Re: Corona outbreak
Post by: wp on March 20, 2020, 11:53:52 pm
Thanks. But why is the download from github working for me on Linux Mint/32bit/gtk2 with Laz trunk/unpatched fpc3.0.4 without your changes? These SSL issues really are annoying. I must say, though, that I don't understand much of SSL.
Title: Re: Corona outbreak
Post by: dbannon on March 21, 2020, 02:04:44 am
I agree with all three statements !

I understand there is some issues relating to the distros stepping back from openssl3 but details beyond the event horizon.

I (would have) expected all maintained distros to be using pretty much the same version now given no one wants to be too far ahead or behind.

Davo
Title: Re: Corona outbreak
Post by: Thaddy on March 21, 2020, 10:36:15 am
Saturday morning:
Code: Text  [Select][+][-]
  1. Well Corona she runs a country
  2. She runs in Durban and the Transvaal
  3. She makes a few of her people happy oh
  4. She don't care about the rest at all
  5. She's got a system they call apartheid
  6. It keeps a brother in subjection
  7. But maybe pressure can make Corona see
  8. How everybody could live as one
  9. Gimme hope Corona
  10. Hope Corona
  11. Gimme hope Corona
  12. 'Fore the morning come
  13. Gimme hope Corona
  14. Hope Corona
  15. Hope before the morning come
  16. I hear she make all the golden money
  17. To buy new weapons any shape of guns
  18. While every mother in black Soweto fears
  19. The killing of another son
  20. Sneakin' across all the neighbours' borders
  21. Now and again having little fun
  22. She doesn't care if the fun and games she play
  23. Is dang'rous to ev'ryone
  24. Gimme hope Corona
  25. Hope Corona
  26. Gimme hope Corona
  27. 'Fore the morning come
  28. Gimme hope Corona
  29. Hope Corona
  30. Hope before the morning come
  31. She's got supporters in high up places
  32. Who turn their heads to the city sun
  33. Corona give them the fancy money
  34. Oh to tempt anyone who'd come
  35. She even knows how to swing opinion
  36. In every magazine and the journals
  37. For every bad move that this Corona makes
  38. They got a good explanation
  39. Gimme hope Corona
  40. Hope Corona
  41. Gimme hope Corona
  42. 'Fore the morning come
  43. Gimme hope Corona
  44. Hope Corona
  45. Hope before the morning come
  46. Gimme hope Corona
  47. Hope Corona
  48. Gimme hope Corona
  49. 'Fore the morning come
  50. Gimme hope Corona
  51. Hope Corona
  52. Hope before the morning come
  53. Even the preacher who works for Jesus
  54. The Archbishop who's a peaceful man
  55. Together say that the freedom fighters
  56. Will overcome the very strong
  57. I wanna know if you're blind Corona
  58. If you wanna hear the sound of drums
  59. Can't you see that the tide is turning
  60. Oh don't make me wait till the morning come
  61. Gimme hope Corona
  62. Hope Corona
  63. Gimme hope Corona
  64. 'Fore the morning come
  65. Gimme hope Corona
  66. Hope Corona
  67. Hope before the morning come
  68. Gimme hope Corona
  69. Hope Corona
  70. Gimme hope Corona
  71. 'Fore the morning comes
  72. Gimme hope Corona
  73. Hope Corona
  74. Hope before the morning come
  75. Gimme hope Corona
  76. Hope Corona
  77. Gimme hope Corona
  78. 'Fore the morning comes
  79. Gimme hope Corona
  80. Hope Corona
  81. Hope before the morning come

We played it yesterday, I hope Eddy Grant is not a member....
Title: Re: Corona outbreak
Post by: gcarreno on March 21, 2020, 08:09:11 pm
I (would have) expected all maintained distros to be using pretty much the same version now given no one wants to be too far ahead or behind.

What I've experienced is that from OpenSSL 1.0.x to 1.1.x it goes BOOM.

Under Ubuntu 19.10 64bits:
I have libssl3.so, libssl.s0.1.0.0 and libssl.s0.1.1 with libssl.so symlinked to libssl.so.1.1 and it goes BOOM. If I symlink to libssl.so.1.0.0 all is fine.

So it must be a backwards compatability issue with the SSL API from 1.0.x to 1.1.x.

Cheers,
Gus
Title: Re: Corona outbreak
Post by: Fred vS on March 21, 2020, 10:45:52 pm
About OpenSLL problems (and similar) this is the guilty:

https://bugs.freepascal.org/view.php?id=32367

I really hope than one day (or year or century or millennium) it will be fixed (all the fixes are there, ready to be committed).

Fre;D
Title: Re: Corona outbreak
Post by: dbannon on March 21, 2020, 11:42:12 pm
I really hope than one day (or year or century or millennium) it will be fixed (all the fixes are there, ready to be committed).

I think all the problems are fixed in FPC320, just not something that can or should be retro fitted to FPC304.  So, what you are hoping for is FPC320 to be formally released. That would be nice.

Davo
Title: Re: Corona outbreak
Post by: Fred vS on March 21, 2020, 11:52:45 pm
Quote
I think all the problems are fixed in FPC320,

Are you talking about the "so.num" problems?:
https://bugs.freepascal.org/view.php?id=32367

In the last fork I did today of fpc 3.2.0 beta, it was not yet fixed (the same for fpc 3.3.1 trunk).

Fre;D
Title: Re: Corona outbreak
Post by: dbannon on March 22, 2020, 08:13:57 am
Quote
I think all the problems are fixed in FPC320,

Are you talking about the "so.num" problems?:
https://bugs.freepascal.org/view.php?id=32367

In the last fork I did today of fpc 3.2.0 beta, it was not yet fixed (the same for fpc 3.3.1 trunk).

Fre;D

No, the discussion was about OpenSSL and its issues in 3.0.4 using certain newer protocols.  Perhaps my 'all the problems" was a little expansive.

Davo
Title: Re: Corona outbreak
Post by: Dimitrios Chr. Ioannidis on March 24, 2020, 01:34:36 pm
Hi,
 
  a little ssl ( again ) fix to compile corona with fpc trunk ...

Code: Diff  [Select][+][-]
  1.  source/cmain.pas | 7 ++++++-
  2.  1 file changed, 6 insertions(+), 1 deletion(-)
  3.  
  4. diff --git a/source/cmain.pas b/source/cmain.pas
  5. index e788b09..28fef7e 100644
  6. --- a/source/cmain.pas
  7. +++ b/source/cmain.pas
  8. @@ -160,7 +160,7 @@ uses
  9.    Math, IniFiles,
  10.    OpenSSL,
  11.    {$IF FPC_FullVersion >= 30200}        // needed for SSL to work in general
  12. -  OpenSSLSockets, FpHttpClient,
  13. +  sslbase, OpenSSLSockets, FpHttpClient,
  14.    {$ELSE}
  15.    opkman_httpclient,
  16.    {$ENDIF}
  17. @@ -762,8 +762,13 @@ end;
  18.  procedure TMainForm.GetSocketHandler(Sender: TObject; const UseSSL: Boolean; out
  19.    AHandler: TSocketHandler);
  20.  begin
  21. +  {$IF FPC_FullVersion >= 30200}        // needed for SSL to work in general
  22. +  AHandler := TOpenSSLSocketHandler.Create;
  23. +  TOpenSSLSocketHandler(AHandler).SSLType := stTLSv1_2;
  24. +  {$ELSE}
  25.    AHandler := TSSLSocketHandler.Create;
  26.    TSSLSocketHandler(AHandler).SSLType := stTLSv1_2;
  27. +  {$ENDIF}
  28.  end;
  29.  
  30.  procedure TMainForm.GridDrawCell(Sender: TObject; aCol, aRow: Integer;


EDIT: I created a pull request. (https://github.com/wp-xyz/corona/pull/11) .


regards,
Title: Re: Corona outbreak
Post by: minesadorada on March 24, 2020, 01:36:35 pm
Works perfectly for me - thanks!
A little worrying to see the exponential curves...
Title: Re: Corona outbreak
Post by: lucamar on March 24, 2020, 02:10:31 pm
A little worrying to see the exponential curves...

Would be more worrying if they were otherwise; all epidemies grow (more or less) like that: 1 person infects 2, those two infect 4, those four infect 8, and so on. What is realy important (say my friends in that field) is the rythm of growth (how many other people each infected person manages to infect) and (for cure development) the inmunity ratio. And lots more things too "technical" for us, mere mortals ;)

And take into account that we suffer a "severe pandemic" every year: few people doesn't get a cold each winter, do they? :D

The moral, really, is that (provided you're not of any high-risk group) there is little to worry about: very basically just keep home as much as possible, follow the instructions of the sanitary autorities to prevent/mitigate contagion and you are all set.
Title: Re: Corona outbreak
Post by: minesadorada on March 24, 2020, 02:45:10 pm
We are programmers - for the most part we can do basic maths.
If the mortality is 1% and half of a population gets infected this year, it is a simple calculation.
I am in a very high risk group, so did the maths early - hence the worry.

I live in Tenerife, Spain where a total lockdown has been in place for more than a week.  Even so, I will be at risk for a long time.

When the fatalities are in the hundreds of thousands maybe folk will take it more seriously.
For me, the most dangerous people are folk under 40 - especially asymptomatic young children.  They are the current superspreaders.
For those counting on an effective vaccine - remember Darwinian evolution:  Mutations are proportional to the number of hosts, and there will be billions.
My greatest hope is that the best mutation (from the virus's point of view) will be benign to Human Beings.  Killing the host is the worst outcome for a virus.

Once again - thank you for the app.
Title: Re: Corona outbreak
Post by: Bart on March 24, 2020, 03:15:24 pm
The moral, really, is that (provided you're not of any high-risk group) there is little to worry about

Hmm, mortality rates for the young and healthy vary between 0.1 and 1%, so reason to worry even for those.
If you're in a high-risk group (like all of my patients), mortality goes up to 40% and more.
That scares the bejesus out of me.

My patients are almost never eligible for admittence on an IC ward, let alone for invasive ventilation therapie.
They literally choke to death if they get severely ill bij this virus.

And in my line of work, we almost have no face mask etc. left. We even ran out of alcohol for desinfecting our hands.

So, yes: I worry.

Bart
Title: Re: Corona outbreak
Post by: zeljko on March 26, 2020, 02:40:57 pm
@wp, please change StatusBar.Refresh to StatusBar.Invalidate or StatusBar.Update since Qt,Qt5 crashes when an point is clicked (don't know reason why but it completely crashes), maybe cocoa/carbon too (all widgetsets that paint outside of paint event isn't supported). Even without any StatusBar.Update/Invalidate/Refresh it works ok (win32 tested under wine)
Title: Re: Corona outbreak
Post by: wp on March 26, 2020, 02:59:17 pm
Replaced it by Statusbar.Update. Please report if the issue still exists. Repainting the statusbar is required because of Statusbar text is changed several times during the download procedure - calling Application.Invalidate would fix this, but then the TAChart measurement tool seems to hang. Statusbar.Update seems to do well, at least on windows; did not check others.
Title: Re: Corona outbreak
Post by: zeljko on March 26, 2020, 03:05:09 pm
It works fine with update (tested qt and qt5 on linux 64bit). Thanks :)
Title: Re: Corona outbreak
Post by: zeljko on March 26, 2020, 03:23:24 pm
gtk2 is also fine
Title: Re: Corona outbreak
Post by: circular on March 27, 2020, 10:18:43 am
We are programmers - for the most part we can do basic maths.
If the mortality is 1% and half of a population gets infected this year, it is a simple calculation.
I am in a very high risk group, so did the maths early - hence the worry.
Yeah we need to take precautions.

Also the problem is that lots of people, even under 50, need to go to hospital. According to a study in America, 20% of people that need medical care are in the range 20-44. But if hospitals are overcrowded, they can't get help and they may die.

So we need to slow down the spread. In the meantime, we can try some cures, like hydroxychloroquine. By the way my government did not test people coming from China even when the first cases were discovered in France, not even take their temperature.
Title: Re: Corona outbreak
Post by: six1 on March 27, 2020, 10:50:24 am
So we need to slow down the spread. In the meantime, we can try some cures, like hydroxychloroquine. By the way my government did not test people coming from China even when the first cases were discovered in France, not even take their temperature.

that's a realy bad idea!

https://theintercept.com/2020/03/24/trump-hyped-chloroquine-cure-covid-19-man-arizona-took-died/
Title: Re: Corona outbreak
Post by: minesadorada on March 27, 2020, 11:09:05 am
To make it quicker to flick between countries, I made a small change to my copy of the source.

Code: Pascal  [Select][+][-]
  1. procedure TMainForm.TreeViewClick(Sender: TObject);
  2. var
  3.   fs: TFormatSettings;
  4.   counts: array[TCaseType] of string = ('', '', '');
  5.   dates: array[TCaseType] of string = ('', '', '');
  6.   dt: TDataType;
  7.   ct: TCaseType;
  8.   saX, saY: TStringArray;
  9.   i: Integer;
  10.   ser: TChartSeries;
  11.   Y, Y0, dY, dY0: Double;
  12. begin
  13.   // START
  14.   if bClearOnClick then
  15.   begin
  16.        Chart.ClearSeries;
  17.        CreateMeasurementSeries;
  18.        UpdateGrid;
  19.   end;
  20.   // END
  21.  
  22.   if TreeView.Selected = nil then ........ etc. etc.
bClearOnClick is a boolean toggled by a checkbox that I added to the UI.  Default value is TRUE.It's probably not the best way to do it - just a quick hack to suit the way I like to use the app.

Title: Re: Corona outbreak
Post by: kupferstecher on March 27, 2020, 11:09:47 am
@wp: Thaks for sharing the application. I just tried, workes fine.
I'd prefer a grid line for each day, would be imho more intuitive.

The possibility to show countries together is very nice. I grouped some regions, its really terrifying that the rising numbers can be seen everywhere in the world.

But,
@all: Please don't make this a non-technical thread.
Title: Re: Corona outbreak
Post by: Alextp on March 27, 2020, 12:01:23 pm
In Moscow we have flu increased, +50 a day, +60 a day, +100 a day, +150 a day... in next week, Msk may be closed at all. or not. no one knows. if internet will be blocked in Msk, I will not have inet. so no updates to all by codes.
no one here is sure for our future.
Title: Re: Corona outbreak
Post by: wp on March 27, 2020, 01:40:37 pm
its really terrifying that the rising numbers can be seen everywhere in the world.
... and that many of the small numbers double also within a few days. Exponential growth is faster than any human activity to prevent damage. Only while the numbers are small there is some chance to do something. Don't waste time.
Title: Re: Corona outbreak
Post by: circular on April 02, 2020, 12:09:18 am
So we need to slow down the spread. In the meantime, we can try some cures, like hydroxychloroquine. By the way my government did not test people coming from China even when the first cases were discovered in France, not even take their temperature.

that's a realy bad idea!

https://theintercept.com/2020/03/24/trump-hyped-chloroquine-cure-covid-19-man-arizona-took-died/
Come on that's a strawman argument! That man self-medicated himself, and not with hydroxychloroquine. The bad idea is to self-medicate and even worse if you don't even know precisely what drug to take. I cannot believe that someone could consider this article as a proof against the drug.

Chloroquine is not a new drug. It has been tested for decades and proven safe, of course under medical supervision. Whether Trump agrees or not does not make it true or false. Use your brain to think instead of bathing in irony and believing just "the contrary of Trump"!

This kind of misdirection would not be too bad if people were not dying because they are not treated soon enough. Used under medical supervision, hydrochloroquine along with a certain antibiotic has already had great effect against Covid-19, just like it already had against SARS. But it needs to be given as soon as the person infection is detected.

For now in France the cure has only been allowed in hospitals, but when people get to hospitals, they are often already pretty bad. Nurses and doctors do not have enough masks nor hydroalcoholic gel because our government did not make stocks and encourages delocalisations so we only start to produce some. We do not have time to make the proper tests to prove things with 99,99% accuracy.
Title: Re: Corona outbreak
Post by: Scoops on April 02, 2020, 12:37:10 am
Im fed up hearing 'stay home' by the French leaders, iam back in work monday after only 10 days temps partiel , the company we cater for are allowed to stay open, so we have to provide catering. so minimum 150  meals, goodbye security of confinement.
Title: Re: Corona outbreak
Post by: kupferstecher on July 28, 2020, 09:28:16 pm
I added coloring for the weekendes, see attached screenshot.
For those interested: Create the Chart.OnChartAfterDrawBackWall event and insert the below code.

Regards

Code: Pascal  [Select][+][-]
  1. procedure TMainForm.ChartAfterDrawBackWall(ASender: TChart; ACanvas: TCanvas;
  2.   const ARect: TRect);
  3. var
  4.   bmp: TBitmap;
  5.   LeftExtent,UnitsPerPixel: Double;
  6.   valX: Double;
  7.   ii: Integer;
  8.   RangeX: Integer;
  9. const
  10.   saturday = 0;
  11.   sunday = 1;
  12.   clWeekend = $00E0E0E0;
  13. begin
  14.   bmp:= TBitmap.Create;
  15.   bmp.Width := ARect.Right  - ARect.Left;
  16.   bmp.Height:= ARect.Bottom - ARect.Top;
  17.  
  18.   bmp.Canvas.CopyRect(Rect(0,0,bmp.width,bmp.height),ACanvas,ARect);
  19.  
  20.   bmp.canvas.Pen.color:= clWeekend;
  21.   LeftExtent:= Chart.CurrentExtent.a.X;
  22.   UnitsPerPixel:= (Chart.CurrentExtent.b.X - LeftExtent) / bmp.width;
  23.  
  24.   for ii:= 1 to bmp.width-1 do begin
  25.     valX:= LeftExtent + ii * UnitsPerPixel; //Calculate chart value at x position
  26.     RangeX:= round(valX) mod 7; // Determine current weekday
  27.     if (RangeX = saturday) or (RangeX = sunday) then begin
  28.       bmp.Canvas.MoveTo(ii,1);
  29.       bmp.Canvas.LineTo(ii,bmp.height);
  30.     end;//if
  31.   end;//do
  32.  
  33.  
  34.   ACanvas.Draw(ARect.Left,ARect.Top,bmp);
  35.   bmp.Free;
  36.  
  37.  
  38. end;
Title: Re: Corona outbreak
Post by: wp on July 30, 2020, 01:09:06 pm
Thanks for this idea. I incorporated it into the current version.
TinyPortal © 2005-2018