Page 1 of 1
Interactively resize axes
Posted: Thu Dec 01, 2011 9:49 am
by 13049272
Hi,
I'm developing an application in .Net 2.0 in VS 2008, using TeeChart Pro v 3.5.3146.24805. The application shows a chart that has 3 vertical axes on the left and 2 horizontal axes as visual seperators. Is it possible to make these horizontal axes draggable so that the user may resize a verticle axis interactively? Or if you have another suggestion to accomplish this, I'd be glad to hear it!
Re: Interactively resize axes
Posted: Fri Dec 02, 2011 4:01 pm
by 10050769
Hello Remeha,
I suggest you use ColorLine Tool to Drag the axes as do in next example:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Legend.Visible = false;
tChart1.Panel.MarginLeft = 12;
for (int i = 0; i < 3; i++)
{
tChart1.Axes.Custom.Add(new Steema.TeeChart.Axis());
tChart1.Series.Add(new Steema.TeeChart.Styles.FastLine());
tChart1[i].FillSampleValues();
tChart1[i].CustomVertAxis = tChart1.Axes.Custom[i];
tChart1[i].GetVertAxis.StartPosition = 33 * i;
tChart1[i].GetVertAxis.EndPosition = 33 * (i + 1);
Steema.TeeChart.Tools.ColorLine colorLine = new Steema.TeeChart.Tools.ColorLine(tChart1.Chart);
colorLine.Axis = tChart1[i].GetVertAxis;
colorLine.Value = tChart1[i].MinYValue();
colorLine.NoLimitDrag = true;
colorLine.DragLine += new EventHandler(colorLine_DragLine);
}
}
void colorLine_DragLine(object sender, EventArgs e)
{
Steema.TeeChart.Tools.ColorLine colorLine = ((Steema.TeeChart.Tools.ColorLine)sender);
int linePos = colorLine.Axis.CalcPosValue(colorLine.Value);
Rectangle chartRect = tChart1.Chart.ChartRect;
double pos = ((double)(linePos - chartRect.Top) / chartRect.Height) * 100;
colorLine.Axis.EndPosition = pos;
}
Can you tell us if previous code works as you expected?
I hope will helps.
Thanks,
Re: Interactively resize axes
Posted: Mon Dec 05, 2011 7:48 am
by 13049272
This does exactly what i want, thank you! I do have a thought, though... This kind of seems like a bit of a workaround, doesn't it? Wouldn't it make more sense for the axis itself to be draggable? Maybe one for the suggestion box?
I'll use this solution,though
Re: Interactively resize axes
Posted: Mon Dec 05, 2011 12:04 pm
by narcis
Hi Remeha,
Sure! There's no built-in functionality to achieve this right now so I have added your request (TF02015942) to the wish-list to be considered for inclusion in future releases.
Re: Interactively resize axes
Posted: Mon Dec 05, 2011 12:23 pm
by 13049272
That's great, thanks again. I have no further questions regarding this topic.
Re: Interactively resize axes
Posted: Tue Dec 06, 2011 10:40 am
by 13049272
Shoot, i do have something to add on this topic: there may be a bug in my version of TeeChart (TeeChart Pro v 3.5.3146.24805). When i hover the mouse over the upper colorline, the cursor changes to a hand. That's good, but the cursor doesn't change when the mouse hovers over one of the other two colorlines. This problem may already have been fixed, since i found it in an older version of TeeChart, can you verify this?
Re: Interactively resize axes
Posted: Tue Dec 06, 2011 12:57 pm
by 10050769
Hello Remeha,
I confirm that it doesn't occurs in last version 3(Build 3.5.3700.30575) so it is fixed.
Thanks,
Re: Interactively resize axes
Posted: Mon Feb 20, 2012 3:15 pm
by narcis
Hi Remeha,
Back to TF02015942, you could do something like in the example below using existing functionality. Does this fit your needs?
Code: Select all
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
tChart1.MouseUp += new MouseEventHandler(tChart1_MouseUp);
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
Steema.TeeChart.Styles.Bar series = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
series.FillSampleValues();
axis = new Steema.TeeChart.Axis(false, false, tChart1.Chart);
tChart1.Axes.Custom.Add(axis);
series.CustomVertAxis = axis;
axis.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
axis.RelativePosition = 50;
tChart1.Zoom.Allow = false;
}
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if (isClicked)
{
axis.RelativePosition = origPos + (e.X - startPos);
tChart1.Invalidate();
}
if (origCursor == null) origCursor = tChart1.Cursor;
if (axis.Clicked(e.Location))
{
tChart1.Cursor = Cursors.VSplit;
}
else
{
tChart1.Cursor = origCursor;
}
}
void tChart1_MouseUp(object sender, MouseEventArgs e)
{
isClicked = false;
tChart1.Invalidate();
}
Steema.TeeChart.Axis axis;
bool isClicked = false;
int startPos;
double origPos;
Cursor origCursor = null;
void tChart1_MouseDown(object sender, MouseEventArgs e)
{
isClicked = axis.Clicked(e.Location);
if (isClicked)
{
startPos = e.X;
origPos = axis.RelativePosition;
}
}
}
Thanks in advance.