Owc画图的问题

johnbl 2006-12-29 07:22:24
try
{
object[] xValues = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
object[] yValues = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

//新規ChartSpace作成:
ChartSpace space1 = new ChartSpace();

//新規ChartをChartSpaceに追加:
ChChart chart1 = space1.Charts.Add(0);

//新規DataSeriesをChartに追加:
ChSeries series1 = chart1.SeriesCollection.Add(0);
//ChSeries series2 = chart1.SeriesCollection.Add(1);

//表タイプを散布図(スムージング、マーカーつき)とする
series1.Type = ChartChartTypeEnum.chChartTypeScatterSmoothLineMarkers;
//series2.Type = ChartChartTypeEnum.chChartTypeScatterSmoothLineMarkers;

//DataSeries名
series1.SetData(ChartDimensionsEnum.chDimSeriesNames, (int)ChartSpecialDataSourcesEnum.chDataLiteral, "系列1");
//series2.SetData(ChartDimensionsEnum.chDimSeriesNames, (int)ChartSpecialDataSourcesEnum.chDataLiteral, "系列2");

//Populate the X and Y values from array:
series1.SetData(ChartDimensionsEnum.chDimXValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, xValues);
series1.SetData(ChartDimensionsEnum.chDimYValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, yValues);
//series2.SetData(ChartDimensionsEnum.chDimXValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, yValues);
//series2.SetData(ChartDimensionsEnum.chDimYValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, xValues);

//Format the chartspace elements.
space1.Border.Color = ChartColorIndexEnum.chColorAutomatic;

//Format the chart elements.
chart1.SeriesCollection[0].Interior.Color = "Rosybrown";
chart1.PlotArea.Interior.Color = "Wheat";
chart1.HasLegend = true;
chart1.Legend.Position = ChartLegendPositionEnum.chLegendPositionRight;
chart1.HasTitle = true;
chart1.Title.Caption = "表1";
chart1.Axes[0].HasTitle = true;
chart1.Axes[0].Title.Caption = "Y 座標";
chart1.Axes[0].NumberFormat = "000";
chart1.Axes[0].HasTickLabels = true;
chart1.Axes[0].TickLabelSpacing = 3;
(程序在这里报错:分类轴并未使用该属性。)
chart1.Axes[1].HasTitle = true;
chart1.Axes[1].Title.Caption = "X 座標";
分类轴并未使用该属性 这个错误怎么修改?
还有一个问题就是我想在x轴显示时间,我该给传什么类型的值进来
...全文
138 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
johnbl 2007-01-03
  • 打赏
  • 举报
回复
Thanks
孟子E章 2006-12-29
  • 打赏
  • 举报
回复
建议你在Excel里做出来你要的样子,边做边录制宏,再看看宏的代码基本可以

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