THistogramSeries 12-hour error in v8.04 for Delphi 2007

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

THistogramSeries 12-hour error in v8.04 for Delphi 2007

Post by toreba » Fri Apr 03, 2009 4:09 pm

Hi,

I recently installed v8.04 for Delphi 2007 and recompiled my code. I found changed behaviour for THistogramSeries. The data is in some cases incorrectly offset by exactly twelve hours compared to either THistogramSeries in v7 or TAreaSeries in v8.04. Has anyone seen anything like this?

I can supply pictures if it helps.

Thanks for any advice.

Toreba

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

Post by Yeray » Mon Apr 06, 2009 9:52 am

Hi Toreba,

Yes, it would be helpful if you could send us these pictures or a simple example project we can run "as-is" to reproduce the problem here.
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
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

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

THistogramSeries 12-hour error in v8.04 for Delphi 2007

Post by toreba » Mon Apr 06, 2009 2:34 pm

Hi Yeray,

I've just uploaded a few files at your upload page under name 'Trevor Cooper'. Hope you can see them. Firstly, the attached PowerPoint document 'THistogramSeries_TAreaSeries.pptx' contains two slides showing two views of some identical data. The first slide shows the first chart 'Rainfall' as a THistogramSeries. The second shows the same data as a TAreaSeries. The code is indentical except for this switch between one series type an the other. You can see that the THistogramSeries version is (incorrectly) offset by exactly 12 hours.

Secondly, I have extracted the data the attached Excel workbook 'EV01.red.xlsx'. Column 1 gives the bar values, column 2 gives the date-time values as real numbers, and column 3 gives the same date-time values as text. Excel interprets the dates (correctly) as running 9-11 July 2008.

I created a small D2007 application to view this extracted data in a design-time TChart. This is attached as TChart_THistogreamSeries.dproj.

(1) If I enter the attached XLSX file then TChart doesn't report the date correctly. I tell TChart that the bottom axis is TDateTime. Excel says the dates are July 2008, while TChart's bottom axis automatic minimum and maximum function reports that they are in year 1903. Also, it won't label the bottom axis with the date-time format I have asked for. I attach slides of this in PowerPoint document TChart_Date_Problems.pptx'. What am I doing wrong?

(2) Design time settings for reading data from the Excel file seem to be volatile. So you'll have to set them up again.

(3) When you select an 'Excel' data source the file open dialog doesn't filter for Excel files like XLS, XLSX etc. But you can enter the filter manually.

Hope that makes sense. Thanks for your help.

Toreba

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

Post by Yeray » Wed Apr 08, 2009 9:36 am

Hi Toreba,

We modified your project to try to reproduce your problems as-is. I've sent to your registered mail account the modified project.

In it, note that clicking on the chart, the series is changed from Bar to Area and viceversa.

Could you try to modify it as we could reproduce your problems here?
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

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

THistogramSeries 12-hour error in v8.04 for Delphi 2007

Post by toreba » Wed Apr 08, 2009 3:44 pm

Hi,

Okay I have modified the test project and am uploading it.

Please note that in my real project I am not using a TSeriesTextSource. I am populating the histogram series from a series I have constructed in memory. I use the series' AddXY method with a Delphi TDateTime value passed as the X. But I don't want to reproduce that method here unless I really have to to prove the point.

So in the revised CSV file I'm using to fake this problem for you, we have a column of data expressing a date as a real number, as recognised happily by Excel.

In this example project I have modified the code to use the design-time TSeriesTextSource, reading the date as a real number from the CSV.

If I define the series as having a date-time x-axis, and then activate the TSeriesTextSource, I get error messages saying '39638.67 is not a valid date and time'. But surely it is.

If I then redefine the series not to have a date-time x-axis, then activate the TSeriesTextSource, then the chart reads the data correctly as dates and displays the correctly formatted date-time axis labelling! Even though it shouldn't!

But then if I click on the chart to convert it to an area series I get the error message '39638.67 is not a valid date and time'.

So clearly (I think) THistogramSeries and TAreaSeries are behaving differently when interpreting real numbers as dates.

Hope that helps.

Thanks

Toreba

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

Post by Yeray » Thu Apr 09, 2009 8:36 am

