PocketQuery failing when resultant has & in it
Asked by Pranjal Shukla:

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 '&amp;' in the entity reference. Nested exception: The entity name must immediately follow the '&amp;' in the entity reference
```

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

We are on MySQL


Answers:
author: Felix Grund (Scandio)
body: Hi Pranjal,

regarding the chart colors, you can take my last example in the article [PocketQuery templating](https://www.scandio.de/atlassian/plugins/pocketquery/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

comments: author: Pranjal Shukla
body: Felix,

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


author: Felix Grund (Scandio)
body: Hi Pranjal! I'll call this P4 according to what we wrote in your [other request](https://answers.atlassian.com/questions/36119279/comments/36187417) :wink:


author: Felix Grund (Scandio)
body: 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](https://www.scandio.de/en/atlassian/plugins-en/pocketquery-en/pocketquery-documentation/) or the [article on templating](https://www.scandio.de/atlassian/plugins/pocketquery/pocketquery-templating/).

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

```
&lt;script&gt;PocketQuery.chart('BarChart');&lt;/script&gt;
```

Let me know if this helps!

Regards, Felix (Scandio)

comments: author: Pranjal Shukla
body: 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?


author: Felix Grund (Scandio)
body: 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\>


author: Pranjal Shukla
body: 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" }, };


Tags: pocketquery