Template:Sparkline

From MediaWiki.org
Jump to navigation Jump to search
Template documentation


Example[edit]

TemplateData[edit]

Create a sparkline graph of at least 2 and up to 24 values; x values should be Unix epoch timestamps, y values should be numbers. Values can be in any order.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
X1x1

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numberrequired
Y1y1

Y value at the corresponding time

Example
35
Numberrequired
X2x2

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numberrequired
Y2y2

Y value at the corresponding time

Example
35
Numberrequired
X3x3

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y3y3

Y value at the corresponding time

Example
35
Numbersuggested
X4x4

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y4y4

Y value at the corresponding time

Example
35
Numbersuggested
X5x5

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y5y5

Y value at the corresponding time

Example
35
Numbersuggested
X6x6

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y6y6

Y value at the corresponding time

Example
35
Numbersuggested
X7x7

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y7y7

Y value at the corresponding time

Example
35
Numbersuggested
X8x8

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y8y8

Y value at the corresponding time

Example
35
Numbersuggested
X9x9

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y9y9

Y value at the corresponding time

Example
35
Numbersuggested
X10x10

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y10y10

Y value at the corresponding time

Example
35
Numbersuggested
X11x11

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y11y11

Y value at the corresponding time

Example
35
Numbersuggested
X12x12

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y12y12

Y value at the corresponding time

Example
35
Numbersuggested
X13x13

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y13y13

Y value at the corresponding time

Example
35
Numbersuggested
X14x14

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y14y14

Y value at the corresponding time

Example
35
Numbersuggested
X15x15

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y15y15

Y value at the corresponding time

Example
35
Numbersuggested
X16x16

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y16y16

Y value at the corresponding time

Example
35
Numbersuggested
X17x17

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y17y17

Y value at the corresponding time

Example
35
Numbersuggested
X18x18

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y18y18

Y value at the corresponding time

Example
35
Numbersuggested
X19x19

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y19y19

Y value at the corresponding time

Example
35
Numbersuggested
X20x20

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y20y20

Y value at the corresponding time

Example
35
Numbersuggested
X21x21

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y21y21

Y value at the corresponding time

Example
35
Numbersuggested
X22x22

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y22y22

Y value at the corresponding time

Example
35
Numbersuggested
X23x23

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y23y23

Y value at the corresponding time

Example
35
Numbersuggested
X24x24

Time value for one of the points, as a Unix timestamp

Example
1446336000
Numbersuggested
Y24y24

Y value at the corresponding time

Example
35
Numbersuggested
Image Widthwidth

Width of the image in pixels

Default
100
Numberoptional
Image Heightheight

Height of the image in pixels

Default
25
Unknownoptional
Line colorcolor

no description

Default
gray
Stringoptional


<graph>

{
   "version": 2,
   "width": 100,
   "height": 25,
   "data": [ {
      "name": "data",
      "values": 
      [ 
        { "x": 10, "y": 100 }
      , { "x": 20, "y": 200 }
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      ]
   } ],
   "scales": [
   {
      "name": "xscale",
      "type": "time",
      "range": "width",
      "domain": {"data": "data", "field": "x"}
   },
   {
      "name": "yscale",
      "type": "linear",
      "range": "height",
      "domain": {"data": "data", "field": "y"}
    }
  ],
  "marks": [
    {
      "from": {"data": "data"},
      "type": "line",
      "properties": {
        "enter": {
          "x": {"scale": "xscale", "field": "x"},
          "y": {"scale": "yscale", "field": "y"},
          "stroke": {"value": "grey"},
          "strokeWidth": {"value": 2}
        }
      }
    }
  ]
}

</graph>