Series.ChangeType issue

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Series.ChangeType issue

Post by Uli » Mon Jun 07, 2010 6:14 am

Hi,

I have to import data series from my old file format into TeeChart. At the import starting point I do not know whether pointer are to draw or not. So I create the series as Line to apply all nessessary properties. Usually they could further exist as Line but due to the bug [TF02014877] I have to convert the series (if pointers.visible=false) to FastLine. I do this with this code:

Code: Select all

            Dim NewSeries As New Steema.TeeChart.Styles.Line(Graph.Chart)
.
.
.
            Try
                If Not NewSeries.Pointer.Visible Then Steema.TeeChart.Styles.Series.ChangeType(NewSeries, GetType(Steema.TeeChart.Styles.FastLine))
            Catch ex As Exception
                If ex.Message = "test" Then MsgBox(ex.Message) '-->it's a dummy line in order to prevent program stop
            End Try
At run time, here (series type conversion) a Invalidcastexception occurs. However, the TeeChart editor shows that the seriers is now a FastLine.

What is wrong?

Best regards

Uli

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

Re: Series.ChangeType issue

Post by Narcís » Mon Jun 07, 2010 7:06 am

Hi Uli,

First of all, please notice that TF02014877 has already been fixed for next TeeChart 2010 maintenance release.

Regarding the issue descride here, could you please attach a simple example project we can run "as-is" to reproduce the problem here?

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

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Series.ChangeType issue

Post by Uli » Mon Jun 07, 2010 8:14 am

Hi Narcis,

in an earlier post
http://www.teechart.net/support/viewtop ... =4&t=11091
I posted a code example to illustrate TF02014877. I removed the files quickly after I got the idea that posting the lic file might not be opportune. Unfortunately, I cannot find this example. But it's possible that Sandra has this example since she reproduced TF02014877. But there the type conversion has to be added (at the end of ReadSeries, just before the last "next" statement).
In the moment I'm a little bit under pressure and have not time enough to prepare such an example. Otherwise you could use this ReadSeries procedure and substitute the values read from file by fixed values:

Code: Select all

