I created a chart containing two series which shows values (AXIS Y - int) of two distribution channels ( SERIES A and B) day by day (AXIS X - datetime) . All data comes from datatable which comes from external db. Until I present data between Monday and Saturday all go well. The problem appears during weekend. It happens that there is no data on channel A on Sunday. In such a case chart with bars get messed. There is no Sunday bar at all ( two Mondays instead of) but data of channel A are shifted one day back.
Below code I wrote:
public Chart DrawBar(OracleConnection oc, Chart ch)
{
DataTable dt = GenerateData(oc, queryBar());
Chart chart1 = ch;
foreach (string s in channel)
{
chart1.Series.Add(s);
chart1.Series[s].XValueType = ChartValueType.DateTime;
chart1.Series[s].YValueType = ChartValueType.Double;
chart1.Series[s].ChartType = SeriesChartType.StackedColumn;
}
foreach (DataRow row in dt.Rows)
{
string series = row["SOURCE"].ToString();
DateTime X = (DateTime)row["DATA"];
String Y = row["HOWMUCH"].ToString();
chart1.Series[series].Points.AddXY(X.ToShortDateString(), Convert.ToDouble(Y));
chart1.Series[series].IsValueShownAsLabel = true;
}
return chart1;
}
I found some info about Series.IsXValueIndexed as well as Chart1.DataManipulator.InsertEmptyPoints but I can't understand how it could be used in my code.