Hello,
I'm fairly new to the newsgroup so apologies if this has been asked before.
I have an xy graph with the y axis going from negative to positive: say -100 to + 100. The x axis goes from 0: say 0 to 100. I want the x axis to go through y=0, but can't find a property to make this happen. This is like the default with an xy scatter graph in Excel 2007.
Any help much appreciated.
Thanks, Ian
Draw axis through origin
Hi Ian,
Here there is an example in ActiveX. If you find problems translating it don't hesitate to let us know.
Here there is an example in ActiveX. If you find problems translating it don't hesitate to let us know.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi Ian,
Here is how I would traduce that VB6 code to delphi:
Here is how I would traduce that VB6 code to delphi:
Code: Select all
uses series, Types;
var usePercentages: Boolean;
procedure TForm1.FormCreate(Sender: TObject);
var series1: TLineSeries;
i: Integer;
begin
Chart1.View3D := false;
series1 := TLineSeries.Create(self);
Chart1.AddSeries(series1);
for i:=-5 to 10 do
Series1.AddXY(i, i, '', clTeeColor);
Chart1.OnAfterDraw := Chart1AfterDraw;
Chart1.MarginUnits := muPixels;
usePercentages := false;
Chart1.Draw;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var chartWidth, chartHeight, horizZeroLoc, vertZeroLoc: Integer;
horizPercentLoc, vertPercentLoc: Double;
begin
with Chart1.Axes do
begin
if usePercentages then
begin
chartWidth := Chart1.ChartRect.Right - Chart1.ChartRect.Left;
horizZeroLoc := Bottom.CalcXPosValue(0) - Chart1.ChartRect.Left;
horizPercentLoc := horizZeroLoc / chartWidth * 100;
Left.PositionUnits := muPercent;
Left.PositionPercent := horizPercentLoc;
chartHeight := Chart1.ChartRect.Bottom - Chart1.ChartRect.Top;
vertZeroLoc := Left.CalcYPosValue(0) - Chart1.ChartRect.Top;
vertPercentLoc := vertZeroLoc / chartHeight * 100;
Bottom.PositionUnits := muPercent;
Bottom.PositionPercent := 100 - vertPercentLoc;
end
else
begin
Left.PositionUnits := muPixels;
Left.PositionPercent := Bottom.CalcXPosValue(0) - Chart1.ChartRect.Left;
Bottom.PositionUnits := muPixels;
Bottom.PositionPercent := Chart1.ChartRect.Bottom - Left.CalcYPosValue(0);
end;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |