Intercepting zero series values with logarithmic axes
Posted: Mon Jul 25, 2016 5:15 am
I have y-axis data that starts at zero. To plot this on a log axis, I want to change the zero value to a small positive value (e.g. 0.1) before plotting. I have created an override version of AddXY (this also changes measurement units e.g. from metres to feet), which is shown below:
At present, I am not testing for a log axis but applying this code to all graphs. It works fine for a linear axis, plotting the first y value at 0.1. However, with a log axis, the first point is not plotted. However, when I first start my program with the data already chosen and the log axis selected, the first point is correctly plotted at 0.1, but then disappears if I move away from that data set and back to it.
What I would like to know is how TeeChart handles zero numbers on a log axis. Is a zero number ignored? If so, when does this happen?
I look forward to any comments you may have.
Best regards
Errol
Code: Select all
// ------ TUnitLineSeries.AddXY ------------------------------------------------
{** add SI values aXValue, aYValue}
function TUnitLineSeries.AddXY(Const AXValue,AYValue:Double;
Const ALabel:String {$IFDEF D4}=''{$ENDIF}; AColor:TColor {$IFDEF D4}=
clTeeColor{$ENDIF}):Integer;
var
sSite,sVarXID,sVarYID :string;
LXValue,LYValue: double;
begin
LXValue := AXValue;
LYValue := AYValue;
// ** check for Depth = 0 change to 0.01 as test
if SameText(YUnitType,'Depth') and (AYValue = 0) and then
LYValue := 0.1;
result:=inherited AddXY(fxUnitObject.ConvertFromSI(LXValue,''),
fyUnitObject.ConvertFromSI(LYValue,''),ALabel,AColor);
end else
result:=0;
end;
At present, I am not testing for a log axis but applying this code to all graphs. It works fine for a linear axis, plotting the first y value at 0.1. However, with a log axis, the first point is not plotted. However, when I first start my program with the data already chosen and the log axis selected, the first point is correctly plotted at 0.1, but then disappears if I move away from that data set and back to it.
What I would like to know is how TeeChart handles zero numbers on a log axis. Is a zero number ignored? If so, when does this happen?
I look forward to any comments you may have.
Best regards
Errol