Predefinição:Bartable
Descrição
editarEsta predefinição adiciona uma barra gráfica embutida em tabelas com valores numéricos (incluindo os negativos) que um leitor pode querer comparar.
Use esta predefinição dentro de uma tabela. A predefinição produz duas células (para os casos em que todos os valores são positivos), ou três (para acomodar barras negativas que vão para a esquerda). Assim, os cabeçalhos da sua tabela deveriam possuir colspan="2" ou colspan="3" (ou combinações semelhantes), respectivamente, para estender corretamente as colunas.
A predefinição gera duas células, se o parâmetro scale for positivo, e três, se for negativo.
Uso
editar{{bartable|value|unit|scale|height|style}}
- value (obrigatório)
- qualquer número real ou expressão matemática que se avalia como um número. As vírgulas podem ser utilizadas em grupos de dígitos. Ver Ajuda:Cálculo (em inglês: en:Help:Calculation) para a sintaxe de expressões matemáticas.
- unit (padrão = string vazia)
- a unidade, ex: "m" para metros. Adicione um espaço se você quiser um espaço entre o valor e a unidade. Se a unit começa com "/", o valor é convertido entre unidades (usando a predefinição convert) da seguinte maneira:
- "/unit1/unit2/round" converte o valor unit1 para unit2 e rotaciona para casas decimais arredondadas (usando
{{convert|value|unit1|unit2|round|abbr=on}}
). Infelizmente, unit1, unit2 ou round não podem conter um "/" ou um "=" — se alguém souber como permitir isso (ou traduzir outros caracteres para ele), por favor, ajude.
- "/unit1/unit2/round" converte o valor unit1 para unit2 e rotaciona para casas decimais arredondadas (usando
- scale (padrão = 1)
- um fator multiplicado por value para a largura da barra em pixels. Use a mesma escala em cada linha, caso contrário o gráfico da barra não irá dimensionar!
- scale pode ser negativo, neste caso uma coluna adicional é criada (para exibir valores negativos). Ver exemplo abaixo.
- height (padrão = "2ex")
- a altura da barra como uma medida CSS, ex: "1em" or "16px".
- style (padrão = string vazia)
- uma string de estilo CSS a ser aplicada à barra, ex: "background:red;".
Exemplos
editarExemplo prático
editar{| class="wikitable" |+ Melting point at 1 atmosphere ! Substance !! Temperature !! colspan="2" | Relative size |- | Mercury || {{bartable| -38.72|/C/F|-2|1em|background:silver}} |- | Bromine || {{bartable| -7.10|/C/F|-2|1em|background:brown}} |- | Water || {{bartable| 0|/C/F|-2|1em}} |- | Phosphorus || {{bartable| 44.10|/C/F|-2|1em|background:red}} |- | Iodine || {{bartable| 113.50|/C/F|-2|1em|background:indigo}} |- | Sulphur || {{bartable| 115.36|/C/F|-2|1em|background:yellow}} |}
Substance | Temperature | Relative size | |
---|---|---|---|
Mercury | −38,72 °C (−38
°F) || align="right" | |
||
Bromine | −7,1 °C (19 °F) | ||
Water | 0 °C (32 °F) | ||
Phosphorus | 44,10 °C (111,38 °F) | ||
Iodine | 113,50 °C (236,30 °F) | ||
Sulphur | 115,36 °C (239,65 °F) |
De 2 colunas (só valores positivos)
editar{| class="wikitable" ! Example || colspan="2" | Rendering |- | Only value || {{bartable|272}} |- | Negative value || {{bartable|-72}} |- | Math expression || {{bartable|exp(1)*1e2}} |- | Value and unit (note added space) || {{bartable|272| km/h}} |- | Value and unit (link to definition) || {{bartable|272|[[Degree_(angle)|°]]}} |- | Value and unit (with formatting) || align="right"|''θ'' = {{bartable|272|°}} |- | Value and unit (with conversion) || {{bartable|272|/km/mi}} |- | Value and scale || {{bartable|272||1/(2^0.5)}} |- | Value and height || {{bartable|272|||4px}} |- | Value and style || {{bartable|272||||background:blue;}} |- | Value with commas, and scale || {{bartable|2,720||.1}} |- | The full monty || {{bartable|18^2|%|sin(1)|2em|border:ridge red;}} |- |}
Example | Rendering | |
---|---|---|
Only value | 272 | |
Negative value | -72 | |
Math expression | exp(1)*1e2 | |
Value and unit (note added space) | 272 km/h | |
Value and unit (link to definition) | 272° | |
Value and unit (with formatting) | θ = 272° | |
Value and unit (with conversion) | 272 km (170 mi) | |
Value and scale | 272 | |
Value and height | 272 | |
Value and style | 272 | |
Value with commas, and scale | 2,720 | |
The full monty | 18^2% |
De 3 colunas (valores positivos e negativos)
editar{| class="wikitable" ! Example || colspan="3" | Rendering |- | Only value || {{bartable|272||-1}} |- | Negative value || {{bartable|-72||-1}} |- | Math expression || {{bartable|exp(1)*1e2||-1}} |- | Value and unit (note added space) || {{bartable|272| km/h|-1}} |- | Value and unit (link to definition) || {{bartable|272|[[Degree_(angle)|°]]|-1}} |- | Value and unit (with formatting) || align="right"|''θ'' = {{bartable|272|°|-1}} |- | Value and unit (with conversion) || {{bartable|272|/km/mi|-1}} |- | Value and scale || {{bartable|272||-1/(2^0.5)}} |- | Value and height || {{bartable|272||-1|4px}} |- | Value and style || {{bartable|272||-1||background:blue;}} |- | Value with commas, and scale || {{bartable|2,720||-.1}} |- | The full monty || {{bartable|18^2|%|sin(-1)|2em|border:ridge red;}} |- |}
Example | Rendering | ||
---|---|---|---|
Only value | 272 | ||
Negative value | -72 | ||
Math expression | exp(1)*1e2 | ||
Value and unit (note added space) | 272 km/h | ||
Value and unit (link to definition) | 272° | ||
Value and unit (with formatting) | θ = 272° | ||
Value and unit (with conversion) | 272 km (170 mi) | ||
Value and scale | 272 | ||
Value and height | 272 | ||
Value and style | 272 | ||
Value with commas, and scale | 2,720 | ||
The full monty | 18^2% |