How to give points different style

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
emwamin
Newbie
Newbie
Posts: 10
Joined: Tue Sep 22, 2015 12:00 am

How to give points different style

Post by emwamin » Tue May 17, 2016 8:03 am

Hi
I am adding data to a TPoint3DSeries using the following code

Code: Select all

Chart1.FreeAllSeries(nil);
mySerie:=TPoint3DSeries.Create(self);
mySerie.Clear;
Chart1.AddSeries(mySerie);
mySerie.ColorEachPoint := true;

for i:=1 to Data.NrOfColumns do
        begin
                mySerie.AddXY(xval,Yval,labelname,Colors[i]);
        end;
After this we can change some attributes of the point object individually. But not the point style.
I wish to give each point its own style (circle, Triangle, Star, etc.). Can you provide sample code for how to do that?

Thanks.

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

Re: How to give points different style

Post by Yeray » Tue May 17, 2016 11:00 am

Hello,

The easiest way would be using the OnGetPointerStyle event.
You could have an array of TSeriesPointerStyle with the same size of your series values arrays. Ie:

Code: Select all

var mySeriePStyles: Array of TSeriesPointerStyle;
//...
procedure TForm1.FormCreate(Sender: TObject);
begin
  //... somewhere after populating the series
  setLength(mySeriePStyles, mySerie.Count);
  for i:=0 to mySerie.Count-1 do
    mySeriePStyles[i]:=TSeriesPointerStyle(Round(random*16));
  //...
end;
Then, you could OnGetPointerStyle event to use that array:

Code: Select all

function TForm1.mySerieGetPointerStyle(Sender:TChartSeries;
                               ValueIndex:Integer): TSeriesPointerStyle;
begin
  result:=mySeriePStyles[ValueIndex];
end;
Don't forget to declare the signature of the event and assign it to the series:

Code: Select all

  private
    { Private declarations }
    function mySerieGetPointerStyle(Sender:TChartSeries;
                               ValueIndex:Integer): TSeriesPointerStyle;
//...
procedure TForm1.FormCreate(Sender: TObject);
begin
  //...
  mySerie.OnGetPointerStyle:=mySerieGetPointerStyle;
  //...
end;
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

emwamin
Newbie
Newbie
Posts: 10
Joined: Tue Sep 22, 2015 12:00 am

Re: How to give points different style

Post by emwamin » Wed May 18, 2016 8:00 am

Hi

Thanks. It worked. But I get an extra point at (0,0). Do you know why I get that and how to avoid it?
I believe that I saw a similar report in another post, but cannot find it now.

BR
Amin

emwamin
Newbie
Newbie
Posts: 10
Joined: Tue Sep 22, 2015 12:00 am

Re: How to give points different style

Post by emwamin » Wed May 18, 2016 4:06 pm

Hi

Please ignore my last post. I found the problem which was that I have indexed the color vector from 1 to N instead of 0 to (N-1).

BR
Amin

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

Re: How to give points different style

Post by Yeray » Thu May 19, 2016 7:11 am

Hello,

Good! Don't hesitate to let us know if you find any problem with the library.
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

Post Reply