Page 1 of 1

Proportional Candles .. possible ???

Posted: Wed Aug 04, 2010 3:12 am
by 8751509
I was wondering whether there is a way to make an individual Candle in a candle series (and for that matter bars also) proportional instead of fixed size.

So when you zoom right in you don't have tiny teeny little candles (ie whatever their fixed size is) but instead they grow to fill the space a little better.

I noticed this behaviour in a commercial package that I believe also uses TChart ... and the question bubbled up .. is this a property that I just cant find or do they do magic with Candle sizes vs zooming ...

Cheers Phil.

Re: Proportional Candles .. possible ???

Posted: Wed Aug 04, 2010 11:29 am
by 10050769
Hello Snarkle,

I made a simple code using Zoomed and UnZoomed events, that I think you can use it in your application for increase candle size when you do zoom.

Code: Select all

 public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        double Xmin,Xmax;
        int defaultWidth;
        Steema.TeeChart.Styles.Candle candle;
        private void InitializeChart()
        {
            candle = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
            candle.FillSampleValues(3);
        
            tChart1.Draw();
            Xmin = tChart1.Axes.Bottom.Minimum;
            Xmax = tChart1.Axes.Bottom.Maximum;
            defaultWidth = candle.CandleWidth;
            tChart1.Zoomed +=new EventHandler(tChart1_Zoomed);
            tChart1.UndoneZoom +=new EventHandler(tChart1_UndoneZoom);
        }
        void tChart1_Zoomed(object sender, EventArgs e)
        {
            double diff = (Xmax - Xmin) / (tChart1.Axes.Bottom.Maximum - tChart1.Axes.Bottom.Minimum);
            tChart1.Header.Text = diff.ToString();

            candle.CandleWidth = (int)(defaultWidth * diff);
        }
   
        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            candle.CandleWidth = defaultWidth;
        }
Could you please, tell us if previous code works as you want?

I hope will helps.

Thanks,

Re: Proportional Candles .. possible ???

Posted: Thu Aug 05, 2010 1:13 am
by 8751509
Thanks Sandra .. that snippet is marvelous ..

Side effect of proprtinal candles.

Posted: Fri Aug 06, 2010 6:31 am
by 8751509
Greetings,

I implemented a variation of the preceeding code snippet ... simply marvelous ;-)
However I have an unexpected side effect where the Candles draw outside the Charts bounds and onto the Axis Label values ...
I remember seeing a property somewhere (I think) that stopped it drawing outside the chart bounds .. but I'll never find it again (no offense guys but the bundled documentation needs some work, some structuring and examples !!!.)
CandleProblem.png
Candle drawing outside Chart bounds
CandleProblem.png (13.22 KiB) Viewed 6603 times
I've attached a pic to show the side effect ... is there, as I have imagined, a property I need to set .... or do I use a workaround and somehow not plot the first and last candles that are visible on the Chart ?

regards Phil.

Re: Proportional Candles .. possible ???

Posted: Fri Aug 06, 2010 9:36 am
by 10050769
Hello Phil,

Could you please attach here a simple example code, where appears your problem, because we can find a good solution for you?

Thanks,

Re: Proportional Candles .. possible ???

Posted: Fri Aug 06, 2010 9:41 am
by yeray
Hi Phil,

I think you are looking for the demo at All Features\Welcome !\Axes\Opaque zones. Isn't it?
However, we can't reproduce it with the code that Sandra posted above. So it would probably be better if you could send us a simple example so we can investigate it.

Re: Proportional Candles .. possible ???

Posted: Mon Aug 09, 2010 1:40 am
by 8751509
Thanks Yeray,

I found this in that example ... tChart1.Aspect.ClipPoints=false;

I made it "true" and now the enlarged candles are suitably clipped ...

Re: Proportional Candles .. possible ???

Posted: Mon Aug 09, 2010 11:50 am
by 10050769
Hello Snarkle,

I am glad that works fine for you now :).

Thanks,