Hi Toreba,
toreba wrote:If I define the series as having a date-time x-axis, and then activate the TSeriesTextSource, I get error messages saying '39638.67 is not a valid date and time'. But surely it is.
Probably your delphi is getting confused with the columns separator and the character to separate integer and decimal part. Try forcing it:

Code: Select all

DecimalSeparator := '.';
toreba wrote:If I then redefine the series not to have a date-time x-axis, then activate the TSeriesTextSource, then the chart reads the data correctly as dates and displays the correctly formatted date-time axis labelling! Even though it shouldn't!
Yes but you always can force the axis to be displayed as datetime or not:

Code: Select all

Series1.XValues.DateTime := False;
To try to avoid confusion, here is the complete code I used in the last project you sent:

Code: Select all

procedure TForm1.Chart1Click(Sender: TObject);
var tmp: TChartSeries;
begin
  tmp:=Series1;

  if (tmp is TBarSeries) then
  begin
    ChangeSeriesType(tmp, TAreaSeries);
    (tmp as TAreaSeries).AreaLinesPen.Visible:=false;
    (tmp as TAreaSeries).Stairs:=true;
  end
  else if (tmp is TAreaSeries) then
  begin
    ChangeSeriesType(tmp, TBarSeries);
    (tmp as TBarSeries).BarWidthPercent:=100;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.XValues.DateTime:=true;

with SeriesTextSource1 do
begin
  Fields.Clear;
  AddField('Y', 2);
  AddField('X', 3);
  HeaderLines := 0;
  FieldSeparator := ',';
  DecimalSeparator := '.';

  FileName := 'EV01.red.csv';
  Series := Series1;
  Active := True;
end;
  Chart1.Axes.Bottom.DateTimeFormat:='dd/mm/yyyy hh:mm:ss';
  Chart1.Axes.Bottom.Increment:=DateTimeStep[dtOneMinute];

  //Series1.XValues.DateTime := False;
  Chart1.Axes.Left.SetMinMax(Series1.YValues.MinValue,Series1.YValues.MaxValue);
end;
toreba wrote:Please note that in my real project I am not using a TSeriesTextSource. I am populating the histogram series from a series I have constructed in memory. I use the series' AddXY method with a Delphi TDateTime value passed as the X. But I don't want to reproduce that method here unless I really have to to prove the point.
In case that you could reproduce the problem adding points with AddXY method and not with TSeriesTextSource, please, try to reproduce in a simple example and we'll be pleased to try to identify the problem.
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

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

THistogramSeries 12-hour error in v8.04 for Delphi 2007

Post by toreba » Thu Apr 09, 2009 12:11 pm

Hi Yeray,

I'm using a machine in the UK and its decimal separator is already '.', so adding the line to set it explicitly at run time doesn't make any difference.

In the project I uploaded back to you yesterday, would you please check the following:

1. At design time, set the series bottom axis to be date-time, and activate the series text source. Do you get the message '39637.68 is not a valid date time'? If so can you explain that?

2. Now, still at design time, set the series bottom axis to be NOT date-time and activate the series text source. Do you see the chart plotted with a date-time bottom axis? If so can you explain that?

3. Now run the project so that the histogram chart is succesfully displayed at run time, and then click on the chart to convert it to an area series. do you get the message '39637.68 is not a valid date time'? If so can you explain that?

This is all using TeeChart 8.04.11395 Win32.

Thanks for your help.

Trevor Cooper

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

Post by Yeray » Thu Apr 09, 2009 2:16 pm

Hi Trevor,

2. Try changing the label from your second line csv:

Code: Select all

0,39638.66944,something
Then you'll see that the axis label is showing your point label that is text, not a value.

1. It seems that SeriesTextSource doesn't handle FloatToDateTime function so that you won't be able to load a double where is expected to be a DateTime.

3. It's the same than 1. You load the values from the source NOT as DateTime. Then at OnCreate you set the axis as DateTime and when you click on the chart, you try to reload the data but this time as DateTime.

I think that you have two options:

A. If your X double values represent the same datetime than the last column (label), you could use this last column to loas your X values as DateTime.

B. You could never set your bottom axis as DateTime, load your X double values and display your third column in axis labels or use custom labels.
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

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

THistogramSeries 12-hour error in v8.04 for Delphi 2007

