Pocketquery: how to display a bar chart with annotations on bars

From the official Google docs about Google Charts I see in the example "Density of Precious Metals, in g/cm^3" I can annotate the value of the bars at its end by adding

var view = new google.visualization.DataView(data);
      view.setColumns([0, 1,
                       { calc: "stringify",
                         sourceColumn: 1,
                         type: "string",
                         role: "annotation" },

And then pass view at the draw() function.


My current code to display a bar is simple as:

PocketQuery.chart('BarChart', {
  height: 700,
  chartArea: {
    height: '100%',
    width: '50%'
How can I add annotations like that by using PocketQuery? Which is the correct call?
Thank you for any help.

1 answer

Hi Stefano,

Sorry for the late reply! In your case, you need to manipulate the data array for the charts. You can achieve this that way:

(function() {
    // Create a new data table object in which the first row already contains
    // the table headers.
    var dataTable = [['col1', 'col2', {role: 'style'}]];
    // Iterate through the PocketQuery result and add the values to the data table. You can do arbitrary manipulations with the data before.
    jQuery.each(PocketQuery.queryArray(), function(index, row) {
        dataTable.push([row.col1, row.col2, '#ccc']);
    PocketQuery.chart('AnnotationChart', {dataTable: dataTable});

You should try around in your developer tools and the JS debugger to dig more into this surrounding. Let me know if you need further help!

Regards, Felix [Scandio]

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Dec 10, 2018 in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

197 views 5 7
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you