Page 1 of 1

Draw icons insted of points in a Series

Posted: Tue Oct 30, 2007 7:11 pm
by 10546756
I need a TSeries where I can define a bitmap or icon for each point, custom drawing would be acceptable. Wich series would be the best to use and how do I insert my bitmaps?

Posted: Tue Oct 30, 2007 10:26 pm
by 9047589
E.g. TImagePointSeries

Posted: Wed Oct 31, 2007 10:25 am
by 10546756
Thanks, was it that easy... Just two small issues left. I have my pictures in a TImageList and in the GetImage event I want to pick a picture from it.

Procedure TMainForm.SeriesGetImage(Sender: TCustomImagePointSeries; ValueIndex: Integer; Picture: TPicture);
Begin
Picture := ImageList.GetPicture(0) ???
End;

The other question is how I controll the with and height of the picture in the different points?

Please help.

Regards, Mikael

Posted: Wed Oct 31, 2007 12:31 pm
by narcis
Hi Mikael,
Thanks, was it that easy... Just two small issues left. I have my pictures in a TImageList and in the GetImage event I want to pick a picture from it.
You can do something like this:

Code: Select all

procedure TForm1.Series1GetImage(Sender: TCustomImagePointSeries;
  ValueIndex: Integer; Picture: TPicture);
var tmpBmp : TBitmap;
begin
  tmpBmp:=TBitmap.Create;
  ImageList1.GetBitmap(ValueIndex, tmpBmp);
  Picture.Bitmap:=tmpBmp;

  Series1.Pointer.VertSize:=(ValueIndex+1)*10;
  Series1.Pointer.HorizSize:=(ValueIndex+1)*10;
end;
The other question is how I controll the with and height of the picture in the different points?
You can use Pointer's VertSize and HorizSize as shown in the code above.

Posted: Wed Oct 31, 2007 2:54 pm
by 10546756
Perfect! Works like a dream.

But I just got another issue. I use both the TDragMarksTool and the TDragPointTool. It seems like I can never reach the mark, it always finds the point to be dragged, even as the pojnt and the mark are located at some distance.
I tried the SeriesMouseEnter event to se when the "point" was hit and it seems like it "hits" when the mouse is "far" away from the bitmap image! More than 50 pixels away!
How can I limit this "active" area to just the bitmap?

regards, Mikael

Posted: Wed Oct 31, 2007 2:58 pm
by narcis
Hi Mikael,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here? You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance!

Posted: Wed Oct 31, 2007 5:37 pm
by 10546756
Hello! Uploaded via the uploade page under name Mikael Lenfors.

Posted: Wed Oct 31, 2007 6:22 pm
by 10546756
Hello, I sent an updated version where you can se the problem better. After program start there is no way to drag the marks away from the point. If you click the button the marks are moved a bit away. After this the marks can be dragged. If you than drag the mark and position it over the point it will be unaccessable again. You can also enable the popup in MapSeriesMouseEnter and the you can se that the event is triggered without the mouse beeing on the image area.

Posted: Wed Nov 07, 2007 12:33 pm
by Pep
Hi Mikael,

I think that the best way to accomplish it would be by adding the following code to your app (checking when the marks are clicked) :

Code: Select all

procedure TForm1.MapChartMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    MapChartDragPointTool.Active := not (MapSeries.Marks.Clicked(x,y)<>-1);
end;

procedure TForm1.MapChartDragPointToolDragPoint(Sender: TDragPointTool;
  Index: Integer);
begin
  MapSeries.Marks.ResetPositions;
end;

Posted: Fri Dec 28, 2007 8:03 pm
by 10546756
Ok, this was a while ago but now I'm back!
The solution you suggested will work for drag but I also have events for MouseEnter and MouseLeave! I show values in a status window when I move the mouse above the icons! Currently these events trigger already when the mouse is located some distance from the icon (like 50 pixels away)!

Posted: Wed Jan 02, 2008 9:15 am
by narcis
Hi Lenfors,

I'm not able to reproduce the problem here. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.