Page 1 of 1

Selecting bars in a series with a TColorBand

Posted: Wed Feb 10, 2016 5:36 pm
by 16573190
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

Re: Selecting bars in a series with a TColorBand

Posted: Thu Feb 11, 2016 9:57 am
by yeray
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

Re: Selecting bars in a series with a TColorBand

Posted: Thu Feb 11, 2016 9:54 pm
by 16573190
Nice work--this looks good. Thank you for the quick turn around.

Ed Dressel