Page 1 of 1

Resetting FirstVisibleIndex if data is reloaded.

Posted: Tue Jul 22, 2008 7:21 pm
by 14049416
I have a candle chart. I load data from a database but instead of binding the data source to the chart I load it manually. This is done to control the gap in candles for weekends. The user has the capability to change the data source via a combobox. When this is done the data is pulled from a new table and displayed. Here is a snippet of code where I reload the new data into the candle chart:

Code: Select all

int count = 1;

this.candleChart.Clear();
            
for (int i = 0; i < this.sourceTable.Rows.Count; i++)
{
      this.candleChart.Add(count++,
            Convert.ToDouble(this.sourceTable.Rows[i]["OPEN1"]),
            Convert.ToDouble(this.sourceTable.Rows[i]["HIGH2"]),
            Convert.ToDouble(this.sourceTable.Rows[i]["LOW3"]),
            Convert.ToDouble(this.sourceTable.Rows[i]["CLOSE4"]));
}
I enable panning and allow the user to scroll via a scrollbar using the Scroll() method. The issue comes in when I reload new data into the candle cahrt it somehow remembers the scroll position of where the chart was with the previous data. In other words, if I load 1000 candles and the user scrolls pr pans to the right say 100 candles then decides to load other data, when it loads the FirstVisibleIndex remains at 100 and it positions the candles as well.

Is there a way to reset this an ensure it starts at zero?

Thanks,
Kevin

Posted: Wed Jul 23, 2008 7:29 am
by narcis
Hi Kevin,

To force axes scales returning to its original position you can use this:

Code: Select all

			tChart1.Axes.Left.Automatic = true;
			tChart1.Axes.Bottom.Automatic = true;
Or use their SetMinMax to set them to desired position.