It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Pocket Query DataTables


I am trying to create a Column Chart using Pocket Query. Could you please tell me how to create a DataTable like this: (I would place this in the Template)

var dataTable = new google.visualization.DataTable();

Assuming this is accepted by this line:

PocketQuery.chart('ColumnChart', {
dataTable: dataTable,
options: options

Or tell me the data array format required to create a stacked column chart showing dates on the X-axis and stacked values of data on the Y-Axis.


3 answers

1 accepted

0 votes
Answer accepted


I agree with you and that works to a point see below. First of all I have three SUM'ed values since I would like a stacked chart so I send in options too.

Like this: (Quick Example Code)

var options = {
interpolateNulls: true,
chartArea: {left: 100, width: '85%', height: '60%'},
title: 'Total Hours over Time',
titleTextStyle: {fontSize: 15},
vAxis: {
title: 'Accumulated Hours',
minValue: 0,
maxValue: 18000
legend: {position: 'top', maxLines: 3}

// Could pass this
options.isStacked = true;

PocketQuery.chart('ColumnChart', options);

and it creates the chart below. 

But the dates are converted from the Human readable date shown in the Table below to the number of seconds which is unless. Therefore I wanted to re-construct the DataTable array applying new Date(X-Axis.value) to every element then send the new form Data Table to the PocketQuery Chart Function like this:

PocketQuery.chart('ColumnChart', {
dataTable: dataTable,
options: options

But it won't let me create a google DataTable and I don't know the format required if its built as an array.

So close, thanks for your assistance and quick response. I am liking Pocket Query.


The simplest way to change that is to use date_format in the SQL statement

SELECT DATE_FORMAT(your_date ,'%Y-%m-%d') ...

Hi Mark,

if your SQL statement results proper columns PocketQuery.chart() handles the data for you. For example you use a statement like this

SELECT DISTINCT month, SUM(value) as result FROM table GROUP BY month;

then your template is very simpe


and it works. If you want to use Google chart options this is a second parameter. You'll find more information in the documentation in the template section and in the JavaScript API section.


If you want to stacked column the use

PocketQuery.chart('ColumnChart', {isStacked: true})

But in that case your statement must return more columns.

Hi Mark,

Thank you for your interest in PocketQuery! The dataTable option must be an array of arrays representing the values of your table. You can call PocketQuery.queryArray() to obtain the result of your query and then iterate over it creating your own array.

Something along these lines:

(function() {
	var result = PocketQuery.queryArray();
	var dataTable = [];
	jQuery.each(PocketQuery.queryArray(), function(index, row) {
		dataTable.push([row.column1name, row.column2name, row.column3name]);
	PocketQuery.chart('ColumnChart', {dataTable: dataTable});

When you create the new rows for the dataTable, you can do arbitrary transformations with the values using JavaScript.

Please also check this: and this:

Best, Felix (Scandio)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Expose your beautifully crafted Dashboard through the Jira Service Desk Customer Portal

  A picture is worth a thousand words, especially when you're trying to find relationships and understand your data. Here, Dashboards play a vital role in gaining insights from a variety of dat...

215 views 3 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you