简体   繁体   English

如何使用Microsoft Visual Studio在C#中的同一x轴上显示具有不同数目的数据点的多个序列?

[英]How to display multiple series with different number of data points on the same x-axis in C# using Microsoft Visual Studio?

Since I have multiple series with varying data points which I want to plot on the same axis, the points overlap each other. 由于我有多个要在同一轴上绘制的不同数据点的序列,因此这些点彼此重叠。 Hence, the date which is my x-axis is not in ascending order and may even be repeated depending on the choices selected. 因此,作为我的x轴的日期不是按升序排列的,甚至可能会根据选择的内容而重复。

I would like for the x-axis to be in ascending order and the series to be broken if need be, as long as the points are plotted according to the date on the a-xis and not repeated. 我希望x轴按升序排列,并在需要时将其破坏,只要根据a-xis上的日期绘制点,并且不再重复。

The data points have been plotted from my Microsoft Access database and contain 100+ data which means I can't hard code it in the program if that's a possible solution. 数据点是从Microsoft Access数据库中绘制的,包含100多个数据,这意味着如果可以的话,我无法在程序中对其进行硬编码。

Is there any way I can rectify this? 有什么办法可以纠正这个问题?

Thanks. 谢谢。

This is how my current chart looks like. 这就是我当前的图表。

在此处输入图片说明

Solution1: 解决方法1:

You could use "symbols" for each data point and a thinner line beteen this symbols to make clear where actual data points are found and where the lines just connect existing data points. 您可以对每个数据点使用“符号”,并在该符号之间使用较细的线,以明确找到实际数据点的位置以及仅连接现有数据点的线的位置。 If there are many data points this requires some careful "Design Choices". 如果有许多数据点,则需要进行一些仔细的“设计选择”。 Probably very small symbols (2 point) and very thin lines (1 point) create a readable chart. 可能非常小的符号(2点)和非常细的线(1点)创建了可读的图表。

Solution 2: 解决方案2:

  • Define/calculate the minimal distance (X-Delta) between two existing data points 定义/计算两个现有数据点之间的最小距离(X-Delta)
  • whenever a series contains a gap larger than this delta, start a new series for drawing purposes. 每当一个序列包含的间隙大于该增量时,就出于绘图目的开始一个新的序列。

This will produce "gaps" in the chart whenever two points have a distance larger than your delta. 只要两点的距离大于您的增量,就会在图表中产生“间隙”。

Solution 3: 解决方案3:

Some charting packages allow to set an Y-Value of NULL and draw a "Gap" in thois case. 在某些情况下,某些图表包允许将Y值设置为NULL并绘制一个“间隙”。 So just add some more datapoints with Y=Null to produce the desired gaps. 因此,只需添加更多Y = Null的数据点即可产生所需的间隙。 This works for some charting libraries while others produce an exception. 这适用于某些图表库,而另一些则产生异常。 Reading the docs or (faster) experiments may help. 阅读文档或(更快)实验可能会有所帮助。

Note: 注意:

For solutions 2 and 3 it is necessary to create special series for charting purposes. 对于解决方案2和3,有必要创建特殊的图表系列。 It is not possible to simply "bind" to data from the database. 无法简单地“绑定”到数据库中的数据。

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

相关问题 如何在c# windows forms中的图表中显示起点和终点x轴label? - How to display start and end points x-axis label in a chart in c# windows forms? Visual Studio C#图表。 如何控制X轴编号? - Visual studio C# chart. How to control the x-axis numbering? 具有多个系列的C#图表,每个系列具有不同的x轴 - C# chart with multiple series, each with different x axis 列系列在 x 轴的不同间隔上使用不同颜色填充同一系列? - Column Series With different color on a different interval at x-axis fill in same series? 使用EPPlus的C#绘图图,在X轴上的序列号\\数据类似于Y轴 - C# Draw Graph using EPPlus with sequential numbers\data in X-Axis similar to Y-Axis 在C#中从数值到时间的X轴缩放 - X-axis scaling from number value to time in C# MsChart:如何将日历周数显示为 X 轴上的标签? - MsChart: How to display Calendar week number as labels on the the X-axis? 在C#2008中,如何在图表上将TimeSpan值显示为X轴? - How can I display TimeSpan values as the X-axis on a chart in C# 2008? x轴不同间隔上不同颜色的折线图填充同一系列? - Line Chart with different colors on a different interval at x-axis fill in same series? 控制日期数据图表上的X轴标记c# - Controlling X-Axis Marks on Date Data Charts c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM