• Hi, I’d like to be able to pass parameters to the chart based on users meta data.
    For example I have a bunch of custom fields such as weight0, weight1, weight2, etc, and I want to display the weight in the chart.
    Is there an easy way to do that in JS or otherwise?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author martynasma

    (@martynasma)

    Hi there.

    Technically, the chart can’t access post’s or user’s meta.

    That said, there are a few workarounds you may try.

    1) Passing in data via shortcode parameter:

    https://www.ads-software.com/plugins/amcharts-charts-and-maps/#can-i-pass-custom-parameters-to-chart-code-via-shortcode

    I guess that won’t work if you need user’s meta.

    2) Implementing an addition to your theme or plugin that will output related user’s meta as a JavaScript. E.g.:

    <script>
    var weight0 = 1;
    var weight2 = 5;
    </script>

    Then just accessing those global JS variables in chart’s code.

    I know this is not ideally convenient, but I can’t think of any other ways.

    I hope this helps.

    Thread Starter billmondei

    (@billmondei)

    Thanks for such a quick reply!
    I think the second solution is pretty close to what I need.
    Is it possible to query user meta data via JS from within the chart JS code?

    Also, is there a way to let users fill-in the data in some kind of a form on a front-end and then visualize it?

    Thank you again!

    Plugin Author martynasma

    (@martynasma)

    Well, there’s no such way to query user meta data, out of the box.

    However, WP provides a cool AJAX system which you can use:

    https://codex.www.ads-software.com/Plugin_API/Action_Reference/wp_ajax_(action)

    You’d still need to implement some sort of plugin or additional to theme, to accommodate such requests, but it’s doable.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to use user meta data as data for the charts’ is closed to new replies.