Click here to Skip to main content
15,910,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,
I have a asp chart which have three datapoints What I want is to change the chart values as I change value in textbox,I have searched about it But not found any useful material Please guide me as I am beginner.Thank you
Posted

You'll have to do it through the C# code. Cause a postback where you change the data points. Since it is just an image, the image has to be regenerated.

So, have a textbox that autopostsback and then change the value in the datapoints on your series and the image will be regenerated.
 
Share this answer
 
Comments
M Ali Qadir 21-Feb-12 12:17pm    
Will you please Elaborate,I can Make the text box autopostback property true then how I will change the series at run time. In fact I want my data in text box should be bound to the Graph Image.
ZurdoDev 21-Feb-12 12:22pm    
Just as an example, you can do something like Chart.Series[seriesName].Points.AddXY(columnName, YVal);
M Ali Qadir 21-Feb-12 12:59pm    
In fact I want that when I enter the value in the text box then it changes the height of graph Respected column according to the value entered. I have tried the above line of code then this code is changing the length of my graph Not the column If there is any material to read about all about this kind of work please suggest me so that I could thoroughly Understand Thank you.
I have done it like this code and its working well.thank you I am beginner and I just ask for understanding I am not Developer so if there is anything you find wrong out of me them please guide me.
Thanks


private void Form1_Load(object sender, EventArgs e)
{

bmpDrawingArea = new Bitmap(Width, Height);
graphDrawingArea = Graphics.FromImage(bmpDrawingArea);
}

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawImage(bmpDrawingArea, 0, 0);
}

private void btnGenerate_Click(object sender, EventArgs e)
{
int monday = int.Parse(this.txtMonday.Text);
int tuesday = int.Parse(this.txtTuesday.Text) ;
int wednesday = int.Parse(this.txtWednesday.Text);
int thursday = int.Parse(this.txtThursday.Text);
int friday = int.Parse(this.txtFriday.Text);
graphDrawingArea.Clear(this.BackColor);
graphDrawingArea.DrawRectangle(new Pen(Color.Red), this.txtMonday.Left + 5, 280 - monday, 40, monday);
graphDrawingArea.DrawRectangle(new Pen(Color.Blue), this.txtTuesday.Left + 5, 280 - tuesday, 40, tuesday);
graphDrawingArea.DrawRectangle(new Pen(Color.Yellow), this.txtWednesday.Left + 5, 280 - wednesday, 40, wednesday);
graphDrawingArea.DrawRectangle(new Pen(Color.Green), this.txtThursday.Left + 5, 280 - thursday, 40, thursday);
graphDrawingArea.DrawRectangle(new Pen(Color.Maroon), this.txtFriday.Left + 5, 280 - friday, 40, friday);
graphDrawingArea.DrawRectangle(new Pen(Color.Black), 10, 280, Width, 1);
Invalidate();
}

private void txtChangeValue_TextChanged(object sender, EventArgs e)
{
txtMonday.Text = ((TextBox)sender).Text;
}

private void txtMonday_TextChanged(object sender, EventArgs e)
{
txtChangeValue.Text = ((TextBox)sender).Text;
}
 
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