Template:Graphical timeline/doc: Difference between revisions
(syntaxhighlight lang="wikitext") |
m (1 revision imported) |
(No difference)
|
Latest revision as of 06:59, 9 May 2024
This is a documentation subpage for Template:Terminate sentence It may contain usage information, categories and other content that is not part of the original template page. |
This page in a nutshell:
|
This template uses Lua: |
The easy way
Type {{include timeline}}
in your article, press preview, and follow the link generated. You'll be presented with a ready-to-go template; once this is finished, return to your article, and { {include timeline} } will display your timeline.
Development
As of May 2021, the template has been converted to Lua and is now implemented at Module:Graphical timeline. New features include:
- Unlimited numbered parameters --- use note435, note34234532, whatever is convenient
- HTML size, memory, and run-time are all proportional to the number of items, not the number of potential items
- Incorrect HTML and fragile CSS now cleaned up
- Annotation text now automatically aligned with arrows (
|disable-arrow-align=true
to turn off) - Box text now automatically centered (
|disable-box-align=true
to turn off)
Template function
This template provides an intuitive, user-friendly and flexible way to insert timelines into articles. It's designed to require the minimum number of variables, and to generate an HTML table.
Why use this template?
The alternative to this template is m:EasyTimeline, using the <template> syntax. EasyTimeline has the following weaknesses:
- Pixelated image produced, which looks different and increases page load time
- Long set-up time – taking 30 minutes plus even when you know what you are doing
- Impenetrable code requiring precise syntax
- Difficult to place bars exactly where you want them
- Changing minimum dates and sizes requires modification in many places
- Everything must be specified – nothing is automatic
- It is not scalable – it does not enlarge with text size.
Using the template
Where to use it
Whilst short timelines can be inserted directly into the article, some editors complain that long, complex timelines break up the flow of the page and make editing difficult. Therefore, you may want to use {{Include timeline}} to host the timeline code on a separate page, which will be automatically included.
Getting started
You can set the switch |help=on
in the template to produce some quick pointers.
When you are getting started, you might want to use {{Graphical timeline|help=on}}
to generate a ready-made, empty template – or type {{subst:Graphical timeline/blank}}
into a sandbox page, save the page, and edit the resulting code. Hopefully, the parameter names are pretty self-explanatory.
What numbers mean
Numeric values are by default in units of em, that is, the height and width of a capital M.
The exception to this is the left and right parameters of a bar, which are set using fractional coordinates. That is to say, the code
|bar1-right=0.5 |bar2-left=0.666 |bar3-left=0.5 |bar3-right=0.666
...will produce bar1 covering the left half of the area, bar2 covering the right-most third, and bar3 in between them. Further, for operational reasons, the height-units are always used to generate border widths.
Bar borders
Borders appear only on the top and bottom of any given bar. Unfortunately, this cannot be changed – to have a border at the top or bottom only of a bar, you should create a separate bar to overlay the end.
Border style can be set to the CSS standards of solid, dotted, dashed, double, groove, ridge, inset
or outset
. Width is in the same units as height, and if none is specified 0.1 to 0.2 is a suitable hairline value.
Blank parameters
Leaving a parameter blank is NOT the same as not specifying it – it will override the template's default value. Be sure to remove any lines you do not specify.
Geological periods
To draw a geological period, use the syntax |period3=Cenozoic, with |period3-left=0.1 as usual. The template will then calculate the beginning, end and correct color of the bar. For an example, see Template:Cenozoic graphical timeline (backlinks edit)
Considerations
Browsers
Unfortunately, different browsers have different ways of dealing with lines of text that overflow their container – some stretch the container whilst others wrap the text. This means it's probably worth checking your finished timeline in at least IE and Firefox if you are making a particularly complex timeline.
Colors
If you are setting colors using html values that look like #e0b539
, do consider that some older monitors, and many projectors, cannot display some colours. Sticking to Web-safe colors ensures maximum compatibility, which is often appreciated; i.e. multiples of 33
, e.g. #ff99cc
or #03C
.
Easy editing
If you create a timeline on a template page, do use the | link-to=
parameter. Specify the page name without Template:
(e.g. My graphical timeline
for Template:My graphical timeline
), and "view", "talk", "edit" links will appear.
Parameter list
The list may be long, but do not be daunted – you only need to use a couple, and the rest give you incredible flexibility!
Replace any instance of # with a number.
To and from are mandatory, all other parameters are optional.
Either spelling of colour/color is always acceptable.
General parameters
General parameters | ||
−200 — – 0 — – 200 — – 400 — – 600 — – 800 — – 1000 — – 1200 — – 1400 — – 1600 — – 1800 — – | ||
Parameter | Function | Default |
---|---|---|
from to |
Bounds the start & end of the timeline. May be negative. | Required |
instance-id | Differentiates this timeline from others that appear on the page | Sometimes required |
title | Writes the title bar | No title |
title-colour | Colours the title bar's background | No colour |
plot-colour | Colours the background for the timeline space | No colour |
unit | Defines the unit of (graphical) measurement | em
|
height-unit width-unit |
Overrides either the height or width unit | <unit>
|
height width |
Sizes the timeline container | 36 10
|
disable-arrow-align | If true (or equivalent), enables text in notes to be nudged away from arrow | false |
disable-box-align | If true (or equivalent), enables text in bars to be nudged away from center | false |
collapsible | If true (or equivalent), enables infobox to be collapsed | false |
state | Use |state=expanded to force the box to the expanded state, or |state=collapsed to hide it.
|
expanded |
Bars
Bars are sizable coloured rectangles with a text label in the middle.
Bar parameters are prefixed with bar#
, where #
is the bar's ID. The number doesn't imply any particular order, but it does have to be unique.
−200 — – 0 — – 200 — – 400 — – 600 — – 800 — – 1000 — – 1200 — – 1400 — – 1600 — – 1800 — – | bar1 bar2 bar3 bar4 bar5 bar6 bar7 bar8 bar9 | |
Parameter | Function | Default |
---|---|---|
-colour (-color) | Sets the background colour | Required |
-from -to |
Positions the top & bottom edges along the timeline | Required |
-left -right |
Positions the left & right edges, as a fraction of the width (0.0 to 1.0 )
|
0.0 1.0
|
-border-width -border-colour -border-style |
Stylises the top & bottom borders, simultaneously; styles are solid dotted dashed double groove ridge inset outset
|
No border |
-text | Writes the central label | No text |
-font-size | Sizes the label | 90%
|
-nudge-down -nudge-up -nudge-right -nudge-left |
Nudges the label around (Units are in ems). Only enabled if |disable-box-align=1
|
0.0
|
Geological periods
Gets data to create a bar with default values for -colour, -from, -to, -text
.
Period parameters are prefixed with period#
, where #
is the period's unique number.
−520 — – −500 — – −480 — – −460 — – −440 — – −420 — – −400 — – −380 — – −360 — – −340 — – −320 — – −300 — – −280 — – −260 — | ||
Parameter | Function | Default |
---|---|---|
null | Names the geological division (e.g. period1=Phanerozoic )
|
Required |
-colour (-color) | Overrides the division's colour | {{Period color|<period>}}
|
-text | Overrides the division's label | <period>
|
-from -to |
Overrides the division's start & end times | -{{Period start|<period>}} -{{Period end|<period>}}
|
-left -right |
Positions the left & right edges, as a fraction of the width (0.0 to 1.0 )
|
0.0 1.0
|
-border-width -border-colour -border-style |
Stylises the top & bottom borders, simultaneously; styles are solid dotted dashed double groove ridge inset outset
|
No border |
-font-size | Sizes the central label | 90%
|
-nudge-down -nudge-up -nudge-right -nudge-left |
Nudges the label around (Units are in ems). Only enabled if |disable-box-align=1
|
0.0
|
Legend
Legend entries coordinate with bars (i.e. legend1
matches the colour of bar1
, etc.).
−400 — – −380 — – −360 — – −340 — – −320 — – −300 — – −280 — – −260 — | bar1 bar2 bar3 |
| ||||||
| ||||||||
caption |
Parameter | Function | Default |
---|---|---|
null (-text) | Writes the entry's label (e.g. legend1=[[Phanerozoic]] eon
|
Required |
-colour (-color) | Overrides the entry's colour | <bar#-colour>
|
Notes
Notes are annotations that show up to the right of the timeline with an arrow (←).
Note parameters are prefixed with note#
, where #
is the note's unique number.
Parameter | Function | Default |
---|---|---|
null | Writes the note's content (e.g. note1=Cambrian explosion )
|
Required |
-at | Positions the arrow & note text vertically along the timeline | Required |
-remove-arrow (-no-arrow) | Removes the note's arrow, if true | 0
|
-nudge-down -nudge-up -nudge-right -nudge-left |
Nudges the note's text around (units are in ems) If arrow, then text is centered next to arrow unless |
0.0
|
-size (-font-size) | Sizes the note's font | 100%
|
-colour (-color) | Colours the note's font |
In use: an example
The code on the left produces the timeline on the right. For another example, please see Ediacaran biota.
Example Timeline | ||||||||||
−550 — – −540 — – −530 — – −520 — – −510 — – −500 — |
| |||||||||
| ||||||||||
<syntaxhighlight lang="wikitext">
Example Timeline | ||||||||||
−550 — – −540 — – −530 — – −520 — – −510 — – −500 — |
| |||||||||
| ||||||||||
</syntaxhighlight>
Notes on the example
{{!}}
must be used wherever you want a | to appear (e.g. the caption)- If you do not specify when a bar should start or end, it will continue to the edge of the plot
- Text should not be too long for the bar
- The way that overflowing text wraps is also handled differently in different browsers – it pokes out of the right of the bar on Firefox, but is wrapped within it by IE. Try to manually enter newlines when required rather than relying on browsers to sort it out. Or position a note over the bar – check out note2, which is nudged left over the plot background.
Blank template to copy
<syntaxhighlight lang="wikitext">
Lua error in Module:Navbar at line 58: Invalid title Template:{{subst:PAGENAMEE}}. | ||
0 — | ||
</syntaxhighlight>