Function ReadSeries() As Boolean        
        ReadSeries = False
        Dim s As String
        Dim s1 As String
        Dim s2 As String
        Dim s3 As String
        Dim LegendText As String
        Dim ii As Integer
        Dim Left As Integer
        Dim Top As Integer
        Dim Bottom As Integer
        Dim Right As Integer
        Dim PointCount As Integer
        Dim d As Double
        Dim b As Boolean
        Dim bt As Byte
        Dim PointShape As Integer
        Dim DrawLine As Boolean
        Dim CustomLegend As Boolean
        'Dim LineWidth As Boolean
        Dim DrawPoints As Boolean
        'Dim PointSize As Integer
        Dim PointColorR As Integer
        Dim PointColorG As Integer
        Dim PointColorB As Integer
        Dim LineColorR As Integer
        Dim LineColorG As Integer
        Dim LineColorB As Integer
        'Dim MyChildWindow As MyChildWindow = Graph.Parent
        'MyStreamReader.BaseStream.Position = MyXYF_Information.Positions(0).Series

        If Ver > 110 Then
            s = ReadString()
            If "Serien" <> s Then Return False
        End If

        'OldSeriesCount:=graph.SeriesCount;
        'for i:=1 to SeriesCount do begin
        Dim MyFunctions As New MyFunctions
        Dim X As Double = Nothing
        Dim Y As Double = Nothing
        Dim i As Integer
        Dim RTFString As String = ""
        For i = 0 To SeriesCount - 1
            'Dim SeriesName As String = MyFunctions.GetSeriesName(Graph, "tmpSeriesFromOldXYFFile")
            Dim NewSeries As New Steema.TeeChart.Styles.Line(Graph.Chart)
            'Folgende Deklarationen (hat so funktioniert) wurden aus der Schleife heraus verschoben...
            'Dim X As Double = Nothing
            'Dim Y As Double = Nothing
            '  series:=Graph.Series[0];
            '  read:=read+fs.read(b, sizeof( Boolean ));             ******* 
            b = MyStreamReader.ReadBoolean
            '  Series.Active:=b;
            '  read:=read+fs.read(cl, sizeof( TColor ));
            ii = MyStreamReader.ReadInt32
            '  Series.BoundsColor:=cl;
            '  read:=read+fs.read(ps, sizeof( TPenStyle ));
            bt = MyStreamReader.ReadByte

            '  Series.BoundsLineStyle:=ps;
            '  read:=read+fs.read(ii, sizeof( integer ));
            ii = MyStreamReader.ReadInt32

            '  Series.BoundsWidth:=ii;
            '  read:=read+fs.read(b, sizeof( boolean ));
            b = MyStreamReader.ReadBoolean
            CustomLegend = b
            '  Series.CustomLegend:=b;
            '  read:=read+fs.read(b, sizeof( Boolean ));
            DrawLine = MyStreamReader.ReadBoolean

            '  Series.DrawLine:=b;
            '  read:=read+fs.read(b, sizeof( Boolean ));
            DrawPoints = MyStreamReader.ReadBoolean

            'If DrawLine Then
            '    If Not DrawPoints Then
            '        NewSeries.ChartType = SeriesChartType.FastLine
            '    Else
            '        NewSeries.ChartType = SeriesChartType.Line
            '    End If
            'End If
            '  Series.DrawPoints:=b;
            '  read:=read+fs.read(b, sizeof( Boolean ));
            NewSeries.LinePen.Visible = DrawLine
            NewSeries.Pointer.Visible = DrawPoints
            b = MyStreamReader.ReadBoolean

            '  Series.FillPoints:=b;
            '  b:=loadGraphAppearance;
            '  loadGraphAppearance:=true;
            '  if not ReadString(@series.LegendName) then exit;
            LegendText = ReadExtendedString(Left, Top, Bottom, Right, RTFString)
            If CustomLegend Then
                If NewSeries.Tag = Nothing Then NewSeries.Tag = ""
                NewSeries.Title = LegendText
                ii = RTFString.IndexOf("*10")
                If ii > 0 Then
                    RTFString = RTFString.Replace("*10", "·10")
                End If
                If RTFString = "" Then
                    RTB.Clear()
                    RTB.Width = 1000
                    RTB.Text = LegendText
                    RTB.Invalidate()
                    RTFString = RTB.Rtf
                End If
                'MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "Oben", Top.ToString)
                'MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "Links", Left.ToString)
                'MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "Höhe", (Bottom - Top).ToString)
                'MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "Breite", (Right - Left + 10).ToString)
                'MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "Orientierung", "0")
                MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "RTF", "ja")
                MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "Alignment", "0")
                MyFunctions.SetValueInTag(NewSeries.Tag, "Benutzerdefinierte Legende", "RTFText", RTFString + "<<Ende des RTF>>")
                Graph.Legend.Font.Color = Color.Transparent
            End If
            '  loadGraphAppearance:=b;
            '  read:=read+fs.read(ls, sizeof( TLegendStatus ));
            bt = MyStreamReader.ReadByte

            '  Series.LegendStatus:=ls;
            '  read:=read+fs.read(cl, sizeof( TColor ));
            ii = MyStreamReader.ReadInt32
            TColor2RGB(ii, LineColorR, LineColorG, LineColorB)
            NewSeries.Color = Color.FromArgb(255, LineColorR, LineColorG, LineColorB)

            '  Series.LineColor:=cl;
            '  read:=read+fs.read(ps, sizeof( TPenStyle ));
            bt = MyStreamReader.ReadByte

            '  Series.LineStyle:=ps;
            '  read:=read+fs.read(ii, sizeof( integer ));
            ii = MyStreamReader.ReadInt32
            NewSeries.LinePen.Width = ii
            '  Series.LineWidth:=ii;
            '  read:=read+fs.read(cl, sizeof( TColor ));
            ii = MyStreamReader.ReadInt32
            TColor2RGB(ii, PointColorR, PointColorG, PointColorB)
            NewSeries.LinePen.Color = Color.FromArgb(255, PointColorR, PointColorG, PointColorB)
            '  Series.PointColor:=cl;

            '  read:=read+fs.read(PointCount, SizeOf(integer));
            PointCount = MyStreamReader.ReadInt32

            '  read:=read+fs.read(pts, sizeof( et_PointShape ));
            PointShape = MyStreamReader.ReadByte

            '  Series.PointShape:=pts;
            '  read:=read+fs.read(w, sizeof( Word ));
            ii = MyStreamReader.ReadInt16
            NewSeries.Pointer.VertSize = ii
            NewSeries.Pointer.HorizSize = ii
            'If DrawPoints Then
            'If Not DrawLine Then NewSeries. = SeriesChartType.Point
            NewSeries.Pointer.Color = Color.FromArgb(255, PointColorR, PointColorG, PointColorB)
            NewSeries.LinePen.Color = Color.FromArgb(255, PointColorR, PointColorG, PointColorB)
            Select Case PointShape
                Case 0
                    NewSeries.Pointer.Style = Styles.PointerStyles.Rectangle
                Case 1
                    NewSeries.Pointer.Style = Styles.PointerStyles.Circle
                Case 2
                    NewSeries.Pointer.Style = Styles.PointerStyles.Diamond
                Case 3
                    NewSeries.Pointer.Style = Styles.PointerStyles.DiagCross
                Case 4
                    NewSeries.Pointer.Style = Styles.PointerStyles.Cross
                Case Else
                    NewSeries.Pointer.Style = Styles.PointerStyles.Rectangle
            End Select
            'Else
            'NewSeries.MarkerStyle = MarkerStyle.None
            'End If
            '  Series.PointSize:=w;
            '  Series.SeriesName:=readstring(false);  ***************************************
            s = ReadString()
            s = MyFunctions.GetSeriesName(Graph, s)
            If Not CustomLegend Then NewSeries.Title = s
            MyFunctions.SetValueInTag(NewSeries.Tag, "Parameter", "ausSpektren3d", "ja")
            MyFunctions.SetValueInTag(NewSeries.Tag, "Parameter", "Serienname", s)
            MyFunctions.SetValueInTag(NewSeries.Tag, "Parameter", "MyFileIO-Version", Ver.ToString)
            'NewSeries.Tag = "[Parameter]" + Chr(13) + "ausSpektren3d: ja" + Chr(13) + "Serienname: " + s
            'NewSeries.Tag = NewSeries.Tag + Chr(13) + "MyFileIO-Version: " + Ver.ToString
            'MyFunctions.SetSeriesName(Graph, NewSeries, s)
            'Dim an As TextAnnotation = Graph.Annotations.FindByName(NewSeries.Name)
            'MyFunctions.AddToSeriesAnnotation(Graph, NewSeries.Name, "Parameter", "aus(Spektren3d) : ja")
            '********************************************************************************

            '  read:=read+fs.read(b, sizeof( Boolean ));
            b = MyStreamReader.ReadBoolean
            '  Series.Sorted:=b;
            '  read:=read+fs.read(ii, sizeof( integer ));
            ii = MyStreamReader.ReadInt32
            If ii = 0 Then NewSeries.HorizAxis = HorizontalAxis.Bottom Else NewSeries.HorizAxis = HorizontalAxis.Top
            '  if ii = 0 then Series.WhichXAxis:=Graph.xAxis
            '  else Series.WhichXAxis:=Graph.xAxis_Second;
            '  read:=read+fs.read(ii, sizeof( integer ));
            ii = MyStreamReader.ReadInt32
            If ii = 0 Then NewSeries.VertAxis = VerticalAxis.Left Else NewSeries.VertAxis = VerticalAxis.Right
            '  if ii = 0 then Series.WhichYAxis:=Graph.yAxis
            '  else Series.WhichYAxis:=Graph.yAxis_Second;
            '  read:=read+fs.read(d, sizeof( double ));
            d = MyStreamReader.ReadDouble

            '  Series.ZValue:=d;
            '  Series.SetPointNumber(PointCount);
            Dim j As Integer
            For j = 1 To PointCount
                '  for j:=1 to PointCount do begin
                '    read:=read+fs.read(x, SizeOf(double));
                X = MyStreamReader.ReadDouble
                '    read:=read+fs.read(y, SizeOf(double));
                Y = MyStreamReader.ReadDouble
                '    series.Add(x, y);
                NewSeries.Add(X, Y)
            Next
            '  If Version > 101 Then begin()
            '    read:=read+fs.read(b, sizeof( Boolean ));
            '    Series.SQRT_X:=b;
            '    read:=read+fs.read(b, sizeof( Boolean ));
            '    Series.Reciproke:=b;
            '  end;
            If Ver > 101 Then
                b = MyStreamReader.ReadBoolean

                b = MyStreamReader.ReadBoolean

            End If
            '  If Version > 105 Then begin()
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.ExSlit:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.EmmSlit:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Wavelength:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Filter:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Speed:=readstring(false);
            '  end;
            If Ver > 105 Then
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "ExSlit: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "EmSlit: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Wellenlänge: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Filter: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Geschwindigkeit: " + s
            End If
            '  If Version > 108 Then begin()
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.method:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.date:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.response:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.expol:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.emmpol:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.filename:=readstring(false);
            '  end;
            If Ver > 108 Then
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Methode: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Datum: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Response: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Exc-Polarisator: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Em-Polarisator: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Dateiname: " + s
            End If
            '  If Version > 111 Then begin()
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.ScanStart:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.ScanEnd:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Averaging:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Averaging_TD:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.StepWidth:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Spektrometer:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.ExperimentTime:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Temperature:=readstring(false);
            '  end;
            If Ver > 111 Then
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "ScanStart: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "ScanEnd: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Averaging: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Averaging_TD: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "StepWidth: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Spektrometer: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "ExperimentTime: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Temperatur: " + s
            End If
            '  If Version > 113 Then begin()
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.TimePerFlash:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.Flashcount:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.DelayAfterFlash:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.SampleWindow:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.DelayIncrement:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.MaxDelay:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.FLLMode:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.ExcWavelength:=readstring(false);
            '    Graph.Series[OldSeriesCount+i].FluorescenceConditions.EmWavelength:=readstring(false);
            '  end;
            If Ver > 113 Then
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "TimePerFlash: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Flashcount: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "DelayAfterFlash: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "SampleWindow: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "DelayIncrement: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "MaxDelay: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "FLLMode: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "ExcWavelength: " + s
                s = ReadString()
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "EmWavelength: " + s
            End If
            '  If Version > 112 Then begin()
            '    read:=read+fs.read(Graph.Series[OldSeriesCount+i].CIEProperties.HasCIEData, SizeOf(boolean));
            '    read:=read+fs.read(Graph.Series[OldSeriesCount+i].CIEProperties.L, SizeOf(double));
            '    read:=read+fs.read(Graph.Series[OldSeriesCount+i].CIEProperties.a, SizeOf(double));
            '    read:=read+fs.read(Graph.Series[OldSeriesCount+i].CIEProperties.b, SizeOf(double));
            '    read:=read+fs.read(Graph.Series[OldSeriesCount+i].CIEProperties.X, SizeOf(double));
            '    read:=read+fs.read(Graph.Series[OldSeriesCount+i].CIEProperties.Y, SizeOf(double));
            '    read:=read+fs.read(Graph.Series[OldSeriesCount+i].CIEProperties.Z, SizeOf(double));
            '  end;
            If Ver > 112 Then
                b = MyStreamReader.ReadBoolean
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "HasCIEData: " + s
                b = MyStreamReader.ReadDouble
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "L: " + s
                b = MyStreamReader.ReadDouble
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "a: " + s
                b = MyStreamReader.ReadDouble
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "b: " + s
                b = MyStreamReader.ReadDouble
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "X: " + s
                b = MyStreamReader.ReadDouble
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Y: " + s
                b = MyStreamReader.ReadDouble
                NewSeries.Tag = NewSeries.Tag + Chr(13) + "Z: " + s
            End If
            '  If Version > 109 Then begin()
            '    read:=read+fs.read(d, sizeof( double ));
            '    TitrationData.StartVolume:=d;
            '    read:=read+fs.read(d, sizeof( double ));
            '    TitrationData.TotalVolume:=d;
            '    read:=read+fs.read(d, sizeof( double ));
            '    TitrationData.LastTitratorConc:=d;
            '    Graph.Series[OldSeriesCount+i].TitrationData:=TitrationData;
            '    read:=read+fs.Read(b, sizeof(b));

            '    Graph.Series[OldSeriesCount+i].PointsContainTitrationData:=b;
            '    if Graph.Series[OldSeriesCount+i].PointsContainTitrationData then begin
            '      SetLength(Graph.Series[OldSeriesCount+i].pointTitrationData, Graph.Series[OldSeriesCount+i].PointCount);
            '      for j:=1 to Graph.Series[OldSeriesCount+i].PointCount do begin
            '        read:=read+fs.read(TitrationData, SizeOf(TTitrationData));

            '        Graph.Series[OldSeriesCount+i].PointTitrationData[j-1]:=TitrationData;
            '      end;
            '    end;
            '  end;
            If Ver > 109 Then
                'Dim StartVolume As Double
                'Dim TotalVolume As Double
                'Dim LastTitratorConc As Double

                d = MyStreamReader.ReadDouble
                b = d <> 0
                s1 = d.ToString
                d = MyStreamReader.ReadDouble
                s2 = d.ToString
                d = MyStreamReader.ReadDouble
                s3 = d.ToString
                If b Then
                    NewSeries.Tag = NewSeries.Tag + Chr(13) + Chr(13) + Chr(13) + "[Titrationsdaten Serie]"
                    NewSeries.Tag = NewSeries.Tag + Chr(13) + "Startvolumen: " + s1
                    NewSeries.Tag = NewSeries.Tag + Chr(13) + "Gesamtvolumen: " + s2
                    NewSeries.Tag = NewSeries.Tag + Chr(13) + "Letzte Titratorkonzentration: " + s3
                End If
                b = MyStreamReader.ReadBoolean
                If b Then
                    NewSeries.Tag = NewSeries.Tag + Chr(13) + Chr(13) + Chr(13) + "[Punkt-Titrationsdaten]"
                    For j = 1 To PointCount
                        d = MyStreamReader.ReadDouble
                        NewSeries.Tag = NewSeries.Tag + Chr(13) + "Startvolumen " + j.ToString + ": " + d.ToString
                        d = MyStreamReader.ReadDouble
                        NewSeries.Tag = NewSeries.Tag + Chr(13) + "Gesamtvolumen " + j.ToString + ": " + d.ToString
                        d = MyStreamReader.ReadDouble
                        NewSeries.Tag = NewSeries.Tag + Chr(13) + "Letzte Titratorkonzentration " + j.ToString + ": " + d.ToString
                    Next
                End If
            End If
            '  If Version > 114 Then begin()
            '    read:=read+fs.read(ii, sizeof( integer ));
            '    for j:=0 to ii-1 do
            '      Graph.Series[OldSeriesCount+i].Protokoll.Add(readstring(false));

            '  end;
            'end;
            If Ver > 114 Then
                ii = MyStreamReader.ReadInt32
                For j = 1 To ii
                    s = ReadString()
                    MyFunctions.AddToSeriesTag(NewSeries, "Protokoll", s)
                Next
            End If
            Try
                If Not NewSeries.Pointer.Visible Then Steema.TeeChart.Styles.Series.ChangeType(NewSeries, GetType(Steema.TeeChart.Styles.FastLine))
            Catch ex As Exception
                If ex.Message = "test" Then MsgBox(ex.Message)
            End Try

        Next
        '  If Version > 110 Then begin()
        '  read:=read+fs.Read(i, sizeof(integer));
        If Ver > 110 Then MyStreamReader.ReadInt32()
        '  result:=read=i;
        '  if not result then exit;
        'end;

        Return True
    End Function
