I am work in Rad Studio 10.1 Berlin with c++. Teechart version 2017.21
If i use DragMark tool and trying to move chart with right click, marks moves with their points. It's normal behavior for me.
But after i dragged any mark and trying to move chart with right click, dragged mark moving wich chart, ignoring it's point.
How can i avoid this movement? I just need the same behavior as before dragging mark.
You can see described behavior in your Teechart Pro Examples(Tee9new.exe) in DragMark tool section
TeeChart DragMark Tool
Re: TeeChart DragMark Tool
Hi Stainslaw,
Here you can find a workaround suggested for this.
http://www.teechart.net/support/viewtop ... ll*#p34033
Don't hesitate to let us know if you still have problems with it.
Here you can find a workaround suggested for this.
http://www.teechart.net/support/viewtop ... ll*#p34033
Don't hesitate to let us know if you still have problems with it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: TeeChart DragMark Tool
Thanks for your code.
But that event i can use for changing marks position then i dragging chart with right mouse?
But that event i can use for changing marks position then i dragging chart with right mouse?
Re: TeeChart DragMark Tool
Hi,
Yes, the idea is to store the marks positions manually when you modify them with the DragMark tool, and apply these positions when you scroll the chart.
Yes, the idea is to store the marks positions manually when you modify them with the DragMark tool, and apply these positions when you scroll the chart.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: TeeChart DragMark Tool
I just tried to store coordinates of marks relatively to the axis.
I did it in OnChartAfterDrawEvent:
Then in OnChartZoomIn and OnChartUndoZoom i tried to repaint marks on them positions, and it works fine BEFORE you drag any point. But after dragging it's works only for UndoZoomEvent. In ZoomIn marks coordinates different everytime i zoom it.
UndoZoom event:
And ZoomIn event:
I did it in OnChartAfterDrawEvent:
Code: Select all
void __fastcall OnChartAfterDraw(TObject *Sender)
{
MarksCoordinates.clear();
if(Chart && __PointTextSeries)
{
for(int i = 0; i < __PointTextSeries->XValues->Count; i++)
{
pair<double, double> tmp;
tmp.first = Chart->BottomAxis->CalcPosPoint(__PointTextSeries->Marks->Positions->Position[i]->LeftTop.X);
tmp.second = Chart->LeftAxis->CalcPosPoint(__PointTextSeries->Marks->Positions->Position[i]->LeftTop.Y);
MarksCoordinates.push_back(tmp);
}
}
}
UndoZoom event:
Code: Select all
void __fastcall OnChartUndoZoom(TObject *Sender)
{
if(__PointTextSeries)
{
for(int i = 0; i < __PointTextSeries->XValues->Count; i++)
{
__PointTextSeries->Marks->Positions->Position[i]->LeftTop.X = Chart->BottomAxis->CalcPosValue(MarksCoordinates.at(i).first);
__PointTextSeries->Marks->Positions->Position[i]->LeftTop.Y = Chart->LeftAxis->CalcPosValue(MarksCoordinates.at(i).second);
}
}
}
Code: Select all
void __fastcall OnChartZoomIn(TObject *Sender)
{
if(__PointTextSeries)
{
for(int i = 0; i < __PointTextSeries->XValues->Count; i++)
{
__PointTextSeries->Marks->Positions->Position[i]->LeftTop.X = __PointTextSeries->CalcPosValue(MarksCoordinates.at(i).first);
__PointTextSeries->Marks->Positions->Position[i]->LeftTop.Y = __PointTextSeries->CalcPosValue(MarksCoordinates.at(i).second);
}
}
}
Re: TeeChart DragMark Tool
Hello,
Here it is an example in Delphi supporting marks drag, zoom and scroll:
Here it is an example in Delphi supporting marks drag, zoom and scroll:
Code: Select all
uses Series;
var Series1: TPointSeries;
var MarksCoordinates: array of TPointFloat;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=False;
Chart1.Legend.Hide;
Series1:=Chart1.AddSeries(TPointSeries) as TPointSeries;
with Series1 do
begin
Marks.Show;
Marks.Arrow.Color:=clRed;
Marks.ArrowLength:=10;
FillSampleValues(10);
end;
with Chart1.Tools.Add(TDragMarksTool) as TDragMarksTool do
begin
OnDraggedMark:=DragMarksDragged;
end;
end;
procedure TForm1.Chart1Scroll(Sender: TObject);
begin
ApplyMarks;
end;
procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
Chart1.Draw;
ApplyMarks;
end;
procedure TForm1.Chart1Zoom(Sender: TObject);
begin
Chart1.Draw;
ApplyMarks;
end;
procedure TForm1.DragMarksDragged(Sender:TDragMarksTool; Index:Integer;
Button:TMouseButton; Shift: TShiftState;
X,Y: Integer);
var i: Integer;
begin
SetLength(MarksCoordinates, Series1.Count);
for i:=0 to Series1.Count-1 do
begin
with Series1.Marks.Positions[i] do
begin
if not Custom then
begin
Custom:=True;
if Index<>i then
begin
LeftTop.X:=Series1.CalcXPos(i) - (Width div 2);
LeftTop.Y:=Series1.CalcYPos(i) - Height - Series1.Marks.ArrowLength;
end;
end;
MarksCoordinates[i].x:=Series1.GetHorizAxis.CalcPosPoint(LeftTop.X + (Width div 2));
MarksCoordinates[i].y:=Series1.GetVertAxis.CalcPosPoint(LeftTop.Y);
end;
end;
end;
procedure TForm1.ApplyMarks;
var i: Integer;
begin
if Length(MarksCoordinates) = Series1.Count then
for i:=0 to Series1.Count-1 do
begin
with Series1.Marks.Positions[i] do
begin
LeftTop.X:=Series1.GetHorizAxis.CalcPosValue(MarksCoordinates[i].x) - (Series1.Marks[i].Width div 2);
LeftTop.Y:=Series1.GetVertAxis.CalcPosValue(MarksCoordinates[i].y);
ArrowTo.X:=LeftTop.X + (Series1.Marks[i].Width div 2);
ArrowTo.Y:=LeftTop.Y + Series1.Marks[i].Height;
ArrowFrom.X:=Series1.CalcXPos(i);
ArrowFrom.Y:=Series1.CalcYPos(i);
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: TeeChart DragMark Tool
Thanks, it works for zoom in and out. But if i add one mark and move it, and after that add another mark, marks moves then i scroll chart with right mouse button.
Re: TeeChart DragMark Tool
Hello,
I don't understand what should I exactly do to reproduce it. Could you please add a simple example?restech wrote:But if i add one mark and move it, and after that add another mark, marks moves then i scroll chart with right mouse button.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |