Page 1 of 2

Dash line appearing as straight line

Posted: Tue May 10, 2011 11:39 am
by 10551566
Hi,

In the editor I set the style of a line series to dash lines but in the report where the chart is printed it always appears as a straight line. Any idea why this is happening?

Regards,
Vincenzo

P.S. Cannot attache screen-shots as an error message appears saying the board quota has been reached.

Re: Dash line appearing as straight line

Posted: Tue May 10, 2011 12:36 pm
by 9350556
Which version of Delphi and TeeChart are you using?

Re: Dash line appearing as straight line

Posted: Tue May 10, 2011 1:05 pm
by 10551566
Delphi 2009 and TeeChart Pro V.8.04.11395 Win32

Re: Dash line appearing as straight line

Posted: Tue May 10, 2011 1:22 pm
by 9350556
Hm, I don't have version 8 but I know that 8.04 is not the latest release. My suggestion is to install 8.08 and see if the problem persists.

Re: Dash line appearing as straight line

Posted: Tue May 10, 2011 3:01 pm
by yeray
Hello,

Yes, please try it with the latest release available at the client area and, if the problem persists, please tell us what reporting component are you using and try to arrange a simple example project we can run as-is to reproduce the problem here.

Thanks in advance.

Re: Dash line appearing as straight line

Posted: Tue May 10, 2011 3:42 pm
by 10551566
Hi,

Thanks for your replies. It's not crucial for me to have a dashed line and installing the latest version just to try it out is too much hassle (have to re-install my current version again later).

Regards,
Vincenzo

Re: Dash line appearing as straight line

Posted: Thu May 12, 2011 11:38 am
by yeray
Hello Vincenzo,

I understand it's not a critical problem but we'll be pleased to take a look at it if we can reproduce it here. But to do so, we'd need to know what reporting component are you using and it would be also really helpful if we could have a simple example project we can run as-is to reproduce the problem here.

Re: Dash line appearing as straight line

Posted: Thu May 12, 2011 2:15 pm
by 10551566
Hi Alonso,

Meanwhile I found out that it has nothing to do with the report component. The line is shown as straight line (instead of dashed) if the vertical axis assigned is the right one (if it's the left it's drawn correctly as dashed). I have created a small example program if you need it, where can I upload it?

Regards,
Vincenzo

Re: Dash line appearing as straight line

Posted: Fri May 13, 2011 9:28 am
by narcis
Hi Vincenzo,

You can attach files to this forums board in your replies. You can compress your project in a zip packages and attach it to your reply.

Thanks in advance.

Re: Dash line appearing as straight line

Posted: Fri May 13, 2011 12:13 pm
by 10551566
Sample program attached.

Re: Dash line appearing as straight line

Posted: Mon May 16, 2011 11:13 am
by yeray
Hello Vincenzo,

The problem here is that the distance between each two points isn't enough for the Dash pen style to be noticed. Note that the line series is drawn in segments.
Here you have an example:

Code: Select all

uses Chart, Series;

var Chart1: TChart;
    Series1: TLineSeries;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;

  Chart1.Color:=clWhite;
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;
  Chart1.Axes.Bottom.Grid.Visible:=false;
  Chart1.Axes.Left.Grid.Visible:=false;

  Series1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
  Series1.Pen.Style:=psDash;
  for i := 0 to 10 do
    Series1.Add(12+i);

  //Series1.Pointer.Visible:=true;

  Chart1.Axes.Bottom.SetMinMax(0, 20);
  Chart1.Axes.Left.SetMinMax(10, 22);

  Chart1.Draw;
end;

procedure TForm1.FormPaint(Sender: TObject);
var YDispl, XDispl, i: Integer;
begin
  YDispl:=300;
  XDispl:=50;
  with Self.Canvas do
  begin
    Pen.Style:=psDash;
    MoveTo(Series1.CalcXPos(0),Series1.CalcYPos(0)+YDispl);
    LineTo(Series1.CalcXPos(Series1.Count-1),Series1.CalcYPos(Series1.Count-1)+YDispl);

    for i:=0 to Chart1[0].Count-2 do
    begin
      MoveTo(Series1.CalcXPos(i)+XDispl, Series1.CalcYPos(i)+YDispl);
      LineTo(Series1.CalcXPos(i+1)+XDispl, Series1.CalcYPos(i+1)+YDispl);
    end;
  end;
end;
An option would be to use psDot style instead of psDash.

Find here a more complete explanation of it.

Re: Dash line appearing as straight line

Posted: Mon May 16, 2011 12:06 pm
by 10551566
Hi,

Thanks for investigating this, I do understand the explanation but nevertheless it would be good if Teechart would automatically convert to dot (or shorter lines) if dashes cannot be drawn.

Regards,
Vincenzo

Re: Dash line appearing as straight line

Posted: Tue May 17, 2011 11:46 am
by yeray
Hi Vincenzo,

TeeChart could include it (or better, the option to check it or not, for not to break backwards compatibility) but it would mean many new conditions (one for each segment to be drawn) so it could affect the performance even for those who use psSolid but have thousands of points.
So I'd suggest you to check it in your code. The following works for me here:

Code: Select all

uses Chart, Series, TeCanvas;

var Chart1: TChart;
    Series1: TLineSeries;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    d: double;
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;

  Chart1.Color:=clWhite;
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;
  Chart1.Axes.Bottom.Grid.Visible:=false;
  Chart1.Axes.Left.Grid.Visible:=false;

  Series1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
  Series1.Pen.Style:=psDash;
  for i := 0 to 10 do
    Series1.Add(12+i);

  Chart1.Axes.Bottom.SetMinMax(0, 20);
  Chart1.Axes.Left.SetMinMax(10, 22);

  if Series1.Pen.Style=psDash then
  for i:=0 to Series1.Count-2 do
  begin
    d:=TeeDistance(Series1.CalcXPos(i+1)-Series1.CalcXPos(i),Series1.CalcYPos(i+1)-Series1.CalcYPos(i));
    if (d < 25) then
    begin
      Series1.Pen.Style:=psDot;
      exit;
    end;
  end;
end;

Re: Dash line appearing as straight line

Posted: Tue May 17, 2011 1:09 pm
by 10551566
Hi,

Thanks for the code sample and I understand that for performance reasons it wouldn't be a good idea to include the automatic switch.

Regards,
Vincenzo

Re: Dash line appearing as straight line

Posted: Thu Dec 15, 2011 10:02 am
by 16458388
Hello,
in my TeeChart project (using TeeChart 2010 and Delphi 2010) I found the same problem as discussed in these posts/replys. However, I observed that this problem seems to be somewhat more general: even a dot-style series "melts" into a solid line if the number of points per page exceeds a certain level (Zooming such a line would restore the dot style).
The chart applications that I am developing with TeeChart, usually contain more than 5 line series within the chart. Of course, to distinguish them from each other it is necessary to use not only different colors but also different styles (solid, dash, dot...).

So, in my opinion the pen style appearance of a series should not be affected by the number of series points, although I can imagine that handling this won't be an easy job for the component developers :(
Do you see any chance, to solve this problem in one of the next releases?

Regards,
Andreas