How can i achieve this? Any help will be greatly appreciated.

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 |
Can you please give an example code? I know how to add one selector and set it to active mode when desired component (such as fastline series) is clicked. I do not know how to set multiple selector tools.If you want do multiple selections I recommend you that add a selector for each series ..
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 |
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.FastLine series1, series2,series3;
int HandleSize = 5;
Color oldBrushColor;
Color oldPenColor;
bool oldGradient;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
series1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
series2 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
series3 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
series1.FillSampleValues();
series2.FillSampleValues();
series3.FillSampleValues();
series1.Color= Color.Blue;
series2.Color = Color.Orange;
series3.Color = Color.Red;
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
}
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
Steema.TeeChart.ChartClickedPart p;
Point pp = new Point();
if (tChart1.Series.Count != 0)
{
foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
{
if (s.Clicked(e.X, e.Y) != -1 && ModifierKeys == Keys.Control)
{
tChart1.AutoRepaint = false;
pp.X = e.X;
pp.Y = e.Y;
tChart1.Chart.CalcClickedPart(pp, out p);
if (p.Part == Steema.TeeChart.ChartClickedPartStyle.Series)
{
DrawSelection(p);
}
}
else
{
tChart1.AutoRepaint = true;
}
}
}
}
private void DrawSelection(Steema.TeeChart.ChartClickedPart Part)
{
int t, X, Y;
int tmpStep, tmpLast, tmpCount;
Steema.TeeChart.Styles.Series tmpSeries = Part.ASeries;
Steema.TeeChart.Drawing.Graphics3D g = tChart1.Chart.Graphics3D;
if (Part.ASeries != null)
{
tmpCount = tmpSeries.LastVisibleIndex - tmpSeries.FirstVisibleIndex;
if (tmpCount == 0) tmpCount = Part.ASeries.Count;
if (tmpCount > 20)
{
tmpStep = tmpCount/ 20;
}
else
{
tmpStep = 1;
}
t = tmpSeries.FirstVisibleIndex;
if (t == -1)t = 0;
tmpLast = tmpSeries.LastVisibleIndex;
if (tmpLast == -1) tmpLast = Part.ASeries.Count - 1;
oldBrushColor = g.Brush.Color;
oldPenColor = g.Pen.Color;
oldGradient = g.Gradient.Visible;
g.Gradient.Visible = false;
g.Brush.Color = Color.Black;
g.Pen.Color = Color.Black;
while (t < tmpLast)
{
X = tmpSeries.CalcXPos(t);
Y = tmpSeries.CalcYPos(t);
g.Rectangle(RectFormPoint1(X, Y), tmpSeries.MiddleZ);
t += tmpStep;
}
g.Brush.Color = oldBrushColor;
oldPenColor = g.Pen.Color = oldBrushColor;
g.Gradient.Visible = oldGradient;
series1.Color = Color.Blue;
series2.Color = Color.Orange;
series3.Color = Color.Red;
}
}
private Rectangle RectFormPoint1(int X, int Y)
{
//return a rectangle few pixels around XY point }
return Steema.TeeChart.Utils.FromLTRB(X - HandleSize, Y - HandleSize, X + HandleSize, Y + HandleSize);
}
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 |
Code: Select all
private class MyFastLine : Steema.TeeChart.Styles.FastLine
{
public bool Selected = false;
public int[] SelectedPoints;
public MyFastLine(Steema.TeeChart.Chart c): base(c){}
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
for (int i = 0; i < 3; i++)
{
MyFastLine myline = new MyFastLine(tChart1.Chart);
myline.FillSampleValues();
if (i == 0)
myline.SelectedPoints = new int[10];
else
myline.SelectedPoints = new int[3];
}
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
if (tChart1.Series.Count > 0)
{
foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
{
if (s.Clicked(e.X, e.Y) != -1 && ModifierKeys == Keys.Control)
{
if (s is MyFastLine)
{
MyFastLine myline = s as MyFastLine;
myline.Selected = !myline.Selected;
if (myline.Selected)
{
if (myline.SelectedPoints.Length < 2)
{
myline.SelectedPoints = new int[1];
myline.SelectedPoints[0] = myline.Count / 2;
}
else
{
myline.SelectedPoints[0] = 0;
for (int i = 1; i < myline.SelectedPoints.Length-1; i++)
{
myline.SelectedPoints[i] = i * myline.Count / (myline.SelectedPoints.Length-1);
}
myline.SelectedPoints[myline.SelectedPoints.Length - 1] = myline.Count - 1;
}
}
tChart1.Invalidate();
}
}
}
}
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
int width = 6;
Steema.TeeChart.Drawing.Graphics3D gd = tChart1.Graphics3D;
if (tChart1.Series.Count > 0)
{
foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
{
if (s is MyFastLine)
{
MyFastLine myline = s as MyFastLine;
if (myline.Selected)
{
gd.Brush.Color = myline.Color;
gd.Brush.Transparency = 50;
for (int i = 0; i < myline.SelectedPoints.Length; i++)
{
Point p = new Point(myline.CalcXPos(myline.SelectedPoints[i]), myline.CalcYPos(myline.SelectedPoints[i]));
Rectangle rect = tChart1.Chart.ChartRect;
if ((p.X >= rect.Left) && (p.X <= rect.Right) && (p.Y >= rect.Top) && (p.Y <= rect.Bottom))
gd.Rectangle(p.X - width, p.Y - width, p.X + width, p.Y + width);
}
}
}
}
}
}
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |