Selection of series' points
-
- Newbie
- Posts: 57
- Joined: Wed Jan 30, 2008 12:00 am
Selection of series' points
Greetings,
I want to select certain points of a sereis by draging a rectangle region.
I tried MouseDown and MouseUp events but just got the x-coordinates and y-coordinates in pixels (not relative to the values of x-axis and y-axis).
Do you have any suggestion about my requirement?
Thanks in advance.
I want to select certain points of a sereis by draging a rectangle region.
I tried MouseDown and MouseUp events but just got the x-coordinates and y-coordinates in pixels (not relative to the values of x-axis and y-axis).
Do you have any suggestion about my requirement?
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 57
- Joined: Wed Jan 30, 2008 12:00 am
Re: Selection of series' points
Greetings,
I want to highlight selected points after selection.
The way coming to my mind is to new a series of the selected points.
Then I could set the pointer style, color... any way I want to present the highlight.
But it seems not a good solution. Do you have any suggestion?
I want to highlight selected points after selection.
The way coming to my mind is to new a series of the selected points.
Then I could set the pointer style, color... any way I want to present the highlight.
But it seems not a good solution. Do you have any suggestion?
Re: Selection of series' points
Hi Chris,
Here you have an example using the same series, simply changing the color of the selected points:
Here you have an example using the same series, simply changing the color of the selected points:
Code: Select all
uses TeCanvas;
var Selected: array of bool;
DrawRectangle: bool;
StartX, StartY: Integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D := false;
Chart1.AllowZoom := false;
DrawRectangle := false;
Chart1[0].FillSampleValues(25);
SetLength(Selected, Chart1[0].Count);
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DrawRectangle := true;
StartX := X;
StartY := Y;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if DrawRectangle then
begin
Chart1.Repaint;
Chart1.Canvas.Brush.Style := bsClear;
Chart1.Canvas.Rectangle(StartX, StartY, X, Y);
end;
end;
procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i: Integer;
begin
for i:=0 to length(Selected)-1 do
begin
if PointInRect(Rect(StartX, StartY, X, Y), Chart1[0].CalcXPos(i), Chart1[0].CalcYPos(i)) then
Selected[i] := true
else
Selected[i] := false;
end;
DrawRectangle := false;
Chart1.Repaint;
end;
function TForm1.Series1GetPointerStyle(Sender: TChartSeries;
ValueIndex: Integer): TSeriesPointerStyle;
begin
Result := psRectangle;
if Selected[ValueIndex] then
Sender.ValueColor[ValueIndex] := clRed
else
Sender.ValueColor[ValueIndex] := Sender.Color;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 57
- Joined: Wed Jan 30, 2008 12:00 am
Re: Selection of series' points
Execuse me. Does this work in VB .NET version?
I try to implement it but encounter two problems:
1. The series.ValueColor[index] is a Read-Only property.
2. GetPointerStyle event is not found.
I try to implement it but encounter two problems:
1. The series.ValueColor[index] is a Read-Only property.
2. GetPointerStyle event is not found.
Re: Selection of series' points
Hello Cris,
First: if you would to directly in run time(code), you needs to do next:
Second: if you would to design time, you have selected event
I hope will helps you,
Thanks,
You can do a similar code with next example, please check that this code works fine in your application:1. The series.ValueColor[index] is a Read-Only property.
Code: Select all
Private Sub p_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.GetPointerStyleEventArgs)
series(e.ValueIndex).Color = Color.Orange
End Sub
If you want to created even in VB you coud do so two ways:2. GetPointerStyle event is not found.
First: if you would to directly in run time(code), you needs to do next:
Code: Select all
AddHandler p.GetPointerStyle, AddressOf Me.p_GetPointerStyle
I hope will helps you,
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 57
- Joined: Wed Jan 30, 2008 12:00 am
Re: Selection of series' points
[quote="Sandra"]Hello Cris,
You can do a similar code with next example, please check that this code works fine in your application:
Greetings,
Thanks. It worked in my program. But my series is of the type Steema.TeeChart.Styles.Line.
This way would change not only the pointer's color but also the line associated with the pointer.
Is there any way to avoid this? I just want the pointer's style changed.
Thanks for you help.
You can do a similar code with next example, please check that this code works fine in your application:
Code: Select all
Private Sub p_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.GetPointerStyleEventArgs)
series(e.ValueIndex).Color = Color.Orange
End Sub
Greetings,
Thanks. It worked in my program. But my series is of the type Steema.TeeChart.Styles.Line.
This way would change not only the pointer's color but also the line associated with the pointer.
Is there any way to avoid this? I just want the pointer's style changed.
Thanks for you help.
Re: Selection of series' points
Hello Cris,
Initialize: Add this two lines
Line_GetPointerStyle Event:
I hope that will helps
Thanks,
Please check next code, that change only pointer's style, for example orange color.Is there any way to avoid this? I just want the pointer's style changed.
Initialize: Add this two lines
Code: Select all
line.Pointer.Visible = true
AddHandler line.GetPointerStyle, AddressOf Me.line_GetPointerStyle
Code: Select all
Private Sub line_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.GetPointerStyleEventArgs)
e.Color = Color.Orange
End Sub
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 57
- Joined: Wed Jan 30, 2008 12:00 am
Re: Selection of series' points
Greetings,
I enabled the zooming tool after highlighting but met some problems.
The line associated with the highlighted points would be drawed outside the chart region.
Before zooming: After zooming: Do you have any iedas about this?
I enabled the zooming tool after highlighting but met some problems.
The line associated with the highlighted points would be drawed outside the chart region.
Before zooming: After zooming: Do you have any iedas about this?
Re: Selection of series' points
Hello Cris,
First: Is possible that you have property tChart1.Aspect.ClipPoint= false, change this for true. I check with last version and works fine.
Second: If previous not works, please you could say what is your actualy version of TeeChartFor .Net?
If your version isn't laster, please update the version and tester code.If the problem still appears you can send a simple example because we can reproduce here. Now,you can attach your projecte direcly in the forums post.
Thanks.
I have commented two things:Do you have any iedas about this?
First: Is possible that you have property tChart1.Aspect.ClipPoint= false, change this for true. I check with last version and works fine.
Second: If previous not works, please you could say what is your actualy version of TeeChartFor .Net?
If your version isn't laster, please update the version and tester code.If the problem still appears you can send a simple example because we can reproduce here. Now,you can attach your projecte direcly in the forums post.
Thanks.
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 57
- Joined: Wed Jan 30, 2008 12:00 am
Re: Selection of series' points
Hi,Sandra wrote:Hello Cris,
Please check next code, that change only pointer's style, for example orange color.Is there any way to avoid this? I just want the pointer's style changed.
Initialize: Add this two linesLine_GetPointerStyle Event:Code: Select all
line.Pointer.Visible = true AddHandler line.GetPointerStyle, AddressOf Me.line_GetPointerStyle
I hope that will helpsCode: Select all
Private Sub line_GetPointerStyle(ByVal series As Steema.TeeChart.Styles.CustomPoint, ByVal e As Steema.TeeChart.Styles.GetPointerStyleEventArgs) e.Color = Color.Orange End Sub
Thanks,
Coule I draw a circle on the outside of the pointer?
Please see the below image.
Re: Selection of series' points
Hello Chris,
I find two solutions for draw a circle, in your selection. The first solution is more simple than the second, but both make a circle around the pointer.
Firts solution: Using GetPointStyles
Second solution: Using AfterDraw and drawing directly in canvas.
Please, check that previous codes works correctly in your application.
I hope will helps.
Thanks,
I find two solutions for draw a circle, in your selection. The first solution is more simple than the second, but both make a circle around the pointer.
Firts solution: Using GetPointStyles
Code: Select all
bool[] Selected;
Steema.TeeChart.Styles.Line line;
bool drawrectangle;
Rectangle rect;
private void InitializeChart()
{
line = new Steema.TeeChart.Styles.Line (tChart1.Chart);
line.FillSampleValues();
line.Pointer.Visible = true;
tChart1.Aspect.View3D = false;
tChart1.Aspect.ClipPoints = true;
drawrectangle = false;
Selected = new bool[line.Count];
tChart1.Panning.MouseButton = MouseButtons.Middle;
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
tChart1.MouseUp += new MouseEventHandler(tChart1_MouseUp);
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
line.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(line_GetPointerStyle);
tChart1.Draw();
ResetCoords();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
if ((X0 != -1) && (Y0 != -1))
{
if (drawrectangle)
{
g.Brush.Visible = false;
g.Pen.Color = Color.Black;
g.Rectangle(X0, Y0, X1, Y1);
}
}
}
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
drawrectangle = true;
X0 = e.X;
Y0 = e.Y;
}
}
void tChart1_MouseUp(object sender, MouseEventArgs e)
{
if ((X0 != -1) && (Y0 != -1))
{
rect = new Rectangle(X0, Y0, e.X -X0, e.Y-Y0);
for (int i = 0; i < Selected.Length; i++)
{
Point p = new Point(tChart1[0].CalcXPos(i), tChart1[0].CalcYPos(i));
if (rect.Contains(p))
{
Selected[i] = true;
}
else
{
Selected[i] = false;
}
}
ResetCoords();
}
drawrectangle = false;
tChart1.Draw();
}
private int X0, Y0, X1, Y1;
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
X1 = e.X;
Y1 = e.Y;
}
tChart1.Invalidate();
}
void line_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
e.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
if (Selected[e.ValueIndex])
{
series.Pointer.Pen.Color = Color.Red;
series.Pointer.Pen.Width = 2;
}
else
{
series.Pointer.Pen.Color = series.Color;
series.Pointer.Pen.Width = 1;
}
}
private void ResetCoords()
{
X0= -1;
Y0= -1;
}
Code: Select all
bool[] Selected;
Steema.TeeChart.Styles.Line line;
bool drawrectangle;
Rectangle rect;
private void InitializeChart()
{
line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line.FillSampleValues();
line.Pointer.Visible = true;
tChart1.Aspect.View3D = false;
tChart1.Aspect.ClipPoints = true;
drawrectangle = false;
Selected = new bool[line.Count];
tChart1.Panning.MouseButton = MouseButtons.Middle;
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
tChart1.MouseUp += new MouseEventHandler(tChart1_MouseUp);
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
line.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(line_GetPointerStyle);
tChart1.Draw();
ResetCoords();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
if ((X0 != -1) && (Y0 != -1))
{
if (drawrectangle)
{
g.Brush.Visible = false;
g.Pen.Color = Color.Black;
g.Rectangle(X0, Y0, X1, Y1);
}
}
for (int i = 0; i < Selected.Length; i++)
{
Point p = new Point(tChart1[0].CalcXPos(i), tChart1[0].CalcYPos(i));
Rectangle rect1 = new Rectangle(p.X - line.Pointer.HorizSize - 5, p.Y - line.Pointer.VertSize - 5, (line.Pointer.HorizSize + 5) * 2, (line.Pointer.VertSize + 5) * 2);
if (Selected[i])
{
g.Brush.Visible = false;
g.Pen.Color = Color.Blue;
g.Ellipse(rect1);
}
}
}
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
drawrectangle = true;
X0 = e.X;
Y0 = e.Y;
}
}
void tChart1_MouseUp(object sender, MouseEventArgs e)
{
if ((X0 != -1) && (Y0 != -1))
{
rect = new Rectangle(X0, Y0, e.X -X0, e.Y-Y0);
for (int i = 0; i < Selected.Length; i++)
{
Point p = new Point(tChart1[0].CalcXPos(i), tChart1[0].CalcYPos(i));
if (rect.Contains(p))
{
Selected[i] = true;
}
else
{
Selected[i] = false;
}
}
ResetCoords();
}
drawrectangle = false;
tChart1.Draw();
}
private int X0, Y0, X1, Y1;
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
X1 = e.X;
Y1 = e.Y;
}
tChart1.Invalidate();
}
void line_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
e.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
if (Selected[e.ValueIndex])
{
e.Color = Color.Red;
}
}
private void ResetCoords()
{
X0= -1;
Y0= -1;
}
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Selection of series' points
Thanks!