Charts with data table tool in web application

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Captell
Newbie
Newbie
Posts: 65
Joined: Fri Sep 18, 2009 12:00 am

Charts with data table tool in web application

Post by Captell » Sat Jul 02, 2011 4:39 am

Hi there,
I'm using dotnet version 4.1.2010.9280 and am having a problem displaying charts in a web application where the chart includes a data table tool. Here is the situation.

I have a windows form application that allows users to create charts and which stores the .ten file in a database, I recently included functionality that allows a data tabel tool to be included on the charts if required.

I also have a web application that used tchart web component to display the .ten files previously saved in the database. Up until I added functionality to allow data tables on that charts this has all worked fine, however, now I'm having problems. See the following code, to get this to work I have to remove the data table tool with the marked code otherwise the foillowing line throws this error.
"Unable to cast object of type 'Steema.TeeChart.Web.WebChart' to type 'Steema.TeeChart.TChart'
The Refresh_Source function takes two parameters the first being of type STEEMA.TCHART.CHART. It is this that it is complaining about and ONLY complains if there is a data table present on the chart.

Code: Select all

 Dim memstream As New System.IO.MemoryStream(m_chart.m_bTeeData)
            memstream.Position = 0
            WebChart.Clear()

            WebChart.Chart.Import.Template.Load(memstream)

>>>>> 
if this bit is removed the following line fails.
            For i As Integer = WebChart.Chart.Tools.Count - 1 To 0 Step -1
               WebChart.Chart.Tools.RemoveAt(i)
            Next
>>>>> 

            m_chart.Refresh_Source(WebChart.Chart, m_sByValue)
Adrian Heald
Director
ITSM Reporting Services Pty Ltd
http://www.reportingservices.com

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

Re: Charts with data table tool in web application

Post by Sandra » Mon Jul 04, 2011 8:47 am

Hello Adrian,

I have made a simple project following your steps and last version of TeeChart.Net 2011 and seems it works fine for me:

Code: Select all

Protected Sub Page_Load(sender As Object, e As EventArgs)
	InitializeChart()
End Sub
Private Series1 As Steema.TeeChart.Styles.Line
Private tmpChart As System.IO.MemoryStream
Private tool3 As Steema.TeeChart.Tools.DataTableTool

Protected Sub InitializeChart()
	Dim ch1 As Steema.TeeChart.Chart
	tmpChart = New System.IO.MemoryStream()
	If Session("ch1") Is Nothing Then
		ch1 = WebChart1.Chart
		ch1.Aspect.View3D = False
		Series1 = New Steema.TeeChart.Styles.Line(ch1)
		Series1.FillSampleValues()

		tool3 = New Steema.TeeChart.Tools.DataTableTool(WebChart1.Chart)

		ch1.Export.Template.Save(tmpChart)

		'save template to a Session variable
		Session.Add("ch1", tmpChart)
	Else
		'retrieve the session stored Chart
		tmpChart = DirectCast(Session("ch1"), System.IO.MemoryStream)
		'set the Stream position to 0 as the last read/write
		'will have moved the position to the end of the stream
		tmpChart.Position = 0

		'import saved Chart
		WebChart1.Chart.Import.Template.Load(tmpChart)
		For i As Integer = WebChart1.Chart.Tools.Count - 1 To 0 Step -1

			WebChart1.Chart.Tools.RemoveAt(i)
		Next

		WebChart1.Chart.Invalidate()
	End If
End Sub
Please can you tell us if previous code reproduce your problem? If previous code doesn't reproduce your problem, please try to arrange a simple code so we can reproduce exactly your problem here.

Thanks,
Best Regards,
Sandra Pazos / 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

Captell
Newbie
Newbie
Posts: 65
Joined: Fri Sep 18, 2009 12:00 am

Re: Charts with data table tool in web application

Post by Captell » Mon Jul 04, 2011 12:48 pm

Hi Sandra,
Try your sample without the following

Code: Select all

For i As Integer = WebChart1.Chart.Tools.Count - 1 To 0 Step -1
         WebChart1.Chart.Tools.RemoveAt(i)
Next
I added that to remove the data table because with the data table there it would fail to cast correctly on my next line of code.
Adrian Heald
Director
ITSM Reporting Services Pty Ltd
http://www.reportingservices.com

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

Re: Charts with data table tool in web application

Post by Sandra » Mon Jul 04, 2011 2:39 pm

Hello Adrian,

Sorry but I'm not able to reproduce the problem here with the modifications you suggested and the same TeeChart build as you use. Can you please attach a simple example project we can run "as-is" to reproduce the problem here and check that it's using the TeeChart version you mentioned?

Thanks,
Best Regards,
Sandra Pazos / 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

Post Reply