Charts (Sparklines)

You are here:

jQuery Sparklines is a JavaScript library that can make a couple of types of sparkline charts on a website. We use this library as one of our basic charting libraries (alongside RGraph).

CHART / CHART_sparklines function

To show an RGraph chart in your spreadsheet you can use a function CHART or CHART_SPARKLINES. The syntax for both functions is similar, except that CHART_SPARKLINES doesn’t require argument library:

=CHART(xvalues, yvalues, library, type, options)

=CHART_SPARKLINES(xvalues, yvalues, type, options)

The arguments meaning:

xvalues – a sequence of numbers (1, 2, 3, 4, …) or cell addresses (A1, A2, A3, …) or a range (A1:A20) specifying labels on x-axis,

yvalues – a sequence of numbers (1, 2, 3, 4, …) or cell addresses (A1, A2, A3, …) or a range (A1:A20) specifying values on y-axis,

library – “rgraph” (with quotes, single or double) specifying library,

type – “line”, “bar”, “pie”, … (with quotes) specifying type of the chart,

options – library specific options, like thickness of the line or bar, shadow etc. Currently the full specification can be found on the library’s website. Options are not mandatory and the field can be left blank. If the value of option is set to be TRUE or FALSE, it needs to be given with quotes (“TRUE” or “true”). The same applies to the colours (“blue”).

A couple of examples:

=CHART([1,2,3,4,5,6,7,8,9,10],[12,6,21,45,32,11,35,65,43,26],"sparklines","line",[{height:60,width:300,lineWidth:3,fillColor:"blue"}])
=CHART([],[1,1,2,5,7,9,3,1],"sparklines","pie",[{width:65,height:65,lineWidth:2,sliceColors:["#3366cc","#dc3912","#ff9900","#109618","#66aa00","#dd4477","#0099c6","#990099"]}])

Insert chart

The process of adding charts can be eased by using ‘Insert chart’ option from the menu or toolbar. Currently, there are 7 types of sparkline charts that can be used:

Line, Bar, Tristate, Discrete, Bullet, Pie, Box.

User can specify main features of the chart, specific for chosen type. A special field ‘Options’, can be used to specify additional features like colours, position of individual chart elements, etc. The options are chart type specific and can be found at jQuery Sparklines page.