TCHART not responding with high precision double values

TeeChart for ActiveX, COM and ASP
Post Reply
Posts: 16
Joined: Thu May 31, 2018 12:00 am

TCHART not responding with high precision double values

Post by Bhanu » Tue Oct 30, 2018 8:01 am


We are using: Teechart activeX pro 2018 and Visual studio 2017

We are getting an issue where TCHART goes into not responding state when we try to plot high precision double values which we read from a file.
We have noticed that this issue arises when the values have very little difference after 10 decimal places.
We managed to run our application by using float types instead of double but this is not desired since accuracy is very important for our application and using float types rounds off the decimal part.

Please look into it and guide us how to handle this problem.

The sample code is given below.

Code: Select all


double Y  = 939.06965494521967;
double Y1 = 939.06965494521955;	

m_TChart.Series(0).AddXY(0, Y, _T(""), RGB(255, 0, 255));
m_TChart.Series(0).AddXY(1, Y1, _T(""), RGB(255, 0, 255));

Site Admin
Site Admin
Posts: 9030
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Re: TCHART not responding with high precision double values

Post by Yeray » Wed Nov 07, 2018 10:35 am


I could reproduce it in ActiveX using VB6, and also in TeeChart VCL.
I think the issue is soon or later you'll have to find a compromise.

Here it is a trick you can do if you are not going to have values far from that ~939. The idea is to substract the integer part to represent the data without errors. Then, use OnGetAxisLabel event to format the labels adding the integer part back in:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
  TChart1.AddSeries scLine
  Dim Y0, Y1 As Double
  Y0 = 939.06965494521967
  Y1 = 939.06965494521955
  TChart1.Series(0).AddXY 0, Y0 - 939, "", clTeeColor
  TChart1.Series(0).AddXY 1, Y1 - 939, "", clTeeColor
  TChart1.Axis.Left.Labels.ValueFormat = ".##############"
  TChart1.Axis.Left.Labels.Style = talPointValue
  TChart1.Axis.Bottom.Increment = 0.2
End Sub

Private Sub TChart1_OnGetAxisLabel(ByVal Axis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
  If Axis = 0 Then
    If (SeriesIndex > -1) And (ValueIndex > -1) Then
      LabelText = "939" + Format$(TChart1.Series(SeriesIndex).YValues.Value(ValueIndex), TChart1.Axis.Left.Labels.ValueFormat)
    End If
  End If
End Sub
Extended.png (13.23 KiB) Viewed 8740 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply