【发布时间】:2021-01-08 16:27:57
【问题描述】:
我正在尝试以如下方法使用融合图绘制多线图:
private void GerarGraficoVarejo(string device)
{
DataTable ChartData2 = new DataTable();
DataTable ChartData3 = new DataTable();
DataTable ChartData4 = new DataTable();
// Add columns to data table
ChartData2.Columns.Add("Data", typeof(System.String));
ChartData2.Columns.Add("Preço", typeof(System.Double));
ChartData3.Columns.Add("Data", typeof(System.String));
ChartData3.Columns.Add("Preço", typeof(System.Double));
ChartData4.Columns.Add("Data", typeof(System.String));
ChartData4.Columns.Add("Preço", typeof(System.Double));
List<Data> datas = _repositorioVivoPreco.recuperarDatasVarejo();
List<VivoPreco> v = _repositorioVivoPreco.ObterValoresMagalu(device, datas);
List<VivoPreco> v2 = _repositorioVivoPreco.ObterValoresIplace(device, datas);
List<VivoPreco> v3 = _repositorioVivoPreco.ObterValoresFastshop(device, datas);
for (int i = 0; i < v.Count; i++)
{
ChartData2.Rows.Add(v[i].DataStrVarejo, v[i].ValorAparelhoVarejo);
}
for (int i = 0; i < v2.Count; i++)
{
ChartData3.Rows.Add(v2[i].DataStrVarejo, v2[i].ValorAparelhoVarejo);
}
for (int i = 0; i < v3.Count; i++)
{
ChartData4.Rows.Add(v3[i].DataStrVarejo, v3[i].ValorAparelhoVarejo);
}
StaticSource source2 = new StaticSource(ChartData2);
StaticSource source3 = new StaticSource(ChartData3);
StaticSource source4 = new StaticSource(ChartData4);
DataModel model2 = new DataModel();
model2.DataSources.Add(source2);
model2.DataSources.Add(source3);
model2.DataSources.Add(source4);
Charts.LineChart column2 = new Charts.LineChart("fourthChart");
// Set the width and the height of the chart
column2.Width.Pixel(400);
column2.Height.Pixel(400);
column2.Data.Source = model2;
// Set Chart Caption
column2.Caption.Text = "Comparativo de Preços";
column2.Legend.Show = false;
column2.XAxis.Text = "Comparativo Magalu";
column2.YAxis.Text = "Vivo";
column2.Scrollable = true;
column2.ThemeName = FusionChartsTheme.ThemeName.FUSION;
ViewData["GraficoVarejo"] = column2.Render();
}
据我了解,每一行都是不同的数据源,还是我错了?因为只画了一条线。如何在我的图表中添加更多多行?
【问题讨论】:
标签: c# fusioncharts