Recent

Author Topic: proper Xaxis design  (Read 19160 times)

wp

  • Hero Member
  • *****
  • Posts: 13412
Re: proper Xaxis design
« Reply #30 on: March 09, 2015, 10:24:09 pm »
Is it possible to download these files somewhere? I must present the readers of the tutorial a way how to get the data. And of course, it must be a free download.

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper Xaxis design
« Reply #31 on: March 10, 2015, 12:07:10 pm »
wp,

i see. These data are ,in this form ,not freely available .
They originate from someone who collects  intradaydata realtime from multiple sources on the internet and builds files for his private use.

I needed these files also  for testing whilst I was adapting  your code in my application.

as i mentioned before I wanted to use multiple panes  there but i ran into an error which i could not solve and got back to your project and adapted it to read a file and i was able to reproduce the error

I followed the instructions in the panes tutorial and before the introduction of the axistransformations it was succesfull !!   see the printscreen in the attachment ( btw group=2 for all 3 axis,group=1 for bottom2

then i filled in de marks.range and the axis range of all 3 left axises and made the usemin and usemax true and put the 3 axistransformations on the chart ; set the min/max to respectively 0-1,1-2,2-10. and connected the 3 left axises to axistransformations

compiling was oke; but during debugging the SIGSEGV error came up:

in   tatransformations.pas line 672:
Code: [Select]
procedure TAutoScaleAxisTransform.ClearBounds;
begin
  inherited ClearBounds;
  with TAutoScaleTransformData(FDrawData) do begin
    FMin := SafeInfinity;          <<----------------------------------------- error
    FMax := NegInfinity;
    FOffset := 0.0;
    FScale := 1.0;
  end;
end;     

what could this be ?

frederic




« Last Edit: March 10, 2015, 12:11:20 pm by frederic »

wp

  • Hero Member
  • *****
  • Posts: 13412
Re: proper Xaxis design
« Reply #32 on: March 10, 2015, 06:02:20 pm »
Yes, I saw the same issue when I was introducing panes in my demo (which you'll find as attachment). The debugger showed me that the SIGSEGV occured in the PrepareAxis method called immediately from FormCreate. The problem here is that the chart has not yet been drawn and therefore the axis limits are not yet known. But you can enforce this calculation by adding a Chart1.Prepare to the start of PrepareAxis.

In my demo you see two series arranged in two panes. The first pane ranges between 0 and 2, the second one between 4 and 6. These numbers are specified in the Range of the AutoscaleAxisTransform and mean that the internal y axis runs between 0 and 6, the lower third (0..2) is covered by the first series, the medium third (2-4) is empty, and the upper third (4-6) is occupied by the other series.

If you want to restrict axis labels to the part of the corresponding series set the axis Marks.AtDataOnly to true. And set the title's PositionOnMarks to roughly center the axis title with respect to the corresponding series data (but centering is not very good, though...).

There is also a zero-line for the upper series (a TConstantLineSeries). I did not assign an axis to it therefore you have to set its Position to 4 (that's the internal axis value where the upper pane starts) - just to confuse you  ;) ...

Play with this demo, modify properties, see what happens and try to understand why.

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper Xaxis design
« Reply #33 on: March 11, 2015, 10:14:25 am »
wp ,

of course  , i understand now.

you introduced the constantline as separation line between the panes .
that is a good idea to provide clarity between the panes .

btw I saw that the crosshair tool needs a maximum Xaxis limitation  in order to avoid a SIGSEGV error

thanks

frederic
« Last Edit: March 11, 2015, 11:55:27 am by frederic »

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper Xaxis design
« Reply #34 on: March 17, 2015, 04:19:44 pm »
wp

Two questions


i see that some where i introduced  a mistake . In the attachment of the printscreen you see that the date indication and the stripes are not at the right place. I cannot find the cause for it.

studying your code i spotted a line in the calculation of the delta which i don't understand . please explain

Code: [Select]

...........
 while DateOf(dt) <= EndDate do begin
      // Skip weekends
      weekday := DayOfWeek(dt);
      //here will come a statement needed for check of extra free days
      if weekday in [wdSunday, wdSaturday] then begin
        dt := dt + 1;
        Continue;
      end;


      // Add date+time to axis chartsource formatted according to "format"
      days := ConvertDateTimeToDaysPassed(dt);
      s := IfThen(NoLabels, '', FormatDateTime(format, dt));
      AChartSource.Add(days, days, s);//   <<--   what is happening here PLEASE EXPLAIN
      // next label
      prev_dt := dt;
      if DELTA < 30 then begin
        dt := dt + DELTA;
        if DELTA < 1.0 then begin
          if dt > DateOf(dt) + ShopClosesAt then begin
            dt := DateOf(dt) + 1 + ShopOpensAt;
            // Remove the last label of a day if it overlaps with the first label
            // of the next day
            if LabelsOverlap(prev_dt, dt, format) then
              AChartSource.Item[AChartSource.Count-1]^.Text := '';
          end;
        end;                             

« Last Edit: March 17, 2015, 04:28:56 pm by frederic »

wp

  • Hero Member
  • *****
  • Posts: 13412
Re: proper Xaxis design
« Reply #35 on: March 17, 2015, 05:36:56 pm »
Unfortunately you do not show all your code.

The stripes are offset because they seem to have a different starting point. You must make sure that the datasources of both axes start at the same time. Maybe the first datapoint of one chartsource starts at, say, 9:00 and the other source starts at midnight. If both series go through the axis transformation then the 9:00 data point becomes 0 while the midnight data point becomes some negative fraction. Be caseful to apply the transformation correctly. To be more precise: I'd speculate that the first datapoint of the 9:00 series is "startdate + startime" (where starttime corresponds to 9:00), but the midnight data start at "startdate" only.

The "AChartSource.Add(days, days, s)" adds the number of days passed since the 1st data point ("days") as an x and y value to the chart source, along with the label "s". Using the days also for the y value, is not necessary, therefore, you can use "AChartSource.Add(days, 0, s)" (with 0 or any other value for y) as well. But maybe you want to rotate the chart (interchange x and y) sometimes in the future, hence I am inserting the value for y as well, and it does not cost anything. - It has nothing to do with the offset in time scales.

frederic

  • Full Member
  • ***
  • Posts: 226
Re: proper Xaxis design
« Reply #36 on: March 17, 2015, 09:16:36 pm »
wp

Quote
To be more precise: I'd speculate that the first datapoint of the 9:00 series is "startdate + startime" (where starttime corresponds to 9:00), but the midnight data start at "startdate" only.


your analysis was completely right!
 startdate always starts at 0:00 hours for both bottomaxises.

i did set the datetime of the first line of the file (starting at 9:01 hours) to be equal with startdate; and that is wrong.
so solved.

The second question: I now see that the y-value "days" was an arbritrary value;
oke ,that solved it!!


thanks again

frederic

 

TinyPortal © 2005-2018