Home forums Using CanvasJS Legends showing only DataPoint Reply To: Legends showing only DataPoint

#7633

andres.chandia
Participant

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 "]";