Page 1 of 1

TeeChart Pro 2013 and TDottedGrayPen

Posted: Mon Feb 17, 2014 4:52 am
by 16566546
I have recently upgraded from TeeChart 8 to TeeChart 2013. I now have a problem with the Get_DottedGrayPen in the following code. Grid is now interpreted as TAxisGridPen, not TDottedGrayPen.

Code: Select all

procedure TformMultipleUnitPrint.Get_AxisTicks(doc:TDOMDocumentXPath;sprefix:string;
  aAxis:TChartAxis);

const
  sGRIDCENT = '/ticks/gridcentered';
  sTICKLEONLY = '/ticks/tickonlabelsonly';
  sTICKLEN = '/ticks/ticklength';
  sTICKINNERLEN = '/ticks/tickinnerlength';

begin
  with aAxis do
  begin
    GridCentered := XMLReadBoolean(doc,sPrefix+sGRIDCENT,GridCentered);
    TickOnLabelsOnly:=XMLReadBoolean(doc,sPrefix+sTICKLEONLY,TickOnLabelsOnly);
    TickLength := XMLReadInteger(doc,sPrefix+sTICKLEN,TickLength);
    TickInnerLength:=XMLReadInteger(doc,sPrefix+sTICKINNERLEN,TickInnerLength);
    Get_ChartAxisPen(doc,sPrefix+'/ticks/axis',Axis);
    Get_DottedGrayPen(doc,sPrefix+'/ticks/grid',Grid);    /// <<< Problem here >>>
    Get_DarkGrayPen(doc,sPrefix+'/ticks/ticksmain',Ticks);
    Get_DarkGrayPen(doc,sPrefix+'/ticks/ticksinner',TicksInner);
  end;
end;

procedure TformMultipleUnitPrint.Get_DottedGrayPen(doc:TDOMDocumentXPath;sP:string;
  aPen:TDottedGrayPen);

const
  sCOL = '/colour';
  sENDSTYLE = '/endstyle';
  sSMALLDOTS = '/smalldots';
  sSTYLE = '/style';
  sVISIBLE = '/visible';
  sWIDTH = '/width';

var
  sResult : string;

begin
  with aPen do
  begin
    Visible := XMLReadBoolean(doc,sP+sVISIBLE,Visible);
    SmallDots := XMLReadBoolean(doc,sP+sSMALLDOTS,SmallDots);
    Width := XMLReadInteger(doc,sP+sWIDTH,Width);
    Color := XMLReadColor(doc,sP+sCOL,Color);

{** end style}
    sResult := ReturnXResult(doc,sP+sENDSTYLE);
    if (sResult <> '') then
    begin
      if (sResult = 'esRound') then
        EndStyle := esRound
      else if (sResult = 'esSquare') then
        EndStyle := esSquare
      else if (sResult = 'esFlat') then
        EndStyle := esFlat;
    end;

{** style}
    sResult := ReturnXResult(doc,sP+sSTYLE);
    if (sResult <> '') then
    begin
      if (sResult = 'psSolid') then
        Style := psSolid
      else if (sResult = 'psDash') then
        Style := psDash
      else if (sResult = 'psDot') then
        Style := psDot
      else if (sResult = 'psDashDot') then
        Style := psDashDot
      else if (sResult = 'psDashDotDot') then
        Style := psDashDotDot
      else if (sResult = 'psClear') then
        Style := psClear
      else if (sResult = 'psInsideFrame') then
        Style := psInsideFrame;
    end;
  end;
end;


Re: TeeChart Pro 2013 and TDottedGrayPen

Posted: Mon Feb 17, 2014 10:50 am
by yeray
Hello Errol,

It would be helpful if you could simplify it to the maximum, but still in a project you can send us and we can run as-is to reproduce the problem here.

Thanks in advance.

Re: TeeChart Pro 2013 and TDottedGrayPen

Posted: Mon Feb 17, 2014 8:39 pm
by 16566546
As I did not write this code and am not familiar with this part of TeeChart, it will take much work to write a test program that reproduces this error. This code worked with TeeChart 8 and now doesn't work with TeeChart 2013. It appears that Grid is now interpreted as a property of TAxisGridPen whereas formerly it must have been interpreted as a property of TDottedGrayPen. Has there been a change of properties for these classes?

I have simplified the problem code and copied it below.

Code: Select all

procedure TformMultipleUnitPrint.Get_AxisTicks(doc:TDOMDocumentXPath;sprefix:string;
  aAxis:TChartAxis);

begin
  with aAxis do
    Get_DottedGrayPen(doc,sPrefix+'/ticks/grid',Grid);  // this line fails because Grid is not  a TDottedGrayPen type
end;

procedure TformMultipleUnitPrint.Get_DottedGrayPen(doc:TDOMDocumentXPath;sP:string;
  aPen:TDottedGrayPen);

begin
// code
end;

Re: TeeChart Pro 2013 and TDottedGrayPen

Posted: Wed Feb 19, 2014 3:07 pm
by narcis
Hi Errol,

Both classes, TDottedGrayPen and TAxisGridPen inherit from TTeePen. Just change TformMultipleUnitPrint.Get_DottedGrayPen signature so that aPen is a TAxisGridPen instance. For example:

Code: Select all

procedure TformMultipleUnitPrint.Get_DottedGrayPen(doc:TDOMDocumentXPath;sP:string;
  aPen:TAxisGridPen);

begin
// code
end;

Re: TeeChart Pro 2013 and TDottedGrayPen

Posted: Wed Feb 19, 2014 7:56 pm
by 16566546
Narcis - your suggested change seems to have fixed the problem as the code now compiles. Thanks.