All Sparkline Line Chart Options in Google Sheets (Formula Examples)

Published on

Most users customize only the color and line width in Sparkline Line charts. But there are more options available. In this guide, I’ll show you how to use all the Sparkline Line Chart Options in Google Sheets—so you can better understand and modify advanced formulas when you come across them.

What Is a Sparkline Line Chart?

A Sparkline Line chart is a mini line graph in a single cell that helps you quickly visualize changes over time. It’s ideal for tracking trends without using a full chart.

All Available Sparkline Line Chart Formula Options

Syntax

SPARKLINE(data, [options])

Here’s a full example that includes all the line chart options:

=SPARKLINE(D2:O3, A2:B11)
Example of all available options used in a Sparkline line chart formula in Google Sheets

Or using inline parameters:

=SPARKLINE(D2:O3, {
  "charttype","line";
  "color","red";
  "empty","ignore";
  "nan","ignore";
  "rtl",false;
  "linewidth",2;
  "xmin",1;
  "xmax",12;
  "ymin",MIN(D3:O3);
  "ymax",MAX(D3:O3)
})

You can also skip options entirely:

=SPARKLINE(D2:O3)

The chart still works—just with default settings.

1. Color and Line Width Options

To change the line color and thickness, use the "color" and "linewidth" options:

=SPARKLINE(D2:O3, {
  "charttype","line";
  "color","red";
  "linewidth",3
})
Customizing the color and line thickness in a line Sparkline chart using formula options

2. Handling Empty and Non-Numeric Values

Use the "empty" and "nan" options to control how Sparkline treats missing or invalid data.

“empty” Option

=SPARKLINE(D2:O3, {"charttype","line";"color","red";"linewidth",3;"empty","zero"})
=SPARKLINE(D2:O3, {"charttype","line";"color","red";"linewidth",3;"empty","ignore"})
  • “zero”: treats empty cells as 0.
  • “ignore”: skips empty cells.
Comparison of Sparkline behavior when empty cells are treated as zero versus ignored

“nan” Option

If a cell contains non-numeric text like "Nil":

=SPARKLINE(D2:O3, {"charttype","line";"color","red";"linewidth",3;"nan","convert"})
=SPARKLINE(D2:O3, {"charttype","line";"color","red";"linewidth",3;"nan","ignore"})
  • “convert”: converts text to 0.
  • “ignore”: ignores it completely.

3. Draw the Line from Right to Left (RTL)

Use "rtl" to reverse the direction of the chart:

=SPARKLINE(D2:O3, {"charttype","line";"color","red";"linewidth",3;"rtl",true})

4. Set Axis Limits: "xmin", "xmax", "ymin", "ymax"

Sparkline auto-detects y-axis bounds, but you can define them:

=SPARKLINE(D3:O3, {"charttype","line";"ymin",MIN(D3:O3);"ymax",MAX(D3:O3)})

Set X-Axis Min/Max

You can use "xmin" and "xmax" to filter the x-values only if you provide an explicit x-axis row. If you omit the x-axis, these settings won’t filter the data—they’ll have no visible effect on the chart.

To demonstrate, I’ll use virtual arrays created with HSTACK and VSTACK functions instead of real cell ranges.

How xmin and xmax filter data points when an x-axis is specified in a line Sparkline chart

Example 1:

=SPARKLINE(VSTACK(HSTACK(1, 2, 3, 4, 5, 6, 7), HSTACK(10, 20, 15, 25, 12, 30, 18)), 
 {"charttype","line";"xmin",2;"xmax",6})

Here, the first row represents the x-axis values:
{1, 2, 3, 4, 5, 6, 7}
The second row is the y-values:
{10, 20, 15, 25, 12, 30, 18}

Since "xmin" is 2 and "xmax" is 6, only the y-values corresponding to x = 2 through x = 6 are plotted:
{20, 15, 25, 12, 30}

Example 2:

=SPARKLINE(HSTACK(20, 15, 25, 12, 30), {"charttype","line"})

This uses just those same five y-values directly, without an x-axis.

Note: When "xmin" and "xmax" are used with an explicit x-axis, Sparkline filters the y-values that fall within that x-range. It does not affect the axis scale alone—it determines which data points are drawn.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

More like this

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.