Support General Displaying Form Data as a visual chart Reply To: Displaying Form Data as a visual chart

#12287
Anh TranAnh Tran
Keymaster

Hi Neil,

As I answer in the other topic, showing the value of custom fields in a different way need some coding. In this case, you want to display in a chart or graph, then the steps will be:

  • Download a chart/graph library required CSS/JS. Depends on which library you use, the files are different.
  • Enqueue a chart/graph library's JS/CSS. This can be done in the theme with wp_enqueue_script and wp_enqueue_style.
  • Get the field values (via helper functions).
  • Output the values in the format required by the chart/graph library. If they required the data in JavaScript, you need to use wp_localize_script to enqueue the data.
  • Write some custom JS to initialize the graph/chart.

That might sound complicated, but the whole process is just trying to pass the data of custom fields to the JS of the library. Depends on which library you use, the code might be different.