Jump to content

Help:RiskData: Difference between revisions

From RiskiPedia
Remove <head> sections from datatable2 tables
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Help:DataTable2 =
= Help:RiskData =


The &lt;datatable2&gt; tag creates a data table to store structured data for use in [[Help:RiskModel|RiskModel]] calculations or [[Help:DropDown|DropDown]] menus. It is typically defined on a "/Data" subpage to organize risk-related data for RiskiPedia pages.
The &lt;riskdata&gt; tag creates a data table to store structured data for use in [[Help:RiskModel|RiskModel]] calculations or [[Help:DropDown|DropDown]] menus. It is typically defined on a "/Data" subpage to organize risk-related data for RiskiPedia pages.


== Syntax ==
== Syntax ==
The &lt;datatable2&gt; tag uses these attributes:
The &lt;riskdata&gt; tag uses these attributes:


* `table`: (Required) A unique name for the table (e.g., `time_of_day`).
* `table`: (Required) A unique name for the table (e.g., `time_of_day`).
Line 13: Line 13:
Basic syntax:
Basic syntax:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="TableName" columns="column1|column2">
<riskdata table="TableName" columns="column1|column2">
Value1|Value2
Value1|Value2
Value3|Value4
Value3|Value4
</datatable2>
</riskdata>
</nowiki></pre>
</nowiki></pre>


== Usage ==
== Usage ==
# Use the &lt;datatable2&gt; tag to define a table, typically on a "/Data" subpage, specifying a unique `table` name and `columns`.
# Use the &lt;riskdata&gt; tag to define a table, typically on a "/Data" subpage, specifying a unique `table` name and `columns`.
# Add data rows with values separated by pipes (`|`), matching the order of columns.
# Add data rows with values separated by pipes (`|`), matching the order of columns.
# Reference the table in a &lt;dropdown&gt; tag to display its data in a menu, or use its column names as variables in a [[Help:RiskModel|RiskModel]] or [[Help:RiskDisplay|RiskDisplay]] calculation.
# Reference the table in a &lt;dropdown&gt; tag to display its data in a menu, or use its column names as variables in a [[Help:RiskModel|RiskModel]] or [[Help:RiskDisplay|RiskDisplay]] calculation.


The &lt;datatable2&gt; tag stores data that can be selected via &lt;dropdown&gt; or used in risk calculations with &lt;riskmodel&gt; or &lt;riskdisplay&gt;.
The &lt;riskdata&gt; tag stores data that can be selected via &lt;dropdown&gt; or used in risk calculations with &lt;riskmodel&gt; or &lt;riskdisplay&gt;.


== Examples ==
== Examples ==
Line 31: Line 31:
Define a table for time-of-day risk multipliers:
Define a table for time-of-day risk multipliers:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="time_of_day" columns="time_period|time_fatality_multiplier|time_injury_multiplier">
<riskdata table="time_of_day" columns="time_period|time_fatality_multiplier|time_injury_multiplier">
Day|1.0|1.0
Day|1.0|1.0
Night|3.56|1.47
Night|3.56|1.47
</datatable2>
</riskdata>
</nowiki></pre>
</nowiki></pre>
This table, named "time_of_day", can be used in a &lt;dropdown&gt; to select "Day" or "Night", or its columns (`time_fatality_multiplier`, `time_injury_multiplier`) can be variables in a &lt;riskmodel&gt;.
This table, named "time_of_day", can be used in a &lt;dropdown&gt; to select "Day" or "Night", or its columns (`time_fatality_multiplier`, `time_injury_multiplier`) can be variables in a &lt;riskmodel&gt;.
Line 41: Line 41:
Define a table for seatbelt usage:
Define a table for seatbelt usage:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="seatbelt_use" columns="belt_status|belt_fatality_multiplier|belt_injury_multiplier">
<riskdata table="seatbelt_use" columns="belt_status|belt_fatality_multiplier|belt_injury_multiplier">
Worn|1.0|1.0
Worn|1.0|1.0
Not worn|1.82|2.0
Not worn|1.82|2.0
</datatable2>
</riskdata>
</nowiki></pre>
</nowiki></pre>
This table, "seatbelt_use", supports a &lt;dropdown&gt; for selecting "Worn" or "Not worn" and provides variables like `belt_fatality_multiplier` for calculations.
This table, "seatbelt_use", supports a &lt;dropdown&gt; for selecting "Worn" or "Not worn" and provides variables like `belt_fatality_multiplier` for calculations.
Line 51: Line 51:
Use a table with a &lt;dropdown&gt; and &lt;riskmodel&gt; on a driving risk page:
Use a table with a &lt;dropdown&gt; and &lt;riskmodel&gt; on a driving risk page:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="DrivingConditions" columns="condition|fatality_risk">
<riskdata table="DrivingConditions" columns="condition|fatality_risk">
Dry|1.0
Dry|1.0
Wet|1.5
Wet|1.5
</datatable2>
</riskdata>
<riskmodel name="DrivingRisk" calculation="base_probability * fatality_risk">Your risk is about {result}%</riskmodel>
<riskmodel name="DrivingRisk" calculation="0.0004 * fatality_risk">Your risk of being in a fatal accident are {{One_In_X|{result}}} per year</riskmodel>
<dropdown table="DrivingConditions" title="Select condition" label_column="condition" />
<dropdown table="DrivingConditions" title="Select condition" label_column="condition" />
<riskdisplay model="DrivingRisk" />
<riskdisplay model="DrivingRisk" />
Line 68: Line 68:


== Troubleshooting ==
== Troubleshooting ==
* **Error: "dropdown: cannot find DataTable2 table X"** – Ensure the `table` name matches exactly and exists on the current page or a "/Data" subpage.
* **Error: "dropdown: cannot find RiskTable table X"** – Ensure the `table` name matches exactly and exists on the current page or a "/Data" subpage.
* **Calculation fails** – Verify that variable names in &lt;riskmodel&gt; or &lt;riskdisplay&gt; calculations match column names in the &lt;datatable2&gt; `columns` attribute.
* **Calculation fails** – Verify that variable names in &lt;riskmodel&gt; or &lt;riskdisplay&gt; calculations match column names in the &lt;riskdata&gt; `columns` attribute.
* **Dropdown shows no data** – Check that the table has data rows and the `label_column` in &lt;dropdown&gt; matches a column name.
* **Dropdown shows no data** – Check that the table has data rows and the `label_column` in &lt;dropdown&gt; matches a column name.
* **Table not rendering** – Ensure the data rows use correct wikitext table syntax (values separated by `|` ).
* **Table not rendering** – Ensure the data rows use correct wikitext table syntax (values separated by `|` ).


For related features, see [[Help:RiskModel|RiskModel documentation]], [[Help:RiskDisplay|RiskDisplay documentation]], [[Help:DropDown|DropDown documentation]], or [[Help:RiskParameter|RiskParameter documentation]].
For related features, see [[Help:RiskModel|RiskModel documentation]], [[Help:RiskDisplay|RiskDisplay documentation]], [[Help:DropDown|DropDown documentation]], or [[Help:RiskParameter|RiskParameter documentation]].

Latest revision as of 22:35, 12 September 2025

Help:RiskData

The <riskdata> tag creates a data table to store structured data for use in RiskModel calculations or DropDown menus. It is typically defined on a "/Data" subpage to organize risk-related data for RiskiPedia pages.

Syntax

The <riskdata> tag uses these attributes:

  • `table`: (Required) A unique name for the table (e.g., `time_of_day`).
  • `columns`: (Required) A pipe-separated list of column names (e.g., `time_period|time_fatality_multiplier`).

The tag’s content is data rows using pipe (`|`) separators.

Basic syntax:

<riskdata table="TableName" columns="column1|column2">
Value1|Value2
Value3|Value4
</riskdata>

Usage

  1. Use the <riskdata> tag to define a table, typically on a "/Data" subpage, specifying a unique `table` name and `columns`.
  2. Add data rows with values separated by pipes (`|`), matching the order of columns.
  3. Reference the table in a <dropdown> tag to display its data in a menu, or use its column names as variables in a RiskModel or RiskDisplay calculation.

The <riskdata> tag stores data that can be selected via <dropdown> or used in risk calculations with <riskmodel> or <riskdisplay>.

Examples

Time of Day Risk Factors

Define a table for time-of-day risk multipliers:

<riskdata table="time_of_day" columns="time_period|time_fatality_multiplier|time_injury_multiplier">
Day|1.0|1.0
Night|3.56|1.47
</riskdata>

This table, named "time_of_day", can be used in a <dropdown> to select "Day" or "Night", or its columns (`time_fatality_multiplier`, `time_injury_multiplier`) can be variables in a <riskmodel>.

Seatbelt Use Risk Factors

Define a table for seatbelt usage:

<riskdata table="seatbelt_use" columns="belt_status|belt_fatality_multiplier|belt_injury_multiplier">
Worn|1.0|1.0
Not worn|1.82|2.0
</riskdata>

This table, "seatbelt_use", supports a <dropdown> for selecting "Worn" or "Not worn" and provides variables like `belt_fatality_multiplier` for calculations.

Combined with RiskModel and Dropdown

Use a table with a <dropdown> and <riskmodel> on a driving risk page:

<riskdata table="DrivingConditions" columns="condition|fatality_risk">
Dry|1.0
Wet|1.5
</riskdata>
<riskmodel name="DrivingRisk" calculation="0.0004 * fatality_risk">Your risk of being in a fatal accident are {{One_In_X|{result}}} per year</riskmodel>
<dropdown table="DrivingConditions" title="Select condition" label_column="condition" />
<riskdisplay model="DrivingRisk" />

This defines a "DrivingConditions" table, a <riskmodel> using its `fatality_risk` column, a <dropdown> to select a condition, and a <riskdisplay> to show the result.

Notes

  • The `table` name must be unique, especially on "/Data" subpages, to avoid conflicts.
  • Column names in the `columns` attribute must match the order of headers and data in the table.
  • Use column names as variables in RiskModel or RiskDisplay calculations, or specify a column in a <dropdown> `label_column`.
  • Tables are often defined on "/Data" subpages but can be referenced from main pages using full names (e.g., `PageName/Data:TableName`).

Troubleshooting

  • **Error: "dropdown: cannot find RiskTable table X"** – Ensure the `table` name matches exactly and exists on the current page or a "/Data" subpage.
  • **Calculation fails** – Verify that variable names in <riskmodel> or <riskdisplay> calculations match column names in the <riskdata> `columns` attribute.
  • **Dropdown shows no data** – Check that the table has data rows and the `label_column` in <dropdown> matches a column name.
  • **Table not rendering** – Ensure the data rows use correct wikitext table syntax (values separated by `|` ).

For related features, see RiskModel documentation, RiskDisplay documentation, DropDown documentation, or RiskParameter documentation.