Page 1 of 1

SOLVED -Display a circle as circle (not oval) without auto..

Posted: Tue Jun 03, 2008 9:28 am
by 10546441
Hi to all the helpful people out there !

I have a little problem in scaling a chart to the right extend.
I want to display different figures with ShapeSeries on my chart, which has a bigger width then height (1.67 times more or less).

The idea now was to use the max / min members of Bottom / Left axis to scale the chart (I want a circle displayed as a circle and a square not like a long table).

Therefor I used the following code, which does not really help me - I think it is because of the margins and maybe others setup values of TChart.

Which Width/Height Values could I use for scaling ?

minx,miny... are the real min / max values in the chart which should be displayed.

the outcommented lower part is for having a little ring of free space around the shapes.

Code: Select all


  { Es soll so skaliert werden, dass das Verhältnis auf X und Y Achse gleich
     bleibt, und im Raster quadratische Muster entstehen }
  chart.LeftAxis.Minimum   := miny; 
  chart.BottomAxis.Minimum := minx; 

  chart.LeftAxis.Maximum   := maxy; 
  chart.BottomAxis.Maximum := 
         (chart.ChartWidth  / chart.chartHeight) * maxx;

  //scale := max((maxx -minx), (maxy-miny));
  //chart.LeftAxis.Minimum   := chart.LeftAxis.Minimum - (scale * 0.1);
  //chart.BottomAxis.Minimum := chart.BottomAxis.Minimum - (scale * 0.1);
  //chart.LeftAxis.Maximum   := chart.LeftAxis.Maximum  + (scale * 0.1);
  //chart.BottomAxis.Maximum := chart.BottomAxis.Maximum + (scale * 0.1);


Posted: Tue Jun 03, 2008 10:21 am
by 10546441
There was a problem in the way I calculated the values.

It needs to be something like this:

Code: Select all

  if ((maxY-minY) / chart.ChartHeight) >= ( (maxX - minX) / chart.ChartWidth ) then
  begin
    chart.LeftAxis.Minimum   := miny;
    chart.LeftAxis.Maximum   := maxy;

    chart.BottomAxis.Minimum := (chart.ChartWidth  / chart.chartHeight) * ((maxY-minY)/(maxX-minX)) * minx;
    chart.BottomAxis.Maximum := (chart.ChartWidth  / chart.chartHeight) * ((maxY-minY)/(maxX-minX)) * maxx;
  end


Posted: Tue Jun 03, 2008 10:25 am
by narcis
Hi ChZiegelt,

Sorry but the subject means you have already found a solution to the issue?

Thanks in advance.

Posted: Tue Jun 03, 2008 11:10 am
by 10546441
Yes, the solution is my second posting.

Thanks for the reply.

Posted: Tue Jun 03, 2008 11:27 am
by narcis
Hi ChZiegelt,

Thanks for the information.

Curious, I must have been reading the first post at the moment you were posting the second since I saw the changed subject but not the second post yet.