Support » Plugin: amCharts: Charts and Maps » How to use user meta data as data for the charts

  • 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


    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:

    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.:

    var weight0 = 1;
    var weight2 = 5;

    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.

    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


    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:

    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.