简体   繁体   English

Winforms-如何在x轴数据点之间获取标签

[英]Winforms - How to get label in between of the x-axis datapoints

System.Web.UI.DataVisualization.Charting System.Web.UI.DataVisualization.Charting

System.Windows.Forms.DataVisualization.Charting System.Windows.Forms.DataVisualization.Charting

BarCharts - Current: 条形图-当前:

Bar Charts - Required: 条形图-必填:

or this: 或这个:

Is it possible for me to get the label in between the x axis ticks? 我可以在x轴刻度之间插入标签吗?

Thanks! 谢谢!

Found the solution! 找到了解决方案!

WinForms Chart control - Show labels between ticks WinForms图表控件-在刻度之间显示标签

How to give custom labels to x axis of chart control? 如何给图表控件的x轴赋予自定义标签?

1) Change the AxisX tick position. 1)更改AxisX刻度位置。

chart1.ChartAreas[0].AxisX.MajorTickMark.IntervalOffset =
                        chart1.ChartAreas[0].AxisX.Interval / 2f;

2) Set up the Custom Label 2)设置自定义标签

int startOffset = 0;
int endOffset = 1;

for (int i = earliestHour; i <= latestHour; i++)
{
   CustomLabel label_chart = new CustomLabel(startOffset, endOffset, xAxis_Label,0, LabelMarkStyle.None);                       
   chart1.ChartAreas[0].AxisX.CustomLabels.Add(label_chart);
   startOffset+=1;
   endOffset+=1;
}

And... you get this! 而且...你明白了!

image 图片

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM