Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
mxGraph: How can I integrate mxgraph into my project in Javascript? I downloaded the mxgraph libraries

In this process, XML in mxgraph format is used with javascript. I wanted to decode the xml and add the graphic to the configuration interface, but it didn't work, where I got the error is the line I gave below,

decoder = mxCodecRegistry.getCodec(mxCell);


var xml = '<root><mxCell id="2" value="World!Vishal" vertex="1"><mxGeometry x="200" y="150" width="80" height="30" as="geometry"/></mxCell><mxCell id="3" edge="1" source="2"><mxGeometry relative="1" as="geometry"><mxPoint x="440" y="90" as="targetPoint"/></mxGeometry></mxCell></root>';
                     var doc = mxUtils.parseXml(xml);
                    var codec = new mxCodec(doc);
                    var elt = doc.documentElement.firstChild;
                    var cells = [];
                    while (elt != null){                
                      cells.push(codec.decodeCell(elt));
                        graph.refresh();
                      elt = elt.nextSibling;
                    }

                this.graph.addCells(cells);

    mxCodec.prototype.decodeCell = function(node, restoreStructures)
{

   restoreStructures = (restoreStructures != null) ? restoreStructures : true;
   var cell = null;
   
   if (node != null && node.nodeType == mxConstants.NODETYPE_ELEMENT)
   {

      var decoder = mxCodecRegistry.getCodec(node.nodeName);
      
     
      if (!this.isCellCodec(decoder))
      {
         var child = node.firstChild;
         
         while (child != null && !this.isCellCodec(decoder))
         {
            decoder = mxCodecRegistry.getCodec(node.nodeName);
            child = child.nextSibling;
         }
      }
      
      if (!this.isCellCodec(decoder))
      {
         decoder = mxCodecRegistry.getCodec(mxCell);
      }

      cell = decoder.decode(this, node);
      
      if (restoreStructures)
      {
         this.insertIntoGraph(cell);
      }
   }
   
   return cell;
};
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda