Dear all,
I am using TAChart and I would like to see the mark of a point when the point is clicked or the mouse is over it.
Actually I do it using tchart.hint, TChartMouseMove event and GetNearestPoint function. In this way I show an hint any time the mouse pass over a point. Is it possible to do it directly using Marks of TChart? I would like to decide to show the mark of a single point and not for all the points in the serie.
Regards,
Andrea
Mailing lists / lazarus / 2009-09
TAChart marks on mouseoverpoint
11 messages · 2 people · –
- AAndrea Mauri 6
- AAlexander Klenin 5
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Andrea Mauri wrote 8 lines
If you do not mind using trunk version, then it is now possible ;-) See dragdropdemo project.
Note however that this might have performance implications compared to your implementation, because showing/hiding the mark requires full chart redraw.
I use trunk version of lazarus so I will check it. thanks,
andrea
Alexander Klenin ha scritto:
Show quoted text 18 lines
I tested the dragdrop demo. It works well anyway I have some questions/doubts about how marks are showed.
1. If the point is on the border of the chart the mark is not fully visible.
2. I have charts with a lot of points, the marks are shown below the points, so often the marks are not fully visible.
I have also another question. I need to draw a unitary circle on a chart. Here the function I use:
// Draws a unitary circle on the given TAChart with the given color
procedure UnitCircle(ParentChart: TChart; Color: TColor);
var
A, B: TDoublePoint;
AA, BB: TPoint;
begin
A.X:=-1;
A.Y:=-1;
B.X:=1;
B.Y:=1;
AA := ParentChart.GraphToImage (A);
BB := ParentChart.GraphToImage(B);
ParentChart.Canvas.Pen.Mode:= pmCopy;
ParentChart.Canvas.Pen.Color:= Color;
ParentChart.Canvas.Pen.Style:= psDash;
ParentChart.Canvas.Brush.Style:= bsClear;
ParentChart.Canvas.Ellipse(AA.x,AA.y,BB.x,BB.y);
end;Anyway I don't know when/where I have to call this procedure in order to be sure that the unitary circle is drawn upon the chart. If I anchor the chart on the form and I put my procedure on the resizeform event I can see the circle for a while and then it immediately disappears. So how can I draw shapes on a chart? I have to put unitary circle but also other things, such as rays from the origin of the chart (0, 0) to all the points in a serie.
Could you help me?
regards,
andrea
Andrea Mauri ha scritto:
Show quoted text 35 lines
Andrea Mauri wrote1. If the point is on the border of the chart the mark is not fully visible.
You can increase Margins.Left and Margins.Right properties to avoid that.
2. I have charts with a lot of points, the marks are shown below the points, so often the marks are not fully visible.
Well, there is only so much pixels on the chart.
If you put enough marks, they will overlap sooner or later. Do you have some concrete proposal to reduce overlapping?
I have also another question. I need to draw a unitary circle on a chart. Here the function I use:
[skip]
Show quoted text 5 lines
Since r21827 you can use TUserDrawnSeries for that. See demo/func/funcdemo project for an example.
I have to put unitary circle but also other things, such as rays from the origin of the chart (0, 0) to all the points in a serie.
For this you need to create your own series class by inheriting TCustomChartSeries, TChartSeries or TLineSeries and overriding Draw method. Do you mean to create something like
http://www.steema.com/products/teechart/screenshots/infopoint3dpolaradar.htm ? If so, you are very welcome to contribute your code back to the TAChart ;-)
Show quoted text 5 lines
Looking at TeeChart from Steema (an old version, Delphi 6 ;) ) I noticed two things.
1. Marks are drawn over the points (the serie) and not below.
2. There is "Clipped" property for Marks. If Clipped is true the marks behave as Marks on TAChart (they are visible only inside the Chart Axis). Otherwise if Clipped is False the marks are visible also outside the Chart Axis.
See image below.
3. An option could be that the marks can be dragged...
Another option I like in Steema Chart is the possibility to have Panel properties (BevelInner, BevelOuter...) But it is not a so important thing, actually I put the TAChart on a panel to do that.
Since r21827 you can use TUserDrawnSeries for that. See demo/func/funcdemo project for an example.
I will check it.
Show quoted text 7 lines
Actually I just need to draw a Principal Component Analysis Loading Plot. That is not a polar chart, it is a simple scatter plot where as an option a unitary circle can be drawn and the rays from the center to the points can be drawn also.
Anyway I would like to contribute to the development of TAChart. Now I am just using it and trying to understand it looking at the source. I am a final user and I am not sure I have the capabilities to contribute on a development basis.. we'll see. :)
thanks,
andrea
Andrea Mauri wrote 5 lines
Currently, they are drawn below points with negative Y and above others. This is intended to reduce clutter, and is absolutely required for bar series -- but maybe it was not a good idea for line series, I am not sure.
2. There is "Clipped" property for Marks. If Clipped is true the marks behave as Marks on TAChart (they are visible only inside the Chart Axis). Otherwise if Clipped is False the marks are visible also outside the Chart Axis. See image below.
It seems you forgot to attach the image.
Anyway, implemented Marks.Clipped in r21840.
3. An option could be that the marks can be dragged...
This is not easy to do correctly and effectively, so patches are welcome ;-)
Another option I like in Steema Chart is the possibility to have Panel properties (BevelInner, BevelOuter...) But it is not a so important thing, actually I put the TAChart on a panel to do that.
I think it is better this way -- the chart component is already overcrowded with it's own properties, there is no need to add ones from Panel too
Show quoted text 7 lines
I see. This is a borderline case, probably too exotic to be included in the general component.
Still, if you have inclination to work on a patch, I would suggest to change TLineSeries.ShowLines property from boolean to enumeration (slNone, slFromPrevious, slFromOrigin).
Anyway I would like to contribute to the development of TAChart. Now I am just using it and trying to understand it looking at the source. I am a final user and I am not sure I have the capabilities to contribute on a development basis.. we'll see. :)
Meaningful feedback is very useful too, so you have already contributed in a small way.
Show quoted text 5 lines
I was misunderstood. With below I intend that marks are drawn back the points, and points over marks.
I try again to attach two images, one from TAChart and one from Steema TChart. You can see that in TAChart points are visible and marks are drawn back points while in Steema TChart marks are always visible and they are drawn over points.
Maybe could be an option to have marks in front or back points?
It seems you forgot to attach the image. Anyway, implemented Marks.Clipped in r21840.
Prefect!
Show quoted text 8 lines
Maybe it is better to leave TLineSeries.ShowLines as boolean property and add TLineSeries.LineStyle (lsNone, lsFromPrevious, lsFromOrigin)? What is your opinion? Anyway I try to do it...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TAchart.jpg
Type: image/jpeg
Size: 2515 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090924/44abeaa4/attachment.jpg> -------------- next part --------------
A non-text attachment was scrubbed...
Name: SteemaTChart.jpg
Type: image/jpeg
Size: 3201 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090924/44abeaa4/attachment-0001.jpg>
Currently, they are drawn below points with negative Y and above others. This is intended…
Show quoted text 6 lines
I created a patch (attached) introducing the property TLineType TLineType = (ltFromPrevious, ltFromOrigin);
I left unchanged the ShowLines property also for retro compatibility. I think that could be useful set the Origin in some way (a Origin property?), by default Origin should be 0, 0 but could be changed by the user. Do you think it is a good idea?
Anyway actually I don't know how to do it...
Another thing is that if the Chart points have for example XMax= 2 Xmin= 1 YMax =2 and YMin = 1 the Origin is not visible. How can I overcome this problem? Actually I do it using XMax, Xmin etc of the Extent property of the TAChart, do you think that is it the best way? andrea
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed... Name: taseries.patch
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090924/7bd46ac0/attachment.ksh>
2009/9/24 Andrea Mauri :
Show quoted text 5 lines
Yes, your patch is generally a step in the right direction. I committed it as r21852 with a few improvements:
1) Added explicit default value for LineType property -- this is required by current Lazarus policy
2) Removed code duplication in Draw procedure --
duplicated code is always undesirable.
I left unchanged the ShowLines property also for retro compatibility.
Indeed, backward compatibility is important.
But I also feel that it is important to avoid excessive complexity. To this end, I tried the implementation which should hide ShowLines property from object inspector, but still read it from old .lfm files. Please test that loading old form with ShowLines = True and False results in LineType set to ltFromPrevious and ltNone correspondingly.
I think that could be useful set the Origin in some way (a Origin property?), by default Origin should be 0, 0 but could be changed by the user. Do you think it is a good idea?
No, I do think this is too much. If the user arises who really needs such a property,
then it can be considered, but even your use case is IMO very rare.
Another thing is that if the Chart points have for example XMax= 2 Xmin= 1 YMax =2 and YMin = 1 the Origin is not visible. How can I overcome this problem? Actually I do it using XMax, Xmin etc of the Extent property of ?the TAChart, do you think that is it the best way?
Of course, this is exactly what they are designed for.
I was misunderstood. With below I intend that marks are drawn back the points, and points…
2009/9/24 Andrea Mauri :
Show quoted text 6 lines
Ah, I see. I have to say that I deliberately choose to draw points over marks, since I felt that points are more important.
I am not so sure now, but still would like more feedback from other users on this issue before changing it.
Meanwhile, if you want to change it for your private build, it is a simple matter of moving DrawLabels call to the end of TLineSeries.Draw procedure.
Maybe could be an option to have marks in front or back points?
Option is always a possibility, but too much options are bad too.
Generally, I think the solution to reduce labels overlapping is to use better placement algorithms.
There is already a crude attempt at this in TBasicPointSeries.DrawLabel procedure -- it skips drawing label if it overlaps with immediately preceding one. There is much way to go in this direction -- see e.g. http://en.wikipedia.org/wiki/Automatic_label_placement
I have experience with developing label placement algorithms, and perhaps will implement some for TChart,
but have no plans to do so in the immediate future. Patches are, as always, welcome ;-)
