• Resolved tangobango

    (@tangobango)


    Hi.

    I need to supply an array inside the JSON of an attribute value.

    Here’s the javascript notation from the Charts docs. (This is for a bubble chart.)

    colorAxis: {colors:['red','#004411']}

    Based on the plugin docs, I substituted %5B%5B %5D%5D for the brackets and got this:

    chart_color_axis='{"colors": %5B%5B "red", "#004411" %5D%5D}'

    but the attribute isn’t recognized.

    Here’s the whole gdoc code

    [gdoc key="https://docs.google.com/spreadsheets/d/1Fv-OFdyIO2yUAIG6OqzzQZAwl20cj4Z1g6ratm-tExc/edit#gid=121136156" chart="Bubble" title="2015" chart_height=600 chart_legend='{"position": "none"}' chart_size_axis='{"minSize": 15, "maxSize": 40}' chart_v_axis='{"maxValue": 250, "title": "Days on Market"}' chart_h_axis='{"title": "Number of Sales"}' chart_color_axis='{"colors"; %5B%5B "red", "#004411" %5D%5D}']

    Output is bottom chart at

    http://test.edkatzman.com/index.php/2017/01/15/bubble-chart/

    Thanks again.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Meitar

    (@meitar)

    A JSON array is [ and ], which is %5B and %5D in the shortcode, respectively. An array inside an array is [[ and ]], which is %5B%5B and %5D%5D, respectively. You probably just want one array, not an array that contains an array.

    Thread Starter tangobango

    (@tangobango)

    Yes, I do want one array.

    Unfortunately, using just %5B %5D doesn’t seem to work, either.

    chart_color_axis='{"colors": %5B "red", "#004411" %5D}'

    • This reply was modified 9 years, 4 months ago by tangobango.
    Plugin Author Meitar

    (@meitar)

    ; is not a JSON key/value separator. You want :.

    Consider using JSONLint to check your JSON syntax.

    Thread Starter tangobango

    (@tangobango)

    I just saw that, but it still doesn’t work. (Sorry for that oversight.)

    Plugin Author Meitar

    (@meitar)

    Several issues here.

    1. Bug in the chart attribute value decoding; this one’s on me. Update to 0.11.4 (released just now) to fix it.
    2. Your data format is wrong and cannot produce an gradient axis. As per the Google Docs, to be used with colorAxis the fourth column must be a number. In your spreadsheet, it is a string.
    3. Once that’s done, your spreadsheet has empty values lower down in the rows which are not formatted correctly. Try deleting all but the visible values on both the rows and columns and trying again.

    Here’s a reduced test case example of a spreadsheet that works for what I think you are trying to do, and this does indeed work.

    Thread Starter tangobango

    (@tangobango)

    Many thanks. #2 sloppy on my part. #3 a new issue for me, as they look empty.

    Also, thanks for the tip about Jsonlint. And for all the rest. I’ve learned a lot from you and feel like I can now chart in WP with the best of them.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Square brackets inside JSON – Escaping not working’ is closed to new replies.