我有这种情况:
我该如何从datagridview的信息创建此图表https://lvcharts.net/App/examples/v1/wf/Stacked%20Area,这不是问题,问题在于我只想使用2个变量(日期和值)来创建图表。
现在我已经用数据向datagridview收费了,我以这种方式继续创建图表:
private void crearGrafica5()
{
int con = 0;
foreach (DataGridViewRow row in dataGridView3.Rows)
{
con++;
}
if (con > 0)
{
Func<ChartPoint, string> labelPoint = chartPoint =>
string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
int conn = 0;
string[] utilidades = new string[dataGridView3.RowCount];
string[] fechas = new string[dataGridView3.RowCount];
cartesianChart2.Series.Clear();
cartesianChart2.Series = new SeriesCollection { };
foreach (DataGridViewRow row in dataGridView3.Rows)
{
utilidades[conn] = row.Cells[3].Value.ToString();
fechas[conn] = row.Cells[3].Value.ToString();
conn++;
}
string values_grafica = "new ChartValues<DateTimePoint> { ";
for(int i=0;i<utilidades.Length;i++)
{
if (i == 0)
{
values_grafica += "new DateTimePoint(new System.DateTime(" + fechas[i] + "," + utilidades + ")";
}
else
{
values_grafica += ",new DateTimePoint(new System.DateTime(" + fechas[i] + "," + utilidades + ")";
}
}
values_grafica = "}";
ChartValues values_gra = new ChartValues<>;
if (conn < 10)
{
cartesianChart2.Series.Add
(
new StackedAreaSeries
{
Title = row.Cells[0].Value.ToString(),
Values = /////this is my problem,
LineSmoothness = 0
}
);
}
conn++;
pieChart1.LegendLocation = LegendLocation.Bottom;
button1.Enabled = true;
}
else
{
button1.Enabled = false;
pieChart1.Series.Clear();
}
}
但是我不知道如何将values_grafica字符串添加到图表的值中。
请帮忙吗?