I need the horizontal axis to be linear in the chart. For example:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
MakeChart();
}
private DataTable _dtChart;
private void MakeChart()
{
_dtChart = new DataTable("Chart");
var column = new DataColumn("COLUMN0", typeof(DateTime));
_dtChart.Columns.Add(column);
column = new DataColumn("COLUMN1", typeof(double));
_dtChart.Columns.Add(column);
column = new DataColumn("COLUMN2", typeof(double));
_dtChart.Columns.Add(column);
column = new DataColumn("COLUMN3", typeof(double));
_dtChart.Columns.Add(column);
_dtChart.BeginLoadData();
var row = new object[_dtChart.Columns.Count];
var date = new DateTime(2007, 1, 1);
row[0] = date; row[1] = 14.163764; row[2] = 13.56391907;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(1); row[1] = 14.16415691; row[2] = 13.56490612;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(2); row[1] = 14.16449642; row[2] = 13.56572723;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(3); row[1] = 14.16489506; row[2] = 13.56701374;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(4); row[1] = 14.16524887; row[2] = 13.56779575;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(5); row[1] = 14.16561508; row[2] = 13.56877995;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(6); row[1] = 14.1659956; row[2] = 13.56987286; row[3] = 12.9375058;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(7); row[1] = 14.16635513; row[2] = 13.57107353; row[3] = 12.93832116;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(8); row[1] = 14.16672421; row[2] = 13.57207203; row[3] = 12.93914642;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(9); row[1] = 14.16709232; row[2] = 13.57329559; row[3] = 12.93998154;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(10); row[1] = 14.1674614; row[2] = 13.57457256; row[3] = 12.94082651;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(11); row[1] = 14.16784954; row[2] = 13.57580566; row[3] = 12.94168131;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(12); row[1] = 14.16822338; row[2] = 13.57705879; row[3] = 12.94254593;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(13); row[1] = 14.16857815; row[2] = 13.57775879; row[3] = 12.9441519;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(14); row[1] = 14.16896725; row[2] = 13.57868004; row[3] = 12.94503586;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(15); row[1] = 14.16935158; row[2] = 13.5797205; row[3] = 12.94592957;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(16); row[1] = 14.16974831; row[2] = 13.58084583; row[3] = 12.94683301;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(17); row[1] = 14.17011547; row[2] = 13.58196545; row[3] = 12.94774618;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(18); row[1] = 14.17047501; row[2] = 13.58280563; row[3] = 12.94866904;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(19); row[1] = 14.17082119; row[2] = 13.58374691; row[3] = 12.94960158;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(20); row[1] = 14.17117214; row[2] = 13.58471298; row[3] = 12.95054378;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(21); row[1] = 14.17156029; row[2] = 13.5856638; row[3] = 12.95149562;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(22); row[1] = 14.17191505; row[2] = 13.58641052; row[3] = 12.95245707;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(23); row[1] = 14.17225742; row[2] = 13.58718204; row[3] = 12.95342813;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(24); row[1] = 14.1726265; row[2] = 13.58848; row[3] = 12.95440876;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(25); row[1] = 14.17300701; row[2] = 13.5894928; row[3] = 12.95539896;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(26); row[1] = 14.17333603; row[2] = 13.59065437; row[3] = 12.95639868;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(27); row[1] = 14.17368698; row[2] = 13.5917902; row[3] = 12.95740793;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(28); row[1] = 14.17403889; row[2] = 13.59270477; row[3] = 12.95842667;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(29); row[1] = 14.17442799; row[2] = 13.59344292; row[3] = 12.95945488;
_dtChart.Rows.Add(row);
row[0] = date.AddDays(30); row[1] = 14.17476845; row[2] = 13.59449482; row[3] = 12.96049254;
_dtChart.Rows.Add(row);
_dtChart.EndLoadData();
var horizontalAxis = new LinearAxis {Title = "Ln"};
var verticalAxis = new LinearAxis
{
AxisType = AxisType.Second,
Title = "Value"
};
var lineSeria = new LineSeries
{
DisplayMember = "COLUMN1",
ValueMember = "COLUMN2",
VerticalAxis = verticalAxis,
HorizontalAxis = horizontalAxis,
};
radChartView1.Series.Add(lineSeria);
radChartView1.DataSource = _dtChart;
radChartView1.Refresh();
}
}
But nothing is drawn on the chart, and the range of the horizontal axis is wrong.
What am I doing wrong?