Page 1 of 1

Controlling number of candles displayed.

Posted: Tue Aug 05, 2008 4:23 pm
by 14049416
Is there a way to control the number of candles displayed in a candle chart other than using the MaxPointsPerPage property? I am loading a 1000 candles but only want to show 50 to start with but the user will need to have the ability to increase or decrease the number of candles displayed during runtime.

Thanks,
Kevin

Re: Controlling number of candles displayed.

Posted: Wed Aug 06, 2008 6:56 am
by Chris
Hello Kevin,
WD_Gordon wrote:Is there a way to control the number of candles displayed in a candle chart other than using the MaxPointsPerPage property? I am loading a 1000 candles but only want to show 50 to start with but the user will need to have the ability to increase or decrease the number of candles displayed during runtime.
I think that using the Page class is still the best way to go. You could present the MaxPointsPerPage property to your users to let them select how many points per page they wish to see, e.g.

Code: Select all

    private Steema.TeeChart.Styles.Candle series;
    private bool setting;

    private void InitializeChart()
    {
      setting = true;
      tChart1.Aspect.View3D = false;
      tChart1.Series.Add(series = new Candle());
      series.FillSampleValues(100);

      tChart1.Page.MaxPointsPerPage = 50;
      tChart1.Page.Current = tChart1.Page.Count - 1;

      numericUpDown1.Value = tChart1.Page.MaxPointsPerPage;
      setting = false;
    }

    private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    {
      if (!setting)
      {
        tChart1.Page.MaxPointsPerPage = (int)numericUpDown1.Value;
      }
    }

Posted: Wed Aug 06, 2008 1:45 pm
by 14049416
Hi Chistopher,

I tried setting the MaxPointsPerPage value during runtime and it works for the most part.

The issue I am running into is I also have a scroll bar set up and I use the Axes.Bottom.Scroll() method to move the points. When I call this method it changes the Axes.Bottom.Automatic property to false. When this happens, setting the MaxPointsPerPage value during runtime no longer works. I even tried setting Axes.Bottom.Automatic = true right after calling the Scroll() method but setting the MaxPointsPerPage value during runtime still doesn't work.

So to sum ti up, setting the MaxPointsPerPage during runtime always works until the first time you call the Scroll() method.

Any thoughts?

Thanks,
Kevin

Posted: Wed Aug 06, 2008 1:46 pm
by 14049416
Sorry Christopher, I needed to add on thing. When I set the Axes.Bottom.Automatic to true it moves to the first page of the candles so that is not an option.

Kevin

Posted: Thu Aug 07, 2008 7:10 am
by Chris
Hello Kevin,
WD_Gordon wrote: Any thoughts?
Well, you could emulate the Paging functionality while enabling users to scroll the chart with code similar to the following (click and drag the bottom axis to scroll):

Code: Select all

    private Steema.TeeChart.Styles.Candle series;
    private Steema.TeeChart.Tools.AxisScroll tool;
    private double step;

    private void InitializeChart()
    {
      button1.Text = "<<";
      button2.Text = "<";
      button3.Text = ">";
      button4.Text = ">>";

      tChart1.Aspect.View3D = false;
      tChart1.Series.Add(series = new Candle());
      series.FillSampleValues(1000);

      tChart1.Axes.Bottom.Labels.Angle = 90;

      step = (series.DateValues[1] - series.DateValues[0]) / 2;
      //tChart1.Page.MaxPointsPerPage = 50;
      //tChart1.Page.Current = tChart1.Page.Count - 1;
      tChart1.Axes.Bottom.SetMinMax(series.DateValues[series.Count - 51] - step, series.DateValues[series.Count - 1] + step);

      tChart1.Tools.Add(tool = new AxisScroll());
      tool.Axis = tChart1.Axes.Bottom;
    }

    private void button1_Click(object sender, EventArgs e)
    {
      tChart1.Axes.Bottom.SetMinMax(series.DateValues[0] - step, series.DateValues[49] + step);
      //tChart1.Page.Current = 1;
    }

    private void button2_Click(object sender, EventArgs e)
    {
      int first = series.FirstVisibleIndex - 49;
      int last = series.LastVisibleIndex - 49;

      if (first < 0)
      {
        first = 0;
        last = 49;
      }

      tChart1.Axes.Bottom.SetMinMax(series.DateValues[first] - step, series.DateValues[last] + step);
      //tChart1.Page.Previous();
    }

    private void button3_Click(object sender, EventArgs e)
    {
      int first = series.FirstVisibleIndex + 49;
      int last = series.LastVisibleIndex + 49;

      if (last >= series.Count)
      {
        first = series.Count - 51;
        last = series.Count - 1;
      }

      tChart1.Axes.Bottom.SetMinMax(series.DateValues[first] - step, series.DateValues[last] + step);
      //tChart1.Page.Next();
    }

    private void button4_Click(object sender, EventArgs e)
    {
      tChart1.Axes.Bottom.SetMinMax(series.DateValues[series.Count - 51] - step, series.DateValues[series.Count - 1] + step);
      //tChart1.Page.Current = tChart1.Page.Count - 1;
    }