如何使x轴忽略的x值的顺序?顺序

2023-09-03 03:50:16 作者:八个字的游戏名字:朕不死ぃ尔等永为臣

首先,我很抱歉,如果我的英语不是很好......

First, I'm sorry if my English isn't that good...

我有4个阵列(第2是系列#1),并且我想将它们绑定到我的图:

I have 4 arrays (the first 2 are for series #1), and I want to bind them to my chart:

double[] yValues1 = { 65.62, 75.54, 60.45, 55.73, 70.42, 200 };
string[] xValues1 = { "France", "Canada", "UK", "USA", "Italy", "India" };
chart.Series["Series1"].Points.DataBindXY(xValues1, yValues1);

double[] yValues2 = { 65.62, 75.54, 60.45, 55.73, 200, 70.42 };
string[] xValues2 = { "France", "Canada", "UK", "USA", "India", "Italy"};
chart.Series["Series2"].Points.DataBindXY(xValues2, yValues2);

和结果(注意:该值和意大利和印度的顺序):

and the result is (Observe: the values and the order of Italy and India):

正如你所看到的,印度应该是与200两个系列,但第二个系列的200提到意大利(即第五位第一辑),因为如果这样下去,按照第一个系列。简言之,我想在两个系列要显示的xValues​​不管顺序,而是根据自己的字符串值。

As you can see, India supposed to be with 200 in both series, but the 200 of the second series referred to Italy (that is fifth in the first series), as if it goes according the first series. In brief, I want the two series to be shown regardless the order of the xValues, but according to their strings values.

顺便说一句,我怎么能限制列的数量,即使我绑定图表与数组的长度更大然后该限制?

And by the way, How can I to limit the number of columns and that even though I binded the chart with array with bigger length then that limit?

推荐答案

要实现这一目标增加一个调用AlignDataPointsByAxisLabel:

To accomplish this add a call to AlignDataPointsByAxisLabel:

Chart.AlignDataPointsByAxisLabel();

这将调整所有的数据点与同一轴上的标签,不管什么样的顺序,他们必然的。

This will align all data points with the same axis label, regardless of what order they are bound.