Help:RiskData: Difference between revisions
No edit summary |
No edit summary |
||
Line 55: | Line 55: | ||
Wet|1.5 | Wet|1.5 | ||
</riskdata> | </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" /> |
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.