zoom chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
JimR
Newbie
Newbie
Posts: 36
Joined: Tue Dec 05, 2017 12:00 am

Re: zoom chart

Post by JimR » Thu Jan 11, 2018 6:30 pm

Clicking the "make iso axes" does make the 3D plot isometric but makes inefficient use of the window. If, for example, one uses a custom fill of 50, 50, and 50 and fill data 50x50x50 then the plot is crowded into the bottom left corner and most of the volume of the plot is empty. See the attached plot. Is there an option to have it more efficiently fill the available window while still keeping it isometric?

Thanks,
Attachments
Screen Shot 01-11-18 at 08.23 AM.PNG
Screen Shot 01-11-18 at 08.23 AM.PNG (114.73 KiB) Viewed 16389 times

JimR
Newbie
Newbie
Posts: 36
Joined: Tue Dec 05, 2017 12:00 am

Re: zoom chart

Post by JimR » Wed Jan 24, 2018 11:36 pm

When I looked closer at the demo I see a problem. Am I not using the demo program correctly? I clicked on generate data (I chose values of 10, 20, and 30 for x, y, z ranges) and then clicked on the make iso button. Seems to look ok but if I click on the rotate speed button and then rotate the plot in various directions it become evident that even though the x,y plane seems to stay iso (the grid makes nice squares) the x,z and y,z planes are not iso. The grids make rectangles now even if I click the make iso button again. I used the original binary file that was uploaded to avoid any problems with a recompile on my computer (however the result were identical).

The first attachment is the yz view and the second is the x,z view. I have rotated the view to as orthogonal as possible to the planes. The x,z screenshot looks generally ok but if you measure them they are off.

I would like to get this to work but my users will expect the results to be exact.

Thanks
Attachments
Screen Shot 01-24-18 at 01.16 PM.PNG
Screen Shot 01-24-18 at 01.16 PM.PNG (13.46 KiB) Viewed 16367 times
Screen Shot 01-24-18 at 01.18 PM.PNG
Screen Shot 01-24-18 at 01.18 PM.PNG (9.34 KiB) Viewed 16367 times

JimR
Newbie
Newbie
Posts: 36
Joined: Tue Dec 05, 2017 12:00 am

Re: zoom chart

Post by JimR » Thu Feb 08, 2018 9:26 am

I have looked at this iso problem some more. I have provided below the iso function I use.It is very similar to others posted on this forum but I don't believe the others take into account the margins around the plot.

Code: Select all

procedure TPlot2DuxF.ISO(Sender: TObject);
var
  MarginsSize, XYScreen: double;
  ChartSizeAdjustment: integer;
  newBottomAxisWidth, NewLeftAxisHeight: integer;
  ScreenAspectRatio, DataAspectRatio: double; { W/H }
begin
  // Does not work for a maximized window because it cannot change the shape of the screen!
  // code adjusts the length of the left and bottom axes and thus the size of the chart and
  // assumes that the window will change in size to accommodate.
  Chart.Axes.Left.Automatic := false;
  { needed to get Axis min and max not data }
  Chart.Axes.bottom.Automatic := false;
  XYScreen := 1.0 * (GetDeviceCaps(Canvas.Handle, HORZSIZE) / Screen.Width) /
    (GetDeviceCaps(Canvas.Handle, VERTSIZE) / Screen.Height);

  if ((Chart.BottomAxis.Maximum - Chart.BottomAxis.Minimum) > 0) and
    ((Chart.BottomAxis.Maximum - Chart.BottomAxis.Minimum) > 0) then
  begin { data exists in chart, safe to rescale }
    ScreenAspectRatio := (Chart.ChartWidth / Chart.ChartHeight) / XYScreen;
    DataAspectRatio := (Chart.BottomAxis.Maximum - Chart.BottomAxis.Minimum) /
      (Chart.LeftAxis.Maximum - Chart.LeftAxis.Minimum);

    if DataAspectRatio > ScreenAspectRatio then
    begin { form too high, expand Width }
      newBottomAxisWidth := round(Chart.ChartHeight * DataAspectRatio);
      ChartSizeAdjustment := newBottomAxisWidth - Chart.ChartWidth;
      if Chart.MarginUnits = muPercent then { allow for margins }
        MarginsSize := (Chart.MarginLeft + Chart.MarginRight) / 100
      else
        MarginsSize := 0;
      Plot2DuxF.ClientWidth := self.ClientWidth - Chart.ChartWidth +
        newBottomAxisWidth + round(MarginsSize * ChartSizeAdjustment);
    end
    else
    begin { form too wide, expand Height }
      NewLeftAxisHeight := round(Chart.ChartWidth / DataAspectRatio);
      ChartSizeAdjustment := NewLeftAxisHeight - Chart.ChartHeight;
      if Chart.MarginUnits = muPercent then // allow for margins
        MarginsSize := (Chart.MarginTop + Chart.MarginBottom) / 100
      else
        MarginsSize := 0;
      Plot2DuxF.ClientHeight := self.ClientHeight - Chart.ChartHeight +
        NewLeftAxisHeight + round(MarginsSize * ChartSizeAdjustment);
    end;
  end;
  Chart.Invalidate;
