C# OWC11

public void OcwChart(int[] Data,string[] DataName,string Yname,string Xname,string ChartName,string Dname)
{
try
{
//创建ChartSpace对象
ChartSpaceClass mySpace = new ChartSpaceClass();
//添加图表
ChChart ChartMonth = mySpace.Charts.Add(0);
//指定图表类型
ChartMonth.Type = ChartChartTypeEnum.chChartTypeColumnClustered;
// ChartMonth.Type = ChartChartTypeEnum.chChartTypeLineMarkers;
ChartMonth.HasTitle = true;
ChartMonth.HasLegend = true;
ChartMonth.Title.Font.Bold = true;
ChartMonth.Title.Font.Size = 12;
ChartMonth.Title.Font.Color = "#ff3300";

ChartMonth.Axes[0].HasTitle = true;
//横轴名称
ChartMonth.Axes[0].Title.Caption = Xname;

ChartMonth.Axes[1].HasTitle = true;
//纵轴名称
ChartMonth.Axes[1].Title.Caption = Yname;

ChartMonth.Axes[0].Title.Font.Bold = true;
ChartMonth.Axes[0].Title.Font.Color = "#995540";
ChartMonth.Axes[1].Title.Font.Bold = true;
ChartMonth.Axes[1].Title.Font.Color = "#994400";




//图表名称
ChartMonth.Title.Caption = ChartName;

生成横轴的名称
//int data_i = 0;
//for (int i = 0; i < 6; i++)
//{
// DataName[data_i] = string.Format("{0:" + string.Format("{0:D2}", i) + "\r\n月\r\n" + "}", (i + 1).ToString());
// data_i++;
//}
string strValue = "";
string strCateory = "";

//将数据格式化
for (int i = 0; i < DataName.Length; i++)
{
strCateory += DataName[i] + '\t';
}

for (int i = 0; i < Data.Length; i++)
{
strValue += Data[i].ToString() + '\t';
}

//添加序列
ChartMonth.SeriesCollection.Add(0);
ChartMonth.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Dname);
ChartMonth.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strCateory);
ChartMonth.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strValue);

//输出图表
string strAbsolutePath = Application.StartupPath + @"\rate.gif";
// mySpace.ExportPicture(strAbsolutePath, "GIF", pictureBox1.Width, pictureBox1.Height);
// pictureBox1.ImageLocation = strAbsolutePath;
}
catch (Exception ex)
{
MessageBox.Show("流量图显示错误:" + ex.Message);
}

}

转载于:https://www.cnblogs.com/cyh328863397/p/7470820.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值