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" },
                       2]);

And then pass view at the draw() function.

 

My current code to display a bar is simple as:

<script>
PocketQuery.chart('BarChart', {
  height: 700,
  chartArea: {
    height: '100%',
    width: '50%'
  }
});
</script>
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:

<script>
(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});
}());
</script>

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

387 views 17 9
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