Selecting an area of a TPolarSeries?
-
- Newbie
- Posts: 60
- Joined: Fri Nov 22, 2013 12:00 am
Selecting an area of a TPolarSeries?
Imagine a user wants to select a certain range on a TLineSeries. With a TColorBandTool, it's easy to implement and easy to make look good (like this).
Now what if we also have a polar series? The axis tools (like TColorLineTool or TColorBandTool) don't seem to work here. I fully understand that a polar chart is an entirely different kind. But I have no idea how one would best implement a "selection" of a portion (like "From 10° to 35°).
I tried adding a pie chart and moving the bits around but it didn't turn out well. I'm looking for ideas.
Anyone?
Now what if we also have a polar series? The axis tools (like TColorLineTool or TColorBandTool) don't seem to work here. I fully understand that a polar chart is an entirely different kind. But I have no idea how one would best implement a "selection" of a portion (like "From 10° to 35°).
I tried adding a pie chart and moving the bits around but it didn't turn out well. I'm looking for ideas.
Anyone?
Re: Selecting an area of a TPolarSeries?
Hi Jens,
I tried your idea of using a TPieSeries and it seems to work wonderfully for me here:
Maybe you are doing something else that makes the TPieSeries not to fit correctly.
If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the situation here.
An alternative would be using custom drawing techniques.
I tried your idea of using a TPieSeries and it seems to work wonderfully for me here:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
with Chart1.AddSeries(TPolarSeries) as TPolarSeries do
begin
FillSampleValues;
end;
with Chart1.AddSeries(TPieSeries) as TPieSeries do
begin
ShowInLegend:=false;
Marks.Visible:=false;
Transparency:=50;
AddPie(10, '', clRed);
RotationAngle:=45;
AngleSize:=90;
end;
end;
If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the situation here.
An alternative would be using custom drawing techniques.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 60
- Joined: Fri Nov 22, 2013 12:00 am
Re: Selecting an area of a TPolarSeries?
It does indeed look flawless. I should have put more emphasis on the "and moving the bits around": I'm a but clueless how to implement rotating the red selection pie around. Or even make it grow or shrink (greater/smaller angle selection).
It could easily be done by using additional components like trackbars and stuff. But it would be even prettier (and more intuitive) if the user could just grab the red pie, move it around and maybe grow/shrink the selection range. For that, I'm looking for something already built into TeeChart.
It could easily be done by using additional components like trackbars and stuff. But it would be even prettier (and more intuitive) if the user could just grab the red pie, move it around and maybe grow/shrink the selection range. For that, I'm looking for something already built into TeeChart.
Re: Selecting an area of a TPolarSeries?
Hi Jens,
I've improved the example above a little bit:
But as you say it could still be interesting if TColorBandTool would support TPolarSeries so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1014
I've improved the example above a little bit:
But as you say it could still be interesting if TColorBandTool would support TPolarSeries so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1014
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 31
- Joined: Fri Nov 21, 2014 12:00 am
Re: Selecting an area of a TPolarSeries?
I still haven't entirely given up on this idea. Is there any way to determine where the user clicks/taps? I know about GetCursorValues(..) and GetCursorValueIndex() method of TChartSeries but they seem to fail on a TPolarSeries and descendants. GetCursorValues outputs weird stuff whereas GetCursorValueIndex always returns -1 ("no point close to the mouse cursor position").
Any idea?
Any idea?
Re: Selecting an area of a TPolarSeries?
Hi Jens,
The series OnClick event already gives you the index of the point the user has clicked. Ie:
The series OnClick event already gives you the index of the point the user has clicked. Ie:
Code: Select all
var polarSeries: TPolarSeries;
pieSeries: TPieSeries;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
polarSeries:=Chart1.AddSeries(TPolarSeries) as TPolarSeries;
with polarSeries do
begin
FillSampleValues;
Brush.Style:=bsClear;
Pen.Visible:=false;
end;
//...
polarSeries.OnClick:=PolarSeriesOnClick;
end;
procedure TForm1.PolarSeriesOnClick(Sender: TChartSeries; ValueIndex: Integer;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Caption:=IntToStr(ValueIndex);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 31
- Joined: Fri Nov 21, 2014 12:00 am
Re: Selecting an area of a TPolarSeries?
Thank you for the suggestion. However, that only works when clicking some point exactly. Which almost impossible when used on a touch screen and/or there are many values (360 or 720).
So far, the closest match I was able to get was by using a TNearestTool which operates on points, not on the axis. This is still pretty inaccurate but probably better than nothing at all
So far, the closest match I was able to get was by using a TNearestTool which operates on points, not on the axis. This is still pretty inaccurate but probably better than nothing at all
Re: Selecting an area of a TPolarSeries?
Hi Jens,
I'm not sure if this is what you are trying to do, but you can use OnMouseMove event to convert the XY coordinates into Angle&Radius as follows:
I'm not sure if this is what you are trying to do, but you can use OnMouseMove event to convert the XY coordinates into Angle&Radius as follows:
Code: Select all
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var Angle, Radius: Double;
begin
Angle:=polarSeries.PointToAngle(X, Y)*HalfDivPi;
Radius:=polarSeries.PointToRadius(X, Y);
Caption:='Angle: ' + FormatFloat('#0.00', Angle) + ', Radius: ' + FormatFloat('#0.00', Radius);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 31
- Joined: Fri Nov 21, 2014 12:00 am
Re: Selecting an area of a TPolarSeries?
Another prime example of how I should read the documentation more carefully: I didn't know about PointToAngle and PointToRadius.
This is, once again, exactly what I was looking for. Awesome!
Now I will be able to move a transparent donut or pie around in order to "fake" a TColorBandTool for polar series. Thank you!
This is, once again, exactly what I was looking for. Awesome!
Now I will be able to move a transparent donut or pie around in order to "fake" a TColorBandTool for polar series. Thank you!
Re: Selecting an area of a TPolarSeries?
Hi Jens,
And don't hesitate to let us know if you find any other problem with it, or if you just want to share such an implementation.
You are welcome!jens.mertelmeyer wrote:Now I will be able to move a transparent donut or pie around in order to "fake" a TColorBandTool for polar series. Thank you!
And don't hesitate to let us know if you find any other problem with it, or if you just want to share such an implementation.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |