Forum Replies Created by andres.chandia

Viewing 15 posts - 1 through 15 (of 21 total)
  • in reply to: Legends showing only DataPoint #7633

    Sorry Anjali, I can not make it work, I only get a blank page, here is the code as I adapted:

    //labels
    {
            $point = array("label" => $row['Descriptors'] , "y" => $row['Count']);
            array_push($data_points, $point);
        }
    $length = sizeof($data_points);
                    echo "[";
                    for ( $i = 0; $i <= $length-1; $i++) { 
                            echo "{ \"label\": \"" , $data_points[$i]['label'],"\", \"y\": " , $data_points[$i]['y'], "}";
                            if( $i < $length-1)
                                    echo ",";
                    }
                    echo "]";
    
    //legends
    {
            $pointB = array("legend" => $row['Descriptors'] , "y" => $row['Count']);
            array_push($data_points, $pointB);
        }
    $lengthB = sizeof($data_points);
                    echo "[";
                    for ( $i = 0; $i <= $lengthB-1; $i++) { 
                            echo "{ \"legendText\": \"" , $data_points[$i]['legend'],"\", \"y\": " , $data_points[$i]['y'], "}";
                            if( $i < $lengthB-1)
                                    echo ",";
                    }
                    echo "]";
    in reply to: Legends showing only DataPoint #7624

    Thanks Anjali, but again I have the same problem, the exemples show how to do it with static data, and not with data retreived from databases, I’ve been trying to reuse this code at the php file:

    {
            $point = array("legend" => $row['Descriptors'] , "y" => $row['Count']);
            array_push($data_points, $point);
        }
    $length = sizeof($data_points);
                    echo "[";
                    for ( $i = 0; $i <= $length-1; $i++) { 
                            echo "{ \"legend\": \"" , $data_points[$i]['legend'],"\", \"y\": " , $data_points[$i]['y'], "}";
                            if( $i < $length-1)
                                    echo ",";
                    }
                    echo "]";

    but besides that I’m not sure that this is the way, I have no success with it…, thanks again

    in reply to: same graphic 2 pages, 2 visualizations #7608

    Yes, that did it, thanks a lot.

    in reply to: Issues retrievng data from MySql #7569

    Yes, thanks a lot, that did it….

    in reply to: Issues retrievng data from MySql #7550

    It seems there is no possible solution for this, isn’t it?

    in reply to: Issues retrievng data from MySql #7535

    So, any ideas about the encoding stuff?

    in reply to: Issues retrievng data from MySql #7513

    I have tried:
    mysql_set_charset('utf8',$con);
    and
    header('Content-Type: text/html; charset=utf-8');
    but no success…

    in reply to: Issues retrievng data from MySql #7511

    Sorry again, I could do it, I did a merge between original file and the one proposed by you, and I could get it, but I have the encoding issues anyway you can check it here: http://parles.upf.edu/llocs/adljc/grafics/graf_tipus_recursos.php, this is the resulting file:

    tipus_recursos.php

    <?php
    header('Content-Type: application/json');
    $con = mysqli_connect("localhost","dbuser","dbpassword","database");
    // Check connection
    if (mysqli_connect_errno($con))
    {
        echo "Failed to connect to DataBase: " . mysqli_connect_error();
    }else
    {
        $data_points = array();
        $result = mysqli_query($con, "SELECT <code>Tipus_1</code> AS 'Tipus', COUNT(*) AS 'Recursos' FROM <code>values</code> GROUP BY <code>Tipus_1</code> DESC");
        while($row = mysqli_fetch_array($result))
        {
            $point = array("label" => $row['Tipus'] , "y" => $row['Recursos']);
            array_push($data_points, $point);
        }
    //    echo json_encode($data_points, JSON_NUMERIC_CHECK);
            $length = sizeof($data_points);
                    echo "[";
                    for ( $i = 0; $i <= $length-1; $i++) { 
                            echo "{ \"label\": \"" , $data_points[$i]['label'],"\", \"y\": " , $data_points[$i]['y'], "}";
                            if( $i < $length-1)
                                    echo ",";
                    }
                    echo "]";
    }
    mysqli_close($con);
    ?>
    in reply to: Issues retrievng data from MySql #7510

    Sorry for this but I’ve been testing the code and no success, no graphic comes out, here are my files, I think I’ve adapted them well, but maybe I’m doing something wrong…

    tipus_recursos.php

    <?php
    $conn = new mysqli("localhost","dbuser","dbpassword","database");
    
            // Check connection
            if ($conn->connect_error) {
                    die("Connection failed: " . $conn->connect_error);
            } else
            {
                    $data_points = array();
                    $result = mysqli_query($conn, "SELECT <code>Tipus_1</code> AS 'Tipus', COUNT(*) AS 'Recursos' FROM <code>values</code>");
    
                    while($row = mysqli_fetch_array($result))
                    {
                            $point = array("label" => $row['Recursos'] , "y" => $row['Tipus']);
                            array_push($data_points, $point);
                    }
    
                    //echo json_encode($data_points, JSON_NUMERIC_CHECK);
                    // JSON data using echo statements
                    $length = sizeof($data_points);
    
                    echo "[";
                    for ( $i = 0; $i <= $length-1; $i++) { 
                            echo "{ \"label\": \"" , $data_points[$i]['label'],"\", \"y\": " , $data_points[$i]['y'], "}";
                            if( $i < $length-1)
                                    echo ",";
                    }
                    echo "]";
            }
    
    ?>

    tipus_recursos.js

    $(document).ready(function () {
            var dataPoints = [];
            $.getJSON("tipus_recursos.php", function (result) {
                var chart = new CanvasJS.Chart("chartContainer2", {
                    data: [
                        {
                            type: "pie",
                            dataPoints: result
                            indexLabel: "#percent"
                        }
                    ]
                });
                chart.render();
            });
        });

    graf_tipus_recursos.php

    <head>
           <script src="jquery.js"></script>
            <script src="canvasjs.js"></script>
            <script src="tipus_recursos.js"></script>
    </head>
    <body>
    <h2>Gràfic per tipus de recursos</h2>
    <div id="chartContainer2" style="width: 1200px; height: 700px;" ></div>
    </body>
    in reply to: Issues retrievng data from MySql #7497

    Of course my friend, take your time, I’ll be waiting for your help….

    in reply to: Issues retrievng data from MySql #7488

    I’m really sorry my friend, I’m going round in circles, I have been searching and searching but I can not know what you mean with your answer, so I don’t know where to head me to, would you have a little mercy on me and give me a hand, I would thank you for ever.

    in reply to: Issues retrievng data from MySql #7484

    Could you please give me an exemple of what you mean to see if I can folow you… thanks…

    in reply to: Issues retrievng data from MySql #7478

    Sorry, I’m lost now, I don’t know what you mean I should do, you mean PHP echo statements…?

    in reply to: Issues retrievng data from MySql #7476

    In case json_encode has some issue encoding the data, try creating the entire json data using echo statements and string concatination. If you can get those values to show up in JSON data chart will automatically render them.

    Sorry but that sounds like chinese to me….

    in reply to: Issues retrievng data from MySql #7475

    Ok, at this file: http://parles.upf.edu/llocs/adljc/grafics/graf_tipus_recursos.php I have put this query:
    SELECTTipus_1AS 'Tipus', COUNT(*) AS 'Recursos' FROMvaluesGROUP BYTipus_1DESC

    You can see the resulting table under the graphic.

    The complete code for rendering the table is this one:

    <?php
    include ("../admin/dbconnect.php");
    $query= "SELECT <code>Tipus_1</code> AS 'Tipus', COUNT(*) AS 'Recursos' FROM <code>values</code> GROUP BY <code>Tipus_1</code> DESC";
    $result = mysql_query($query);
    if (!$result) {
        die("Query to show fields from table failed");
    }
    
    $fields_num = mysql_num_fields($result);
    
    echo "<table class='sortable'><tr>";
    
    // printing table headers
    for($i=0; $i<$fields_num; $i++)
    {
        $field = mysql_fetch_field($result);
        echo "<td align=center>".strtr(" {$field->name} ", $transname)."</td>";
    }
    echo "</tr>\n";
    // printing table rows
    
    while($row = mysql_fetch_row($result))
    {
        echo "<tr onMouseOver=this.bgColor='#e0e0e7'; onMouseOut=this.bgColor='white';>";
    
        // $row is array... foreach( .. ) puts every element
        // of $row to $cell variable
        foreach($row as $cell)
            echo "<td align=center>$cell</td>";
        echo "</tr>\n";
    }
    mysql_free_result($result);
    ?>

    2. Type of data: Tipus_1 set(‘lingüístic’,’jurídic’) NOT NULL,

Viewing 15 posts - 1 through 15 (of 21 total)