Home Forums Chart Support Rendering a Chart with a button click & using json_encode

Rendering a Chart with a button click & using json_encode

Viewing 3 posts - 1 through 3 (of 3 total)
  • #6137

    Hello,

    I’d like to use a pie chart to show the results of a few calculations. I’ve got 3 fields that the users enters numbers into. Then these numbers are used in calculations in an ajax call. I’ve used json_encode to return this ajax call as an array, with 3 numbers in.

    Here is a Js fiddle http://jsfiddle.net/jx9sJ/5/ . In this example the entered numbers are displayed in a graph. I would like to send the entered numbers to ajax for some calculations, and then display them in a graph like this.

    When the user clicks ‘submit’ the 3 entered numbers are used in calculations by ajax, & then returned json_encode($total);.

    My code so far:

    $total['tot1'] = $numwelds + $numconwelds + $mpcountrys ;
    	$total['tot2'] = $numwelds + $numconwelds + $fortot2 ;
    	$total['tot3'] = ($numwelds + $numconwelds) + $fortot2 / $fortot3; 
        $response = json_encode($total);
        header("Content-Type: application/json");  
        echo $response;
        exit;

    An example of the array in $response (by print_r) :

    Array ( [tot1] => 3 [tot2] => 5 [tot3] => 1 )

    How can I tie json_encode($total); to a graph to display the calculated results please? When the user clicks ‘submit’

    #6138

    Just to clarify:

    I’m struggling to create the graph from the values, which are in json_encode. How can this be done? So all this is done when the user clicks a button

    #6141

    Please ignore this now. I’ve posted another post with a more accurate question.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.