Proportional Candles .. possible ???

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Proportional Candles .. possible ???

Post by Snarkle » Wed Aug 04, 2010 3:12 am

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.
--------------------
Cheers Phil.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Proportional Candles .. possible ???

Post by Sandra » Wed Aug 04, 2010 11:29 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: Proportional Candles .. possible ???

Post by Snarkle » Thu Aug 05, 2010 1:13 am

Thanks Sandra .. that snippet is marvelous ..
--------------------
Cheers Phil.

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Side effect of proprtinal candles.

Post by Snarkle » Fri Aug 06, 2010 6:31 am

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 6609 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.
--------------------
Cheers Phil.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Proportional Candles .. possible ???

Post by Sandra » Fri Aug 06, 2010 9:36 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Proportional Candles .. possible ???

Post by Yeray » Fri Aug 06, 2010 9:41 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: Proportional Candles .. possible ???

Post by Snarkle » Mon Aug 09, 2010 1:40 am

Thanks Yeray,

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

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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Proportional Candles .. possible ???

Post by Sandra » Mon Aug 09, 2010 11:50 am

Hello Snarkle,

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

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply