I have to save a scaled chart in a bitmap, that means I computed the size of the bitmap, the length of axes and the start position of axis in pixel.
I try to change the chart with Chart1.Width, Chart1.Height, Chart1.LeftAxis.IStartPos, Chart1.BottomAxis.IStartPos, Chart1.LeftAxis.IAxisSize and Chart1.BottomAxis.IAxisSize. If I look on my bitmap, the bitmap size is correct, but the axes length is not correct.
What can I do?
Best regards
Roland
save scaled chart as bitmap
Sorry, I forgot:
I work with Delphi 7 and TeeChart 8.04 VCL.
I try to change the Chart with this code:
Chart1.Height:=iLeft+iBreit+iRight;
Chart1.Width:=iTop+iLang+iBottom;
Chart1.MarginUnits:=muPixels;
Chart1.MarginLeft:=iTop;
Chart1.MarginBottom:=iLeft;
Chart1.MarginRight:=iBottom;
Chart1.MarginTop:=iRight;
Chart1.LeftAxis.IAxisSize:=iBreit;
Chart1.BottomAxis.IAxisSize:=iLang;
I work with Delphi 7 and TeeChart 8.04 VCL.
I try to change the Chart with this code:
Chart1.Height:=iLeft+iBreit+iRight;
Chart1.Width:=iTop+iLang+iBottom;
Chart1.MarginUnits:=muPixels;
Chart1.MarginLeft:=iTop;
Chart1.MarginBottom:=iLeft;
Chart1.MarginRight:=iBottom;
Chart1.MarginTop:=iRight;
Chart1.LeftAxis.IAxisSize:=iBreit;
Chart1.BottomAxis.IAxisSize:=iLang;
Hi Roland,
If we understand well what you are trying to do, why don't you do like this?
Then save your chart to a bitmap:
If that's not what you want, please, try to explain what are you exactly trying to achieve.
If we understand well what you are trying to do, why don't you do like this?
Code: Select all
Chart1.CustomChartRect := true;
Chart1.ChartRect := Rect(50,50,Chart1.Width-100,Chart1.Height-100);
Code: Select all
Chart1.SaveToBitmapFile(filename,Chart1.ChartRect);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
In my software I compute the size of horizontal and vertical axis in pixel. Now I want to create a bitmap of the chart
with the exact length of axes in pixel.
Example:
The resulting bitmap has the correct size (1030 x 1560 Pixel).
The horizontal axis begins at pixel 63 and stops at pixel 1000 (length 937 pixel - not 830).
The vertical axis begins at pixel 83 and end at pixel 1497 (lenght 1414 pixel - not 1340).
Thanks!
Roland
with the exact length of axes in pixel.
Example:
Code: Select all
iLeft:=90;
iTop:=100;
iWidth:=830; {length of horizontal axis in pixel}
iRight:=110;
iBottom:=120;
iHeight:=1340;
iWidth:=830; {length of vertical axis in pixel}
iRight:=60;
iBottom:=60;
iHeight:=1340;
Chart1.Width:=iLeft+iWidth+iRight;
Chart1.Height:=iTop+iHeight+iBottom;
Chart1.LeftAxis.IAxisSize:=iHeight;
Chart1.BottomAxis.IAxisSize:=iWidth;
Chart1.SaveToBitmapFile(SavePictureDialog1.Filename);
The horizontal axis begins at pixel 63 and stops at pixel 1000 (length 937 pixel - not 830).
The vertical axis begins at pixel 83 and end at pixel 1497 (lenght 1414 pixel - not 1340).
Thanks!
Roland
Hi Roland,
I'm not sure to understand what are you exactly trying to do. You are setting iWidth, iRight, iBottom and iHeight and you are resetting them before using. And with this code, I get an image with different size and different chart size than what you say.
Here is how I would do to obtain the image you seem to wish:
I'm not sure to understand what are you exactly trying to do. You are setting iWidth, iRight, iBottom and iHeight and you are resetting them before using. And with this code, I get an image with different size and different chart size than what you say.
Here is how I would do to obtain the image you seem to wish:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var imageWidth, imageHeight, ChartWidth, ChartHeight: Integer;
begin
imageWidth := 1030;
imageHeight := 1560;
ChartWidth := 830;
ChartHeight := 1340;
Chart1.Width:=imageWidth;
Chart1.Height:=imageHeight;
Chart1.CustomChartRect := true;
Chart1.ChartRect := Rect((imageWidth-ChartWidth) div 2,(imageHeight-ChartHeight) div 2,
ChartWidth+((imageWidth-ChartWidth) div 2),ChartHeight+((imageHeight-ChartHeight) div 2));
Chart1.SaveToBitmapFile('C:\tmp\myChart.jpg');
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Yeray,
that's exactly what I try to code...
I have a well log and have to create a Bitmap with a vertical depth axis from top down into the borehole (for a given scale like 1cm = 40 m) and a horizontal axis with the result of a physical measurement (for a given scale too).
Now, you have solved my problem.
Thank you.
Roland
that's exactly what I try to code...
I have a well log and have to create a Bitmap with a vertical depth axis from top down into the borehole (for a given scale like 1cm = 40 m) and a horizontal axis with the result of a physical measurement (for a given scale too).
Now, you have solved my problem.
Thank you.
Roland