Commit 91687e3b9e168028e49f757b4fd6e5bf2f6695fd
1 parent
f1312106
Exists in
master
and in
7 other branches
Correção na obtenção de dados para geração dos gráficos
Showing
1 changed file
with
16 additions
and
7 deletions
Show diff stats
classesphp/graficos.php
... | ... | @@ -401,7 +401,9 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t |
401 | 401 | //agrupa se for o caso |
402 | 402 | $dados = agrupaValores($valores,0,1,$tipo); |
403 | 403 | foreach($valores as $valor){ |
404 | - $cores[$valor[0]] = $valor["cores"]; | |
404 | + if(!empty($valor[0])){ | |
405 | + $cores[$valor[0]] = $valor["cores"]; | |
406 | + } | |
405 | 407 | } |
406 | 408 | //calcula os parametros para o grafico |
407 | 409 | $nval = count($dados); |
... | ... | @@ -412,7 +414,7 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t |
412 | 414 | $nnval[] = "n;x"; |
413 | 415 | if ($tipo != "xy"){ |
414 | 416 | for ($i=0;$i < $nval; ++$i){ |
415 | - if ($dados[$tempm[$i]] > 0){ | |
417 | + if ($tempm[$i] != "" && $dados[$tempm[$i]] > 0){ | |
416 | 418 | $pp = ($dados[$tempm[$i]] * 100) / $soma; |
417 | 419 | if ($percentual == "TRUE"){ |
418 | 420 | $temp = "'".$tempm[$i]." (".round($pp,0)."%)';".$dados[$tempm[$i]]; |
... | ... | @@ -429,6 +431,7 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t |
429 | 431 | $tempval[] = $temp; |
430 | 432 | } |
431 | 433 | } |
434 | + $nval = count($tempval); | |
432 | 435 | } |
433 | 436 | else{ |
434 | 437 | foreach ($valores as $v){ |
... | ... | @@ -459,13 +462,13 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t |
459 | 462 | function dadosLinhaDoTempo($map_file,$tema,$ext="") |
460 | 463 | { |
461 | 464 | $map = ms_newMapObj($map_file); |
462 | - | |
465 | + | |
463 | 466 | if($ext && $ext != ""){ |
464 | 467 | $e = explode(" ",$ext); |
465 | 468 | $extatual = $map->extent; |
466 | 469 | $extatual->setextent((min($e[0],$e[2])),(min($e[1],$e[3])),(max($e[0],$e[2])),(max($e[1],$e[3]))); |
467 | 470 | } |
468 | - | |
471 | + | |
469 | 472 | $layer = $map->getLayerByName($tema); |
470 | 473 | $selecionados = carregaquery2($map_file,$layer,$map); |
471 | 474 | if ($exclui == ""){$exclui = "nulo";} |
... | ... | @@ -685,6 +688,7 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch |
685 | 688 | $sopen = $layer->open(); |
686 | 689 | if($sopen == MS_FAILURE){return "erro";} |
687 | 690 | $res_count = $layer->getNumresults(); |
691 | + //echo $res_count;echo "\n"; | |
688 | 692 | for ($i=0;$i<$res_count;++$i){ |
689 | 693 | if($versao == 6){ |
690 | 694 | $shape = $layer->getShape($layer->getResult($i)); |
... | ... | @@ -718,6 +722,7 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch |
718 | 722 | {$v[$item] = $vitem;} |
719 | 723 | } |
720 | 724 | //pega o centroide |
725 | + //echo $i;echo "\n"; | |
721 | 726 | if($centroide == true){ |
722 | 727 | $c = $shape->getCentroid(); |
723 | 728 | if (($prjTema != "") && ($prjMapa != $prjTema)){ |
... | ... | @@ -727,11 +732,15 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch |
727 | 732 | } |
728 | 733 | $v["centroide"] = "POINT(".$c->x." ".$c->y.")"; |
729 | 734 | } |
735 | + //echo $i;echo "---\n"; | |
730 | 736 | //pega a cor da classe onde cai o registro |
731 | 737 | if($nclasses > 0 && $versao >= 6){ |
732 | - $classe = $layer->getclass($layer->getClassIndex($shape)); | |
733 | - $cor = $classe->getstyle(0)->color; | |
734 | - $v["cores"] = $cor->red." ".$cor->green." ".$cor->blue; | |
738 | + $cx = $layer->getClassIndex($shape); | |
739 | + if($cx > -1){ | |
740 | + $classe = $layer->getclass($cx); | |
741 | + $cor = $classe->getstyle(0)->color; | |
742 | + $v["cores"] = $cor->red." ".$cor->green." ".$cor->blue; | |
743 | + } | |
735 | 744 | } |
736 | 745 | if (count($v) == 1){ |
737 | 746 | $valores[] = $v[0]; | ... | ... |