反转折线图的方向 [英] Reverse the direction of line chart

查看:413
本文介绍了反转折线图的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过许多事情,例如设置 Right to Left 或者打乱<$ c $> IsReversed $ c> ChartArea 但没有去。任何建议?

I have tried many things such as setting Right to Left or messing with the IsReversed property for ChartArea but no go. Any advice?

对于缺乏信息,我认为这只是一个开关在图表属性中的某个地方,我忽略了。无论如何,我正在制作一个自定义图表,现在的行从左到右,但我需要它反方向。

Sorry for the lack of info, I figured it would be just a switch somewhere in the Chart properties that I was overlooking. Anyways, I am making a custom chart and right now the lines are going from left to right BUT I need it to go in the reverse direction

我想另一种方法把它woudl是如何添加点从右到左?

I guess another way to put it woudl be how do I add points going from right to left?

推荐答案

如果要反转x轴,所有您需要做的是

If you want to reverse the x-axis all you need to do is

private void button1_Click(object sender, EventArgs e)
{
    ChartArea CA = chart1.ChartAreas[0];
    CA.AxisX.IsReversed = true;
}

前后:

如果要将y轴保持为左边,请使用:

If you want to keep the y-axis to the left use this:

private void button2_Click(object sender, EventArgs e)
{
    ChartArea CA = chart1.ChartAreas[0];
    CA.AxisY2.Enabled = AxisEnabled.True;
    CA.AxisY.Enabled = AxisEnabled.False;
    CA.AxisX.IsReversed = true;
}

如果您在评论时只想添加 DataPoints 到左边,你可以这样做:

If, as you comment, you simply want to add DataPoints to the left, you can do so like this:

Series S = chart1.Series[0];
DataPoint dp = new DataPoint(dp.XValue, dp.YValues[0]);
S.Points.Insert(0, dp);

这可能有点慢,但它会工作,以及在结尾添加。您可能需要查看此帖子 Points 集合中的各个位置插入 DataPoints

This may be a little slower, but it will work just as well as Adding them at the end. You may want to have a look at this post, where DataPoints are inserted at various spots in the Points collection..

注意 Points 通常像数组一样访问,但实际上是类型 DataPointCollection 以便添加和删除等许多其他操作很容易获得。

Note the Points is often accessed like an array but really is of type DataPointCollection so adding and removing and many other operations are readily available.

一个常见的用法是从左边移除Points以创建一个'移动'图表,如示波器。

One common use is removing Points from the left to create a 'moving' chart like an oscillograph..

这篇关于反转折线图的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