PocketQuery failing when resultant has & in it

I wrote a query which returns me Confluence Space Name and Number of active pages in it. I nested PocketQuery Macro in Chart Macro to have bar graph. The rendering failed because one of the space name has '&' in it. Using just PocketQuery macro returns me a table without any errors.

Here is the error i am getting:

The entity name must immediately follow the '&' in the entity reference. Nested exception: The entity name must immediately follow the '&' in the entity reference

.I modified my query to omit the space with & and bang the chart appeared perfectly.

 

We are on MySQL

2 answers

Hi Pranjal,

Thank you for your interest in PocketQuery! There seems to be an issue with the Chart macro which apparently breaks with different combinations:

https://jira.atlassian.com/browse/CONF-33581

Have you tried to use the PocketQuery chart abilities instead? You could create a custom template for a 'BarChart' as explained in the PocketQuery documentation or the article on templating

You could probably try with this template as a starting point:

<script>
PocketQuery.chart('BarChart');
</script>

Let me know if this helps!

Regards, Felix (Scandio)

I did try but the bars are getting smudged as their are 20 odd. Any way to increase the size of the chart the way it's there in chart macro?

Yes of course you can configure the size. You can basically pass all possible options to the PocketQuery.chart call, see here: https://developers.google.com/chart/interactive/docs/gallery/barchart#configuration-options For example, this will make the chart 400px high, 700px wide and each bar 20px wide: <script> PocketQuery.chart('BarChart', { height: 400, width: 700, bar: { groupWidth: 20 } }); </script>

Felix, I have a question. How do i change the color of the bars in PC charts. The examples you pointed me to are defining bar colors while defining the data. In this case data is getting populated via query. I could relate that in PC function PocketQuery.chart(), second argument is actually variable options defined in goggle examples. var options = { title: "Density of Precious Metals, in g/cm^3", width: 600, height: 400, bar: {groupWidth: "95%"}, legend: { position: "none" }, };

Hi Pranjal,

regarding the chart colors, you can take my last example in the article PocketQuery templating. You need to provide your own data table to the charts API that you can build up from the query result. For this you need to do some JS programming along these lines:

&lt;script&gt;
(function() {
	// result from the query as array of row objects
	var result = PocketQuery.queryArray();
	// the new datatable for the chart
	var dataTable = [];
	// some logic to get the data you with into the new dataTable
	$.each(result, function(rowNumber, rowObject) {
		dataTable.push(rowObject.nameColumn, rowObject.numberColumn, 'someColourHere');
	});
	PocketQuery.chart('BarChart', {
		title: "Density of Precious Metals, in g/cm^3",
		width: 600,
		height: 400,
		bar: {groupWidth: "95%"},
		legend: { position: "none" },
		dataTable: dataTable // provide a custom data table for the chart
	});
}(jQuery));
&lt;/script&gt;

Let me know if you need further help!

Felix

 

Felix,

The above template doesn't seem to work. Could you please check once again?

Hi Pranjal! I'll call this P4 according to what we wrote in your other request wink

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,943 views 27 12
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