[PocketQuery] Google Chart Api formatting all dates in Epoch...

Deleted user May 8, 2014

I've tried using hAxis: {format: 'MM/d/y'} to force it to a more normal format, but it doesn't do anything at all...Is there anyway to force the format for a specific column in a pocketquery dataset that's been returned from the query, and then render the chart?

<!-- Template Contents -->

<script>

var options = { hAxis: {format: 'MM/d/y'} };

PocketQuery.chart('LineChart', options);

</script>

That just blatantly ignores the format change even though it should adjust accordingly...

3 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.
May 20, 2014

I analysed this a little further and found the source of the problem: we're serializing the result from the database to JSON using (FlexJSON) and then passing the JSON to Google Charts. FlexJSON serializes all date strings to epoch numbers and in Google Charts this number is displayed.

However, I also checked what would happen if FlexJSON didn't serialize the strings to numbers. If the strings stay in a default date format in the JSON string, Google Charts won't format the dates properly either.

I'm currently implementing a new feature in PocketQuery with which you'll be able to override the data that is given to the Google Charts API. With this feature, you can use a DateFormatter object and make the dates format as you desire. This will take some more time though and will be part of either PocketQuery 1.13 or 1.14. In the meantime, your workaround seems quite smart to me.

Deleted user May 20, 2014

Thanks for the update. I'm still exploring what's possible with the Google Charts api through your addon so far things are working really well. I'll definitely be looking forward to the update.

Christian Koch May 21, 2014

Thanks for the feedback! If you like it, why not leave a little review on the Marketplace? :)

0 votes
Deleted user May 18, 2014

I ended up getting it to work by doing the following in the query itself. It would be nice to be able to format with hAxis properties, seems some work, while others do not.

CONVERT(nvarchar(10),dateadd(DAY,0,datediff(day,0,CreatedTime)), 101)

In both tables and charts that I have tried to just use the CreatedTime and then apply hAxis format string, it still renders the CreatedTime in epoch.

0 votes
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.
May 15, 2014

Hi Jason,

Sorry I read that post a little too late. I hope you're still interested in a reply ;). Can you please show me your SQL statement? The rendered table when you use the default template would be helpful too.

Felix

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events