Commit 1040a35f2e2a5b8bc1b42c5214562ebb8abcd7da

Authored by Edmar Moretti
1 parent 0176ee87

--no commit message

classesjs/classe_util.js
... ... @@ -1446,7 +1446,9 @@ i3GEO.util = {
1446 1446 {String}
1447 1447 */
1448 1448 rgb2hex: function(str) {
1449   - var rgb = str.split(",");
  1449 + var re = new RegExp(" ", "g"),
  1450 + s = str.replace(re,','),
  1451 + rgb = s.split(",");
1450 1452 function hex(x) {
1451 1453 var hexDigits = ["0", "1", "2", "3", "4", "5", "6", "7", "8","9", "A", "B", "C", "D", "E", "F"];
1452 1454 return hexDigits[(x - x % 16) / 16] + hexDigits[x% 16];
... ...
classesphp/funcoes_gerais.php
... ... @@ -1178,6 +1178,7 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch
1178 1178 $prjTema = $layer->getProjection();
1179 1179 $layer->set("template","none.htm");
1180 1180 $layer->setfilter("");
  1181 +
1181 1182 $indicesel = array();
1182 1183 //pega os valores dos indices dos elementos selecionados para comparacao posterior
1183 1184 if ($selecionados == "sim")
... ... @@ -1193,11 +1194,14 @@ function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$ch
1193 1194 $layer->close();
1194 1195 }
1195 1196 $valores = array();
  1197 + $nclasses = $layer->numclasses;
1196 1198 if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS)
1197 1199 {
  1200 + $layer->draw();
1198 1201 $sopen = $layer->open();
1199 1202 if($sopen == MS_FAILURE){return "erro";}
1200 1203 $res_count = $layer->getNumresults();
  1204 +
1201 1205 for ($i=0;$i<$res_count;++$i)
1202 1206 {
1203 1207 $result = $layer->getResult($i);
... ... @@ -1221,16 +1225,21 @@ function pegaValoresM($mapa,$layer,$itens,$exclui=&quot;nulo&quot;,$selecionados=&quot;nao&quot;,$ch
1221 1225 {$v[] = $shape->values[$item];}
1222 1226 else
1223 1227 {$v[$item] = $shape->values[$item];}
1224   - if($centroide == true){
1225   - $c = $shape->getCentroid();
1226   - if (($prjTema != "") && ($prjMapa != $prjTema))
1227   - {
1228   - $projOutObj = ms_newprojectionobj($prjTema);
1229   - $projInObj = ms_newprojectionobj($prjMapa);
1230   - $c->project($projInObj, $projOutObj);
1231   - }
1232   - $v["centroide"] = "POINT(".$c->x." ".$c->y.")";
  1228 + }
  1229 + if($centroide == true){
  1230 + $c = $shape->getCentroid();
  1231 + if (($prjTema != "") && ($prjMapa != $prjTema))
  1232 + {
  1233 + $projOutObj = ms_newprojectionobj($prjTema);
  1234 + $projInObj = ms_newprojectionobj($prjMapa);
  1235 + $c->project($projInObj, $projOutObj);
1233 1236 }
  1237 + $v["centroide"] = "POINT(".$c->x." ".$c->y.")";
  1238 + }
  1239 + if($nclasses > 0){
  1240 + $classe = $layer->getclass($shape->classindex);
  1241 + $cor = $classe->getstyle(0)->color;
  1242 + $v["cores"] = $cor->red." ".$cor->green." ".$cor->blue;
1234 1243 }
1235 1244 if (count($v) == 1)
1236 1245 {$valores[] = $v[0];}
... ...
classesphp/graficos.php
... ... @@ -391,6 +391,9 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t
391 391 if ($exclui == ""){$exclui = "nulo";}
392 392 $valores = pegaValoresM($map,$layer,array($itemclasses,$itemvalores),$exclui,$selecionados);
393 393 $dados = agrupaValores($valores,0,1,$tipo);
  394 + foreach($valores as $valor){
  395 + $cores[$valor[0]] = $valor["cores"];
  396 + }
394 397 //calcula os parametros para o grafico
395 398 $nval = count($dados);
396 399 $max = max($dados);
... ... @@ -405,9 +408,9 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t
405 408 {
406 409 $pp = ($dados[$tempm[$i]] * 100) / $soma;
407 410 if ($percentual == "TRUE")
408   - {$nnval[] = "'".$tempm[$i]." (".round($pp,0)."%)';".$dados[$tempm[$i]];}
  411 + {$nnval[] = "'".$tempm[$i]." (".round($pp,0)."%)';".$dados[$tempm[$i]].";".$cores[$tempm[$i]];}
409 412 else
410   - {$nnval[] = "'".$tempm[$i]."';".$dados[$tempm[$i]];}
  413 + {$nnval[] = "'".$tempm[$i]."';".$dados[$tempm[$i]].";".$cores[$tempm[$i]];}
411 414 }
412 415 }
413 416 }
... ... @@ -416,7 +419,7 @@ function iniciaDadosGrafico($map_file,$tema,$exclui,$itemclasses,$itemvalores,$t
416 419 $nnval[] = "x;y";
417 420 foreach ($valores as $v)
418 421 {
419   - $nnval[] = $v[0].";".$v[1];
  422 + $nnval[] = $v[0].";".$v[1].";".$cores[$v[0]];
420 423 }
421 424 }
422 425 return array("dados"=>$nnval,"ndados"=>$nval,"max"=>$max);
... ...
ferramentas/graficointerativo/index.js.php
... ... @@ -259,11 +259,12 @@ i3GEOF.graficointerativo = {
259 259 ' </div>' +
260 260 ' <p class=paragrafo >Excluir o seguinte valor: ' +
261 261 $inputText("","","i3GEOgraficointerativoexcluir","",3,"") +
262   - ' <p class=paragrafo ><input type=checkbox style=cursor:pointer id=i3GEOgraficointerativoCoresA /> gera cores aleatórias</p>' +
  262 + ' <p class=paragrafo ><input type=checkbox style="cursor:pointer;top:3px;position:relative;" id=i3GEOgraficointerativoCoresA /> gera cores aleatórias</p>' +
263 263 ' <p class=paragrafo ><input id=i3GEOgraficointerativobotao1 type="buttom" value="Obter dados" /></p>'+
264 264 ' <div id=i3GEOgraficointerativoDados ></div>'+
265 265 '</div>' +
266 266 '<div class=guiaobj id="i3GEOgraficointerativoguia3obj" style="left:1px;display:none;top:-5px">' +
  267 + ' <p class=paragrafo ><input style=cursor:pointer type=checkbox id=i3GEOgraficointerativoAdLinhas checked /> Adiciona as linhas em gráficos de barras</p>' +
267 268 ' <p class=paragrafo ><input style=cursor:pointer type=checkbox id=i3GEOgraficointerativoAcumula /> Utiliza valores acumulados</p>' +
268 269 ' <p class=paragrafo ><input style=cursor:pointer type=checkbox id=i3GEOgraficointerativoRelativa /> Utiliza valores relativos (%)</p>' +
269 270 ' <p class=paragrafo ><input style=cursor:pointer type=checkbox id=i3GEOgraficointerativoDadosPuros /> Não processa os valores ao obter os dados (mantém os dados como estão na tabela de atributos) - essa opção é útil nos gráficos de distribuição de pontos</p>' +
... ... @@ -295,7 +296,7 @@ i3GEOF.graficointerativo = {
295 296 titulo = "Gráficos interativos <a class=ajuda_usuario target=_blank href='" + i3GEO.configura.locaplic + "/ajuda_usuario.php?idcategoria=3&idajuda=84' >&nbsp;&nbsp;&nbsp;</a>";
296 297 janela = i3GEO.janela.cria(
297 298 "380px",
298   - "240px",
  299 + "260px",
299 300 "",
300 301 "",
301 302 "",
... ... @@ -523,7 +524,7 @@ i3GEOF.graficointerativo = {
523 524 }
524 525 //verifica se no objeto com os dados existe um terceiro valor com as cores
525 526 if(v[2]){
526   - cor = v[2];
  527 + cor = i3GEO.util.rgb2hex(v[2]);
527 528 }
528 529 ins.push($inputText("","",id+"_cor","",12,cor,"cor"));
529 530 ins.push("</td><td>");
... ... @@ -549,12 +550,15 @@ i3GEOF.graficointerativo = {
549 550 valores = [],
550 551 valoresS = [],
551 552 acumulado = [],
  553 + acum,
552 554 nomes = [],
553 555 cores = [],
554 556 indice = $i("i3GEOgraficointerativoComboTemasId").options.selectedIndex,
555 557 titulo = $i("i3GEOgraficointerativoComboTemasId").options[indice].text,
556 558 par = [],
  559 + parcor = [],
557 560 soma = 0,
  561 + total = 0,
558 562 menor = inputs[1].value * 1,
559 563 maior = 0,
560 564 menorNome = inputs[0].value * 1,
... ... @@ -573,7 +577,7 @@ i3GEOF.graficointerativo = {
573 577 legendaX = "",
574 578 legendaY = "",
575 579 fill = "#C4B86A",
576   - pointSize = 2;
  580 + pointSize = 4;
577 581 if(i3GEOF.graficointerativo.titulo != "")
578 582 {titulo = i3GEOF.graficointerativo.titulo}
579 583 if($i("i3GEOgraficointerativoComboXid"))
... ... @@ -581,12 +585,17 @@ i3GEOF.graficointerativo = {
581 585 if($i("i3GEOgraficointerativoComboYid"))
582 586 {legendaY = $i("i3GEOgraficointerativoComboYid").value;}
583 587 for(i=0;i<ninputs;i = i + 3){
  588 + temp = inputs[i+1].value * 1;
  589 + total += temp;
  590 + }
  591 + for(i=0;i<ninputs;i = i + 3){
584 592 nomes.push(inputs[i].value+" ");
585 593 cores.push(inputs[i+2].value);
586 594 temp = inputs[i+1].value * 1;
587 595 valores.push(temp);
588 596 valoresS.push(temp+" ");
589   - acumulado.push(ultimo + temp);
  597 + acum = ultimo + temp;
  598 + acumulado.push(acum);
590 599 ultimo = ultimo + temp;
591 600 soma += temp;
592 601 if(temp > maior)
... ... @@ -599,6 +608,13 @@ i3GEOF.graficointerativo = {
599 608 if(temp < menorNome)
600 609 {menorNome = temp;}
601 610 par.push({"value":inputs[i+1].value * 1,"label":inputs[i].value+" "});
  611 +
  612 + temp = inputs[i+1].value * 1;
  613 + if($i("i3GEOgraficointerativoAcumula").checked)
  614 + {temp = acum;}
  615 + if($i("i3GEOgraficointerativoRelativa").checked)
  616 + {temp = (temp * 100) / total;}
  617 + parcor.push({"colour":inputs[i+2].value,"value":temp,"label":inputs[i].value+" "});
602 618 }
603 619 if($i("i3GEOgraficointerativoAcumula").checked){
604 620 valores = acumulado;
... ... @@ -637,8 +653,12 @@ i3GEOF.graficointerativo = {
637 653 };
638 654 }
639 655 if(i3GEOF.graficointerativo.tipo === "line" || i3GEOF.graficointerativo.tipo === "scatter" || i3GEOF.graficointerativo.tipo === "hbar" || i3GEOF.graficointerativo.tipo === "area" || i3GEOF.graficointerativo.tipo === "bar_round" || i3GEOF.graficointerativo.tipo === "bar_round_glass" || i3GEOF.graficointerativo.tipo === "bar_filled" || i3GEOF.graficointerativo.tipo === "bar_glass" || i3GEOF.graficointerativo.tipo === "bar_3d" || i3GEOF.graficointerativo.tipo === "bar_sketch" || i3GEOF.graficointerativo.tipo === "bar_cylinder" || i3GEOF.graficointerativo.tipo === "bar_cylinder_outline"){
  656 + temp = valores;
  657 + if(i3GEOF.graficointerativo.tipo === "line" || i3GEOF.graficointerativo.tipo === "scatter" || i3GEOF.graficointerativo.tipo === "area")
  658 + {temp = parcor;}
640 659 parametros = {
641   - "elements":[{
  660 + "elements":[
  661 + {
642 662 "type": i3GEOF.graficointerativo.tipo,
643 663 "start-angle": 180,
644 664 "colour": corunica,
... ... @@ -646,13 +666,14 @@ i3GEOF.graficointerativo = {
646 666 "alpha": alpha,
647 667 "stroke": stroke,
648 668 "animate": 1,
649   - "values" : valores,
  669 + "values" : temp,
650 670 "tip": "#val#",
651 671 "gradient-fill": gradient,
652 672 "fill": fill,
653 673 "fill-alpha": alpha,
654   - "dot-style": { "type": "anchor", "colour": "#9C0E57", "dot-size": pointSize }
655   - }],
  674 + "dot-style": { "type": "solid-dot", "colour": "#9C0E57", "dot-size": pointSize }
  675 + }
  676 + ],
656 677 "x_axis": {
657 678 "colour": "#A2ACBA",
658 679 "grid-colour": corGrid,
... ... @@ -683,6 +704,19 @@ i3GEOF.graficointerativo = {
683 704 "style": "{font-size: "+tituloSize+"; color:"+tituloCor+"; text-align: "+tituloAlinhamento+";}"
684 705 }
685 706 };
  707 + if($i("i3GEOgraficointerativoAdLinhas").checked){
  708 + parametros.elements.push({
  709 + "type": "line",
  710 + "colour": "#FFFFFF",
  711 + "start-angle": 180,
  712 + "alpha": 0,
  713 + "stroke": 0,
  714 + "width": 0,
  715 + "animate": 1,
  716 + "values" : parcor,
  717 + "dot-style": { "type": "solid-dot", "colour": "#9C0E57", "dot-size": pointSize }
  718 + });
  719 + }
686 720 if(i3GEOF.graficointerativo.tipo === "hbar"){
687 721 n = valores.length;
688 722 temp = [];
... ... @@ -733,7 +767,7 @@ i3GEOF.graficointerativo = {
733 767 "fill": "#45909F",
734 768 "fill-alpha": 0.4,
735 769 "loop": true,
736   - "values": valores
  770 + "values": parcor
737 771 }],
738 772 "radar_axis": {
739 773 "max": maior,
... ...