How can I center a chart produced via PocketQuery?
Asked by lcc:

I would like to center the charts produced via PocketQuery. Centering the PocketQuery macro does nothing to the chart, it always renders against the left side.  
[](https://community.atlassian.com/t5/Confluence-questions/How-can-I-center-a-chart-produced-via-PocketQuery/qaq-p/122071?attachment-id=9869){#link_1190d1290f8956}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/20319/1/screen-chart.png){#display_1190d1290f8956_0}  
[](https://community.atlassian.com/t5/Confluence-questions/How-can-I-center-a-chart-produced-via-PocketQuery/qaq-p/122071?attachment-id=9870){#link_1190d1290f8956_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/20319/2/2-column-example-sized.PNG){#display_1190d1290f8956_2}  
[](https://community.atlassian.com/t5/Confluence-questions/How-can-I-center-a-chart-produced-via-PocketQuery/qaq-p/122071?attachment-id=9871){#link_1190d1290f8956_1}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/20319/3/2-column-example-no-size.PNG){#display_1190d1290f8956_4}


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

Can you try to put this on top of your template:

```
&lt;style&gt;.pocket-chart div[dir='ltr'] { margin: 0 auto; }&lt;/style&gt;
```

Regards, Felix

comments: author: lcc
body: Felix,

Thanks for the tip, I was able to get it to work for Pie, Line and Bar chart's. I haven't had any luck yet with the Gauge chart. I have a few more things to check, I'll let you know if I succeed or not.

Thank you for your help! I've been chasing this on and off for awhile.

Lynn


author: Felix Grund (Scandio)
body: Thanks Lynn! I'll check with Gauge myself later. If you haven't yet, would you consider leaving a review for PQ on the marketplace? :smile:


author: Felix Grund (Scandio)
body: For my Gauge chart example it worked like this:

```
&lt;style&gt;.pocket-chart &gt; table { margin: 0 auto; }&lt;/style&gt;
```


author: lcc
body: Hi Felix,

I think I've found what's happening. If you define the chart without setting a width, it will fill the container you place the chart it. For example the following is from a two column page and the pie chart fills each column and is centered.

2-column-example-no-size.PNG

On the other hand if you try to define the size of the chart. The chart get's rendered but the result is not centered. For example the same chart, same two column page format, but with a width and height of 400 pixels. The chart renders, but is rendered up against the left side of the column.

2-column-example-sized.PNG

The template is defined as:

```
<script>var options = {        pieSliceText: 'value',        height: 400,        width: 400,        sliceVisibilityThreshold: 0,        backgroundColor: {stroke: "#666", strokeWidth: 1}};PocketQuery.chart('PieChart',options);</script>
```

I've tried putting a \<div\> tag around everything and a few other ideas, but I haven't found a combination that works yet.

Thanks,

Lynn


author: Felix Grund (Scandio)
body: Hi Icc,

In my example, the chart is already centered by default actually:

screen-chart.png

Can you provide a screenshot?

Regards, Felix (Scandio)


author: Monika Antos [Adaptavist]
body: If nothing else works, you may want to explore the 'center' macro from the free Content Formatting Macros add-on:

<http://www.adaptavist.com/doco/display/CFP/center+Macro>

Cheers!

comments: author: Felix Grund (Scandio)
body: I would not recommend to use the center macro since output of the PocketQuery macro will always depend on a macro of another plugin. I'd try to minimize cross-plugin dependencies as far as possible.


Tags: pocketquery