2016-05-15 79 views
1

我在我的jsp中使用融合圖表來呈現數據。這是我正在使用的代碼。使用javascript和jsp將數據插入融合圖表

FusionCharts.ready(function(){ 
var summaryChart = new FusionCharts( 
{ 
    type: "line", 
    renderAt: "chartContainer1", 
    width: "500", 
    height: "300", 
    dataFormat: "json", 
    "dataSource": { 
"chart": { 
    "caption": "Total Revenues from 2008-2013", 
    "numberprefix": "$", 
    "bgcolor": "FFFFFF", 
    "showalternatehgridcolor": "0", 
    "plotbordercolor": "008ee4", 
    "plotborderthickness": "3", 
    "showvalues": "0", 
    "divlinecolor": "CCCCCC", 
    "showcanvasborder": "0", 
    "tooltipbgcolor": "00396d", 
    "tooltipcolor": "FFFFFF", 
    "tooltipbordercolor": "00396d", 
    "numdivlines": "2", 
    "yaxisvaluespadding": "20", 
    "anchorbgcolor": "008ee4", 
    "anchorborderthickness": "0", 
    "showshadow": "0", 
    "anchorradius": "4", 
    "chartrightmargin": "25", 
    "canvasborderalpha": "0", 
    "showborder": "0" 
}, 

"data": [ 
    { 
     "label": "2009", 
     "value": "4400000", 
     "color": "008ee4" 
    }, 
    { 
     "label": "2010", 
     "value": "4800000", 
     "color": "008ee4" 
    }, 
    { 
     "label": "2011", 
     "value": "5500000", 
     "color": "008ee4" 
    }, 
    { 
     "label": "2012", 
     "value": "6700000", 
     "color": "008ee4", 
     "anchorradius": "7", 
     "tooltext": "Historical high" 
    }, 
    { 
     "label": "2013", 
     "value": "4200000", 
     "color": "008ee4" 
} 
] 
} 
    }); 
summaryChart.render(); 
}); 

我想添加一些已經從數據庫中讀取的數據作爲數據到這個圖表。我嘗試使用javascipt內部的數組和東西,仍然無法做到這一點。 請幫幫我。

回答