Zooming Candle Chart
Zooming Candle Chart
While Zooming Candle Chart only candle height and space between candle increases. I also want that candle width must be increase automatically in same proportion.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Zooming Candle Chart
Hello,
One possibility is to run code such as the following:
One possibility is to run code such as the following:
Code: Select all
Candle series = new Candle();
double widthRatio;
int origCandleWidth;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(series);
series.FillSampleValues();
tChart1.Zoomed += tChart1_Zoomed;
tChart1.UndoneZoom += tChart1_UndoneZoom;
tChart1.BeforeDrawSeries += tChart1_BeforeDrawSeries;
tChart1.Draw();
origCandleWidth = series.CandleWidth;
widthRatio = (tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum) / origCandleWidth;
}
bool zoomed = false;
void tChart1_UndoneZoom(object sender, EventArgs e)
{
zoomed = true;
}
void tChart1_Zoomed(object sender, EventArgs e)
{
zoomed = true;
}
void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
{
if(zoomed)
{
double range = tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum;
double tmpRatio = range / origCandleWidth;
if (widthRatio > 0 && widthRatio != tmpRatio)
{
series.CandleWidth = Utils.Round((widthRatio / tmpRatio) * origCandleWidth);
}
else
{
series.CandleWidth = origCandleWidth;
}
}
zoomed = false;
}
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Zooming Candle Chart
We tried the following code, it worked for us, but can you please include TeeChart Control's Size to calculate candle width?
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Zooming Candle Chart
If you use the Control's size than the Candle width will not change when you zoom the Chart, which was the original request.Quant wrote:We tried the following code, it worked for us, but can you please include TeeChart Control's Size to calculate candle width?
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |