Need help in BoxPlot
Posted: Thu Aug 13, 2009 9:17 am
I want to select multiple box plot points and then exclude and include according to the selection.
How to acheive this.
How to acheive this.
Steema Software - Customer Support Forums
http://216.92.243.79/support/
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
bool[] Selected1;
bool[] Selected2;
bool[] Selected3;
bool drawrectangle;
Steema.TeeChart.Styles.Box box1, box2, box3;
Rectangle rect;
private void InitializeChart()
{
//-----------------INITIALIZE CHART WITH BOXPLOT-----------------------//
box1 = new Steema.TeeChart.Styles.Box(tChart1.Chart);
box2 = new Steema.TeeChart.Styles.Box(tChart1.Chart);
box3 = new Steema.TeeChart.Styles.Box(tChart1.Chart);
tChart1.Aspect.View3D = false;
tChart1.Aspect.ClipPoints = true;
drawrectangle = false;
box1.FillSampleValues();
box2.FillSampleValues();
box3.FillSampleValues();
box1.Position = 1;
box2.Position = 2;
box3.Position = 3;
box1.Color = Color.Red;
box2.Color = Color.Yellow;
box3.Color = Color.Green;
box1.Title = "Box1";
box2.Title = "Box2";
box3.Title = "Box3";
box1.Pointer.Visible = true;
box2.Pointer.Visible = true;
box3.Pointer.Visible = true;
Selected1 = new bool[box1.Count];
Selected2 = new bool[box2.Count];
Selected3 = new bool[box3.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);
box1.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(box1_GetPointerStyle);
box2.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(box1_GetPointerStyle);
box3.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(box1_GetPointerStyle);
tChart1.Draw();
ResetCoords();
}
Code: Select all
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 < Selected1.Length; i++)
{
for (int j = 0; j < tChart1.Series.Count; j++)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
Rectangle rect1 = new Rectangle(p.X - box1.Pointer.HorizSize - 5, p.Y - box1.Pointer.VertSize - 5, (box1.Pointer.HorizSize + 5) * 2, (box1.Pointer.VertSize + 5) * 2);
switch (j)
{
case 0:
if (Selected1[i])
{
g.Brush.Visible = false;
g.Pen.Color = Color.Blue;
g.Ellipse(rect1);
}
break;
case 1:
if (Selected2[i])
{
g.Brush.Visible = false;
g.Pen.Color = Color.Blue;
g.Ellipse(rect1);
}
break;
case 2:
if (Selected3[i])
{
g.Brush.Visible = false;
g.Pen.Color = Color.Blue;
g.Ellipse(rect1);
}
break;
}
if (Selected1[i] && Selected2[i] && Selected3[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 < Selected1.Length; i++)
{
for (int j = 0; j < tChart1.Series.Count; j++)
{
if (j == 0)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
if (rect.Contains(p))
{
Selected1[i] = true;
}
else
{
Selected1[i] = false;
}
}
else if (j == 1)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
if (rect.Contains(p))
{
Selected2[i] = true;
}
else
{
Selected2[i] = false;
}
}
else if (j == 2)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
if (rect.Contains(p))
{
Selected3[i] = true;
}
else
{
Selected3[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 box1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
e.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
if (e.ValueIndex != -1)
{
if (Selected1[e.ValueIndex])
{
e.Color = Color.Red;
}
else if (Selected2[e.ValueIndex])
{
e.Color = Color.Red;
}
else if (Selected2[e.ValueIndex])
{
e.Color = Color.Red;
}
}
}
private void ResetCoords()
{
X0 = -1;
Y0 = -1;
}
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
bool[] Selected1;
bool[] Selected2;
bool[] Selected3;
// Steema.TeeChart.Styles.Line line;
bool drawrectangle;
Steema.TeeChart.Styles.Box box1,box2,box3;
Rectangle rect;
private void InitializeChart()
{
//------------------INITIALIZE CHART WITH LINE--------------------------//
//line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
//line.FillSampleValues();
//line.Pointer.Visible = true;
//-----------------INITIALIZE CHART WITH BOXPLOT-----------------------//
box1 = new Steema.TeeChart.Styles.Box(tChart1.Chart);
box2 = new Steema.TeeChart.Styles.Box(tChart1.Chart);
box3 = new Steema.TeeChart.Styles.Box(tChart1.Chart);
tChart1.Aspect.View3D = false;
tChart1.Aspect.ClipPoints = true;
drawrectangle = false;
box1.FillSampleValues();
box2.FillSampleValues();
box3.FillSampleValues();
box1.Position = 1;
box2.Position = 2;
box3.Position = 3;
box1.Color = Color.Red;
box2.Color = Color.Yellow;
box3.Color = Color.Green;
box1.Title = "Box1";
box2.Title = "Box2";
box3.Title = "Box3";
box1.Pointer.Visible = true;
box2.Pointer.Visible = true;
box3.Pointer.Visible = true;
Selected1 = new bool[box1.Count];
Selected2 = new bool[box2.Count];
Selected3 = new bool[box3.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);
box1.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(box1_GetPointerStyle);
box2.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(box2_GetPointerStyle);
box3.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(box3_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 < Selected1.Length; i++)
{
for (int j = 0; j < tChart1.Series.Count; j++)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
Rectangle rect1 = new Rectangle(p.X - box1.Pointer.HorizSize - 5, p.Y - box1.Pointer.VertSize - 5, (box1.Pointer.HorizSize + 5) * 2, (box1.Pointer.VertSize + 5) * 2);
switch(j)
{
case 0 :
if (Selected1[i])
{
g.Brush.Visible = false;
g.Pen.Color = Color.Blue;
g.Ellipse(rect1);
}
else
{
box1.Pointer.Brush.Color = Color.Red;
}
break;
case 1 :
if (Selected2[i])
{
g.Brush.Visible = false;
g.Pen.Color = Color.Blue;
g.Ellipse(rect1);
}
else
{
box2.Pointer.Brush.Color = Color.Yellow;
}
break;
case 2 :
if (Selected3[i])
{
g.Brush.Visible = false;
g.Pen.Color = Color.Blue;
g.Ellipse(rect1);
}
else
{
box3.Pointer.Brush.Color = Color.Green;
}
break;
}
if (Selected1[i] && Selected2[i] && Selected3[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 < Selected1.Length; i++)
{
for (int j = 0; j < tChart1.Series.Count; j++)
{
if (j == 0)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
// Point p1 = new Point((tChart1[j] as Steema.TeeChart.Styles.Box).CalcXPos((int)(tChart1[j] as Steema.TeeChart.Styles.Box).MildOut.Series[i].X), (tChart1[j] as Steema.TeeChart.Styles.Box).CalcYPos((int)(tChart1[j] as Steema.TeeChart.Styles.Box).MildOut.Series[i].Y));
if (rect.Contains(p))
{
Selected1[i]=true;
}
else
{
Selected1[i]=false;
}
}
else if (j == 1)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
if (rect.Contains(p))
{
Selected2[i] = true;
}
else
{
Selected2[i] =false;
}
}
else if (j == 2)
{
Point p = new Point(tChart1[j].CalcXPos(i), tChart1[j].CalcYPos(i));
if (rect.Contains(p))
{
Selected3[i] = true;
}
else
{
Selected3[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();
}
// Add GetPointerStyle for 3 box plots.
void box1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
e.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
for (int i = 0; i < Selected1.Length; i++)
{
if (Selected1[i])
{
series.Pointer.Brush.Color = Color.GreenYellow;
}
}
}
// Add GetPointerStyle for 3 box plots.
void box3_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
e.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
for (int i = 0; i < Selected3.Length; i++)
{
if (Selected3[i])
{
series.Pointer.Brush.Color = Color.GreenYellow;
}
}
}
// Add Get PointerStyle for 3 box plots.
void box2_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
{
e.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
for (int i = 0; i < Selected2.Length; i++)
{
if (Selected2[i])
{
series.Pointer.Brush.Color = Color.GreenYellow;
}
}
}
private void ResetCoords()
{
X0 = -1;
Y0 = -1;
}
I couldn't reproduce your issue, please see next image:1) Only the points at the Q1 of each box is getting selected and not all the points of the box.
I couldn't reproduce your this problem: If you want reproduce same with image, you could say what is your version of TeeChartFor.Net?Unable to select the circular point of 1st box (which is in the rectangular box ) and change its color .
I could reproduce your problem, and now, isn't possible paint only MidleOut of BoxPlot series, I have added your suggestion in Feauter Request with number[TF02014359] to regards in features versions of TeeChartFor .Net.Here the Color of the box is getting changing when selected instead of changing the color of the point using which box plot is plotted.
You, could change the color of outside points of BoxPlot(MiddleOut or ExtrOut), but as I said in last post, There is a Feauter Request with number[TF02014359] that explain that when selected the point outside plot is not possible change the color only this when is selected. But If you want change the color for Outside boxplot, because there aren't transparents please see next lines of code:Instead of marking with circle, Is it possible to change the color of those points which is represent outside of the boxplot.
Code: Select all
box1.MildOut.Transparency = 0;
box2.MildOut.Transparency = 0;
box3.MildOut.Transparency = 0;
box1.MildOut.Brush.Color = Color.GreenYellow;
box2.MildOut.Brush.Color = Color.GreenYellow;
box3.MildOut.Brush.Color = Color.GreenYellow;