Recent

Author Topic: proper xaxis application  (Read 9231 times)

frederic

  • Full Member
  • ***
  • Posts: 226
proper xaxis application
« on: August 11, 2015, 04:38:53 pm »
dear specialists,

i applied the concept of the earlier thread on this subject but ran into several errors.( e.a .edrawerror,dataleaks  etc)
So i prepared a testproject to demonstrate this
But also there i ran into the problem that i couldn't show the values of the x-axis labels although all "visible"-properties were true.

this has to be solved first in order to show the other issues
can someone give me a hint?

attached the testproject in included
frederic

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #1 on: August 11, 2015, 05:24:57 pm »
Sorry I dont't want to sound arrogant, but I don't have enough time to step through 1000 lines of poorly formatted code to understand what may be wroing without knowing what is wrong. You should precisely describe the steps to reproduce the issue that you see. Which buttons to click, in which order, any input required, and what do you expect in which situation of the program?
« Last Edit: August 11, 2015, 06:14:43 pm by wp »

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper xaxis application
« Reply #2 on: August 12, 2015, 04:06:41 pm »
Wp ,
 when i reread my question i can understand your reaction ;you are right; i can compress it

I changed the testproject( see new one attached) a little bit.So forget my former testproject

When you start up the project ,click “makegraph “button on the toolbar.

The  graphfrm will show up with chart1 on it.
The “chart”of the Xaxisseries is the horizontal line with value 5 .
The values for the xaxis are not shown although the values are known in the timechartsource and the datechartsource. That is problem i couldn't solve.


but let me also explain a little bit further:
The difference with the earlier thread is that now everything is derived from socalled bars( time increments from 1 min (here in the testproject)  to 200 min or more).
The Xaxis should be presented as you have shown in the former thread.  The bars position is determined by the “days”variable;
An extra complication ,that is introduced ,is the possibility that the opening hours per day may vary and we have specialdays ( often the Monday,but also other days, are not a working days or not full working days) The feederunit  in the project (for simplicity,now set with a fixed opening and closing)will take care of all that and present  bar arrays from which the dt -data, daybegin,weekbegin and monthbegin  will be derived in order to construct the Xaxis . 

This the reason why i am modifying the “updatelabels” procedure and it but becomes more complicated .

frederic

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #3 on: August 12, 2015, 05:56:08 pm »
After setting a breakpoint at the end of the UpdateAxisLabels method I see that the method always ends with AChartSource.Count = 0. This seems to originate in the line "if dt > 1" because in the line before that you get "dt" from the element FdubDTTime[0] which has not been initialized in "SetGraphXaxisArray22" and has the value 0 (your init loop runs from 1 to n, but dynamic arrays are 0-based).

I am not sure if this is the main cause of your issue, but I think I cannot help you in more detail because this would require in-depth understanding of your code. Use the debugger to step through every line of every procedure, or add "WriteLn" calls to check temporary values of more complex variables which the debugger cannot resolve,  and compare each value with what you would expect.

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper xaxis application
« Reply #4 on: August 13, 2015, 05:19:38 pm »
ooh ,
i had played around with  the starting conditions.
your suggestion to use writeln calls mixed me up in other kind of issue',not for this thread.
i will come back when i am further.
thanks so far

frederic


wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #5 on: August 13, 2015, 07:08:24 pm »
Quote from: frederic
suggestion to use writeln calls
Just in case you don't know if you are on Windows and want to write to the console: Calling "WriteLn" from the gui requires to uncheck the "Win32 gui application" in the "Project options" / "Compiler options" / "Config and target" / "Target-specific options"
« Last Edit: August 13, 2015, 09:26:58 pm by wp »

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #6 on: August 13, 2015, 09:57:40 pm »
Let me summarize your description in my own words to make sure that I understand everything and remember to other thread correctly:
  • Your x data are equally spaced, at some predefined intervals (minutes) - is that what you call "bars"?
  • Data are collected / available only during a given time interval per day (beginning at "FOpeningTimeArr[]" and ending at "FClosingTimeArr[]", and only on working days (i.e. normally between Mo and Fr, except for some holidays known to the program)
  • There are two x axes: a coarse one labelled by date, and a fine one labelled by times.
  • Labels must not be drawn in the data gaps (time between closingtime of one day and openingtime of the next day, non-working days), i.e. a line series must not show a x gap over the weekend and over night. In a line series, can the last data point of a day be connected with the first data point of the next day? Or do you want only the contiguous data of each day be connected?
  • Labels must adapt to zooming and chart resizing. For example, at larger magnification, the label interval should become smaller
  • Labels must not overlap and must be "nice" numbers (i.e. every 10 minutes, not every 13.5 minutes, or every 2 days, not every 2.5 days)
  • Please define the "nice" intervals for the dates and times. I'd propose
    - date interval: 1 day, 2 days, 7 days, 1 month, 2 months, 3 months
    - time intervals: 6 hours, 3 hours, 2 hours, 1 hour, 30 min, 15 min, 10 min, 5 min, 1 min
A question to your program (maybe I have asked it already in the other thread): Why do you have an xaxisseries?

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper xaxis application
« Reply #7 on: August 15, 2015, 10:17:19 pm »
Wp ,i am sorry not to react earlier,

Quote
Just in case you don't know if you are on Windows and want to write to the console: Calling "WriteLn" from the gui requires to uncheck the "Win32 gui application" in the "Project options" / "Compiler options" / "Config and target" / "Target-specific options"

i tried that, but the console creen remained black !
  I started an other thread in the general forum,which solved the problem in an acceptable way.
But I learned the advantage of using writewln calls instead of memo because  one can use it anytime also in units without form.
 Disadvantage, however it appeared ,that one has to open and close the file in the same function/procedure.

Quote
Your x data are equally spaced, at some predefined intervals (minutes) - is that what you call "bars"?

 Oh ,I see ,I need to be more specific about my intentions.
The  Y-data  which will be displayed in the chart will be based on  chosen  multiminute time increment.
However not all sizes of  time increments will fit exactly between opening and closing time on a day .So i decided that the size of all time increment the day will be kept the same exept the last one. The last timeincrement on a day may be increased to maximum 1.50001 times the choosen time increment.

For x-axis value display this will have no consequenses ; the X-value of all XY data is a “double”value based on the “daysvalue” as in the earlier thread.

Quote
Data are collected / available only during a given time interval per day (beginning at "FOpeningTimeArr[]" and ending at "FClosingTimeArr[]", and only on working days (i.e. normally between Mo and Fr, except for some holidays known to the program)
yes


Quote
There are two x axes: a coarse one labelled by date, and a fine one labelled by times.
yes
 For the display there are these 2 axes. The most important;however, is the most important is the virtual one ,the 'days' variable (see former thread).All chart data will arrive as x,y  = days, yvalue.

Quote
Labels must not be drawn in the data gaps (time between closingtime of one day and openingtime of the next day, non-working days), i.e. a line series must not show a x gap over the weekend and over night. In a line series, can the last data point of a day be connected with the first data point of the next day?
  Yes

Quote
Or do you want only the contiguous data of each day be connected?
No

Quote
Labels must adapt to zooming and chart resizing. For example, at larger magnification, the label interval should become smaller
yes

Quote
Labels must not overlap and must be "nice" numbers (i.e. every 10 minutes, not every 13.5 minutes, or every 2 days, not every 2.5 days)

yes,dateinterval     1 day,
                          1 week(starting first workday in week,ending last workday in week) ,
                          1 month(starting first workday in month,ending last workday in month)
     time interval      1 min,5 min,10 min,60 min ,120 min

The original reason for the use of Xaxisseries is the requirement to be able to see the xaxis also beyond the current available XY chart data.
By deriving the values by using the crosshair ,it can be a great help  with preparation of designing  possible projections .
It offers further greater flexibility  and accuracy then to base everything on bars .


frederic
« Last Edit: August 16, 2015, 11:54:51 am by frederic »

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #8 on: August 15, 2015, 11:44:19 pm »
Ah, I forgot: Opening and closing times are always the same? Or could it be that, for example on New Year's Eve, closing occurs earlier?

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper xaxis application
« Reply #9 on: August 16, 2015, 11:53:56 am »
wp
opening and closingtimes  are not always the same.

therefore FOpeningTimeArr[]" and "FClosingTimeArr[] are part of input for procedure SETgraphXaxisarray22.
So per workday opening and closingtimes are known.

b.t.w both arrays are integer arrays show the minuteof theday



frederic

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #10 on: August 16, 2015, 01:50:05 pm »
Storing opening/closing times in an array will make a labelling procedure very unflexible. If your program stores them for this year then your program won't work any more in 2016!

Is there a way to determine the opening/closing time for a specific day? I am thinking of using the first data point of a day for the opening time and the last data point for the closing time.

Quote
b.t.w both arrays are integer arrays show the minuteof theday
You mean that these times are given as the count of minutes after midnight? Why that? Why don't you use TTime?

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper xaxis application
« Reply #11 on: August 16, 2015, 04:47:01 pm »
Quote
Is there a way to determine the opening/closing time for a specific day? I am thinking of using the first data point of a day for the opening time and the last data point for the closing time.

so i started also,but was confronted with the fact it may be that not every first minute or last minute was filled with data ; unfortunately ,there are gaps in the data supply. Therefore I had to make sure that the timeline (the axis is always complete) otherwise the basis for making good projections would fail .Having said that ,i realised that an axis based on the smallest timeincrement available(1 minute) ,would be the best solution;  Even better than the " days"variable.

The feederunit will get its opening and closing times from a special Times-unit. This unit can make a file per year which lists 365 days indicating per day :workday (or not) with opening and closing minute per day. When opening/closingtimes of a shop change that can easily be corrected in the list .Of course ,each year has its own specific list and needs to be updated according to the latest knowledge

Quote
You mean that these times are given as the count of minutes after midnight? Why that? Why don't you use TTime?

yes,these times are given as the count of minutes after midnight
you can use TTtime as well ,but in my case a lot of the calculations were based on minutes

« Last Edit: August 16, 2015, 04:51:28 pm by frederic »

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #12 on: August 16, 2015, 05:15:47 pm »
Quote
making good projections
Huh, what's that? Do you want to make a trend analysis, fit a curve? Fiddling with gaps in the data will affect the result. So far, I had the impression that you only want a "nice" x axis.

Still under the assumption that this is an axis labelling topic: What is the problem if the "official" opening time is 9:00, but the first data set is available only at 9:02. The axis labels of this day still can begin at 9:00. What if such gaps occur during the day?

Sorry for all these questions. But I am thinking of finding a more general solution (although I fear that your requirements are too special)
« Last Edit: August 16, 2015, 05:21:59 pm by wp »

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper xaxis application
« Reply #13 on: August 17, 2015, 10:39:42 am »
yes ,it is still the nice x-axis question without overlapping labels during zooming

but also, yes as i explained , this x-axis will be used in an application were trend analysis will be made.

So the  construction of the xaxis should should not be affected by the the wish to have no overlapping .

Quote
What is the problem if the "official" opening time is 9:00, but the first data set is available only at 9:02. The axis labels of this day still can begin at 9:00.

as long the labeling starts and ends at the right times  every day then it ist oke. But to make it clearer: a day1 (FROM 9-18 H) and day2( 9-12h) need to have a different x-axis spacing .
I see that the range of shop opening hours range from 5 to 14 hours; this might change the overlapping rules for the date-time labels

Quote
Sorry for all these questions. But I am thinking of finding a more general solution
it is better to explain what and why I want to change certain things; when it goes too far then i have to step back and accept that overlapping in certain situations is unavoidable.

frederic
« Last Edit: August 17, 2015, 11:44:13 am by frederic »

wp

  • Hero Member
  • *****
  • Posts: 13625
Re: proper xaxis application
« Reply #14 on: August 17, 2015, 07:35:40 pm »
Coming back to your program: Did you follow the input with the unitialized  FdubDTTime[0]? This originates in the line "for n:=1 to Ffutmaxbars do ..." of Tstdchartfrm.SetGraphXaxisArray22 where n := 0 is not used.

Moreover, there is another missing assignment for the index 0 in TForm1.makeXaxarray. Here "mm" is set to 0, and later incremented by 1 ("mmm:=mmm+1") before a value is assigned to "FDTXAxarr1[mmm]", i.e. FDTXAxarr1[0] is never touched. And in the before-mentioned SetGraphXaxisArray22 this array serves as the source for FdubDTTime.

The axis labels show up after initializing "mm" with -1, and starting the n loop of the first paragraph with 0.

As I said before, all these details are very confusing to me, and I am not going to find all these logical bugs for you, they are not related to TAChart - sorry. Just one hint: Before getting the axis labels right, fix all these issues on the basis of your "virtual" axis units.

What I can offer is to try to improve the TDateTimeIntervalChartSeries to get nicer axis labels for the average application, but I am almost sure that this will not fix your very special requirements.
« Last Edit: August 18, 2015, 11:49:42 am by wp »

 

TinyPortal © 2005-2018