I have to use separate option values in my form in order to be able to filter the graphs the way I need.
So I have an option label like "Satisfied" and a value like "__satisfied__"
The example below only works for fields where there is no secondary option value - so only "Satisfied" https://formidableforms.com/knowledgebase/frm_graph_data/#kb-show-only-percentages
In the table produced whenthere ARE secondary option values - the graph data is all set at zero.
If I look at the JS on the page which is generating the graph - the relevant bit looks like ["Satisfied",0],["Unsatisfied",0]] etc etc.
The snippet is targeting the right graph on the page - I can see the tooltip is changing - so it is working - it's just not calculating the percentages correctly. So I'm guessing there is some mismatch between the php snippet and the label/values when using the secondary option values in the form.
This is the snippet from the example
add_filter( 'frm_graph_data', 'frm_percentage_graph', 10, 2 ); function frm_percentage_graph( $data, $atts ) { if ( isset( $atts['title'] ) && $atts['title'] == 'Gas by Percentage' ) { $data[0][1] = "Percentage of gas used"; $total = FrmProStatisticsController::stats_shortcode( array( 'id' => 4124, 'type' => 'count' ) ); for ( $i = 1, $l = count( $data ); $l > $i; $i++ ) { $graph_value = 0; if ( $total !== 0 ){ $individual_count = FrmProStatisticsController::stats_shortcode( array( 'id' => 4124, 'type' => 'count', '4124' => $data[$i][0] ) ); $percent = ( $individual_count/ $total ) * 100; $graph_value = round( $percent, 1); } $data[ $i ][1] = $graph_value; } } return $data; }
Does anyone out there with php and Formidable skills know how to make this work - or any pointers I can look into?
Thanks in advance!
Link to Google Chart Tools: https://developers.google.com/chart
BTW, if Google Charts doesn't provide what you need, try ChartJS.
Please login or Register to submit your answer