Home forums Using CanvasJS Can't find the error

This topic contains 1 reply, has 2 voices, and was last updated by  Priyanka M S 3 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22049

    Gnutzmann
    Member

    SQLs are fine, but the graph does not show and has no PHP error. Please help me!

        
        $dataPoints1 = array(
            array("y" => $fisio_atto, "label" => "Fisioterapia"),
            array("y" => $fono_atto, "label" => "Fonoaudiologia"),
            array("y" => $pedag_atto, "label" => "Pedagogia"),
            array("y" => $psico_atto, "label" => "Psicologia"),
            array("y" => $terapia_atto, "label" => "Terapia Ocupacional"),
            array("y" => $social_atto, "label" => "Serviço Social"),
            array("y" => $neurologia_atto, "label" => "Neurologia"),
            array("y" => $ortopedia_atto, "label" => "Ortopedia")
        );
        $dataPoints2 = array(
            array("y" => $fisio_acomp, "label" => "Fisioterapia"),
            array("y" => $fono_acomp, "label" => "Fonoaudiologia"),
            array("y" => $pedag_acomp, "label" => "Pedagogia"),
            array("y" => $psico_acomp, "label" => "Psicologia"),
            array("y" => $terapia_acomp, "label" => "Terapia Ocupacional"),
            array("y" => $social_acomp, "label" => "Serviço Social"),
            array("y" => $neurologia_acomp, "label" => "Neurologia"),
            array("y" => $ortopedia_acomp, "label" => "Ortopedia")
        );
        $dataPoints3 = array(
            array("y" => $fisio_LE, "label" => "Fisioterapia"),
            array("y" => $fono_LE, "label" => "Fonoaudiologia"),
            array("y" => $pedag_LE, "label" => "Pedagogia"),
            array("y" => $psico_LE, "label" => "Psicologia"),
            array("y" => $terapia_LE, "label" => "Terapia Ocupacional"),
            array("y" => $social_LE, "label" => "Serviço Social"),
            array("y" => $neurologia_LE, "label" => "Neurologia"),
            array("y" => $ortopedia_LE, "label" => "Ortopedia")
        );
        $dataPoints4 = array(
            array("y" => $fisio_AV, "label" => "Fisioterapia"),
            array("y" => $fono_AV, "label" => "Fonoaudiologia"),
            array("y" => $pedag_AV, "label" => "Pedagogia"),
            array("y" => $psico_AV, "label" => "Psicologia"),
            array("y" => $terapia_AV, "label" => "Terapia Ocupacional"),
            array("y" => $social_AV, "label" => "Serviço Social"),
            array("y" => $neurologia_AV, "label" => "Neurologia"),
            array("y" => $ortopedia_AV, "label" => "Ortopedia")
        );   
    ?>
    <script>
    window.onload = function() {
    
    var chart = new CanvasJS.Chart("chartContainer", {
    	animationEnabled: true,
    	title: {
    		text: "Atendimentos em cada setor"
    	},
    	data: [{
    		type: "column",
    		showInLegend: true,
    		name: "Em atendimento",
    		color: "gold",
            yValueFormatString: "#,##0.## tonnes",
    		<?php echo json_encode($dataPoints1, JSON_NUMERIC_CHECK); ?>
    	},
    	{
    		type: "column",
    		showInLegend: true,
    		name: "Em acompanhamento",
    		color: "silver",
    		<?php echo json_encode($dataPoints2, JSON_NUMERIC_CHECK); ?>
    	},
               {
    		type: "column",
    		showInLegend: true,
    		name: "Em avaliação",
    		color: "black",
    		<?php echo json_encode($dataPoints4, JSON_NUMERIC_CHECK); ?>
    	},
    	{
    		type: "column",
    		showInLegend: true,
    		name: "Em lista de espera",
    		color: "#A57164",
    		<?php echo json_encode($dataPoints3, JSON_NUMERIC_CHECK); ?>
    	}]
    });
    function hideIndexLabel() {
          var length = chart.options.data[0].dataPoints.length;
          for(var i = 0; i < length; i++ ) {		  
            if( chart.options.data[0].dataPoints[i].y === 0  || chart.options.data[0].dataPoints[i].y === null ) {
                chart.options.data[0].dataPoints[i].indexLabel = " ";
    			chart.options.data[0].dataPoints[i].indexLabelLineThickness = 0;
            }
            else
              chart.options.data[0].dataPoints[i].indexLabel = chart.options.data[0].dataPoints[i].indexLabel;
          }      
    }
    
    hideIndexLabel();
    chart.render();
    
    }
    </script>
    </head>
    <body>
    <div id="chartContainer" style="height: 370px; width: 100%;"></div>
    <script src="canvasjs.min.js"></script>
    </body>
    </html>
    #22051

    Priyanka M S
    Member

    @gnutzmann,

    Kindly share a sample project that reproduces the issue you are facing(along with sample database) over onedrive or google-drive, so that we can understand your scenario better and help you out.

    __
    Priyanka M S
    Team CanvasJS

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

You must be logged in to reply to this topic.