ComponentOne之WebChart用法

using c1.web.c1webchart; //命名空间,必需加入,否则找不到里面的类和方法等 using c1.web.c1webchartbase; using c1.win.c1chart; protected c1.web.c1webchart.c1webchart c1webchart1; // 控件声明 1) 主要属性 c1webchart1.header.text="chart 头"; //图表头标题 c1webchart1.footer.text="chart 尾"; //图表尾文本 c1webchart1.backcolor = color.lightsteelblue; //背景色 c1webchart1.imageformat = system.drawing.imaging.imageformat.png; //图像存储格式 c1webchart1.chartgroups.group0.charttype = chart2dtypeenum.bar; //图表 // 类型,chart2dtypeenum枚举下有所有的图表样式,如饼图/柱状图等 c1webchart1.width=800; //图表宽度 2) 主要方法 a .x轴标签(坐标)的方法,直接调用即可 public void addaxisx() { // label x axis with product names axis ax = c1webchart1.chartarea.axisx; ax.valuelabels.clear(); ax.annomethod = annotationmethodenum.valuelabels; for(int i = 0; i < 100; i++) { //datarowview drv = dv[i]; ax.valuelabels.add(i, (i+1).tostring()); } try { ax.max = 10 - .5; } catch {} } a .y轴标签(坐标)的方法,直接调用即可 public void addaxisy() { // label y axis with product names axis ay = c1webchart1.chartarea.axisy; ay.valuelabels.clear(); ay.annomethod = annotationmethodenum.valuelabels; for(int i = 0; i < 10; i++) { //datarowview drv = dv[i]; ay.valuelabels.add(i, (50*i).tostring()); } try { ay.max = 20 - .5; } catch {} } c.画图表的方法 public void getpiedata() { c1webchart1.legend.visible = true; //图表区块注释. this.addaxisx(); //上面方法a this.addaxisy(); //上面方法b //生成数据 pointf[] data = new pointf[10]; for (int i = 0; i < data.length; i++) { float y = float.parse((3*i+5).tostring()); data[i] = new pointf(i, y); } //清除现有的饼图 chartdataseriescollection dscoll = c1webchart2.chartgroups[0].chartdata.serieslist; dscoll.clear(); //汇图,即将点数组交给控件,它会自己分配,并画出图形 chartdataseries series = c1webchart1.chartgroups[0].chartdata.serieslist[0]; series.pointdata.copydatain(data);// 这里的data是pointf类型 //给区块加标签 for(int i=0; i < data.length; i++) { chartdataseries series = dscoll.addnewseries(); series.pointdata.length = 1; series.y[0] = data[i].y; series.label="我是:"+(i+1).tostring(); //加标签 c1.win.c1chart.label lbl = c1webchart1.chartlabels.labelscollection.addnewlabel(); lbl.text = string.format("{0} ({1:c})","第:"+i.tostring()+"扇区", data[i].y); lbl.compass = labelcompassenum.radial; lbl.offset = 20; lbl.connected = true; lbl.visible = true; lbl.attachmethod = attachmethodenum.dataindex; attachmethoddata am = lbl.attachmethoddata; am.groupindex = 0; am.seriesindex = i; am.pointindex = 0; } } finished.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值