我在柱形圖一些自定義標籤(有點我的代碼):C#圖表排列軸線標籤
chart.ChartAreas[0].AxisX.IsMarginVisible = true;
chart.ChartAreas[0].AxisX.LabelStyle.IsEndLabelVisible = true;
chart.ChartAreas[0].AxisX.LineColor = Color.LightGray;
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.LightGray;
chart.ChartAreas[0].AxisX.LabelStyle.Angle = 0;
chart.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Trebuchet MS", 10);
chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = Color.LightGray;
chart.ChartAreas[0].AxisX.Interval = 1;
chart.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Weeks;
chart.ChartAreas[0].AxisX.IsLabelAutoFit = true;
chart.ChartAreas[0].AxisX.LabelStyle.IsEndLabelVisible = false;
DateTime minDate = DateTime.Parse(dt.Rows[0]["Date"].ToString());
DateTime maxDate = DateTime.Parse(dt.Rows[dt.Rows.Count - 1]["Date"].ToString());
for (int i = 0; i < dt.Rows.Count - 1; i++)
{
chart.ChartAreas[0].AxisX.CustomLabels.Add(new CustomLabel(minDate.ToOADate(),
minDate.AddDays(6).ToOADate(),
minDate.ToShortDateString() + "-" + minDate.AddDays(6).ToShortDateString(),
0,
LabelMarkStyle.None));
minDate = minDate.AddDays(7);
}
如此以來,我自定義拉布勒文字是那麼的漫長minDate.ToShortDateString() + "-" + minDate.AddDays(6).ToShortDateString()
它看起來像
如果可以,我該如何移動到左軸標籤?
我的建議是縮短標籤。從可用性角度來看,它們很難閱讀,信息也會丟失。只需使用例如30/3 - 5/4,或者甚至,因爲這些看起來是幾周,只是開始日期,例如, 30/3,6/4等 – Kif