Home Forums Chart Support base64

base64

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

    i encoded the chart into base64 url and assigned that into js var variable,now i want to pass that value into php variable ,how do i do that

    #26574

    @senith,

    You can pass the value of variables from JavaScript to PHP code using mechanisms such as GET or POST methods. Please refer this article for more information.

    __________
    Indranil Deo
    Team CanvasJS

    #26578

    What i do is:

    Create a Form with POST Method and a text area inside with style=”display:none;” to hidde it.

    <form action="/GetBase64Chart/" method="post" name="formToSendBase64" id="formToSendBase64">
        <textarea style="display:none;" id="txtareaBase64" name="txtareaBase64"> </textarea>
    </form>

    and with JS i create a button to “Export” the Base64 to the backend. Then i get the base64 of the canvas chart and i passed it to the textarea value like in the next code…

    $("#exportButton").click(function () {
                    var canvas = $("#Chart .canvasjs-chart-canvas").get(0);
    
                    var dataURL = canvas.toDataURL();
    
                    document.getElementById("txtareaBase64").value = dataURL;
    
                    var form = document.getElementById("formToSendBase64");
    
                    form.submit();
                });
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.