简体   繁体   English

C#向图表添加负值

[英]C# adding negative values to chart

Can anybody help me, why I can't add negative values to the chart (windows form)? 谁能帮我,为什么我不能向图表(Windows窗体)添加负值? the part of code is below: 代码部分如下:

chart1.Series["Series1"].Points.AddXY(a, Convert.ToDouble(rx_str_copy));

for example as input: rx_str_copy = "-128.00" 例如作为输入: rx_str_copy =“ -128.00”

It throws a communicate that input string is wrong. 它引发一个输入字符串错误的通知。 With positive values I don't have any problems 拥有积极的价值观,我没有任何问题

What is wrong? 怎么了?

I'm updating my question: 我正在更新我的问题:

So far I've tried to add values without dot, so it was just like integer covered in string and then converted to double. 到目前为止,我尝试添加不带点的值,因此就像将整数覆盖在字符串中然后转换为双精度一样。 Now I'm trying to add values with dot so now it's double covered in string and then convert to double. 现在,我尝试使用点添加值,因此现在将其双倍覆盖在字符串中,然后转换为双精度。

I realized problem with negative and positive values also. 我也意识到负值和正值的问题。 So the problem lies with dot in string. 因此问题出在字符串中的点。 Can anybody help with that? 有人可以帮忙吗?

A simple test case like this works perfectly for me. 像这样的简单测试用例非常适合我。 For your case, is a a double already? 对于你的情况,是a已经是双?

public Form1 ()
{
    InitializeComponent();
}

private void chart1_Click ( object sender, EventArgs e )
{
    string rx_str_copy = "-128.00";
    chart1.Series["Series1"].Points.AddXY(-1.00, Convert.ToDouble(rx_str_copy));
}

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

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