Page 2 of 2

Re: zoom chart

Posted: Thu Jan 11, 2018 6:30 pm
by 16582473
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,

Re: zoom chart

Posted: Wed Jan 24, 2018 11:36 pm
by 16582473
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

Re: zoom chart

Posted: Thu Feb 08, 2018 9:26 am
by 16582473
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

Re: zoom chart

Posted: Fri Feb 09, 2018 4:34 pm
by Marc
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 16374 times
Regards,
Marc

Re: zoom chart

Posted: Mon Feb 12, 2018 2:43 am
by 16582473
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

Re: zoom chart

Posted: Fri Apr 20, 2018 11:52 pm
by 16582473
Any new progress on this problem for 3D plots?

Jim

Re: zoom chart

Posted: Mon Jul 16, 2018 7:05 am
by Marc
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