Best regards

Uli

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Series.ChangeType issue

Post by Uli » Mon Jun 07, 2010 8:48 am

Hi Narcis,

I can add another observation: I develop under Win 7 Pro (64 bit), but use for development a 32 bit Project withTeechart for .net 2010. I just compiled a test release version and the old file format import runs under Win 7 as expected. Installing the same program on a Win XP SP3 machine leads to the following behavior: After type conversion I have two series instead of one: one line (with the not acceptable Legend symbols) and one fastline... So it seems to be a heavy problem.

Regards,

Uli

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Series.ChangeType issue

Post by Uli » Mon Jun 07, 2010 11:49 am

Hi Narcis,

please help.

I'm very disappointed. With TF02014877 and the Series.ChangeType bug the TeeChart is practically useless for me. Due to TF02014877 I spent a lot of hours to make the logic working with fastline series instead of line. Now I discovered that I can work with that try/except construct under Windows 7 but not under Windows XP.

Though I have practically no time in the moment I checked the code to reproduce the bug: It's practically not more required than written in my first message concerning this topic, you only have to fill the series with sample points. This easy check could be done by Steema, too, I think. Then run it under Win XP and Win 7.

Hoping on a fast workaround/fix

Uli

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

Re: Series.ChangeType issue

Post by Sandra » Thu Jun 10, 2010 12:18 pm

