Need to find a solution to plot all date values to candlestick chart in C#. Have a struct that contains the date as a string along with the values for open, high, low, and close. Reading values from a .csv file with stock data. Currently it is plotting all the points correctly, but only plotting a few of the date values depending on the amount of values plotted. See attached image.
I would like to have it display all the dates that are applicable to the values on the chart. So in this case the dates that should be displayed are as follows:
Only the dates of 2/2/2015, 2/9/2015, 2/17/2015, and 2/24/2015 are being shown. The following is the code related to the current state of the chart.
chart1.Series["stock"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Candlestick;
/*set the maximum y value axis*/
chart1.ChartAreas[0].AxisY.Maximum = System.Convert.ToDouble(maxX);
/*set the minimum y value axis*/
chart1.ChartAreas[0].AxisY.Minimum = System.Convert.ToDouble(minY);
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray;
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
chart1.ChartAreas[0].AxisX.MinorGrid.LineColor = System.Drawing.Color.LightGray;
chart1.ChartAreas[0].AxisX.LabelStyle.Angle = 45;
foreach (candleStick stock in chartData)
{
int currentIndex = chart1.Series["stock"].Points.Count;
chart1.Series["stock"].Points.AddXY(stock.date, stock.high);
chart1.Series["stock"].Points[currentIndex].YValues[0] = System.Convert.ToDouble(stock.high);
chart1.Series["stock"].Points[currentIndex].YValues[1] = System.Convert.ToDouble(stock.low);
chart1.Series["stock"].Points[currentIndex].YValues[2] = System.Convert.ToDouble(stock.open);
chart1.Series["stock"].Points[currentIndex].YValues[3] = System.Convert.ToDouble(stock.close);
chart1.Series["stock"].Points[currentIndex].AxisLabel = stock.date;
chart1.Series["stock"].Points[currentIndex].Color = Color.Black;
}
Any help on this would be greatly appreciated. Thanks!
This may help,
chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.NotSet;
chart1.ChartAreas[0].AxisX.Interval=1;