Sample usage
SPARKLINE(A1:B8, {"charttype","line";"ymax",10} )
Syntax
- data: the range of cells or array of data to plot on the chart
- options: [OPTIONAL] A range or array of optional settings with their associated values used to customize the chart
- charttype: the type of chart to plot (default is "line")
- Use "line" for a line chart
- Use "bar" for a stacked bar chart
- For line charts only:
- xmin: sets the minimum value along the horizontal axis; any number is a valid value
- xmax: sets the maximum value along the horizontal axis; any number is a valid value
- ymin: sets the minimum value along the vertical axis; any number is a valid value
- ymax: sets the maximum value along the vertical axis; any number is a valid value
- For bar charts only:
- max: sets the maximum value along the horizontal axis; any number is a valid value
Notes on sparkline syntax
- For line charts, "data" can either be a 1-dimensional array of values or a 2-dimensional array containing values and spacing along the horizontal axis.
- For bar charts, only one row or column of data can be plotted.
- The "text color" and "text background color" buttons in the spreadsheet toolbar can be used to set the color and background color for line charts.
- Each sparkline function only accepts a few hundred data points. If a broken image icon is shown in the cell, try reducing the number of data points plotted on the chart and try again.
Common errors
- When entering customization options using an array, make sure the options are formatted using curly brackets { }.
- Options can be placed in a N x 2 range (ie. any number of rows but only two columns) in the spreadsheet and a reference to that range (eg. C1:D4) can be used.
- In array notation (using curly brackets), options are separated from their associated values using commas (,) and option-value pairs are separated by semicolons (;). For example: {option1, value1; option2, value2; ... }.
Examples of a sparkline function use
Insert a simple sparkline
=SPARKLINE(A1:A5)

Insert a sparkline using optional parameters
Reference a range
=SPARKLINE(A2:E2, A4:B5)

Use an array
=SPARKLINE(A1:A5, {"charttype","bar";"max",40})

Plot stock prices
Plot the price of a stock over a 30-day period
=SPARKLINE(GOOGLEFINANCE("GOOG","price",TODAY()-30,TODAY()))

