简体   繁体   中英

How to make points more compact using fastpoint chart in

I am new to C# winform. As title, my problem is how to make the points more compact in fastpoint chart. To make it clear, how to proportionally reduce the distance of the blue points like the red line segments shown in the image; that is, make the X axis more compact:

在此输入图像描述

I have searched and found a lot of information about control the interval of X or Y axis labels but which is not the situation here.

You can control the range of data values for each Axis by setting their Minimum and Maximum values.

The syntax is:

someChart.ChartAreas[CAIndexOrName].AxisX.Minimum = someDoubleValue;

Let's prepare a chart to show one day:

Axis ax = chart.ChartAreas[0].AxisX;   // a short reference

ax.IntervalType = DateTimeIntervalType.Hours;
ax.Interval = 1;

To set the properties to some DateTime values you need to convert them to doubles; for this conversion there are two built-in functions: DateTime.ToOADate and, to reverse DateTime.FromOADate

This makes the x-axis display 24 hours:

DateTime dt = DateTime.Today;

ax.Minimum =  dt.ToOADate();
ax.Maximum = (dt.AddHours(24)).ToOADate();

ax.LabelStyle.Format = "H:mm";   // optional

You also may want to control the data type of the series values:

 Series s = chart.Series[0];
 s.XValueType = ChartValueType.DateTime;  // or some other type, maybe Time

Note you you can also control both the Interval of the Labels and TickMarks and Gridlines on each axis but also set an Offset to start them a little earlier or later..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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