PocketQuery failing when resultant has & in it

Pranjal Shukla November 18, 2015

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

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.
November 23, 2015

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:

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

Let me know if you need further help!

Felix

 

Pranjal Shukla February 17, 2016

Felix,

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

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.
February 22, 2016

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

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.
November 18, 2015

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)

Pranjal Shukla November 18, 2015

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?

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.
November 18, 2015

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>

Pranjal Shukla November 19, 2015

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events