vb.net 将图表的比例设置为最大值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22326867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:01:54  来源:igfitidea点击:

vb.net setting the scale to a chart to maximum

vb.netwinformsmschart

提问by Dylan de St Pern

I have a line chart in VB using the standard WinForm Chartcontrol (System.Windows.Forms.DataVisualization.Charting.Chart). On the Y axis is the amount of cars, on the X axis is the time. Each point is submitted every hour. it looks like this:

我在 VB 中有一个使用标准 WinFormChart控件 ( System.Windows.Forms.DataVisualization.Charting.Chart)的折线图。Y 轴是汽车数量,X 轴是时间。每个点每小时提交一次。它看起来像这样:

This is the graph

这是图表

As you can see the time (X-axis) is displaying correctly, it shows 1 then 2 then 3 and so on.. but as the chart gets bigger it starts removing the grid on the x values, as well as their labels, like so:

正如您所看到的时间(X 轴)显示正确,它显示 1 然后 2 然后 3 等等......但是随着图表变大它开始删除 x 值上的网格,以及它们的标签,比如所以:

Image 2

图 2

Please can someone inform me as to how I can prevent the graph from automatically removing the x values label.

请有人告诉我如何防止图表自动删除 x 值标签。

Thank you, and I have not provided code because I have tried everything and none of it seems to work. I have a feeling its somewhere in the properties for the graph.

谢谢,我还没有提供代码,因为我已经尝试了所有方法,但似乎都不起作用。我有一种感觉,它在图表的属性中的某个地方。

EDIT:

编辑:

Here is the code that I use to generate the chart.

这是我用来生成图表的代码。

Dim lightvehicleaveragetime As New Series
lightvehicleaveragetime.Name = "Light Vehicle"
lightvehicleaveragetime.ChartType = SeriesChartType.Spline
Form3.Chart1.Series.Add(lightvehicleaveragetime
lightvehicleaveragetime.IsValueShownAsLabel = True
lightvehicleaveragetime.BorderWidth = 3

The rest of the code runs in a while loop, and everytime the hour changes, it will add:

其余代码在while循环中运行,每次小时变化,它会添加:

lightvehicleaveragetime.Points.AddXY(hour & ":" & minute & ":" & seconds, alllightvehicleentriesgraphtime)
lightvehicleaveragetime.LabelToolTip = time
lightvehicleaveragetime.MarkerStyle = MarkerStyle.Circle
lightvehicleaveragetime.MarkerSize = 5
lightvehicleaveragetime.MarkerColor = Color.Black

回答by TylerDurden

It seems as if you need to restrict the x axis values to be hours. the interval type or minor/major grids might help. Have you tried

似乎您需要将 x 轴值限制为小时。间隔类型或次要/主要网格可能会有所帮助。你有没有尝试过

  Chart1.ChartAreas(0).AxisX.IntervalType = DateTimeIntervalType.Hours

and try setting

并尝试设置

  Chart1.ChartAreas(0).AxisX.Interval = 1