Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Ajuanca/GraphIt/doc
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Usage = Place the following snippet on the wiki page, replacing ''function_name'' with the name of the function to be used, and giving the parameters separated with <code>|</code>. Specific parameters, the ones with a specific name, like <code>avgs</code>, are assigned with the <code>=</code> sign: <code>|''avgs=2,3,4''|</code>. For all the examples shown below, the file [[c:Data:COVID-19 cases in Asturias.tab|Data:COVID-19 cases in Asturias.tab]] is going to be used. <code><nowiki>{{</nowiki>#invoke:{{BASEPAGENAME}}|''function_name''|''param1''|''param2''|''param name = param value''}}</code> == Incidence proportion: <code>get_incidence</code> == This function calculates the incidence proportion of a specific event for all the available dates. I.e.: The daily confirmed cases of flu per 10.000 inhabitants in [[Asturias]]. === Parameters === The possible parameters are: *<code>src=</code> or the '''first''' param: The name of the Tabular file. These files are hosted on [[c:Main page|Wikimedia Commons]], inside the ''Data'' namespace ("''Data'':name of tabular file.tab"). The files in this section must end with the suffix ("Data: name of tabular file''.tab''"). I.e. The file itself, "<code>[[c:Data:COVID-19 cases in Asturias.tab|COVID-19 cases in Asturias.tab]]</code>" *<code>column_name=</code> or the '''second''' param: The name of the column where the data of the event is stored. I.e. The column with the total confirmed cases of COVID-19 in Asturias, called "<code>total_cases</code>". *<code>date_name=</code> or the '''third''' param: The name of the column where the date of the data of the event is stored. I.e. The column with the date (in a [[String (computer science)|String]] format YYYY-MM-DD), called "<code>date</code>". *<code>inhabitants=</code> or the '''fourth''' param: The population size of the given region. I.e. 1,018,775 total inhabitants living in Asturias, according to the [[Instituto Nacional de Estadística (Spain)|INE]] as a temporarly data for January 1st, 2020. *<code>nth=</code> or the '''fifth''' param: The power of 10 for the generated output (the power of ten to the n''th'', 10<sup>n</sup>). This value normally will be 4 or 5, althought can be changed for smaller or bigger population sizes. I.e. 5, which causes the output to be given per 10<sup>5</sup> inhabitants (100,000). *<code>graph=</code> param: A [[Boolean]] (true or false) specifiying if a graph should be generated as an output. '''Default is false'''. I.e. <code>true</code> (showing a graph as an output). *<code>ltable=</code> param: A [[Boolean]] (true or false) specifiying if the [[Lua]] variable should be generated as an output. '''Default is false'''. I.e. <code>false</code> (no returning the variable itself). This is a extrange value to be requested. *<code>wtable=</code> param: A [[Boolean]] (true or false) specifiying if a Wikitable table should be generated as an output. '''Default is false'''. I.e. <code>false</code> (no returning a wikitable). This options is still '''NOT AVAILABLE'''. ''Note 1: Instead of the <code>column_name</code> parameter, <code>column_title</code> can be used intead. Alike, <code>date_title</code> can be given. It is unusual, but two or more columns could have the same title (but not the same name), so this approach is less safe than <code>column_name</code> and <code>date_name</code>.'' ''Note 2: If <code>graph=true</code> is requested, all parameters available at the [[Module:Graph]] can be given. They will be passed to this moduled without any kind of modification.'' As a recap, the snippet to include will look like this: <code>{{((}}#invoke:{{BASEPAGENAME}}|'''get_all_incidence'''|''src''|''colum_name''|''date_name''|''inhabitants''|''nth''|graph=''true''{{))}}</code> === Examples === Let's say we want a graph of the [[c:Data:COVID-19 cases in Asturias.tab|Data:COVID-19 cases in Asturias.tab]] Tabular file, showing the daily incidence of the total COVID-19 confirmed cases (which is registered in the "total_cases" column), expressed per 100.000 inhabitants, and assuming a total population of 1,018,775. Also note that the date is written in a format compatible with the [[Template:Graph]] (in the "date" row). In this case, we will type: <code>{{((}}#invoke:{{BASEPAGENAME}}|get_all_incidence|COVID-19 cases in Asturias.tab|total_cases|date|1018775|5|graph=true{{))}}</code> which will output: {{#invoke:{{BASEPAGENAME}}|get_all_incidence|COVID-19 cases in Asturias.tab|total_cases|date|1018775|5|graph=true}} But this is an awful graph. remmeber that we can pass any Module:Graph parameter. In this case, we should specify that the x-values are dates. We can give a width and height, and other line width and color. A legend is also available. With <code>{{((}}#invoke:{{BASEPAGENAME}}|get_all_incidence|COVID-19 cases in Asturias.tab|total_cases|date|1018775|5|graph=true|height=300|width=800|colors=#2c72ff|linewidth=2|xType=date|legend=Legend|y1Title=Confirmed cases per 100.,000 inhabitants|title=COVID-19 cases in Asturias{{))}}</code> we get: {{#invoke:{{BASEPAGENAME}}|get_all_incidence|COVID-19 cases in Asturias.tab|total_cases|date|1018775|5|graph=true|height=300|width=800|colors=#2c72ff|linewidth=3|legend=Legend|y1Title=Confirmed cases per 100.,000 inhabitants|title=COVID-19 cases in Asturias|xType=date}} == Various incidence proportions: <code>get_incidences</code> == This function calculates various incidence proportions of the given events for all the available dates. It can also output the medium of a specified interval, instead of all daily values. I.e.: The week average of the daily confirmed cases of flu per 10.000 inhabitants in [[Asturias]]. === Parameters === The possible parameters are: *<code>src=</code> or the '''first''' param: The name of the Tabular file. These files are hosted on [[c:Main page|Wikimedia Commons]], inside the ''Data'' namespace ("''Data'':name of tabular file.tab"). The files in this section must end with the suffix ("Data: name of tabular file''.tab''"). I.e. The file itself, "<code>[[c:Data:COVID-19 cases in Asturias.tab|COVID-19 cases in Asturias.tab]]</code>" *<code>column_names=</code> or the '''second''' param: The name of all the columns where the data of the events are stored. Each name should be separated by a comma (<code>,</code>). I.e. The column with the total confirmed cases of COVID-19 in Asturias, and the column with the total recovered people, called "<code>total_cases</code> and <code>total_recovered</code>" respectively. *<code>date_name=</code> or the '''third''' param: The name of the column where the date of the data of the event is stored. I.e. The column with the date (in a [[String (computer science)|String]] format YYYY-MM-DD), called "<code>date</code>". *<code>inhabitants=</code> or the '''fourth''' param: The population size of the given region. I.e. 1,018,775 (<code>1018775</code>) total inhabitants living in Asturias, according to the [[Instituto Nacional de Estadística (Spain)|INE]] as a temporarly data for January 1st, 2020. *<code>nth=</code> or the '''fifth''' param: The power of 10 for the generated output (the power of ten to the n''th'', 10<sup>n</sup>). This value normally will be 4 or 5, althought can be changed for smaller or bigger population sizes. I.e. 5, which causes the output to be given per 10<sup>5</sup> inhabitants (100,000). *<code>avgs=</code> param: A list of values that specify by how many items the average should be done. The number of avgs should be equal to the number ot <code>column_names</code> given, and they're also given with a <code>,</code> beetween each element. I.e. Calculate the average for two days and three days: <code>2,3</code>. *<code>graph=</code> param: A [[Boolean]] (true or false) specifiying if a graph should be generated as an output. '''Default is false'''. I.e. <code>true</code> (showing a graph as an output). *<code>ltable=</code> param: A [[Boolean]] (true or false) specifiying if the [[Lua]] variable should be generated as an output. '''Default is false'''. I.e. <code>false</code> (no returning the variable itself). This is a extrange value to be requested. *<code>wtable=</code> param: A [[Boolean]] (true or false) specifiying if a Wikitable table should be generated as an output. '''Default is false'''. I.e. <code>false</code> (no returning a wikitable). This options is still '''NOT AVAILABLE'''. ''Note 2: If <code>graph=true</code> is requested, all parameters available at the [[Module:Graph]] can be given. They will be passed to this moduled without any kind of modification.'' As a recap, the snippet to include will look like this: <code>{{((}}#invoke:{{BASEPAGENAME}}|'''get_incidences'''|''src''|''colum_names''|''date_name''|''inhabitants''|''nth''|''avgs''|graph=''true''{{))}}</code> === Examples === Let's say we want a graph of the [[c:Data:COVID-19 cases in Asturias.tab|Data:COVID-19 cases in Asturias.tab]] Tabular file, showing the daily incidence of the total COVID-19 confirmed cases (which is registered in the "total_cases" column), expressed per 100,000 inhabitants, and assuming a total population of 1,018,775. We will request an average per two days. In the same plot, the recovered cases, also expressed per 100,000, with an average of one week. In this case, we will type: <code>{{((}}#invoke:{{BASEPAGENAME}}|get_incidences|COVID-19 cases in Asturias.tab|total_cases,total_recovered|date|1018775|5|avgs=2,7|graph=true{{))}}</code> which will output: {{#invoke:{{BASEPAGENAME}}|get_incidences|COVID-19 cases in Asturias.tab|total_cases,total_recovered|date|1018775|5|avgs=2,7|graph=true}}
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:((
(
edit
)
Template:))
(
edit
)
Module:Graph
(
edit
)
Module:Sandbox/Ajuanca/GraphIt
(
edit
)