Selecting bars in a series with a TColorBand

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TestAlways
Newbie
Newbie
Posts: 12
Joined: Mon Mar 09, 2015 12:00 am

Selecting bars in a series with a TColorBand

Post by TestAlways » Wed Feb 10, 2016 5:36 pm

I need to create a UI that uses color bands to select a series of bars in a chart using a TBarSeries.

The attached demo gets close--when the mouse goes down, it finds the closest center of a bar bar then selects from the middle of the bar to the middle of the bar when the mouse goes up.

But I need it to find the closest point between two bars and start there. (After getting that right, I need to add multiple color bands, but I believe after getting this first step right everything else should be easy).

How can I achieve this?

Thank you,

Ed Dressel
Attachments
Selection Point 3b.zip
(6.02 KiB) Downloaded 735 times

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

Re: Selecting bars in a series with a TColorBand

Post by Yeray » Thu Feb 11, 2016 9:57 am

Hello,

I've played a bit with your application and I think I improved it a bit.
First note CalcXPos returns x pixel position of the left side of a bar, not the middle.
I basically used XValue[lIdx] as the ColorBand values instead of using lIdx as value.
Then I implemented a CalcOffset function to calculate the offset to add to a given bar index and mouse X position. When the given X pixel position is on the left side of the bar, the offset is negative.
Selection Point 3b.zip
(3.74 KiB) Downloaded 732 times
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

TestAlways
Newbie
Newbie
Posts: 12
Joined: Mon Mar 09, 2015 12:00 am

Re: Selecting bars in a series with a TColorBand

Post by TestAlways » Thu Feb 11, 2016 9:54 pm

Nice work--this looks good. Thank you for the quick turn around.

Ed Dressel

Post Reply