c#的chart标题_C#chart用法的几个例子

第一个简单的chart: spline// Create new data series and set it's visual attributes

Series series = new Series("Spline");

series.ChartType = SeriesChartType.Spline;

series.BorderWidth = 3;

series.ShadowOffset = 2;

// Populate new series with data

series.Points.AddY(67);

series.Points.AddY(57);

series.Points.AddY(83);

series.Points.AddY(23);

series.Points.AddY(70);

series.Points.AddY(60);

series.Points.AddY(90);

series.Points.AddY(20);

// Add series into the chart's series collection

Chart1.Series.Add(series);

同时显示2条曲线

// Populate series with random data

Random random = new Random();

for (int pointIndex = 0; pointIndex < 10; pointIndex++)

{

Chart1.Series["Series1"].Points.AddY(random.Next(45, 95));

Chart1.Series["Series2"].Points.AddY(random.Next(5, 75));

}

// Set series chart type

Chart1.Series["Series1"].ChartType = SeriesChartType.Line;

Chart1.Series["Series2"].ChartType = SeriesChartType.Spline;

// Set point labels

Chart1.Series["Series1"].IsValueShownAsLabel = true;

Chart1.Series["Series2"].IsValueShownAsLabel = true;

// Enable X axis margin

Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;

// Enable 3D, and show data point marker lines

Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;

Chart1.Series["Series1"]["ShowMarkerLines"] = "True";

Chart1.Series["Series2"]["ShowMarkerLines"] = "True";

显示column类型图

// Create new data series and set it's visual attributes

Series series = new Series("FlowRead");

series.ChartType = SeriesChartType.Column;

series.BorderWidth = 3;

series.ShadowOffset = 2;

// Populate new series with data

series.Points.AddY(67);

series.Points.AddY(57);

series.Points.AddY(83);

series.Points.AddY(23);

series.Points.AddY(70);

series.Points.AddY(60);

series.Points.AddY(90);

series.Points.AddY(20);

// Add series into the chart's series collection

Chart1.Series.Add(series);

很多点,效率还可以

// Fill series data

double yValue = 50.0;

Random random = new Random();

for (int pointIndex = 0; pointIndex < 20000; pointIndex++)

{

yValue = yValue + (random.NextDouble() * 10.0 - 5.0);

Chart1.Series["Series1"].Points.AddY(yValue);

}

// Set fast line chart type

Chart1.Series["Series1"].ChartType = SeriesChartType.FastLine;

}

日期,xy类型

// Create a new random number generator

Random rnd = new Random();

// Data points X value is using current date

DateTime date = DateTime.Now.Date;

// Add points to the stock chart series

for (int index = 0; index < 10; index++)

{

Chart1.Series["Series1"].Points.AddXY(

date,                // X value is a date

rnd.Next(40, 50));    // Close Y value

// Add 1 day to our X value

date = date.AddDays(1);

}

int-int的xy数据绘图

// Create a new random number generator

Random rnd = new Random();

// Add points to the stock chart series

for (int index = 0; index < 10; index++)

{

Chart1.Series["Series1"].Points.AddXY(

rnd.Next(10, 90),                // X value is a date

rnd.Next(40, 50));    // Close Y value

}

数据库数据,datetime-int类型

string connStr = "server=localhost;database=seis_project;uid=seisprjs;pwd=seisprjs";

SqlConnection myConn = new SqlConnection(connStr);

string selStr = "select 时间,序号 from pub_log_read order by 序号 asc";

SqlCommand myCmd = myConn.CreateCommand();

myCmd.CommandText = selStr;

myConn.Open();

SqlDataReader sdr = myCmd.ExecuteReader(CommandBehavior.CloseConnection);

// Since the reader implements and IEnumerable, pass the reader directly into

// the DataBindTable method with the name of the Column to be used as the XValue

Chart1.DataBindTable(sdr, "时

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值