Thank you very much , that was the problem.
Thank you very much , that was the problem.
Buenos dias!!! tengo un inconveniente con la implementación del tipo "Pie", muestra otro gráfico cuando coloco la variable data, si colocó los datos a mano funciona bien, pero cuando coloco la variable generada no dibuja otro gráfico, realizo un "echo" de la variable y tiene exactamente el mismo contenido que los datos puestos a mano. Puede ayudarme con este problema? le adjunto el código
$sql = "select s.nombre, count(p.id) AS cantidad FROM proyecto p, sector s WHERE p.idSector = s.id GROUP BY p.idSector ORDER BY cantidad DESC";
$raw = $base = Yii::$app->db->createCommand($sql_sector)->queryAll();
foreach ($raw as $d){
$nombre= $d['nombre'];
$cantidad = (int)$d['cantidad'];
$data[] = [$nombre,$cantidad*1];
}
$data = json_encode($data);
echo $data;
el resultado de ese "echo" es : [["Agropecario",94],["Industrial",88],["Turismo",55],["Servicios",28],["Fruticola",21],["Minero",2],["Apicola",2],["Pesquero",1]]
echo Highcharts::widget([
'options' => [
'title' => ['text' => 'Sample title - pie chart'],
'plotOptions' => [
'pie' => [
'cursor' => 'pointer',
],
],
'series' => [
[
'type' => 'pie',
'name' => 'Elements',
'data' => $data,
]
],
],
]);
Eso me dibuja un gráfico raro como que no encuentra la serie, en cambio si coloco esto
echo Highcharts::widget([
'options' => [
'title' => ['text' => 'Sample title - pie chart'],
'plotOptions' => [
'pie' => [
'cursor' => 'pointer',
],
],
'series' => [
[
'type' => 'pie',
'name' => 'Elements',
'data' =>[["Agropecario",94],["Industrial",88],["Turismo",55],["Servicios",28],["Fruticola",21],["Minero",2],["Apicola",2],["Pesquero",1]],
]
],
],
]);
Se visualiza correctamente.
Estoy generando mal la variable $data? porque realizando un "echo" la variable me muestra el mismo contenido, pero dibuja un gráfico extraño, no el correcto
Good morning!!! I have a problem with the implementation of the type " Pie" , drawing another sample when placed the variable data , if placed the data by hand works well , but when I put the variable generated does not draw another picture, place an " echo" of the variable and It has exactly the same content as the data made hand. You can help me with this problem? I attach the code
$sql = "select s.nombre, count(p.id) AS cantidad FROM proyecto p, sector s WHERE p.idSector = s.id GROUP BY p.idSector ORDER BY cantidad DESC";
$raw = $base = Yii::$app->db->createCommand($sql_sector)->queryAll();
foreach ($raw as $d){
$nombre= $d['nombre'];
$cantidad = (int)$d['cantidad'];
$data[] = [$nombre,$cantidad*1];
}
$data = json_encode($data);
echo $data;
the result of this "echo " is : [["Agropecario",94],["Industrial",88],["Turismo",55],["Servicios",28],["Fruticola",21],["Minero",2],["Apicola",2],["Pesquero",1]]
echo Highcharts::widget([
'options' => [
'title' => ['text' => 'Sample title - pie chart'],
'plotOptions' => [
'pie' => [
'cursor' => 'pointer',
],
],
'series' => [
[
'type' => 'pie',
'name' => 'Elements',
'data' => $data,
]
],
],
]);
That draws me a weird graph as you can not find the series , however if I put this
echo Highcharts::widget([
'options' => [
'title' => ['text' => 'Sample title - pie chart'],
'plotOptions' => [
'pie' => [
'cursor' => 'pointer',
],
],
'series' => [
[
'type' => 'pie',
'name' => 'Elements',
'data' =>[["Agropecario",94],["Industrial",88],["Turismo",55],["Servicios",28],["Fruticola",21],["Minero",2],["Apicola",2],["Pesquero",1]],
]
],
],
]);
It is displayed correctly.
I am generating $data wrong ? because I making an " echo" variable shows me the same content, but draws a weird graphic , not the right
thanks
Hi! I’m working on a project right now and I need to show my data in a highchart widget, I’m using postgresql, can you give me an idea how to put data from my database to my highchart widget.
\dosamigos\highcharts\HighCharts::widget([
'clientOptions' => [
'chart' => [
'type' => 'column'
],
'title' => [
'text' => 'Monthly Report'
],
'xAxis' => [
'categories' => [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
]
],
'yAxis' => [
'title' => [
'text' => 'Number of Person'
]
],
'series' => [
['name' => 'Captured','data' => [100,220,411,123,123,123,123,123,213,123,123,123]], //this should be data from database.
['name' => 'Killed', 'data' => [51,71,31,155,166,133,14,12,12,11,11,13]], //this should be data from database.
['name' => 'Surrendered', 'data' => [500,7,3,200,2,2,2,2,2,2,2,0]] //this should be data from database.
]
]
]);