limit the bars to be displayed
limit the bars to be displayed
i have a bar chart . i want that user should be tretented with a choice to enter taht how many bars he can see. Say for example there are total 10 bars. now if user enter 3 then the chart should display only firts 3 bars.
Hello shikha!
if you see 3 bars on the chart when user enter 3 or the other number ,you can do:
But,if then you see all bars, you can put buttons next and previous in form, for exemple:
Button next
Button previous
Best Regards
Sandra
if you see 3 bars on the chart when user enter 3 or the other number ,you can do:
Code: Select all
int n;
n = Convert.ToInt32 (textBox1.Text);
tChart1.Axes.Bottom.Increment = 1;
tChart1.Page.MaxPointsPerPage = n;
Button next
Code: Select all
tChart1.Page.Next();
Code: Select all
tChart1.Page.Previous();
Sandra
Great! But just one thing. I would prefer to display arrows rather than buttons. so i tried usng axis arrow. I pasted same code as you told and which i aws using for buttons in my code in axisa rrow click function. It fails there. when i click axis arrow it does not show rest of bars rather just 1 bar and then i again need to click axis arrow.
--this works--
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
tcStraAssessRC.Page.Next()
tcStraAssessRC.Refresh()
End Sub
-- thsi fails--
Private Sub AxisArrow2_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles AxisArrow2.Click
tcStraAssessRC.Page.Next()
tcStraAssessRC.Refresh()
End Sub
--this works--
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
tcStraAssessRC.Page.Next()
tcStraAssessRC.Refresh()
End Sub
-- thsi fails--
Private Sub AxisArrow2_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles AxisArrow2.Click
tcStraAssessRC.Page.Next()
tcStraAssessRC.Refresh()
End Sub
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi shikha,
AxisArrow tools are not designed for that. They already change axes scale so I can't think of a way to make paging and AxisArrow functionality compatible.
AxisArrow tools are not designed for that. They already change axes scale so I can't think of a way to make paging and AxisArrow functionality compatible.
Best Regards,
Narcís Calvet / 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 |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi shikha,
The button doesn't go down. It's in the same position you set it at designtime. When chart is being rendered labels, axis title, etc. make margins increase your button is no longer tied to the bottom axis. You can solve that changing button's position dynamically like this:
Also be very careful where do you call TChart1.Refresh(), TChart1.Draw(), TChart1.Invalidate() and the likes as your application could easily fall into an enless loop! You shouldn't use such methods in AfterDraw event.
The button doesn't go down. It's in the same position you set it at designtime. When chart is being rendered labels, axis title, etc. make margins increase your button is no longer tied to the bottom axis. You can solve that changing button's position dynamically like this:
Code: Select all
Private Sub tChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D)
Dim visiblePoints As Integer = ((Bar1.LastVisibleIndex - Bar1.FirstDisplayedIndex) + 1)
' axisArrow1.Active = Not (visiblePoints = Bar1.Count)
'this works
'TChart1.Refresh()
Dim Tmp As New System.Drawing.Point(TChart1.Chart.ChartRect.Left, TChart1.Chart.ChartRect.Bottom)
Me.Button4.Location = TChart1.Location + Tmp
End Sub
Best Regards,
Narcís Calvet / 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 |
hEY, THANKS SO MUCH FOR YOUR HELP. iTS REALLY HELPING. one thing left where i needeed your help. I want to put a validation
1. on next and previous buttons -When scrolling all the way to the right, and there are no more bars to display for the next scroll action, the next button should be disabled. Similarly, when there is nothing left to scroll to the left, the "previous" button should be disabled.
2. they(next and previous) button should be visible only if there are no of bars that are displayed currently is less than the total bars of series.
I am uploading TWO.zip file for as is. It has these two buttons and i have tried the code for it but it does not work. I have given maxno of bars to be displayed as 2. my code looks like this:
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
TChart1.Page.Next()
If TChart1.Series(1).LastVisibleIndex = TChart1.Series(0).Count Then
btnNext.Enabled = False
End If
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
TChart1.Page.Previous()
If TChart1.Series(1).FirstVisibleIndex = 0 Then
btnPrevious.Enabled = False
End If
End Sub
Private Sub tChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D)
Dim visiblePoints As Integer = TCHART1.Series(1).LastVisibleIndex - TCHART1.Series(1).FirstDisplayedIndex
Me.btnNext.Visible = Not (visiblePoints = TCHART1.Series(1).Count)
Me.btnPrevious.Visible = Not (visiblePoints = TCHART1.Series(1).Count)
If TChart1.Series(1).LastVisibleIndex = TChart1.Series(1).Count Then
btnNext.Enabled = False
Else
btnNext.Enabled = True
End If
If TChart1.Series(1).FirstVisibleIndex = 1 Then
btnPrevious.Enabled = False
Else
btnPrevious.Enabled = True
End If
End Sub
1. on next and previous buttons -When scrolling all the way to the right, and there are no more bars to display for the next scroll action, the next button should be disabled. Similarly, when there is nothing left to scroll to the left, the "previous" button should be disabled.
2. they(next and previous) button should be visible only if there are no of bars that are displayed currently is less than the total bars of series.
I am uploading TWO.zip file for as is. It has these two buttons and i have tried the code for it but it does not work. I have given maxno of bars to be displayed as 2. my code looks like this:
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
TChart1.Page.Next()
If TChart1.Series(1).LastVisibleIndex = TChart1.Series(0).Count Then
btnNext.Enabled = False
End If
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
TChart1.Page.Previous()
If TChart1.Series(1).FirstVisibleIndex = 0 Then
btnPrevious.Enabled = False
End If
End Sub
Private Sub tChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D)
Dim visiblePoints As Integer = TCHART1.Series(1).LastVisibleIndex - TCHART1.Series(1).FirstDisplayedIndex
Me.btnNext.Visible = Not (visiblePoints = TCHART1.Series(1).Count)
Me.btnPrevious.Visible = Not (visiblePoints = TCHART1.Series(1).Count)
If TChart1.Series(1).LastVisibleIndex = TChart1.Series(1).Count Then
btnNext.Enabled = False
Else
btnNext.Enabled = True
End If
If TChart1.Series(1).FirstVisibleIndex = 1 Then
btnPrevious.Enabled = False
Else
btnPrevious.Enabled = True
End If
End Sub
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi shikha,
According to the project you sent you are using quite an old version of TeeChart. Using latest TeeChart for .NET v3 release next button is enabled for me here. Could you please uninstall your v3 version, download and install latest version and check if this solves the problem for you?
Thanks in advance.
According to the project you sent you are using quite an old version of TeeChart. Using latest TeeChart for .NET v3 release next button is enabled for me here. Could you please uninstall your v3 version, download and install latest version and check if this solves the problem for you?
Thanks in advance.
Best Regards,
Narcís Calvet / 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 |
Hi
I am sorry for a typo..
i wrote..
if you run the program i have uploaded you would see previous button works but next button do not.next button does not become enabled even as we reach the last bar.
it should be..
if you run the program i have uploaded you would see previous button works but next button do not.
next button does not become DISabled as we reach the last bar. That is as the last bar is displayed the next button should be disabled as we dont need it any more. IS It happening at your end???
2. i have v3.2945.19737 currently.
I am sorry for a typo..
i wrote..
if you run the program i have uploaded you would see previous button works but next button do not.next button does not become enabled even as we reach the last bar.
it should be..
if you run the program i have uploaded you would see previous button works but next button do not.
next button does not become DISabled as we reach the last bar. That is as the last bar is displayed the next button should be disabled as we dont need it any more. IS It happening at your end???
2. i have v3.2945.19737 currently.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi shikha,
Thanks for the information.
Also, I don't understand why do you initialize Bar1 series in the first line of InitializeChart(). If you comment in this line and replace all series indexes for "0" you may avoid some confusion.
Thanks for the information.
Yes, now I see what the problem is, you should use Series.Count-1 instead of Series.Count, for example:IS It happening at your end???
Code: Select all
Private Sub tChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D)
Dim visiblePoints As Integer = TCHART1.Series(1).LastVisibleIndex - TCHART1.Series(1).FirstDisplayedIndex
Me.btnNext.Visible = Not (visiblePoints = TCHART1.Series(1).Count)
Me.btnPrevious.Visible = Not (visiblePoints = TCHART1.Series(1).Count)
If TChart1.Series(1).LastVisibleIndex = TChart1.Series(1).Count - 1 Then
btnNext.Enabled = False
Else
btnNext.Enabled = True
End If
If TChart1.Series(1).FirstVisibleIndex = 1 Then
btnPrevious.Enabled = False
Else
btnPrevious.Enabled = True
End If
End Sub
Code: Select all
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
TChart1.Page.Next()
If TChart1.Series(1).LastVisibleIndex = TChart1.Series(0).Count - 1 Then
btnNext.Enabled = False
End If
End Sub
So I see. I recommend you to install latest version. The one you are using is from January 2008. Many issues have been fixed/enhanced/implemented since then.2. i have v3.2945.19737 currently.
Best Regards,
Narcís Calvet / 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 |
One problem that i noticed is that
1.when orange2 is the last displayed bar then
?TCHART1.Series(0).LastVisibleIndex=4
2. when orange3 is the last displayed bar then
?TCHART1.Series(0).LastVisibleIndex=4
Ie irrespective last bar or second last bar of chart is the last displayed/visible bar at runtime, the TCHART1.Series(0).LastVisibleIndex=4?? how is this happening?
1.when orange2 is the last displayed bar then
?TCHART1.Series(0).LastVisibleIndex=4
2. when orange3 is the last displayed bar then
?TCHART1.Series(0).LastVisibleIndex=4
Ie irrespective last bar or second last bar of chart is the last displayed/visible bar at runtime, the TCHART1.Series(0).LastVisibleIndex=4?? how is this happening?