• Home
  • Random
  • Nearby
  • Log in
  • Settings
Donate Now If Wikipedia is useful to you, please give today.
  • About Wikipedia
  • Disclaimers
Wikipedia

Template:Value color

  • Template
  • Talk
  • Language
  • Watch
  • Edit
Template documentation[view] [edit] [history] [purge]
Shortcut
  • {{vcolorTemplate:Vcolor}}
This template uses Lua:
  • Module:Value color (sandbox)

This template returns the color for a given value in a range. It interpolates the colour between given min and max values and colors (if not specified, these are assumed to be white for the min and black for the max). It might be a good idea to use it with a template like {{Greater color contrast ratio}} to make sure the text is legible.

Usage

edit

{{Value color|value|min|max|min color|max color}}

Parameters
  • |1= - The value of the cell. Must be a number.
  • |2= - The minimum value of the range.
  • |3= - The maximum value of the range.
  • |4= - The color for the minimum value specified by |2=.
  • |5= - The color for the maximum value specified by |3=.
  • |hex= - Return the color in the format #RRGGBB rather than rgb(RRR, GGG, BBB).

Examples

edit
  • <span style="color:{{Value color|10|10|20|FF0000|0000FF}}">Foo</span> → Foo
  • <span style="color:{{Value color|15|10|20|FF0000|0000FF}}">Foo</span> → Foo
  • <span style="color:{{Value color|20|10|20|FF0000|0000FF}}">Foo</span> → Foo
  • {{Value color|50|25|100|FF0000|0000FF}} → rgb(170,0,85)
  • {{Value color|50|25|100|FF0000|0000FF|hex=y}} → #aa0055

See also

edit
  • {{Cell color}}
The above documentation is transcluded from Template:Value color/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Value_color&oldid=1064569514"
Last edited on 9 January 2022, at 01:59

Languages

    • العربية
    • Авар
    • বাংলা
    • Esperanto
    • ਪੰਜਾਬੀ
    • Slovenščina
    • اردو
    Wikipedia
    • Wikimedia Foundation
    • Powered by MediaWiki
    • This page was last edited on 9 January 2022, at 01:59 (UTC).
    • Content is available under CC BY-SA 4.0 unless otherwise noted.
    • Privacy policy
    • About Wikipedia
    • Disclaimers
    • Contact Wikipedia
    • Code of Conduct
    • Developers
    • Statistics
    • Cookie statement
    • Terms of Use
    • Desktop