DataTable列到图表(图表)

编程入门 行业动态 更新时间:2024-10-20 11:47:28
本文介绍了DataTable列到图表(图表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个DataTable如下: new |老| New_1 |情节 2.1 | 1.1 | 4.3 | 0.60 0.4 | 1.2 | 2.1 | 0.12 3.1 | 2.3 | 3.2 | 0.29 我想绘制图表:1new vs plot,Old vs plot,new_1 vs plot1并将每个图保存为图像,从而为每列创建多个图表图像。 我想使用列索引,绘图列的索引是固定的。 我想如果我能够保存图像每次使用不同的名称并循环列索引,我将能够为每列生成图表。

I have a DataTable as the following: new | Old | New_1| plot 2.1 | 1.1 | 4.3 | 0.60 0.4 | 1.2 | 2.1 | 0.12 3.1 | 2.3 | 3.2 | 0.29 I want to plot chart's with: 1new vs plot , Old vs plot, new_1 vs plot1 and save each of plots as images thus creating multiple chart images one for each column. I want to use column index, the index of plot column is fixed. I think if I am able to save image with different names each time and loop the column index ,I will be able to generate charts for each column.

for (int g = 0; g < resultDt.Columns.Count-1; g++) // (resultDt.Columns.Count-1) last column is plot { Chart chart = new Chart(); chart.DataSource = resultDt; chart.Width = 800; chart.Height = 550; //create serie... Series serie1 = new Series(); serie1.Name = "Serie1"; serie1.Color = Color.FromArgb(112, 255, 200); serie1.BorderColor = Color.FromArgb(164, 164, 164); serie1.ChartType = SeriesChartType.Line; serie1.XValueMember = resultDt.Columns[0].ColumnName; serie1.YValueMembers = "plot"; chart.Series.Add(serie1); //create chartareas... ChartArea ca = new ChartArea(); ca.Name = "ChartArea1"; ca.BackColor = Color.White; ca.BorderColor = Color.FromArgb(26, 59, 105); ca.BorderWidth = 0; ca.BorderDashStyle = ChartDashStyle.Solid; ca.AxisX = new Axis(); ca.AxisY = new Axis(); //ChartArea ca = new ChartArea("main"); ca.BackColor = System.Drawing.Color.FromArgb(64, System.Drawing.Color.White); chart.ChartAreas.Add(ca); //databind... chart.DataBind(); //save result... chart.SaveImage(@"C:\myChart.png", ChartImageFormat.Png); }

推荐答案

chart.SaveImage(@"C:\Matlab\" + (g).ToString() + ".png", ChartImageFormat.Png);

更多推荐

DataTable列到图表(图表)

本文发布于:2023-11-22 14:58:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617887.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图表   DataTable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!