让ZeGraph在X方向上填满

默认的效果是

image

希望能够在x方向上填满,两边不留。尝试出来的方法是:用zg1.GraphPane.XAxis.Scale.Max 和Min来设置,而且必须在画完图后设置。

zg1.GraphPane.CurveList.Clear();

zg1.GraphPane.XAxis.Type = AxisType.Date;
zg1.GraphPane.XAxis.Scale.Format = "M'/'d";

string sDate1 = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd");
string sDate2 = DateTime.Now.ToString("yyyy-MM-dd");

double x1 = (double)new XDate(Convert.ToInt32(sDate1.Substring(0, 4)), Convert.ToInt32(sDate1.Substring(5, 2)), Convert.ToInt32(sDate1.Substring(8, 2)));
double x2 = (double)new XDate(Convert.ToInt32(sDate2.Substring(0, 4)), Convert.ToInt32(sDate2.Substring(5, 2)), Convert.ToInt32(sDate2.Substring(8, 2)));

Pub.CreateLine(zg1, sDate1,  listView1.SelectedItems[0].SubItems[1].Text);  
Pub.CreateGraph(zg1, sDate1,sDate2, listView1.SelectedItems[0].SubItems[1].Text );                                     //要填充的图案最后划

zg1.GraphPane.XAxis.Scale.Max = x2;
zg1.GraphPane.XAxis.Scale.Min = x1;

zg1.Refresh();

image

原文地址:https://www.cnblogs.com/jetz/p/1676855.html