Actual value of XValue
Actual value of XValue
Hi,
I have a DBChart with the X-Axis as DateTime. In an OnSeriesClick event I know how to display the Y-Value but how do I display the actual X-Value? Not the ValueIndex or the XLabel[ValueIndex] but the actual date from the underlying CrossTab data series at that ValueIndex. Without formatting.
Every attempt I make at this returns the ValueIndex or the Label.
I've tried variations of:
Series1.XValueToText(Series1.XValue[ValueIndex])
DBChart1.BottomAxis.CalcPosPoint(X))
DBChart1[SeriesIndex].XValues[ValueIndex]
DBChart1[Series.SeriesIndex].XLabel[ValueIndex]
DBChart1[Series.SeriesIndex].XValueToText(ValueIndex)
DBChart1[Series.SeriesIndex].XValueToText(DBChart1[Series.SeriesIndex].XValue[ValueIndex])
DBChart1[Series.SeriesIndex].XValue[ValueIndex]
DBChart1[Series.SeriesIndex].XValues.Items[ValueIndex]
and nothing gives me the date except XLabel and I want the date from the series that SET that XLabel.
How do I do this?
Thanks.
I have a DBChart with the X-Axis as DateTime. In an OnSeriesClick event I know how to display the Y-Value but how do I display the actual X-Value? Not the ValueIndex or the XLabel[ValueIndex] but the actual date from the underlying CrossTab data series at that ValueIndex. Without formatting.
Every attempt I make at this returns the ValueIndex or the Label.
I've tried variations of:
Series1.XValueToText(Series1.XValue[ValueIndex])
DBChart1.BottomAxis.CalcPosPoint(X))
DBChart1[SeriesIndex].XValues[ValueIndex]
DBChart1[Series.SeriesIndex].XLabel[ValueIndex]
DBChart1[Series.SeriesIndex].XValueToText(ValueIndex)
DBChart1[Series.SeriesIndex].XValueToText(DBChart1[Series.SeriesIndex].XValue[ValueIndex])
DBChart1[Series.SeriesIndex].XValue[ValueIndex]
DBChart1[Series.SeriesIndex].XValues.Items[ValueIndex]
and nothing gives me the date except XLabel and I want the date from the series that SET that XLabel.
How do I do this?
Thanks.
Re: Actual value of XValue
Hello,
Note a TDateTime is actually a Double. So you need to format it or you'll just get a number.
Try this:
Note a TDateTime is actually a Double. So you need to format it or you'll just get a number.
Try this:
Code: Select all
FormatDateTime('dd/mm/yyy hh:nn:sss', DBChart1[SeriesIndex].XValue[ValueIndex]);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Actual value of XValue
Ok - the first segment of the series should return "31/08/2004" but instead returns "30/12/1899 00:00:00" because DBChart1[SeriesIndex].XValue[ValueIndex] is returning "0". Second segment returns "1", third segment returns "2", etc.
Similarly:
Segment Date Actual date
1 31/12/1899 30/09/2004
2 01/01/1900 31/10/2004
3 02/01/1900 30/11/2004
4 03/01/1900 31/12/2004
How do I get this to return the actual date? Do I have a setting wrong someplace?
Thanks.
Similarly:
Segment Date Actual date
1 31/12/1899 30/09/2004
2 01/01/1900 31/10/2004
3 02/01/1900 30/11/2004
4 03/01/1900 31/12/2004
How do I get this to return the actual date? Do I have a setting wrong someplace?
Thanks.
Re: Actual value of XValue
Hello,
You may have added the values with label but, if you are getting 0, 1, 2,... in the XValues array it's probably because you added the values in your series without XValue; this is through Add() function or similar.
You may have added the values with label but, if you are getting 0, 1, 2,... in the XValues array it's probably because you added the values in your series without XValue; this is through Add() function or similar.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Actual value of XValue
There is 1 series: Series1 and the Data Source is set to CrossTab with the Dataset set to a SQL query returning a Location, Total and AsOfDate . It is grouped by location (6 locations) so that the result is 6 series with the total summed for each date and the AsOfDate. Labels is set to AsOfDate. It has a Total (Y-Axis) and the AsOfDate (X-Axis).
How can I get the AsOfDate from the series? Is it because of the CrossTab and/or the chart knowing that AsOfDate is the X-Label that only the ValueIndex is returned?
Thanks.
How can I get the AsOfDate from the series? Is it because of the CrossTab and/or the chart knowing that AsOfDate is the X-Label that only the ValueIndex is returned?
Thanks.
Re: Actual value of XValue
Hello,
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Actual value of XValue
I enclose a sample project.
There are 2 examples - 2 series - one loaded with the "Add" command and one with Data Source set to Dataset. If you click on a segment in either series the results are the same. A date returned is only correct if from the XLabel. Everything else I do results in a date of 1899 or 1900 because the ValueIndex is returned instead of a date in Double format.
I would like to get the X-Axis date from the series rather than have to get the ValueIndex and go to the original data source for it.
How do I do this?
There are 2 examples - 2 series - one loaded with the "Add" command and one with Data Source set to Dataset. If you click on a segment in either series the results are the same. A date returned is only correct if from the XLabel. Everything else I do results in a date of 1899 or 1900 because the ValueIndex is returned instead of a date in Double format.
I would like to get the X-Axis date from the series rather than have to get the ValueIndex and go to the original data source for it.
How do I do this?
- Attachments
-
- TeeChartXValueResponse.zip
- (17.61 KiB) Downloaded 863 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Actual value of XValue
Hello,
Even I suggested you (via email) to use interpolation as I posted here, this will not work in your project because your series don't provide DateTime values to your series as X values, you only provide them as axis labels. What happens here is that you feed Y values and labels to your series. TeeChart fills X values with sequential values: 0, 1, 2, 3, etc. Given you set your series XValues to be DateTime and looking at, what you get are the DateTime representation of those sequential values TeeChart uses as X values. To obtain the DateTime values you expect, you should populate your series with those values. I have modified your project (find it attached) doing that for the manually populated series.
Even I suggested you (via email) to use interpolation as I posted here, this will not work in your project because your series don't provide DateTime values to your series as X values, you only provide them as axis labels. What happens here is that you feed Y values and labels to your series. TeeChart fills X values with sequential values: 0, 1, 2, 3, etc. Given you set your series XValues to be DateTime and looking at
Code: Select all
System.TDateTime
- Attachments
-
- TeeChartXValue.zip
- (7.17 KiB) Downloaded 869 times
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Actual value of XValue
Hi,
So - how do I do this from a dataset (as a data-aware control)? The issue here is that we don't want to do ANYTHING manually! A floating point number and a date (in date form - not text) are being pulled from a database table and the data source is set to crosstab. In my example, in the manually added data, it is clear where the text xvalues come from - but how is it that I can't get the actual dates from the version of the series loaded via crosstab?
How do I do this from a dataset without manually adding anything?
Thanks.
So - how do I do this from a dataset (as a data-aware control)? The issue here is that we don't want to do ANYTHING manually! A floating point number and a date (in date form - not text) are being pulled from a database table and the data source is set to crosstab. In my example, in the manually added data, it is clear where the text xvalues come from - but how is it that I can't get the actual dates from the version of the series loaded via crosstab?
How do I do this from a dataset without manually adding anything?
Thanks.
Re: Actual value of XValue
Ok - I think I see what might be happening here.
The Data Source is set to CrossTab and in the Dataset there are floating point values loaded as YValues, there is a "Group by" set to the data field I want to group by.
The X-Axis has a Dataset date field assigned as XValues but that date field is identified in the "Labels" list box. I'm guessing that the actual date values are being assigned to the series XValues as text labels rather than as the original date values I'm expecting.
How do I get the date values for the X-Axis loaded into the series in their original format so that they can be individually retrieved via a ChartClickSeries event?
Thanks.
The Data Source is set to CrossTab and in the Dataset there are floating point values loaded as YValues, there is a "Group by" set to the data field I want to group by.
The X-Axis has a Dataset date field assigned as XValues but that date field is identified in the "Labels" list box. I'm guessing that the actual date values are being assigned to the series XValues as text labels rather than as the original date values I'm expecting.
How do I get the date values for the X-Axis loaded into the series in their original format so that they can be individually retrieved via a ChartClickSeries event?
Thanks.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Actual value of XValue
Hello,
I see, the problem is setting XValues for the second series on the OnCreate event. Commenting out the line below solves the problem.
For values being visible you may also need to add the line below at the bottom of Button2Click method.
Making those changes will require changes on the scroll segments calculation and axes settings though.
I see, the problem is setting XValues for the second series on the OnCreate event. Commenting out the line below solves the problem.
Code: Select all
for I := 0 to DBChart[1].Count - 1 do
begin
DBChart[1].Labels[i]:=DateToStr(DBChart[1].XValues[i]);
//DBChart[1].XValues[i]:=i;
end;
Code: Select all
DBChart.Axes.Bottom.Automatic:=True;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |