对不起我的英语不好。
我想编写一个 Web 应用程序,用户填写表格并将其发送到服务器。服务器将请求的数据作为 JSON 对象发送。有了这些数据,一个图表和一个图例就用 Dojo 来创建。图形和图例如下所示:
http://www.gm.fh-koeln.de/~mi932/chart_with_legend.PNG
1 问题:在图例中,数字47、14、11、...没有显示,而是一个给定的要显示的文本,它位于JSON对象中。我怎么做?
2 问:我使用道场的Claro 主题。但是主体只有5种颜色,然后重复颜色。给定不同颜色的圆圈的每个扇区,我该如何做到这一点?
3 问题:如果用户进行新的查询,旧图表和旧图例将被删除,新图表和图例将被删除。这仅适用于图表。图例将被隐藏而不显示。我究竟做错了什么?
客户端看起来像这样:
<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");
}
};
}
);
谁能帮我?我提前谢谢你。