Trying to put a PHP math result into JavaScript chart

I’ve been trying to figure this out for days. I hope I can explain this clear. I am trying to call up the results of this simple math equation in JavaScript code below:

             <?php  
             $x=37;  
             $y=15;  
             $z=$x-$y;  
             echo " ",$z;  
             ?> 

part of the script code

        { y: $z, label: "slice" },
        { y: 2, label: "pepper" },
        { y: 15, label: "sprite" },
        { y: 23, label: "coke" }

I now trying to put the $z in the script code

i tried using JavaScript and call tags, but that just messes up the JavaScript code. It only works if the number is posted only. Let know if what I did is possbile