Page 1 of 1
Show Selected using 2 charts
Posted: Mon Aug 14, 2017 5:42 am
by 16880166
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.
Re: Show Selected using 2 charts
Posted: Thu Aug 17, 2017 12:12 pm
by 10050769
Hello realsol,
I think you can active the Hover propierty. The code below shows you how?
Hoping this helps you.
Thanks in advance
Re: Show Selected using 2 charts
Posted: Thu Aug 17, 2017 7:20 pm
by 16880166
Sandra wrote:Hello realsol,
I think you can active the Hover propierty. The code below shows you how?
Hoping this helps you.
Thanks in advance
This gave me an error on 'Hover', so I tried this in the OnSeriesClick Event:
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.
Re: Show Selected using 2 charts
Posted: Fri Aug 18, 2017 11:20 am
by 10050769
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