Template:Medical cases chart
此模板使用Lua语言: |
本模板使用以下模板样式: |
简介
[编辑]This template should be used for all outbreak, epidemic and pandemic medical cases charts based on {{Bar box}} to maintain consistency. It displays horizontal bars for up to 5 different classifications of cases for each valid date or interval. It offers two columns to make numbers explicit and to show relative or absolute changes. It also uses a sophisticated toggling system to control the visualization of data rows across many months or years. It is designed to be flexible, but still standardizes some parts of the chart. This template should be transcluded in other templates, NOT in article pages. Suggest features in the talk page or code them if they're neither controversial nor incompatibility prone.
参见
[编辑]用法
[编辑]{{Medical cases chart |float = side of the page where the chart will be located (left|center|right|none) [optional, defaults to: right] |barwidth = width of the stacked bars area (thin|medium|wide|auto) [optional, defaults to: medium] |numwidth = max width of the numbers in the right columns (AA or AAAA)<-(n|t|m|w|x|d) [optional, defaults to: mm; see info below] |rowheight = height of each bar, in multiples of the text height [optional, defaults to: 1.6] |pretitle = text at the beginning of the title [optional] |disease = name of the disease |location = location of the outbreak the chart is showing |location2 = broader location such as state/province or country [optional] |location3 = broadest location such as country [optional] |posttitle = text at the end of the title [optional] |outbreak = name of the main outbreak for the links of the {{navbar}} [see info below] |recoveries = whether to display recoveries in the legend (yesno) [optional, defaults to: yes] |reclbl = alternate label for the 2nd cases classification [optional, defaults to: Recoveries] |altlbl1 = alternate label for the 3rd cases classification (hide) [optional, defaults to: Active cases] |altlbl2 = alternate label for the 4th cases classification [optional] |altlbl3 = alternate label for the 5th cases classification [optional] |collapsible= whether rows are collapsible (forced no if days span <= duration) (yesno) [optional, defaults to: 'auto'] |duration = span of last days to initially display to control default chart height [optional, defaults to: 15] |nooverlap = whether to prevent the last month's toggle from overlapping, in days, [optional, defaults to: no; see info below] with the "Last XX days" toggle (yesno) |right1 = heading of the 1st data column [optional, defaults to: # of cases] |right1data = cases classification of the 1st column for auto filling (1-5|alttot1-2) [optional, defaults to: 3, if right1 is "# of cases"] |changetype1= calculate percent change (%) or absolute change (#) (p|a) [optional, defaults to: percent] |right2 = heading of the 2nd data column [optional] |right2data = cases classification of the 2nd column for auto filling (1-5|alttot1-2) [optional, defaults to: 1, if right2 is "# of deaths"] |changetype2= calculate percent change (%), absolute change (#) or onlypercent (p|a|o) [optional, defaults to: percent] |changetype = applies to both 1st and 2nd change columns [optional] |datapage = tabular data page from Commons to scrape cases data from ['optional'; see its talk section and module] |data = data lines for each valid date or interval ['optional'; see Data's syntax] |caption = caption under the chart [optional] }}
It may be desirable to make a specific outbreak chart have different widths depending on the page it is displayed. The barwidth
parameter can be used to achieve this. For example, |barwidth={{{barwidth|wide}}}
will display the chart wide in the template page itself, but will allow different widths when the outbreak template is transcluded with this parameter in article pages.
numwidth
is a sequence of the initials of none, thin, medium, wide, extra wide and default, and it determines the maximum width of each number in the data columns. Therefore, one should be chosen that minimizes the total width, but which doesn't make the numbers break/wrap on mobile view. Using 2 or 4 characters allocates one or two data columns, respectively. For example, |numwidth=mw
sets the right1 value column to medium and the right1 change column to wide. |numwidth=mwnt
sets the right1 value column to medium, the right1 change column to wide, the right2 value column to none, and the right2 change column to thin.
The {{navbar}} links are contructed like this: outbreak
data/[
[
location3
/]
location2
/]
*location
medical cases chart. outbreak
may be more descriptive than disease
to avoid page name collisions. So, for example, COVID-19 charts have |outbreak=COVID-19 pandemic
. location
has "the " internally removed and is capitalized to become *location
.
By default, the "Last X days" button toggles days which intersect with those of the last months. This happens regardless of the state (activated or not) of the month buttons. In fact, due to limitations of custom collapsing, toggles are stateless (a workaround is used to simulate two 'states'). All in all, this can lead to situations where clicking one button causes unintuitive toggling like creating date gaps. nooverlap
works around this issue by forcing the buttons of the last months to not overlap with the "Last X days" button. The result is usually a partial last month button, "Mon XX-XX", where XX are the first and last days of the month that the button affects. Extra info in the main bug discussion.
To display absolute change in the first column and percent change in the second column, set the following (AA represents any two allowed characters, # represents the classification number being shown, which should be the same for right1data
and right2data
):
|numwidth=AAnw |right1data=# |changetype1=a |right2data=# |changetype2=o
Data
[编辑]The data
parameter should be populated by a sequence of lines containing a different set of parameters separated by semicolons, ;
.
{{{2}}}
All values are optional, and empty values can be represented by sequential semicolons (e.g. ;;
). Omitting the date will treat the row as a date interval, unless the date can be automatically interpolated (for 1 day intervals). This is mostly done when no new cases are reported. Omitting a classification value makes a 0 width stacked bar and ommiting all values or the line itself is recommended to depict dates where no data is reported.
The expression for total in the 3rd cases classification has deaths and recoveries automatically subtracted from it. If a manual calculation of the number in that classification (generally active cases) is wanted, use alttot1
. The same applies to the expression for total in the 5th cases classification and alttot2
.
The 1st column #
, 1st column change
, 2nd column #
, and 2nd column change
values can be automatically calculated if omitted. The 1st column values will be automatically calculated if right1
is omitted or |right1=# of cases
, and the 2nd column values will be automatically calculated if |right2=# of deaths
. If right1
or right2
are set to other values, the columns can still be automatically calculated by setting right1data
and right2data
to the classification number wanted for display in columns 1 and 2, respectively (e.g. 1
for deaths, 2
for recoveries, 3
for total, etc.). The changes in the first and second columns are automatically wrapped in parentheses.
The other parameters=values
can be any number of the parameters below and their values, separated by semicolons. See the examples.
alttot1 = alternate expression for active cases (3rd cases classification) alttot2 = alternate expression for number in the 5th cases classification firstright1= whether a change in the first column is not applicable (n.a.) (yesno) firstright2= whether a change in the second column is not applicable (n.a.) (yesno) enddate = end date of interval if automatic one causes incorrect toggling behavior [required if chart ends with interval] note0 = note text post-fixed to the date, that should create a minimum space consuming object, like a note link, to avoid wrapping note1 = like note0, only post-fixed to column 1 note2 = like note1, only post-fixed to column 2
例子
[编辑]{{Medical cases chart |numwidth=mmmw |disease=2019冠状病毒病 |location=中國大陸 |outbreak=2019冠狀病毒病病例數 |altlbl1=确诊 |altlbl2=湖北省临床诊断(2.10-2.15) |altlbl3=确诊或临床诊断{{noteTag|不包含无症状感染者}} |right1=病例数<br />(不含临床诊断) |right2=病例数<br />(含临床诊断) |data= ... |caption= <div class="center" style="width:90%; margin-left:auto; margin-right:auto;"><small>...</small></div> ... }}
TemplateData
[编辑]Produces charts based on {{Bar box}} for outbreak, epidemic and pandemic medical cases.
参数 | 描述 | 类型 | 状态 | |
---|---|---|---|---|
Disease | disease | name of the disease | 字符串 | 必需 |
Outbreak | outbreak | name of the main outbreak (for link of the {{navbar}}) | 字符串 | 必需 |
Location | location | location of the outbreak the chart is showing | 字符串 | 必需 |
Data | data | data lines for each valid date (see Data's and Rows' syntax)
| 未知 | 必需 |
Pretitle | pretitle | text at the beginning of the title
| 未知 | 可选 |
Bar width | barwidth | width of the stacked bars area (thin|medium|wide)
| 未知 | 可选 |
Number width | numwidth | max width of the numbers in the right columns (xx or xxxx)<-(n|t|m|w|d)
| 未知 | 可选 |
Float | float | on what side of the page should the chart be located (left|right|none)
| 字符串 | 可选 |
Location 2 | location2 | broader location such as state/province or country | 字符串 | 可选 |
Location 3 | location3 | broadest location such as country | 字符串 | 可选 |
Post-title | posttitle | text at the end of the title | 未知 | 可选 |
Recoveries | recoveries | display recoveries in the legend (no|n|0) | 未知 | 可选 |
Recoveries label | reclbl | alternate label for the recoveries classification | 未知 | 可选 |
Alt label 1 | altlbl1 | alternate label for the 3rd case classification | 未知 | 可选 |
Alt label 2 | altlbl2 | alternate label for the 4th case classification
| 未知 | 可选 |
Alt label 3 | altlbl3 | alternate label for the 5th case classification | 未知 | 可选 |
Toggles bar | togglesbar | HTML of the toggles bar to show/hide rows | 未知 | 可选 |
Right 1 | right1 | heading of the first data column
| 未知 | 可选 |
Right 2 | right2 | heading of the second data column | 字符串 | 可选 |
rows | rows | 无描述 | 未知 | 可选 |
Divisor | divisor | manual override of the scaling divisor of the bars
| 未知 | 可选 |
Collapsible | collapsible | whether the rows are collapsible (yes|y|1) | 未知 | 可选 |
Caption | caption | caption under the chart | 未知 | 可选 |
上述文档嵌入自Template:Medical cases chart/doc。 (编辑 | 历史) 编者可以在本模板的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。本模板的子页面。 |