Hello Uli,

I have tried to reproduce your problem with your code, adding your new ReadSeries() that you have sent, and here doesn't appears exception(Invalidcastexception) using last version of TeeChart.Net. Please, could you explain exactly what steps we have follow for reproduce the problem here?

On the other hand, I have made a simple code that works fine here with last version of TeeChart.Net. Please, check if you can reproduce your problem using next:

Code: Select all

private Steema.TeeChart.Styles.Line line; 
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line.FillSampleValues();
            line.Pointer.Visible = true;
            line.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Diamond;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Steema.TeeChart.Styles.Series s = tChart1[0];
            Steema.TeeChart.Styles.Series.ChangeType(ref s, typeof(Steema.TeeChart.Styles.FastLine));

        }
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

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Series.ChangeType issue

Post by Uli » Fri Jun 11, 2010 6:13 am

Hi Sandra,

thanks for the help. Yes, your code works.

The critical point was that changetype method obviously requires a "general" series object as parameter, please see:

Code: Select all

    Dim lineser As Steema.TeeChart.Styles.Line

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        lineser = New Steema.TeeChart.Styles.Line(TChart1.Chart)
        lineser.FillSampleValues()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        '***** This code leads to exception ******
        Steema.TeeChart.Styles.Series.ChangeType(lineser, GetType(Steema.TeeChart.Styles.FastLine))

        '***** this executes without exception *****
        'Dim s As Steema.TeeChart.Styles.Series = TChart1(0)
        'Steema.TeeChart.Styles.Series.ChangeType(s, GetType(Steema.TeeChart.Styles.FastLine))
    End Sub
OK, I can live with that. But it seems to me that it would be more logic if the changetype method would accept "special" series types (like line, bar, etc), too...
Or the help could make it more clear...

Best regards

Uli

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

Re: Series.ChangeType issue

Post by Sandra » Fri Jun 11, 2010 10:35 am

Hello Uli,

I could reproduce exception with last version of TeeChart .Net, and I have added it in wish-list with number [TF02014960] to be considered for inclusion in future releases.

On the other hand, Please, could you say us if next lines of code solve problem you have with Series.ChangeType?

Code: Select all

 Dim s As Steema.TeeChart.Styles.Series = lineser
        Steema.TeeChart.Styles.Series.ChangeType(s, GetType(Steema.TeeChart.Styles.FastLine))


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

Uli
Newbie
Newbie
Posts: 80
Joined: Thu Apr 22, 2010 12:00 am

Re: Series.ChangeType issue

Post by Uli » Mon Jun 14, 2010 5:33 am

Hallo Sandra,

this code runs without exception.

Best regards

Uli

Post Reply