Post by toreba » Thu Apr 09, 2009 3:28 pm

Yaray,

In my original post I mentioned the problem was with THistogramSeries. In this test project we've set up a TBarSeries which is a different animal. I can see now that there is no problem with a TBarSeries.

But there is a problem with the THistogramSeries, and I have reproduced it in the version of the project I have uploaded.

(To mimic the real application I have modified the project (1) to use the AddXY method to populate the series, and (2) to create the series at run time. To avoid confusion I have deleted the design time series and the series text source)

So now, you run the project and the THistogram displays. You click to convert to TAreaSeries, and all the data moves left by 12 hours. Eh voila!

Also, the zoom beaviour of the THistogramSeries is all wrong.

Hope that helps.

Trevor Cooper
Last edited by toreba on Thu Apr 09, 2009 3:34 pm, edited 1 time in total.

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

Post by Yeray » Tue Apr 14, 2009 11:39 am

Hi Trevor,

Excuse us, in your original post you mentioned Histogram Series but in your first code we saw Bar Series and that's why we didn't try with histograms. Now I've been able to reproduce this with your code, I've simplified a little bit and I've added this to the wish list to be fixed in further releases (TV52014082).

Code: Select all

procedure TForm1.Chart1Click(Sender: TObject);
var tmp: TChartSeries;
begin
  tmp:=Self.Chart1.Series[0];

  if (tmp is THistogramSeries) then
  begin
    ChangeSeriesType(tmp, TBarSeries);
    (tmp as TBarSeries).BarWidthPercent := 100;
    Chart1.Title.Text[0] := 'TBarSeries';
  end
  else if (tmp is TBarSeries) then
  begin
    ChangeSeriesType(tmp, THistogramSeries);
    Chart1.Title.Text[0] := 'THistogramSeries';
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(THistogramSeries.Create(Self));
  Chart1[0].Marks.Visible:= False;
  Chart1[0].XValues.DateTime:=True;
  Chart1[0].Pen.Color:=Chart1[0].Color;
  Chart1.Legend.Visible:=False;
  Chart1.Title.Text[0] := 'THistogramSeries';

  DecimalSeparator:='.';

  with Chart1[0] do
  begin
    AddXY(39638.76528,0);
    AddXY(39638.8625,1.5);
    AddXY(39638.95972,12);
    AddXY(39639.05694,6);
    AddXY(39639.15417,0);
    AddXY(39639.25139,0);
    AddXY(39639.34861,0);
    AddXY(39639.44583,0);
    AddXY(39639.54306,0);
    AddXY(39639.64028,0);
    AddXY(39639.7375,0);
    AddXY(39639.83472,0);
    AddXY(39639.93194,6);
    AddXY(39640.02917,6);
    AddXY(39640.12639,0);
    AddXY(39640.22361,0);
    AddXY(39640.32083,1.2);
  end;

  Chart1.Axes.Bottom.DateTimeFormat:='dd/mm/yyyy hh:mm:ss';
  Chart1.Axes.Bottom.Increment:=DateTimeStep[dtOneMinute];
  Chart1.Axes.Bottom.LabelsAngle:=90;
  Chart1.View3D := false;
end;
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

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

THistogramSeries 12-hour error in v8.04 for Delphi 2007

Post by toreba » Tue Apr 14, 2009 5:06 pm

Yaray,

Yes I apologise for confusing you (and myself) with TBarSeries instead of THistogramSeries.

You say that a fix is on the wish list for further releases. Can you tell me when the next release would be and whether this fix would be in it?

Thanks for all your help.

Trevor Cooper

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 Apr 15, 2009 7:05 am

Hi Trevor,

Next release will be out by the end of this month or beginning of May. I think it's unlikely this issue is fixed on it. As a workaround you can use TBarSeries setting BarWidthPercent to 100 instead of THistogramSeries.
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

toreba
Newbie
Newbie
Posts: 15
Joined: Thu Feb 06, 2003 5:00 am
Location: UK

THistogramSeries 12-hour error in v8.04 for Delphi 2007

Post by toreba » Wed Apr 15, 2009 2:20 pm

Narcís, Yeray,

Okay, I'll do that. Thankyou for your help in this matter.

Regards

Trevor Cooper

Post Reply