我几乎让这个东西工作了。我必须克服的最后一个障碍是引用 XML 页面。在处理 Fusion Charts 时,他们引用一个 XML 页面来检索图表信息,如下所示:
<script type="text/javascript"><!--
FusionCharts.setCurrentRenderer('javascript');
var myChart = new FusionCharts("/Dashboard/Charts/MSCombi2D.swf", "popChartDiv", "100%", "100%", "0");
myChart.setXMLUrl("/Data/Data.xml");
myChart.render("test");
var myChart1 = new FusionCharts("/Dashboard/Charts/MSCombi2D.swf", "Line3ChartDiv", "100%", "100%", "0");
myChart1.setXMLUrl("/Data/Data.xml");
myChart1.render("test");
function chartRender(arg) {
if (arg == "Tab1") {
myChart.render("test");
}
else if (arg == "Tab2") {
myChart1.render("test");
}
return false;
}
// -->
</script>
代码中的这个脚本给了我问题:
myChart.setXMLUrl("/Data/Data.xml");
我的图表信息来自 C# 页面而不是 XML 页面。所以我的问题是,我需要在这里放置什么来代替 setXMLUrl() ,因为它不是来自 XML 页面?这是 C# 信息:
public void SetLine3Chart(DataSet exDT)
{
StringBuilder xmlData = new StringBuilder();
xmlData.Append("<chart caption='Current Period: Total Months: 12' chartBottomMargin='8' chartTopMargin='04' captionPadding='01' xAxisNamePadding='-20' yAxisNamePadding='05' chartRightMargin='20' showBorder='0' yAxisName='' xAxisName='' numberPrefix='$' formatNumberScale='0'>");
xmlData.Append("<categories>");
xmlData.Append("<category label='January'/>");
xmlData.Append("<category label='February'/>");
xmlData.Append("<category label='March'/>");
xmlData.Append("<category label='April'/>");
xmlData.Append("<category label='May'/>");
xmlData.Append("<category label='June'/>");
xmlData.Append("</categories>");
xmlData.Append("<dataset seriesName='Budget Spent' >");
xmlData.Append("<set value='3478'/>");
xmlData.Append("<set value='2557'/>");
xmlData.Append("<set value='5379'/>");
xmlData.Append("<set value='4987'/>");
xmlData.Append("<set value='1790'/>");
xmlData.Append("<set value='6367'/>");
xmlData.Append("</dataset>");
xmlData.Append("<dataset seriesName='Average Spending' renderAs='Line'>");
xmlData.Append("<set value='4375'/>");
xmlData.Append("<set value='4675'/>");
xmlData.Append("<set value='6354'/>");
xmlData.Append("<set value='7648'/>");
xmlData.Append("<set value='4578'/>");
xmlData.Append("<set value='4763'/>");
xmlData.Append("</dataset>");
xmlData.Append("<styles>");
xmlData.Append("<definition>");
xmlData.Append("<style name='Font_0' type='font' font='Arial' size='12' color='666666' rightMargin='15' />");
xmlData.Append("</definition>");
xmlData.Append("<application>");
xmlData.Append("<apply toObject='CAPTION' styles='Font_0'/>");
xmlData.Append("</application>");
xmlData.Append("</styles>");
xmlData.Append("</chart>");
Literal9.Text = FusionCharts.RenderChart("/Dashboard/Charts/MSCombi2D.swf", "", xmlData.ToString(), "line3Chart", "100%", "100%", false, false);
}
该文件名为 Scripts.ascx.cs 。