end { ISO };
I call this from a procedure that detects the end of a user resizing/moving the form.

This simple approach cannot work for the 3D case because the apparent lengths of the axes vary depending on the rotation angle of the plot. It is not sufficient to assume the plot is an orthogonal plot at 45 degrees. I hope someone can figure out a general solution and incorporate it into TChart. Until then I must untangle my 3D scatterplot from the TChart environment as my plots must exactly preserve the 3D aspect ratios as a user rotates the plot. A shame as I have put in a lot of time trying to find a way to make it work. I believe it should be implemented internally to the TChart component.

Jim

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: zoom chart

Post by Marc » Fri Feb 09, 2018 4:34 pm

Hello Jim,

Ok, we'll have another look. Orthogonal did bring down the variables and makes it more controllable but is not true isometric. If we were to fix 120º angles between the planes it would be truer to the definition of isometric projection and would be the only setup at which each plane of equal value have the same physical length on a 2D screen. Rotation would be of that chart. The re-dimensioning of the Chart to take up more space for working values after ISO is applied is an extra challenge.

Example attached.
iso_teechart.gif
TeeChart rotation, OpenGL
iso_teechart.gif (1.89 MiB) Viewed 16325 times
Regards,
Marc
Steema Support

JimR
Newbie
Newbie
Posts: 36
Joined: Tue Dec 05, 2017 12:00 am

Re: zoom chart

Post by JimR » Mon Feb 12, 2018 2:43 am

One problem in communicating is that I have been using term "isometric" a bit loosely to match some other posts. What is needed is to be able to plot so that a cube would stay a cube or a sphere a sphere while being rotated arbitrarily. The strict definition is just an orthogonal view at 45 degrees (an earlier posting does that quite well). However, a more general solution is needed.

Yes, more trouble but in many applications it is essential. If plotting a skull, for example, one would not want it to distort in shape as it is rotated. What has to be done is to make the plot correctly scaled in a 3D virtual space and then just project everything down to the 2D canvas. I am sure that is what is being down already except for the proper scaling of axes in the virtual 3D space before it is projected onto the canvas.

Something else to note from my example 2D code above is that when I scale the plot I do not extend the ranges of the axes so as to keep the chart the same size. I adjust the size of the chart as needed to fit axes appropriate for my data (my example is a little crude I am working on making it have a more expected behavior when a user resizes the window. The same would be needed for 3D. Different rotations should just give different views of the same object. I guess that could be an option.

I would very much appreciate any work you could do on this problem.

Jim

JimR
Newbie
Newbie
Posts: 36
Joined: Tue Dec 05, 2017 12:00 am

Re: zoom chart

Post by JimR » Fri Apr 20, 2018 11:52 pm

Any new progress on this problem for 3D plots?

Jim

Marc
Site Admin
Site Admin
Posts: 1209
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: zoom chart

Post by Marc » Mon Jul 16, 2018 7:05 am

Hello Jim,

Sorry, we're just finding it difficult to get resource time on this. I'll close this thread as it seems the conversation has moved to:

http://www.teechart.net/support/viewtop ... =3&t=16902

I'll make new comments there.

Regards,
Marc
Steema Support

Post Reply