1. How can I highlight the chart area border of a custom vertical axis as shown in the attached image at runtime?
2. Is there a way to put buttons similar to form ControlBox buttons (also shown in the attached image at the top right corner for each of the custom vertical axis) and have these buttons trigger events (similar behavior to the controlbox, but is somewhat customized). Please note that these Charts and all related buttons are created and placed at runtime.
Questions on chart area related to a custom Y-axis
Questions on chart area related to a custom Y-axis
- Attachments
-
- tchart.png (19.97 KiB) Viewed 5201 times
Re: Questions on chart area related to a custom Y-axis
Hello asupriya,
I have made a simple project that I think its behaviour is as you want. Please, see next code, and check if works as you want.1. How can I highlight the chart area border of a custom vertical axis as shown in the attached image at runtime?
Code: Select all
private Steema.TeeChart.Styles.FastLine[] fs = new Steema.TeeChart.Styles.FastLine[7];
private Steema.TeeChart.Axis[] myAxis = new Steema.TeeChart.Axis[7];
private Steema.TeeChart.ChartController tChartController1;
bool drawrectangle;
private int X0, Y0, X1, Y1;
private void InitializeChart()
{
// this.WindowState = FormWindowState.Normal;
this.AutoScroll = true;
//Chart object
tChartController1 = new Steema.TeeChart.ChartController();
tChart1.AllowDrop = true;
tChart1.Aspect.View3D = false;
tChart1.Dock = DockStyle.Top;
tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
tChart1.Aspect.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
tChartController1.Chart = tChart1;
//Now cursor tool
tChart1.Panel.MarginLeft = 30;
//Now fast lines
for (int i = 0; i <= 6; i++)
{
//fastlines
fs[i] = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
fs[i].FillSampleValues(1800);
fs[i].DrawAllPoints = false;
//axis
if (i == 0)
{
myAxis[i]= new Steema.TeeChart.Axis(tChart1.Chart);
myAxis[i].StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
myAxis[i].StartPosition = 0;
myAxis[i].EndPosition = 55;
myAxis[i].Title.Text = "Axis_" + i;
myAxis[i].Title.TextAlign = StringAlignment.Near;
myAxis[i].Automatic = true;
fs[i].CustomVertAxis = myAxis[i];
tChart1.Axes.Custom.Add( myAxis[i]);
}
else
{
myAxis[i] = new Steema.TeeChart.Axis(tChart1.Chart);
myAxis[i].Title.Text = "Axis_" + i;
myAxis[i].Title.TextAlign = StringAlignment.Near;
myAxis[i].Automatic = true;
myAxis[i].StartEndPositionUnits = Steema.TeeChart.PositionUnits.Pixels;
tChart1.Axes.Custom.Add( myAxis[i]);
myAxis[i].StartPosition = myAxis[i - 1].EndPosition + 5;
myAxis[i].EndPosition = myAxis[i].StartPosition + 50;
fs[i].CustomVertAxis = myAxis[i];
}
}
this.Controls.Add(tChartController1);
tChart1.MouseUp += new MouseEventHandler(tChart1_MouseUp);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Draw();
}
void tChart1_MouseUp(object sender, MouseEventArgs e)
{
Steema.TeeChart.TChart tmpChart = (Steema.TeeChart.TChart)sender;
Steema.TeeChart.Axis dragDropAxis;
Rectangle rect = tChart1.Chart.ChartRect;
//int tmp = this.AutoScrollPosition.Y;
for (int i = 0; i < tmpChart.Axes.Custom.Count; i++)
{
dragDropAxis = tmpChart.Axes.Custom[i];
if (!dragDropAxis.Horizontal &&((dragDropAxis.IStartPos <= e.Y) && (dragDropAxis.IEndPos >= e.Y)))
{
drawrectangle = true;
Y0 = dragDropAxis.CalcYPosValue(dragDropAxis.Minimum);
Y1 = dragDropAxis.CalcYPosValue(dragDropAxis.Maximum);
X1 = rect.Right;
X0 = rect.Left;
}
}
tChart1.Refresh();
}
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.Red;
g.Pen.Width = 3;
g.Rectangle(X0, Y0, X1, Y1);
}
}
else
{
ResetCoords();
}
}
private void ResetCoords()
{
X0 = -1;
Y0 = -1;
Y1 = -1;
X1 = -1;
}
You need to add those buttons to a TChart instead of a Form. The chart being button's parent shouldn't affect their functionality. Regarding button's positioning, you already know regions positions and dimensions due to axes positioning.2. Is there a way to put buttons similar to form ControlBox buttons (also shown in the attached image at the top right corner for each of the custom vertical axis) and have these buttons trigger events (similar behavior to the controlbox, but is somewhat customized). Please note that these Charts and all related buttons are created and placed at runtime.
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: Questions on chart area related to a custom Y-axis
Just tried your example and it worked perfectly. Thanks Sandra.