Jump to content

Help:RiskData: Difference between revisions

From RiskiPedia
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..."
 
Remove <head> sections from datatable2 tables
Line 9: Line 9:
* `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 includes a `<head>` section with wikitext table headers (starting with `!`) and data rows using pipe (`|`) separators.
The tag’s content is data rows using pipe (`|`) separators.


Basic syntax:
Basic syntax:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="TableName" columns="column1|column2">
<datatable2 table="TableName" columns="column1|column2">
<head>
!Column 1
!Column 2
</head>
Value1|Value2
Value1|Value2
Value3|Value4
Value3|Value4
Line 24: Line 20:


== Usage ==
== Usage ==
1. 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;datatable2&gt; tag to define a table, typically on a "/Data" subpage, specifying a unique `table` name and `columns`.
2. In the `<head>` section, define column headers using wikitext table syntax (e.g., `!Header`).
# Add data rows with values separated by pipes (`|`), matching the order of columns.
3. 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.
4. 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;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;.
Line 37: Line 32:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="time_of_day" columns="time_period|time_fatality_multiplier|time_injury_multiplier">
<datatable2 table="time_of_day" columns="time_period|time_fatality_multiplier|time_injury_multiplier">
<head>
!Time of day
!Fatality risk multiplier
!Injury risk multiplier
</head>
Day|1.0|1.0
Day|1.0|1.0
Night|3.56|1.47
Night|3.56|1.47
Line 52: Line 42:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="seatbelt_use" columns="belt_status|belt_fatality_multiplier|belt_injury_multiplier">
<datatable2 table="seatbelt_use" columns="belt_status|belt_fatality_multiplier|belt_injury_multiplier">
<head>
!Seat-belt usage
!Fatality risk multiplier
!Injury risk multiplier
</head>
Worn|1.0|1.0
Worn|1.0|1.0
Not worn|1.82|2.0
Not worn|1.82|2.0
Line 67: Line 52:
<pre><nowiki>
<pre><nowiki>
<datatable2 table="DrivingConditions" columns="condition|fatality_risk">
<datatable2 table="DrivingConditions" columns="condition|fatality_risk">
<head>
!Driving condition
!Fatality risk multiplier
</head>
Dry|1.0
Dry|1.0
Wet|1.5
Wet|1.5
Line 90: Line 71:
* **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;datatable2&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 `<head>` section and data rows use correct wikitext table syntax (`!` for headers, `|` for data).
* **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]].

Revision as of 16:41, 11 September 2025

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 names (e.g., `time_period|time_fatality_multiplier`).

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

Basic syntax:

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

Usage

  1. Use the <datatable2> 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 <datatable2> 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:

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

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:

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

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:

<datatable2 table="DrivingConditions" columns="condition|fatality_risk">
Dry|1.0
Wet|1.5
</datatable2>
<riskmodel name="DrivingRisk" calculation="base_probability * fatality_risk">Your risk is about {result}%</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 DataTable2 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 <datatable2> `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.