Control/filter in PocketQuery macro

hello, Im using PocketQuery macro in confluence and I don't know how to set up some kind of controller/filter as described here https://developers.google.com/chart/interactive/docs/gallery/controls

can you please give me an example how to set it up? what code write into pocketquery template and what in confluence page?

thanks in advance!

michal

3 answers

This widget could not be displayed.

Hi Michal,

Thank you for your interest in PocketQuery. In the Google Chart docs, there is a link to a jsfiddle:

screen-gcharts.png

Could you prepare your demo scenario with the GC API without PocketQuery? I will then have a look on how this can be integrated in a PQ template.

Regards, Felix

This widget could not be displayed.

Hello Felix,

here is my example https://jsfiddle.net/nsma8h55/1/

I figured it out somehow in jsfiddle, I had to use controlType "CategoryFilter" because for NumberRangeFilter the column has to be number (in my case it is string in format 2015.00.00). So this kind of behavior would be fine for me.

And is there possibility to show eg. last 3 rows by default and then change it within that filter?

Thanks for your help!

Michal

Hi Michal! In view mode of the page with the PocketQuery macro, could you open a dev console in your browser and run PocketQuery.chartJson("yourQueryName") ? I'd like to examine your result and if it's compatible for the Google Chart API.

hi, here is the result: "{"cols":[{"id":"releaseID","label":"releaseID","type":"string"},{"id":"US","label":"US","type":"number"},{"id":"CA","label":"CA","type":"number"},{"id":"GB","label":"GB","type":"number"},{"id":"IE","label":"IE","type":"number"},{"id":"ES","label":"ES","type":"number"},{"id":"WW","label":"WW","type":"number"},{"id":"AVERAGE","label":"AVERAGE","type":"number"}],"rows":[{"c":[{"v":"2015.08.00"},{"v":2178.66},{"v":2308.80},{"v":2218.10},{"v":2422.66},{"v":2158.50},{"v":2145.70},{"v":2238.736666}]},{"c":[{"v":"2015.08.00"},{"v":2274.08},{"v":2128.56},{"v":2351.60},{"v":2251.68},{"v":2383.40},{"v":2221.26},{"v":2268.430000}]},{"c":[{"v":"2015.08.00"},{"v":2567.52},{"v":2631.80},{"v":2603.50},{"v":2696.34},{"v":2745.50},{"v":2820.26},{"v":2677.486666}]},{"c":[{"v":"2015.08.00"},{"v":4071.15},{"v":4060.05},{"v":3727.35},{"v":4735.25},{"v":4303.90},{"v":3851.88},{"v":4124.930000}]},{"c":[{"v":"2015.09.00"},{"v":3830.82},{"v":3706.35},{"v":3652.75},{"v":5080.93},{"v":4087.80},{"v":3937.18},{"v":4049.305000}]},{"c":[{"v":"2015.09.00"},{"v":3910.88},{"v":3962.05},{"v":3711.25},{"v":4536.48},{"v":4058.00},{"v":4031.90},{"v":4035.093333}]},{"c":[{"v":"2015.09.00"},{"v":3963.90},{"v":3584.43},{"v":3569.32},{"v":4853.68},{"v":3871.12},{"v":4147.85},{"v":3998.383333}]},{"c":[{"v":"2015.09.00"},{"v":4089.43},{"v":3465.20},{"v":3522.60},{"v":3959.50},{"v":3938.40},{"v":3701.22},{"v":3779.391666}]},{"c":[{"v":"2015.10.00"},{"v":2660.62},{"v":2580.70},{"v":2707.50},{"v":3135.85},{"v":2602.75},{"v":2536.32},{"v":2703.956666}]},{"c":[{"v":"2015.10.00"},{"v":3519.72},{"v":4166.82},{"v":4014.85},{"v":6525.50},{"v":4010.55},{"v":3718.50},{"v":4325.990000}]},{"c":[{"v":"2015.10.00"},{"v":3604.32},{"v":4142.70},{"v":4569.00},{"v":5960.62},{"v":3740.70},{"v":3388.50},{"v":4234.306666}]},{"c":[{"v":"2015.11.00"},{"v":5232.32},{"v":3381.38},{"v":3078.47},{"v":2521.22},{"v":4617.52},{"v":2163.78},{"v":3499.115000}]},{"c":[{"v":"2015.11.00"},{"v":5360.77},{"v":3491.38},{"v":2980.25},{"v":2143.97},{"v":4154.90},{"v":1926.62},{"v":3342.981666}]},{"c":[{"v":"2015.11.00"},{"v":5734.48},{"v":2750.75},{"v":3194.78},{"v":2254.10},{"v":4497.05},{"v":1994.85},{"v":3404.335000}]},{"c":[{"v":"2015.12.00"},{"v":2541.15},{"v":2548.43},{"v":2547.45},{"v":3511.50},{"v":2575.78},{"v":2499.12},{"v":2703.905000}]},{"c":[{"v":"2015.12.00"},{"v":3037.78},{"v":2740.15},{"v":2633.50},{"v":3826.10},{"v":2951.45},{"v":2571.30},{"v":2960.046666}]},{"c":[{"v":"2015.12.00"},{"v":3187.60},{"v":2785.03},{"v":2699.47},{"v":3926.05},{"v":2950.88},{"v":2768.68},{"v":3052.951666}]},{"c":[{"v":"2015.12.00"},{"v":3247.35},{"v":3003.10},{"v":2775.95},{"v":4205.65},{"v":2868.75},{"v":3136.65},{"v":3206.241666}]},{"c":[{"v":"2015.13.00"},{"v":2873.38},{"v":2741.25},{"v":2931.12},{"v":3901.62},{"v":2770.00},{"v":3116.29},{"v":3055.610000}]},{"c":[{"v":"2015.15.00"},{"v":2168.93},{"v":2330.55},{"v":2167.38},{"v":2073.75},{"v":2182.55},{"v":2078.95},{"v":2167.018333}]},{"c":[{"v":"2015.15.00"},{"v":2240.72},{"v":2393.68},{"v":2137.72},{"v":2112.90},{"v":2153.55},{"v":2258.57},{"v":2216.190000}]},{"c":[{"v":"2015.15.00"},{"v":2385.65},{"v":2617.38},{"v":2400.97},{"v":2273.10},{"v":2405.85},{"v":2434.68},{"v":2419.605000}]},{"c":[{"v":"default"},{"v":2318.57},{"v":2318.43},{"v":2144.00},{"v":2042.57},{"v":2202.67},{"v":2336.43},{"v":2227.111666}]},{"c":[{"v":"default"},{"v":2582.22},{"v":2289.50},{"v":2241.10},{"v":2278.20},{"v":2241.53},{"v":2585.45},{"v":2369.666666}]}]}"

Can you also paste the result for PocketQuery.queryArray("yourQueryName") ?

[Object { releaseID="2015.08.00", US=2178.66, CA=2308.8, více...}, Object { releaseID="2015.08.00", US=2274.08, CA=2128.56, více...}, Object { releaseID="2015.08.00", US=2567.52, CA=2631.8, více...}, Object { releaseID="2015.08.00", US=4071.15, CA=4060.05, více...}, Object { releaseID="2015.09.00", US=3830.82, CA=3706.35, více...}, Object { releaseID="2015.09.00", US=3910.88, CA=3962.05, více...}, Object { releaseID="2015.09.00", US=3963.9, CA=3584.43, více...}, Object { releaseID="2015.09.00", US=4089.43, CA=3465.2, více...}, Object { releaseID="2015.10.00", US=2660.62, CA=2580.7, více...}, Object { releaseID="2015.10.00", US=3519.72, CA=4166.82, více...}, Object { releaseID="2015.10.00", US=3604.32, CA=4142.7, více...}, Object { releaseID="2015.11.00", US=5232.32, CA=3381.38, více...}, Object { releaseID="2015.11.00", US=5360.77, CA=3491.38, více...}, Object { releaseID="2015.11.00", US=5734.48, CA=2750.75, více...}, Object { releaseID="2015.12.00", US=2541.15, CA=2548.43, více...}, Object { releaseID="2015.12.00", US=3037.78, CA=2740.15, více...}, Object { releaseID="2015.12.00", US=3187.6, CA=2785.03, více...}, Object { releaseID="2015.12.00", US=3247.35, CA=3003.1, více...}, Object { releaseID="2015.13.00", US=2873.38, CA=2741.25, více...}, Object { releaseID="2015.15.00", US=2168.93, CA=2330.55, více...}, Object { releaseID="2015.15.00", US=2240.72, CA=2393.68, více...}, Object { releaseID="2015.15.00", US=2385.65, CA=2617.38, více...}, Object { releaseID="default", US=2318.57, CA=2318.43, více...}, Object { releaseID="default", US=2582.22, CA=2289.5, více...}, Object { releaseID="default", US=3301.25, CA=2733.88, více...}]

Ok, I need a serialized version of this. Please run JSON.stringify(PocketQuery.queryArray("yourQueryName")). Sorry for this ;)

"[{"releaseID":"2015.08.00","US":2178.66,"CA":2308.8,"GB":2218.1,"IE":2422.66,"ES":2158.5,"WW":2145.7,"AVERAGE":2238.736666},{"releaseID":"2015.08.00","US":2274.08,"CA":2128.56,"GB":2351.6,"IE":2251.68,"ES":2383.4,"WW":2221.26,"AVERAGE":2268.43},{"releaseID":"2015.08.00","US":2567.52,"CA":2631.8,"GB":2603.5,"IE":2696.34,"ES":2745.5,"WW":2820.26,"AVERAGE":2677.486666},{"releaseID":"2015.08.00","US":4071.15,"CA":4060.05,"GB":3727.35,"IE":4735.25,"ES":4303.9,"WW":3851.88,"AVERAGE":4124.93},{"releaseID":"2015.09.00","US":3830.82,"CA":3706.35,"GB":3652.75,"IE":5080.93,"ES":4087.8,"WW":3937.18,"AVERAGE":4049.305},{"releaseID":"2015.09.00","US":3910.88,"CA":3962.05,"GB":3711.25,"IE":4536.48,"ES":4058,"WW":4031.9,"AVERAGE":4035.093333},{"releaseID":"2015.09.00","US":3963.9,"CA":3584.43,"GB":3569.32,"IE":4853.68,"ES":3871.12,"WW":4147.85,"AVERAGE":3998.383333},{"releaseID":"2015.09.00","US":4089.43,"CA":3465.2,"GB":3522.6,"IE":3959.5,"ES":3938.4,"WW":3701.22,"AVERAGE":3779.391666},{"releaseID":"2015.10.00","US":2660.62,"CA":2580.7,"GB":2707.5,"IE":3135.85,"ES":2602.75,"WW":2536.32,"AVERAGE":2703.956666},{"releaseID":"2015.10.00","US":3519.72,"CA":4166.82,"GB":4014.85,"IE":6525.5,"ES":4010.55,"WW":3718.5,"AVERAGE":4325.99},{"releaseID":"2015.10.00","US":3604.32,"CA":4142.7,"GB":4569,"IE":5960.62,"ES":3740.7,"WW":3388.5,"AVERAGE":4234.306666},{"releaseID":"2015.11.00","US":5232.32,"CA":3381.38,"GB":3078.47,"IE":2521.22,"ES":4617.52,"WW":2163.78,"AVERAGE":3499.115},{"releaseID":"2015.11.00","US":5360.77,"CA":3491.38,"GB":2980.25,"IE":2143.97,"ES":4154.9,"WW":1926.62,"AVERAGE":3342.981666},{"releaseID":"2015.11.00","US":5734.48,"CA":2750.75,"GB":3194.78,"IE":2254.1,"ES":4497.05,"WW":1994.85,"AVERAGE":3404.335},{"releaseID":"2015.12.00","US":2541.15,"CA":2548.43,"GB":2547.45,"IE":3511.5,"ES":2575.78,"WW":2499.12,"AVERAGE":2703.905},{"releaseID":"2015.12.00","US":3037.78,"CA":2740.15,"GB":2633.5,"IE":3826.1,"ES":2951.45,"WW":2571.3,"AVERAGE":2960.046666},{"releaseID":"2015.12.00","US":3187.6,"CA":2785.03,"GB":2699.47,"IE":3926.05,"ES":2950.88,"WW":2768.68,"AVERAGE":3052.951666},{"releaseID":"2015.12.00","US":3247.35,"CA":3003.1,"GB":2775.95,"IE":4205.65,"ES":2868.75,"WW":3136.65,"AVERAGE":3206.241666},{"releaseID":"2015.13.00","US":2873.38,"CA":2741.25,"GB":2931.12,"IE":3901.62,"ES":2770,"WW":3116.29,"AVERAGE":3055.61},{"releaseID":"2015.15.00","US":2168.93,"CA":2330.55,"GB":2167.38,"IE":2073.75,"ES":2182.55,"WW":2078.95,"AVERAGE":2167.018333},{"releaseID":"2015.15.00","US":2240.72,"CA":2393.68,"GB":2137.72,"IE":2112.9,"ES":2153.55,"WW":2258.57,"AVERAGE":2216.19},{"releaseID":"2015.15.00","US":2318.57,"CA":2318.43,"GB":2144,"IE":2042.57,"ES":2202.67,"WW":2336.43,"AVERAGE":2227.111666},{"releaseID":"2015.15.00","US":2385.65,"CA":2617.38,"GB":2400.97,"IE":2273.1,"ES":2405.85,"WW":2434.68,"AVERAGE":2419.605},{"releaseID":"2015.15.00","US":2582.22,"CA":2289.5,"GB":2241.1,"IE":2278.2,"ES":2241.53,"WW":2585.45,"AVERAGE":2369.666666},{"releaseID":"2015.15.00","US":3301.25,"CA":2733.88,"GB":2692.2,"IE":2710.9,"ES":2983.93,"WW":2969.97,"AVERAGE":2898.688333}]"

This widget could not be displayed.

Hi Michal,

I reproduced your use case. This requires some further JS programming - your use case is not 100% covered by the PQ JavaScript API. I created some code for you (Gist) and also added some comments in it. I think this should be sufficient for you. Otherwise let me know!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Tuesday in Confluence

Add-on evaluation with confluence templates

Atlassian market place contains number of Apps/Addons which improves the capability of out of the box Atlassian products. It is good to follow a plugin evaluation process before install add-ons. So t...

105 views 12 6
Read article

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