[英]Enable scrolling in x-axis for chart control
I can't seem to enable a scroll bar on x-axis. 我似乎无法在x轴上启用滚动条。 I'm using the code below to generate the chart.
我正在使用下面的代码来生成图表。
List<int> xVal = new List<int>();
List<int> yVal = new List<int>();
for (int i = 0; i <= maxQueuetime ; i++)
{
xVal.Add(i);
yVal.Add(graph2Yaxis[i]);
}
chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
chart1.Series[0]["PointWidth"] = "1";
chart1.Series[0].Points.DataBindXY(xVal, yVal);
This will let the user drag over a portion of the chart he want to see and then a scrollbar will show up: 这将使用户将其拖到想要查看的图表的一部分上,然后将显示一个滚动条:
ChartArea CA = chart1.ChartAreas[0];
CA.CursorX.IsUserSelectionEnabled = true;
To make the scrollbar show up by code use at least this line: 要使滚动条按代码显示,请至少使用以下这一行:
CA.AxisX.ScaleView.Zoom(firstDataPoint, lastDataPointInView);
Depending on your data you may want to set the ScaleView.SizeType
根据您的数据,您可能需要设置
ScaleView.SizeType
CA.AxisX.ScaleView.SizeType = DateTimeIntervalType.Number;
I suggest adding a little help to tell the user how to zoom in.. 我建议添加一些帮助来告诉用户如何放大..
To prevent zooming you can change the default: 为了防止缩放,您可以更改默认值:
CA.AxisX.ScaleView.Zoomable = false;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.