Forum Replies Created by B_Juarez

Viewing 6 posts - 1 through 6 (of 6 total)
  • in reply to: SQLServer + PHP + Canvasjs #25513

    Hello @manoj-mohan

    I really apreciate your help, at last I found the source of the problem, In Spanish we use the ortigrafic accent and I’m working with word “Económica”, when I get the information from DB the word appears like this “Econ�mica” and the strange character is the problem. I need find a solution to remplace this character since the DB query because I can’t change the information inside the table.

    Best regards

    in reply to: SQLServer + PHP + Canvasjs #25512

    Hello @manoj-mohan

    Thanks a lot for your help, I found the problem, If I get only numbers from database the chart works fine

    
    $dataPoints = array(
            array("y" => 4, "label" => 56),
            array("y" => 4, "label" => 68),
            array("y" => 8, "label" => 12),
            array("y" => 28, "label" => 1)
    );
    
    But, when I get a string, the chart doesn't work.
    
    $dataPoints = array(
            array("y" => 4, "label" => "Bancario y Financiero"),
            array("y" => 4, "label" => "Comercio Exterior"),
            array("y" => 8, "label" => "Competencia Económica"),
            array("y" => 28, "label" => "Corporativo")
    );
    

    Do you have any idea?

    Best regards

    in reply to: SQLServer + PHP + Canvasjs #25478

    Hello @manoj-mohan

    I reinstalled CanvasJS in a 64 bits operative system and PHP 7.3. I downloaded the libraries for SQL Server ans installed the controllers, but I continue with the problem.

    If I generate the array manually, I don’t have problems, but when I get the information from my SQL Server Database its imposible display the chart, I show the informarion with “echo” or “print_r”, but the chart never appears.

    Regards.

    in reply to: SQLServer + PHP + Canvasjs #25446

    @manoj-mohan

    Thanks a lot for your tip. Before PHP 5.6 I was programming in PHP 7.3, but my Operative System is at 32 bits and I didn’t find the SQL controller for this version (PHP 7 + OS 32 bits), let me try at 64 bits OS and reload the SQL controllers. Let you know the results.

    Best Regards
    Keep in touch

    in reply to: SQLServer + PHP + Canvasjs #25323

    Thank you Manoj,

    I continue researchig.

    Regards

    in reply to: SQLServer + PHP + Canvasjs #25291

    @manoj-mohan

    Thanks a lot for your help, I used MySQL and my chart worked fine, but when I changed to SQLSrv, didn’t work. The connection to DB is working and information is the same than MySQL, the code is next:

    Techinal Requirements:
    – XAMPP for Windows 5.6.39
    – PHP Version 5.6.39
    php.ini file (I downloaded the SQLSrv drivers to establish the connection between my develop environment with my DB in another sever)
    extension=php_pdo_sqlsrv_56_ts.dll
    extension=php_sqlsrv_56_ts.dll

    Thanks again and let me know if you need more detail please.

    CODE:

    <?php
    $serverName = "192.2.1.21, 1433"; //serverName\instanceName, portNumber (default is 1433)
    $connectionInfo = array( "Database"=>"Legal", "UID"=>"sa", "PWD"=>"T07Pass");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    
    if( $conn === false ) {
        die( print_r( sqlsrv_errors(), true));
    }
    
    $queryG = "SELECT count(A.CveAsunto) as y, TL.Nombre as label 
    		   FROM GeniusLegal.dbo.TipoLey TL INNER JOIN GeniusLegal.dbo.Asunto A ON  TL.CveTipoLey=A.CveTipoLey 
    		   WHERE YEAR(A.FechaApertura)=2019 and A.CveAsuntoEstatus=1 GROUP BY TL.Nombre";
    $dataG = sqlsrv_query($conn, $queryG);
    $dataPoints = array();
    while( $row = sqlsrv_fetch_array($dataG, SQLSRV_FETCH_ASSOC) ) {
    	  array_push($dataPoints, $row);
    }
    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
    	<meta charset="UTF-8">
    	<title> Dashboard - © 2019 Powered by Jauregui y Del Valle, S.C. </title>
    	<meta name="description" content="JDV">
    	<meta name="author" content="JDV">
    	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    	<link rel="stylesheet" type="text/css" href="source/bootstrap-3.3.6-dist/css/bootstrap.css">
    	<link rel="stylesheet" type="text/css" href="source/font-awesome-4.5.0/css/font-awesome.css">
    	<link rel="stylesheet" type="text/css" href="style/slider.css">
    	<link rel="stylesheet" type="text/css" href="style/mystyle.css">
    <script type="text/javascript">
    window.onload = function () {
            var chart = new CanvasJS.Chart("chartContainer", {
                title: {
                    text: "Asuntos \"Activos\" por tipo"
                },
                animationEnabled: true,
                legend: {
                    fontSize: 12,
                    fontFamily: "Helvetica"
                },
                theme: "light2",
                data: [
                {
                    type: "doughnut",
                    indexLabelFontFamily: "Garamond",
                    indexLabelFontSize: 13,
                    indexLabel: "{label}: {y}",
                    startAngle: -20,
                    showInLegend: false,
    				dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
                }
                ]
            });
            chart.render();
    }
    </script>
    </head>
    <body>
    <div id="chartContainer" style="width: 50%; height: 300px;display: inline-block;"></div>
    <script src="../canvasjs-2.2/canvasjs.min.js"></script>
    </body>
    </html>
    <?php 
    	sqlsrv_close($conn);
    ?>
Viewing 6 posts - 1 through 6 (of 6 total)