0

私の英語でごめんなさい。

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:

http://www.gm.fh-koeln.de/~mi932/chart_with_legend.PNG

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?

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?

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?

クライアントは次のようになります。

<script>
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 

        });
        });
    }
    );
</script>

チャートは次のように作成されます。

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 => JSON-Objekt
            for(var i=0; i < 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");


        }
    };
}
);

誰でも私を助けることができますか?よろしくお願いします。

4

2 に答える 2

1

質問 2 の場合:

独自のテーマを定義することも、事前定義された Dojo テーマを円グラフに使用することもできます。

例と説明は、http: //dojotoolkit.org/documentation/tutorials/1.9/charting/の Point Chart Themes にあります。

テーマの API は次のとおりです。

http://dojotoolkit.org/api/dojox/charting/themes/Minty

およびそれらのプレビュー:

http://download.dojotoolkit.org/release-1.5.0/dojo-release-1.5.0/dojox/charting/tests/theme_preview.html

多分これは少し役立ちます。

よろしく、ミリアム

于 2013-09-02T06:31:49.530 に答える