I am using zedGraph to plot BarCharts in C#. I am getting issues related with bar width when I try to plot large amount of data e.g. more than 5 years daily data. The Bars are becoming wider and overlapping. Is there any way to auto scaling the bar width to fit the pane?
Here is a code that I am trying:
private void precipitationBHChart(ZedGraphControl zgc, DataTable dataTable)
{
dataTable.Columns[0].ColumnName = "Date";
dataTable.Columns[1].ColumnName = "Precipitation";
GraphPane myPane = zgc.GraphPane;
//// set opposite axes major tic and minor tic
myPane.XAxis.MajorTic.IsOpposite = false;
myPane.XAxis.MinorTic.IsOpposite = false;
myPane.YAxisList[0].MajorTic.IsOpposite = false;
myPane.YAxisList[0].MinorTic.IsOpposite = false;
// set xAxis type to date
myPane.XAxis.Type = AxisType.Date;
// Disable zoom
zgc.ZoomButtons = MouseButtons.None;
zgc.ZoomButtons2 = MouseButtons.None;
zgc.ZoomStepFraction = 0;
// set xAxis scale min and max value
object maxDate = dataTable.Compute("MAX(Date)", null);
object minDate = dataTable.Compute("MIN(Date)", null);
myPane.XAxis.Scale.Max = Convert.ToDateTime(maxDate).ToOADate();
myPane.XAxis.Scale.Min = Convert.ToDateTime(minDate).ToOADate();
// Make up some data points from the Sine function
PointPairList list1 = new PointPairList();
foreach (DataRow dr in dataTable.Rows)
{
list1.Add(Convert.ToDateTime(dr[0]).ToOADate(), Convert.ToDouble(dr[1]));
}
BarItem bar1 = myPane.AddBar("Precipitation", list1, Color.DarkGray);
// Calculate the Axis Scale Ranges
zgc.AxisChange();
}
Here is sample chart: https://drive.google.com/file/d/0B8BnppTIW9YFczF4ZnlTLUJjOG8/view?usp=sharing