title: Configuration of a pie chart and a legend in the dojo
body: <p>Sorry for my english.</p>
  
  <p>I want to program a web application where a user fills out a form and sends it to the server. The server sends the requested data as a JSON object. With these data, a diagram and a legend with Dojo to create.
  The graph and legend look like this:</p>
  
  <p><a href="http://www.gm.fh-koeln.de/~mi932/chart_with_legend.PNG" rel="nofollow">http://www.gm.fh-koeln.de/~mi932/chart_with_legend.PNG</a></p>
  
  <p>1 Question: In the legend, the number 47, 14, 11, ... are not displayed, but a given text to be displayed, which is located in the JSON object. How do I do that?</p>
  
  <p>2 Question: I use the Claro theme of the dojo. But the subject has only 5 colors, then repeat the colors. How can I do that every sector of a circle given a different color?</p>
  
  <p>3 Question: If the user makes a new query, the old chart and the old legend will be deleted and the new chart and legend. This only works with the chart. The legend will be hidden and not displayed. What am I doing wrong?</p>
  
  <p>Client looks like this:</p>
  
  <pre><code>&lt;script&gt;
  require(["dojo/dom", 
           "dojo/on", 
       "dojo/request", 
       "dojo/dom-form",
       "statsDiagramme/kreisDiagramm",
       "statsDiagramme/stabDiagramm",
       "dojo/json", 
       "dojox/json/query", 
       "dijit/Dialog", 
       "dijit/form/Button",
        "dojo/domReady!"],
  
  function(dom, on, request, domForm, kreisdiagramm, stabdiagramm, json){
  
       var form = dom.byId('sqlOptForm');      
       on(form, "submit", function(evt){                      
           evt.stopPropagation();         
           evt.preventDefault();      
  
           request.post("ServletStatsSQLOPT", {       
  
      data: domForm.toObject("sqlOptForm"),   
      handleAs: "json"
  
       }).then(function(response){
  
      var fehler = dojox.json.query("fehlermeldung", response);
  
      if(fehler == ""){   
                                  dojo.html._emptyNode("statsKreisDiagramm");
                                  dojo.html._emptyNode("statsStabDiagramm");
                                  dojo.html._emptyNode("legende");
  
                                  stabdiagramm.setStabDiagramm(response); 
                                  kreisdiagramm.setKreisDiagramm(response);
                                  dom.byId("statsKreisDiagramm").style.visibility = 'visible';
                                  dom.byId("statsStabDiagramm").style.visibility = 'hidden';
                                  dom.byId("statsMenuButton").style.visibility = 'visible';
                                  dom.byId("legende").style.visibility = 'visible';                   
  
      }
      else {                  
          // ERROR 
  
      }
  
      }, function(error) {    
          // ERROR 
  
          });
          });
      }
      );
  &lt;/script&gt;
  </code></pre>
  
  <p>The chart is created as:</p>
  
  <pre><code>define([
  "dojox/charting/Chart",
  "dojox/charting/themes/Claro",
  "dojox/charting/plot2d/Pie",
  "dojox/charting/action2d/Tooltip",
  "dojox/charting/action2d/MoveSlice",
  "dojox/charting/widget/Legend",
  "dojox/charting/plot2d/Markers",
  "dojox/charting/widget/Legend",
  "dojox/charting/axis2d/Default",
  
  "dojo/domReady!"
  ], 
  function(Chart, theme, PiePlot, Tooltip, MoveSlice, Legend){
  
      return{
          setKreisDiagramm: function(response) {
  
              var daten = new Array(response.summeArray.length);          
              // response =&gt; JSON-Objekt
              for(var i=0; i &lt; response.summeArray.length; i++) {
                  daten[i] = { x: 1, y: response.summeArray[i].summe };   
              }
  
              var kreisDiag = new Chart("statsKreisDiagramm");        
  
              kreisDiag.setTheme(theme);          
  
  
              kreisDiag.addPlot("default", {
                  type: PiePlot,                  
                  radius: 180,
                  fontColor: "black",
                  labelOffset: 30,                
                  markers: true
              });
  
              kreisDiag.addSeries("Zusammenfassung", daten);      
  
              var tip = new Tooltip(kreisDiag, "default");        
  
              var mag = new MoveSlice(kreisDiag,"default");       
  
              kreisDiag.render();
  
              var legend = new Legend({ chart: kreisDiag, horizontal: false },   "legende");
  
  
          }
      };
  }
  );
  </code></pre>
  
  <p>Can any one help me?
  I thank you in advance.</p>