limit the bars to be displayed

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

limit the bars to be displayed

Post by Neelam » Thu Nov 27, 2008 7:35 am

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.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Post by Sandra » Thu Nov 27, 2008 9:51 am

Hello shikha!

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;
  
But,if then you see all bars, you can put buttons next and previous in form, for exemple:

Button next

Code: Select all

tChart1.Page.Next();
Button previous

Code: Select all

 tChart1.Page.Previous();
Best Regards
Sandra

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Wed Dec 03, 2008 5:57 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Dec 03, 2008 9:30 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Wed Dec 03, 2008 12:06 pm

Ok i can use buttons. BUt the drawback is that if i place button on chart then when i run the button moves down in run time. Is there a way to put controls on chart so taht they do not move from their place when u run the progrma.

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Wed Dec 03, 2008 12:10 pm

uploaded file also for as is analysis. thanks

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Wed Dec 03, 2008 12:18 pm

in uploaded file one.zip , plesae find that the button with text "next page" moves down when u run the program

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Dec 03, 2008 3:00 pm

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:

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
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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Fri Dec 05, 2008 9:13 am

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

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Fri Dec 05, 2008 9:20 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Dec 05, 2008 10:37 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Fri Dec 05, 2008 10:51 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Dec 05, 2008 11:27 am

Hi shikha,

Thanks for the information.
IS It happening at your end???
Yes, now I see what the problem is, you should use Series.Count-1 instead of Series.Count, for example:

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
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.
2. i have v3.2945.19737 currently.
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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Fri Dec 05, 2008 12:00 pm

I CHANGED THE CODE AS U TOLD ME. BUT NOW ITS NOT SHOWING ME LAST BAR(ORANGE3)??
THE NEXT BUTTON IS GETTING DISABLED AFTER SHOWING BARS TILL ORANGE2.I AM UPLOADING THE LATEST VERSION "THREE.ZIP".

Neelam
Advanced
Posts: 193
Joined: Fri Jun 08, 2007 12:00 am

Post by Neelam » Fri Dec 05, 2008 12:24 pm

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?

Post Reply