I'm trying to display visits to different websites over time, and it works fine. But when I try to add another website which I start tracking after I started tracking the other sites, the chart displays it as if I started it together with the other sites. For example when I have those arrays:
{
dates[] { "8/1", "8/2", "8/3" }
visits[] { 100, 74, 96 }
}
{
dates[] { "8/1", "8/2", "8/3" }
visits[] { 52, 86, 23 }
}
It works fine.. But when I have those arrays:
{
dates[] { "8/1", "8/2", "8/3" }
visits[] { 100, 74, 96 }
}
{
dates[] { "8/3" }
visits[] { 52 }
}
It shows me the second as it had 52 visits on 8/1 and not on 8/3
Here's my code:
public void drawChart(List<object[]> data)
{
chart1.Series.Clear();
for (int i = 0; i < data.Count; i = i + 3)
{
chart1.Series.Add(data[i+2][0].ToString());
chart1.Series[i / 3].Points.DataBindXY(data[i], data[i+1]);
chart1.Series[i / 3].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
chart1.Series[i / 3].IsValueShownAsLabel = true;
chart1.Series[i / 3].BorderWidth = 3;
}
}
The list contains the arrays, first array contains the dates, second one contains the visits and the third contains only one object which is the series name.