Page 1 of 1
scrolling
Posted: Thu Nov 27, 2008 7:05 am
by 13045482
is there a way to find that whether the chart displays all bars or there are any hidden? actually i have a bar chart and i am using axis arrow for scrolling. now the axis arrows should not appear when all the bars can be seen as in taht case there is no point to scroll.
Posted: Thu Nov 27, 2008 9:43 am
by narcis
Hi shikha,
Yes, you can do something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Bar bar1;
private Steema.TeeChart.Tools.AxisScroll axisScroll1;
void InitializeChart()
{
bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.FillSampleValues();
axisScroll1 = new Steema.TeeChart.Tools.AxisScroll(tChart1.Chart);
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
int visiblePoints = (bar1.LastDisplayedIndex() - bar1.FirstDisplayedIndex()) + 1;
axisScroll1.Active = visiblePoints == bar1.Count ? false : true;
}
Posted: Thu Nov 27, 2008 12:17 pm
by 13045482
thanks , but i am using axis arrow whereas you have used axis scroll. Are they same. If they are different what are the differences. Also wills ame code will work for both. Thanks.
Posted: Thu Nov 27, 2008 12:19 pm
by 13045482
also request you to give answers in vb.net language rather than c sharp as i am working into vb.net. Many thanks for your kind help!!!
Posted: Thu Nov 27, 2008 12:31 pm
by narcis
Hi shikha,
thanks , but i am using axis arrow whereas you have used axis scroll. Are they same. If they are different what are the differences. Also wills ame code will work for both. Thanks.
Sorry, my fault. No, those tools are not the same but same code should apply to both of them.
The AxisArrow tool is used to display small arrows at beginning and / or end positions of axes.
The AxisScroll Tool allows you to drag an Axis by selecting it with the Mouse and dragging the Axis with the Left MouseButton depressed.
also request you to give answers in vb.net language rather than c sharp as i am working into vb.net. Many thanks for your kind help!!!
We use to make our examples in C# because it's the native language in which TeeChart for .NET is implemented and this makes it easier for us to debug projects. Anyway you can easily convert C# code to VB.NET using any of those conversion engines:
Kamal Patel's conversor
Carlos Aguilar's conversor
If this doesn't help don't hesitate to let us know.
Posted: Thu Nov 27, 2008 2:29 pm
by 13045482
thanks. but i am getting one error at this line :
TChart1.AfterDraw += New Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw)
error is - its an event and can not be called directly.use raise event statement to raise an event.
Posted: Thu Nov 27, 2008 2:43 pm
by narcis
Hi shikha,
Carlos Aguilar's conversor worked fine for me here. I also changed AxisScroll to AxisArrow tool:
Code: Select all
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitializeChart()
End Sub
Dim bar1 As Steema.TeeChart.Styles.Bar
Dim axisArrow1 As Steema.TeeChart.Tools.AxisArrow
Private Sub InitializeChart()
bar1 = New Steema.TeeChart.Styles.Bar(tChart1.Chart)
bar1.FillSampleValues()
axisArrow1 = New Steema.TeeChart.Tools.AxisArrow(TChart1.Chart)
axisArrow1.Axis = TChart1.Axes.Bottom
AddHandler tChart1.AfterDraw, AddressOf Me.tChart1_AfterDraw
End Sub
Private Sub tChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D)
Dim visiblePoints As Integer = ((bar1.LastDisplayedIndex - bar1.FirstDisplayedIndex) + 1)
axisArrow1.Active = Not (visiblePoints = bar1.Count)
End Sub
Also you can easily generate events at designtime selecting the object you'd like to work with, go to "Properties" window, select "Events" tab, choose the event you'd like to assign and dobule click on it.
Hope this helps!
Posted: Thu Nov 27, 2008 3:42 pm
by 13045482
Great! just one thing , it works absolutely fine in sense that it disables the scrolling arrow(axisArrow1) when all the bars are shown.But it remains visible. is there any way to also hide it along with making it disbled.
Posted: Thu Nov 27, 2008 3:46 pm
by 13045482
also LastDisplayedIndex was not present( it said this property not available) so i have used LastVisibleIndex instead. i am using teechart version 3.02
Posted: Thu Nov 27, 2008 4:48 pm
by 13045482
Hey, it worked after i put teechart1.refresh. Thanks!!
Posted: Thu Nov 27, 2008 6:30 pm
by narcis
Hi shikha,
You're welcome. I'm glad to hear that worked.
also LastDisplayedIndex was not present( it said this property not available) so i have used LastVisibleIndex instead. i am using teechart version 3.02
Ok, this is available with latest releases. Last one is from 3rd November 2008:
http://www.teechart.net/support/viewtopic.php?t=8636