Display of trendline with a pocketquery template

Keith Wallace December 14, 2015

I want to display a trendline in pocketquery template:


PocketQuery.chart('LineChart',
{
title: 'Case Trendline',
width: 1000,
heigth: 500,
vAxis: {title: 'Number'},
trendlines: { 0: {
type: 'linear',
color: 'green'},
}
});

 

The SQL query returns the date as string in the form '2015-01'.

A trendline in only displayed if the date column is of object Date. 

Any idea how I can convert the string to a Date object in the pocketquery template, so that a trendline is displayed?

Here is the sql query:

select cast(year(Createdon) as varchar(10)) + '-' + right('0' + cast(month(Createdon) as varchar),2) as [The Month],
count(*) as 'Opened Cases'
from IncidentBase
where casetypecode = 1
and Createdon >= '2012-01-01'
and Createdon <= getdate()
group by cast(year(Createdon) as varchar(10)) + '-' + right('0' + cast(month(Createdon) as varchar),2), convert(varchar(6), Createdon, 112)
order by convert(varchar(6), Createdon, 112)

2 answers

1 accepted

0 votes
Answer accepted
Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2015

Hi Keith,

Thank you for your interest in PocketQuery. I suggest try to use the dataTable option and do some JS transformation such that your result will be accepted by the chart API. It works like this...

&lt;script&gt;
(function() {
  var result = PocketQuery.queryArray(); // result array of the query
  var columnsArray = PocketQuery.queryColumns(); // result columns
  var dataTable = [columnsArray]; // start with one row that contains the query columns
  jQuery.each(result, function(index, row) { // for each row in the result
  	// do some transformation and push adequate data into your dataTable like this:
  	var myDate = new Date(row.column2Name);
    dataTable.push([row.column1Name, myDate, row.whateverColumnName]);
  });
  PocketQuery.chart('Timeline', {
  	// ...your options...
    dataTable: dataTable
  });
}())
&lt;/script&gt;

Let me know if you need further help!

Regards, Felix (Scandio)

ChandraG February 9, 2017

I want to change bar color in pocket query template which is written as below, default color is blue but i want to change as per my requirement. Please suggest.

<script>
PocketQuery.chart('ColumnChart', {
  title: ''Test",
  width: 500,
  height: 450,
  showTip: true
});

0 votes
Keith Wallace December 15, 2015

Perfect. This worked. Thx

Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2015

Glad to hear that! If you like PocketQuery, would you consider leaving a review at the marketplace? :)

Keith Wallace December 15, 2015

I will. Great Tool!

Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2015

Thanks a lot, Keith!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events