Reposition series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Eric
Newbie
Newbie
Posts: 99
Joined: Wed Sep 14, 2005 4:00 am

Reposition series

Post by Eric » Fri Dec 22, 2006 8:53 am

Dear Sir

How to i re-position the series items?
for example the bar chart contain a few bar item. i write a code to remove those item value = 0. after removed those 0 value bar item. the tchart still remand the space. how to I call tchart to draw the series correctly?

eric

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Fri Dec 22, 2006 10:01 am

Hi Eric

We can't reproduce the problem here with the latest version available at the client area. Which teeChart version are you using ?

If the problem persist, could you please send us a simple example project we can run "as-is" or some code so that we can reproduce the problem here?

You can post your files at news://steema.public.attachments newsgroup

Thanks in advance
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

Eric
Newbie
Newbie
Posts: 99
Joined: Wed Sep 14, 2005 4:00 am

Post by Eric » Fri Dec 22, 2006 10:15 am

Dear Sir
Below is the sample code. click the button 1 then only click the button 2.
you can see the bar 3 and 4 is stick together already. how do make tchart draw collectly the position? or any method to so suppress zero?


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TChart1.Series.Add(New Steema.TeeChart.Styles.Bar3D)
TChart1.Series(0).Add(23, "1", TChart1.Series(0).Color)
TChart1.Series(0).Add(0, "2", TChart1.Series(0).Color)
TChart1.Series(0).Add(453, "3", TChart1.Series(0).Color)
TChart1.Series(0).Add(2343, "4", TChart1.Series(0).Color)
TChart1.Series(0).Add(0, "5", TChart1.Series(0).Color)
TChart1.Series(0).Add(53, "6", TChart1.Series(0).Color)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SuppressSeriesZero()
End Sub
Public Sub SuppressSeriesZero()
If TChart1.Series.Count <> 0 Then
Dim i, ii As Integer
Dim Total As Double = 0
For i = 0 To TChart1.Series(0).Count - 1
For ii = 0 To TChart1.Series.Count - 1
If InStr(TChart1.Series(ii).GetType.Name, "Horiz") = 0 Then
Total = Total + TChart1.Series(ii).YValues.Value(i)
Else
Total = Total + TChart1.Series(ii).XValues.Value(i)
End If
If Total <> 0 Then
Exit For
End If
Next
If Total = 0 Then
For ii = 0 To TChart1.Series.Count - 1
TChart1.Series(ii).Delete(i)
Next
i = i - 1
End If
Total = 0
Next
TChart1.Refresh()
End If

End Sub


thank

Eric
Newbie
Newbie
Posts: 99
Joined: Wed Sep 14, 2005 4:00 am

Post by Eric » Fri Dec 22, 2006 10:21 am

Dear Sir

I have the same problem at TChart activeX version 6.
Can you please let me know how to draw the chart correctly after removed the series item

Thank
Eric

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 22, 2006 11:33 am

Hi Eric,

The chart is not drawn incorrectly. When you populate one series without specifing the X values they are automatically added an range from 0 to Series.Count-1.

When you remove the series points which have a 0 value, the other points X values are not modified. Therefore the series is not drawn incorrectly as the bottom axis respects the series X values.

To achieve what you request you can use XValues.FillSequence() method or implement something like RemoveEmptySpaces:

Code: Select all

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		TChart1.Series.Add(New Steema.TeeChart.Styles.Bar3D)
		TChart1.Series(0).Add(23, "1", TChart1.Series(0).Color)
		TChart1.Series(0).Add(0, "2", TChart1.Series(0).Color)
		TChart1.Series(0).Add(453, "3", TChart1.Series(0).Color)
		TChart1.Series(0).Add(2343, "4", TChart1.Series(0).Color)
		TChart1.Series(0).Add(0, "5", TChart1.Series(0).Color)
		TChart1.Series(0).Add(53, "6", TChart1.Series(0).Color)
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		SuppressZeroValues()

		TChart1(0).XValues.FillSequence()
		'or
		'RemoveEmptySpaces()
	End Sub

	Public Sub SuppressZeroValues()
		If TChart1.Series.Count <> 0 Then
			Dim i As Integer

			For i = 0 To TChart1(0).Count - 1
				If (TChart1(0).YValues(i) = 0) Then
					TChart1(0).Delete(i)
				End If
			Next

		End If
	End Sub

	Public Sub RemoveEmptySpaces()
		Dim i As Integer

		For i = 0 To TChart1(0).Count - 1
			TChart1(0).XValues(i) = i
		Next

	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
Image Image Image Image Image Image
Instructions - How to post in this forum

Eric
Newbie
Newbie
Posts: 99
Joined: Wed Sep 14, 2005 4:00 am

Post by Eric » Tue Dec 26, 2006 2:06 am

Dear Sir

Ya.. it work thank alot

Eric

Post Reply