aspx.cs:
private string chartstr = "";
SaleCount2Service service = new SaleCount2Service();
private void AddChart(string caption)
{
// palette:1-5 调色板
chartstr = "<chart palette='5' caption='" + caption + "' showValues='1' divLineDecimalPrecision='1' limitsDecimalPrecision='1' PYAxisName='销售量' formatNumberScale='0' baseFont='宋体' baseFontSize='16'>";
List<SaleCount2Entity> list = service.GetSaleCount2();
chartstr += "<categories>";
for (int i = 0; i < list.Count; i++)
{
chartstr += string.Format("<category label='{0}'/>", list[i].UserName);
}
chartstr += "</categories><dataset seriesName='汽车销售量' renderAs='area' parentYAxis='P'>";
for (int j = 0; j < list.Count; j++)
{
chartstr += string.Format("<set value='{0}'/>", list[j].CarNumber);
}
chartstr += "</dataset><dataset seriesName='电脑销售量' renderAs='Line' parentYAxis='P'>";
for (int k = 0; k < list.Count; k++)
{
chartstr += string.Format("<set value='{0}'/>", list[k].ComputerNumber);
}
chartstr += "</dataset><dataset seriesName='衣服销售量' renderAs='Line' parentYAxis='P'>";
for (int h = 0; h < list.Count; h++)
{
chartstr += string.Format("<set value='{0}'/>", list[h].ClothNumber);
}
chartstr += "</dataset></chart>";
chartstr += "";
}
public string CreateChart(string flash, string caption)
{
AddChart(caption);
return FusionCharts.RenderChart("fc3/" + flash, "", chartstr, "", "780", "330", false, false);
}
/*
<chart palette='2' caption='Emmy的标题' subCaption='Emmy的副标题' showValues='1' divLineDecimalPrecision='1' limitsDecimalPrecision='1' PYAxisName='销售量' formatNumberScale='0'>
<categories>
<category label='A' />
<category label='B' />
<category label='C' />
<category label='D' />
<category label='E' />
<category label='F' />
<category label='G' />
<category label='H' />
<category label='I' />
<category label='J' />
</categories>
<dataset seriesName='汽车销售量' renderAs='area' parentYAxis='P'>
<set value='3242' />
<set value='3171' />
<set value='700' />
<set value='1657' />
<set value='1566' />
<set value='1126' />
<set value='987' />
<set value='1654' />
<set value='933' />
<set value='958' />
</dataset>
<dataset seriesName='电脑销售量' renderAs='Line' parentYAxis='P'>
<set value='332' />
<set value='71' />
<set value='70' />
<set value='15687' />
<set value='156' />
<set value='526' />
<set value='97' />
<set value='15' />
<set value='9' />
<set value='928' />
</dataset>
<dataset seriesName='衣服销售量' renderAs='Line' parentYAxis='P'>
<set value='342' />
<set value='311' />
<set value='400' />
<set value='1287' />
<set value='1846' />
<set value='176' />
<set value='944' />
<set value='165' />
<set value='903' />
<set value='500' />
</dataset>
</chart>
*/
aspx:
<script src="fc3/FusionCharts.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<%=CreateChart("ms/MSColumn3D.swf", "Emmy测试图--MSColumn3D.swf")%>
</div>
3维图形如下: