Ciao a tutti!!!
sto lavorando su un progetto che consiste nel utilizzarejavascript,servlet,e dojo....ho creato una pagina html da cui con un pulsante invoco una javascript scritto su un file di nome Chart_function in questa maniera
Calcolate <input type="submit" value="click here" onclick="loadChart('multiFormatSample','temperatur e')"> </p>
multiformat è il nome della tabella e temperature il campo da cui estraggo i dati nella servlet attraverso un database.
il file chart_function è cosi definito:
dojo.require("dojox.charting.Chart2D");
var chart1=null;
var chartData=null;
var period="year";
var selection=0;
loadChart = function(sensor,camp){
dojo.xhrGet({
url: "http://localhost:8080/Data_Servlet/Data_Servlet",
content: {
sensorId: sensor,
selcamp: camp,
},
load: function(text){
viewChart(text);
},
error: function(error, ioargs){
var message = ""
switch (ioargs.xhr.status) {
case 404:
message = "The requested page was not found"
break;
case 500:
message = "The server reported an error."
break;
case 407:
message = "You need to authenticate with a proxy"
break;
default:
message = "Unknown error."
}
window.alert(message + " - " + error);
}
});
}
viewChart = function(chartDataStr) {
var Chart;
chartData = dojo.eval(chartDataStr);
//ricerca nella radio buton di selzione del grafico per prendere il valore del grafico da visualizzare
for (counter = 0; counter < project.Radio_Chart.length; counter++)
{
if (project.Radio_Chart[counter].checked)
{
Chart = project.Radio_Chart[counter].value;
}
}
//dataChart = chartData;
if (Chart=="Area_Chart"){
makeAreaChart(chartData);
} else {
if (Chart=="Bar_Chart")
makeBarChart(chartData);
}
}
makeAreaChart=function(chartData){
if (chart1!=null) {
chart1.destroy();
}
var chart1 = new dojox.charting.Chart2D("simplechart");
chart1.addPlot("default", {type: "Areas", lines: true, areas: false, markers: true});
chart1.addAxis("x");
chart1.addAxis("y", {vertical: true});
chart1.addSeries("Series 1",dojo.eval(chartData));
chart1.render();
}
makeLinearChart = function(chartData) {
if (chart1!=null) {
chart1.destroy();
}
chart1 = new dojox.charting.Chart2D("simplechart");
chart1.addPlot("default", {type: "Lines"});
chart1.addAxis("x");
chart1.addAxis("y", {vertical: true});
chart1.addSeries("Series 1", dojo.eval(chartData));
chart1.render();
}
makeBarChart = function(chartData) {
if (chart1!=null) {
chart1.destroy();
}
chart1 = new dojox.charting.Chart2D("simplechart");
chart1.addPlot("default", {
type: "Columns"
});
chart1.addAxis("x", {
labels: [{value: 1, text: "Jan"}, {value: 2, text: "Feb"},
{value: 3, text: "Mar"}, {value: 4, text: "Apr"},
{value: 5, text: "May"}, {value: 6, text: "Jun"},
{value: 7, text: "Jul"}, {value: 8, text: "Aug"},
{value: 9, text: "Sep"}, {value: 10, text: "Oct"},
{value: 11, text: "Nov"}, {value: 12, text: "Dec"}]
});
chart1.addAxis("y", {
vertical: true, min: 0, minorTicks : true,
stroke: "grey",
majorTick: {stroke: "black", length: 4},
minorTick: {stroke: "gray", length: 2}
});
chart1.addSeries("Series 1", dojo.eval(chartData), {stroke: {color:"blue"}, fill: "lightblue"});
/*chart1.setTheme("dojox.charting.themes.PlotKit.bl ue");*/
chart1.render();
};
il problema è che quando clicco sul pulsante nn appare niente...cosa puo essere?
grazie in anticipoi!!!