そこで、カスタム ビジネス オブジェクトのリストを Rad チャートにバインドします。この例では、1 年間の月間収益の概要です。X 軸のラベルに設定している日付が、設定したとおりにレンダリングされません。
これが私の基本的なコードです。指定された年のmonthLedgerオブジェクトのリストを取得することがわかります。monthLedgerオブジェクトにはさまざまなプロパティがありますが、このシナリオの主なプロパティはmonthLedger.Full_dateとmonthLedger.Revenue_Amountです。
List<monthLedger> year = getYearRevenueByMonth(2011);
DataSeries ser = new DataSeries();
foreach(monthLedger month in year)
{
ser.Add(new DataPoint
{
YValue = Convert.ToDouble(month.Revenue_Amount),
Label = month.Revenue_Amount.ToString("0.00###"),
XValue = month.Full_Date.ToOADate()
});
}
radChart1.DefaultView.ChartArea.AxisX.IsDateTime = true;
radChart1.DefaultView.ChartArea.AxisX.AutoRange = true;
radChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM";
radChart1.DefaultView.ChartArea.DataSeries.Add(ser);
2011 年のリストで取得するデータは次のとおりです (Full_Date || Revenue_Amount):
- {01/01/2011 午前 12:00:00} || 0.00
- {01/02/2011 午前 12:00:00} || 0.00
- {01/03/2011 午前 12:00:00} || 0.00
- {01/04/2011 午前 12:00:00} || 0.00
- {01/05/2011 午前 12:00:00} || 0.00
- {01/06/2011 午前 12:00:00} || 0.00
- {01/07/2011 午前 12:00:00} || 0.00
- {01/08/2011 午前 12:00:00} || 0.00
- {01/09/2011 午前 12:00:00} || 0.00
- {01/10/2011 12:00:00 AM} || 0.00
- {01/11/2011 午前 12:00:00} || 246.50
- {01/12/2011 午前 12:00:00} || 311.60
私が期待するのは 12 か月の素晴らしいグラフですが、最終的に 13 列がグラフ化され、ラベル付けされた日付は、OLE Automation Date に変換した日付とまったく同じではありません。
グラフィック結果のスクリーンショットを添付しました。
私は何を間違っていますか?