Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a simple chart in my c#
i have updated the values,
without using the Update() or Refresh() can we able to Update the new value in chart?
can you give me a solution for this

What I have tried:

Update() and Refresh()
but i need to update without using the Update() or Refresh()
Posted
Updated 18-Sep-16 22:53pm
Comments
VR Karthikeyan 19-Sep-16 4:39am    
Not enough information. What is your UI platform, are you using Winforms or WPF? And Show what you have tried. Update your question with more details.
Rajesh Kanna 19-Sep-16 5:40am    
I am using in C# windows Application
Rajesh Kanna 19-Sep-16 5:37am    
My Code
Button 1: To Plot the Values in Graph
Button 2: Update The Particular Axis Value with the old Maximum Value in the axis + new value
My Values are increasing properly,,,
eg i have (x=1,y=2) updating y=2,so old max val=2+2=>4 so My result is (1,4),its working ,but when i give y=-10 the graph is plotting to but the old (1,4) marked size is still visibled
My Code


private void button1_Click(object sender, EventArgs e)
{
chart1.Series.Clear();
chart1.Series.Add(name);
chart1.ChartAreas[0].AxisY.Maximum = double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = double.NaN;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.ChartAreas[0].AxisX.Maximum = double.NaN;
chart1.Series[name].Points.AddXY(1, 2);
chart1.Series[name].Points.AddXY(2, 10);
chart1.Series[name].Points.AddXY(3, 5);
chart1.Series[name].Points.AddXY(4, 8);
chart1.Series[name].Points.AddXY(5, 10);
chart1.Update();
}

private void button2_Click(object sender, EventArgs e)
{
X = double.Parse(textBox1.Text);//added today
if (MyTempXValue != X)
{
try
{
MaximumValue = 0;
chart1.Update();
X = double.Parse(textBox1.Text);
double point = X - 1;
MaximumValue = chart1.Series[name].Points[(int)point].GetValueByName("Y");
MessageBox.Show(MaximumValue.ToString());
double UerValue = double.Parse(textBox3.Text);
Y = MaximumValue + UerValue;
MyTempValue = Y;//storing Maximum Value in temp variable
MyTempXValue = X;//storing the X value in Temp Variable /added today
chart1.Series[name].Points.AddXY(X, Y);
chart1.DataBind();
chart1.Update();
chart1.Invalidate();
}
catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
}
else
{
try
{
MessageBox.Show(MyTempValue.ToString());
chart1.Update();
X = double.Parse(textBox1.Text);
double point = X - 1;
double UerValue = double.Parse(textBox3.Text);
MyTempValue = MyTempValue + UerValue;
chart1.Series[name].Points.AddXY(X, MyTempValue);
chart1.DataBind();
chart1.Update();
}
catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
}
}

1 solution

try like this

C#
int index = 2;
string seriesName = "Series1";
chart1.Series[seriesName].Points.ElementAt(index).SetValueXY("New Value", 555);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900