icyer 你在吗? 我想就“在页面中使用MSChart图表控件”中,有点请教:
我用你的那个类,改成了一个可以显示多行多列的类,
可有一点美中不足之处?怎么把他的默认显示类型更改成其他的?
比如是饼图或线图??
strScript += this.BuildChartProperty("ChartType", "1", false);
问题点数:20、回复次数:9Top
1 楼icyer()回复于 2002-10-14 17:13:11 得分 20
修改中间那个参数,就可以改变图形类型。
Top
2 楼icyer()回复于 2002-10-14 17:18:18 得分 0
线图好像是3
Top
3 楼Sunny3141(太阳)回复于 2002-10-14 17:22:10 得分 0
不行啊,我试了的啦。Top
4 楼Sunny3141(太阳)回复于 2002-10-14 17:25:22 得分 0
1 是条形
3 是线形
10 是饼形
我都知道啊。
现在只有1 能用。Top
5 楼icyer()回复于 2002-10-14 19:51:59 得分 0
BuildControl函数中,把
string strScript = "<script language=JavaScript>";
与
strScript += "</script>";
之间的代码替换为:
strScript += this.BuildChartProperty("ColumnCount", "1", false);
strScript += this.BuildChartProperty("RowCount", (mstrArrLabel == null)?"3":mstrArrLabel.Length.ToString(), false);
strScript += this.BuildChartProperty("ShowLegend", "False", false);
strScript += this.BuildChartProperty("ChartType", "3", false);
int i;
if (mstrArrLabel != null && mdblArrValue != null && mstrArrLabel.Length == mdblArrValue.Length)
{
for (i = 0; i < mstrArrLabel.Length; i++)
{
strScript += this.BuildChartProperty("Row", ((int)(i + 1)).ToString(), false);
strScript += this.BuildChartProperty("RowLabel", mstrArrLabel[i], true);
strScript += this.BuildChartProperty("Data", mdblArrValue[i].ToString(), false);
}
}
Top
6 楼Sunny3141(太阳)回复于 2002-10-15 09:21:28 得分 0
不好意思,代码现在成了这个样子:
string ChartType ="1";
switch(ChartDataType)
{
case 1:
ChartType = "3";
break;
case 2:
ChartType = "1";
break;
case 3:
ChartType = "14";
break;
default:
ChartType = "3";
break;
}
this.Controls.Clear();
strStyle = "style='WIDTH:" + ChartWidth.ToString() + "px;HEIGHT:" + ChartHeight.ToString() + "px'";
string strChart = "<OBJECT ID=" + sFunctionID + " codeBase=mschart.cab classid=clsid:3A2B370C-BA0A-11D1-B137-0000F8753F5D " + strStyle + "></OBJECT>";
LiteralControl litChart = new LiteralControl();
litChart.Text = strChart;
this.Controls.Add(litChart);
string strScript = "<script language=JavaScript>";
strScript += this.BuildChartProperty("ChartType", ChartType, false);
strScript += this.BuildChartProperty("RowCount", (DataLabel == null)?"1":DataLabel.Length.ToString(), false);
strScript += this.BuildChartProperty("ColumnCount", (DataLegend == null)?"2":DataLegend.Length.ToString(), false);
strScript += this.BuildChartProperty("Legend.Location.LocationType", "1", false);
strScript += this.BuildChartProperty("ShowLegend", mblnShowLegend.ToString().ToLower(), false);
int nRow;
int nCol;
int nCount;
if (DataLabel != null && DataLegend != null && ChartValue != null && DataLabel.GetUpperBound(0) == ChartValue.GetUpperBound(0) && DataLegend.GetUpperBound(0) == ChartValue.GetUpperBound(1))
{
for (nRow = 0; nRow < DataLegend.Length; nRow++)
{
strScript += this.BuildChartProperty("Column", ((int)(nRow + 1)).ToString(), false);
strScript += this.BuildChartProperty("ColumnLabel", DataLegend[nRow], true);
}
nCount= ChartValue.GetUpperBound(1) + 1;
for (nRow = 0; nRow < DataLabel.Length; nRow++)
{
strScript += this.BuildChartProperty("Row", ((int)(nRow + 1)).ToString(), false);
strScript += this.BuildChartProperty("RowLabel", DataLabel[nRow], true);
for (nCol = 0; nCol < nCount; nCol++)
{
strScript += this.BuildChartProperty("Column", ((int)(nCol + 1)).ToString(), false);
strScript += this.BuildChartProperty("Data", ChartValue[nRow, nCol].ToString(), false);
}
}
}
strScript += "</script>";
LiteralControl litScript = new LiteralControl(strScript);
this.Controls.Add(litScript);
使用没有问题!
希望可以对你有一点点帮助。
我还有一点疑问?
那我在客户端怎么办?
她只给我画一个虚宽。
里面没有什么东西。
谢谢指导。
Top
7 楼icyer()回复于 2002-10-15 10:33:11 得分 0
其实最主要的还是客户端的脚本,你在IE中把生成的脚本拷贝下来,另外保存为一个HTML文件,然后再修改里面的JavaScript代码,等你在HTML文件中调试好之后,再修改.cs中的相应代码。
Top
8 楼Sunny3141(太阳)回复于 2002-10-15 10:39:40 得分 0
我怎么都搞不出来,你给个看看。Top
9 楼Sunny3141(太阳)回复于 2002-10-17 17:12:33 得分 0
谢谢你icyer() ,虽然我没有用你的方法完成这个工作,可我还是谢谢你。
谢谢你在我错误的发言里的跟贴。
不好意思,那时太急了。Top




