Show Selected using 2 charts

TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
Post Reply
realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Show Selected using 2 charts

Post by realsol » Mon Aug 14, 2017 5:42 am

Attached are two charts. When the user clicks on a month in the BarChart (January in this case), it displays that months expense categories below in a PieChart. Is there any way to color or keep the clicked bar highlighted (like when hovering over it)? This way the user always see which month is being displayed in the PieChart below.

Thanks.
Attachments
2017-08-13_2233.png
2017-08-13_2233.png (68.7 KiB) Viewed 16890 times

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

Re: Show Selected using 2 charts

Post by Sandra » Thu Aug 17, 2017 12:12 pm

Hello realsol,

I think you can active the Hover propierty. The code below shows you how?

Code: Select all

Chart1.Hover.Visible := Hover;
Hoping this helps you.
Thanks in advance
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

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: Show Selected using 2 charts

Post by realsol » Thu Aug 17, 2017 7:20 pm

Sandra wrote:Hello realsol,

I think you can active the Hover propierty. The code below shows you how?

Code: Select all

Chart1.Hover.Visible := Hover;
Hoping this helps you.
Thanks in advance
This gave me an error on 'Hover', so I tried this in the OnSeriesClick Event:

Code: Select all

Chart1.Hover.Visible := true;
But it still doesn't keep the bar in hover state. I know which bar they click, I just need to somehow highlight it after a user clicks it.

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

Re: Show Selected using 2 charts

Post by Sandra » Fri Aug 18, 2017 11:20 am

Hello realsol,

I have made a simple code with help of MouseDown and MouseUp events, I can select a concrete bar value when I do click in it. The code I have used is below:

Code: Select all

procedure TForm2.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  begin
  if avalueIndex<>-1 then
    Chart1[0].ValueColor[avalueIndex] :=aColor;
end;


procedure TForm2.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var valueIndex:Integer;
begin
valueIndex:=Chart1[0].Clicked(X, Y);
   if valueIndex>-1 then
   begin
      Chart1[0].ValueColor[valueIndex] := clRed;
      avalueIndex :=  valueIndex;
    end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
 Chart1.AddSeries(TBarSeries).FillSampleValues();
 aColor := Chart1[0].Color;
 avalueIndex:=-1;

end;
Could you confirm us if it works in your end?

Thanks in advance
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