Help:RiskData: Difference between revisions
Created page with "= Help:DataTable2 = The <datatable2> 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 <datatable2> 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..." |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Help: | = Help:RiskData = | ||
The < | The <riskdata> 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 < | The <riskdata> 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`). | ||
* `columns`: (Required) A pipe-separated list of column names (e.g., `time_period|time_fatality_multiplier`). | * `columns`: (Required) A pipe-separated list of column names (e.g., `time_period|time_fatality_multiplier`). | ||
The tag’s content | The tag’s content is data rows using pipe (`|`) separators. | ||
Basic syntax: | Basic syntax: | ||
<pre><nowiki> | <pre><nowiki> | ||
< | <riskdata table="TableName" columns="column1|column2"> | ||
Value1|Value2 | Value1|Value2 | ||
Value3|Value4 | Value3|Value4 | ||
</ | </riskdata> | ||
</nowiki></pre> | </nowiki></pre> | ||
== Usage == | == Usage == | ||
# Use the <riskdata> 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. | |||
# Reference the table in a <dropdown> 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 < | The <riskdata> tag stores data that can be selected via <dropdown> or used in risk calculations with <riskmodel> or <riskdisplay>. | ||
== Examples == | == Examples == | ||
Line 36: | Line 31: | ||
Define a table for time-of-day risk multipliers: | Define a table for time-of-day risk multipliers: | ||
<pre><nowiki> | <pre><nowiki> | ||
< | <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 | ||
</ | </riskdata> | ||
</nowiki></pre> | </nowiki></pre> | ||
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>. | 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>. | ||
Line 51: | Line 41: | ||
Define a table for seatbelt usage: | Define a table for seatbelt usage: | ||
<pre><nowiki> | <pre><nowiki> | ||
< | <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 | ||
</ | </riskdata> | ||
</nowiki></pre> | </nowiki></pre> | ||
This table, "seatbelt_use", supports a <dropdown> for selecting "Worn" or "Not worn" and provides variables like `belt_fatality_multiplier` for calculations. | This table, "seatbelt_use", supports a <dropdown> for selecting "Worn" or "Not worn" and provides variables like `belt_fatality_multiplier` for calculations. | ||
Line 66: | Line 51: | ||
Use a table with a <dropdown> and <riskmodel> on a driving risk page: | Use a table with a <dropdown> and <riskmodel> on a driving risk page: | ||
<pre><nowiki> | <pre><nowiki> | ||
< | <riskdata table="DrivingConditions" columns="condition|fatality_risk"> | ||
Dry|1.0 | Dry|1.0 | ||
Wet|1.5 | Wet|1.5 | ||
</ | </riskdata> | ||
<riskmodel name="DrivingRisk" calculation=" | <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 87: | Line 68: | ||
== Troubleshooting == | == Troubleshooting == | ||
* **Error: "dropdown: cannot find | * **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 < | * **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. | * **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 | * **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
- Use the <riskdata> 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.
- 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.