draw unconnected points in line series of tchart

Is it possible to draw unconnected points in a line series of a TChart ? Can I turn off the automatic connecting of points drawn using AddXY ?
ChLaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ThommyCommented:
Why not using a different seriestype like TPointSeries????

You can change at runtime with TChart function ChangeSeriesTyp(..)
0
ThommyCommented:
You may also use the trick to set series line color to background color...
0
ChLaAuthor Commented:
I think the reason I never used the point series is because the picture of it doesn't look anything like what I am trying to do. I deleted the three line series and replaced them with point series. It seems to be working except for two things. One of the lines is still connecting to itself. So I zoomed way in to see the points. But I see zigzag (stairstep) lines, no points. What is happening here ? What is making the point series like a line series ?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

ThommyCommented:
Can you provide a screenshot of the zigzag lines?
0
ChLaAuthor Commented:
Here is a picture. On the left you see the chart now using point series, after drawing the three lines. These were plotted using PlotXY, On the right you see I have zoomed into the chart to show the lines very close. I was expecting to see dots, but instead I see zigzag lines.
Twosmallcharts.jpg
0
ChLaAuthor Commented:
In this second image of nearly the same pan, but CCW, you see a line has been added connecting the end of the first segment to the start of the fifth segment, for the center line only. Also you may notice the third main segment of the center line isn't drawn after the line returns on the right (after going off to the left). This is almost certainly because of an AddNullXY I haven't yet removed since changing to point series from line series. I wonder if more lines will appear when I remove all the addnullXY's ?
0
ChLaAuthor Commented:
0
ChLaAuthor Commented:
I have done a further experiment. I started a new project. I put a TChart on the form. I put a panel on the form. I added a point series to the chart. I made adjustments to the chart so it looks like the other chart shown above. I added an onclick event to the panel "Chart1.Series[1].AddXY(20, 20, '', clRed); ".
When I click on the panel I get this message: Mdiapp Access Violation at address 40340000. Read of address 40340000".
What is going on here ?
0
ThommyCommented:
Your problem sounds really, very strange!!!

Can you please provide a small example project, so that I can get this issue reproduced?

Or better, you may consult Steema TeeChart support...
Steema Support Central
0
ChLaAuthor Commented:
I agree it sounds very wierd. IN fact, I was thinking my installation of TChart that came with Delphi 2010 is corrupted. Last night I remembered I have an installation of Delphi 2010 on another computer. I repeated the above experiment precisely and got the same results, as if AddXY isn't a command that can be used with a point series. I will try to attach the test project. I am not sure which files to include. Let me know. I will attach the executable now. I will also attach the .pas file.
0
ChLaAuthor Commented:
Here is the .pas file
ChartTest2.pas
0
ThommyCommented:
Please also attach the .dpr and .dfm files...
0
ChLaAuthor Commented:
Here are those two files
ChartTest2.dfm
MDIAPP.dpr
0
ThommyCommented:
The access violation occurrs because you tried to reference a point series by index, that does not exist.
Series indexes always start with '0' not with '1!!!
Because you have created just one point series at design time, you have to reference it with index '0' as follows:
Chart1.Series[0].AddXY(20, 20, '', clRed);

After having corrected this error, I tried out AddXY(..) in relation with point series.
I cannot identify any problems and there are no zigzag lines either!

So please try yourself, if you can reproduce your problem with that demo app and tell me how you did...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ThommyCommented:
Can you please post the part of your code, where you are dynamically drawing the lines?
0
ThommyCommented:
In your previous post ID: 40202666 you mention, that "the three lines are plotted using PlotXY"

Could you please explain that?

I've never heard of a function PlotXY in TChart!!!
0
ChLaAuthor Commented:
I'm sorry. I used AddXY. I misremembered it as PlotXY because that is what it means to me.
0
ChLaAuthor Commented:
Okay, you are right about it being series zero, not one. I actually thought of this a few nights ago. But when I looked and saw the series was numberes one and not zero, I dismissed the idea. That solves this problem and allows me to do some experimenting with point series. Still, it doesn't solve the mysteries of the other question, about plotted points connecting together, and such. For some reason I stopped getting answers to the other question. I suppose I need to have simpler smaller questions.
0
ChLaAuthor Commented:
Okay, you asked for some of my code for drawing lines. Here is my code for the main segment, the third segement.

// ***FullSpeedPan************************************************************************

  // Chart1.Series[5].AddNullXY(PLastPlotCentPntX,PLastPlotCentPntY);

  TimesThroughLoop := 0;
  Days := 0;
  LastDays := 0;

  while TimesThroughLoop < FullSpeedPanFrames do
  Begin
    TimesThroughLoop := TimesThroughLoop + 1;
    TestInt := TestInt + 1;
    If PanDirection = 0 then
      RunningDegrees := RunningDegrees + (PanStepsFrame * PanDegreesStep)
    else
      RunningDegrees := RunningDegrees - (PanStepsFrame * PanDegreesStep);
    RunningS := (RunningS + FrameIntervalTotalSec);
    if RunningS > 59 then
    Begin
      RunningM := RunningM + (RunningS div 60);
      RunningS := (RunningS mod 60);
    End;
    If RunningM > 59 then
    Begin
      RunningH := RunningH + (RunningM div 60);
      RunningM := (RunningM mod 60);
    End;

    DecimalTime := (RunningH + (RunningM / 60));

    While DecimalTime > 24 do // if we go over 24 hours
    begin
      Days := Days + 1;
      DecimalTime := DecimalTime - 24; // fix hours
      if FSPLOnlyOnceFlag = 0 then
      begin
        FSPLOnlyOnceFlag := 1;
        Chart1.Series[5].AddNullXY(PLastPlotCentPntXL, PLastPlotCentPntYL);
      end;

      Chart1.Series[4].AddNullXY(PLastPlotCentPntXR, PLastPlotCentPntYR);
      Chart1.Series[3].AddNullXY(PLastPlotCentPntXC, PLastPlotCentPntYC);
      //Memo1.Lines.Add(IntToStr(Days));
    end;

    If Days <> LastDays then // this prevents connecting end of one line to start of next when hrs go over repeatedly
        begin
        Chart1.Series[5].AddNullXY(PLastPlotCentPntXL, PLastPlotCentPntYL);
        IterationTest := IterationTest + 1;
        Memo1.Lines.Add(IntToStr(Days) + ' Days');
        end;

    AdjustedRunningDeg := RunningDegrees;
    if RunningDegrees < 0 then // this fixes running degrees if it goes under
    begin
      AdjustedRunningDeg := RunningDegrees + 360;
      Chart1.Series[3].AddNullXY(PLastPlotCentPntXC, PLastPlotCentPntYC);
    end;
    if RunningDegrees > 360 then // this fixes running degrees if it goes over
    begin
      AdjustedRunningDeg := RunningDegrees - 360;
      Chart1.Series[3].AddNullXY(PLastPlotCentPntXC, PLastPlotCentPntYC);
    end;

    // Chart1.Series[4].AddNullXY(AdjustedRunningDeg,DecimalTime);

    Chart1.Series[3].AddXY(AdjustedRunningDeg, DecimalTime, '', clBlack);

    Chart1.Series[3].AddNullXY(AdjustedRunningDeg, DecimalTime);

    PLastPlotCentPntXC := AdjustedRunningDeg;
    PLastPlotCentPntYC := DecimalTime;

    AdjustedRunningDeg := RunningDegrees;
    if (RunningDegrees - (LensFOV / 2)) < 0 then // this fixes running degrees if it goes under
    begin
      AdjustedRunningDeg := RunningDegrees + 360;
      if FSPLOnlyOnceFlag = 0 then // this doesn't seem to be helping
      begin
        FSPLOnlyOnceFlag := 1;
        Chart1.Series[5].AddNullXY(PLastPlotCentPntXL, PLastPlotCentPntYL);
      end;

      // Chart1.Series[5].AddNullXY(PLastPlotCentPntXL,PLastPlotCentPntYL);
    end;
    if (RunningDegrees - (LensFOV / 2)) > 360 then     // this fixes running degrees if it goes over
    begin
      AdjustedRunningDeg := RunningDegrees - 360;

      // if FSPLOnlyOnceFlag = 0 then           //not sure this is helping
      // FSPLOnlyOnceFlag := 1;
      // Chart1.Series[5].AddNullXY(PLastPlotCentPntXL,PLastPlotCentPntYL);
      // end;

      // Chart1.Series[5].AddNullXY(PLastPlotCentPntXL,PLastPlotCentPntYL);
    end;

    Chart1.Series[5].AddXY(AdjustedRunningDeg - (LensFOV / 2), DecimalTime, '', clBlue);

    if (PanDirection = 1) and (Days <> LastDays) then  // this prevents connecting end of one line to start of next when hrs go over repeatedly during CCW
      begin
      Chart1.Series[5].AddNullXY((AdjustedRunningDeg - (LensFOV / 2)),DecimalTime);
      //Chart1.Series[4].AddNullXY((AdjustedRunningDeg + (LensFOV / 2)),DecimalTime);
      //Memo1.Lines.Add('if both ifs');
      end;

    //Chart1.Series[5].AddNullXY(PLastPlotCentPntXL, PLastPlotCentPntYL);       //this preventx left line from being drawn


    PLastPlotCentPntXL := AdjustedRunningDeg - (LensFOV / 2);
    PLastPlotCentPntYL := DecimalTime;

    if FirstPointOnceOnlyFlagL = 0 then
    begin
      FirstPointXL := PLastPlotCentPntXL;
      FirstPointYL := DecimalTime;
      FirstPointOnceOnlyFlagL := 1;
    end;

    Chart1.Series[5].AddNullXY(FirstPointXL,FirstPointYL);
  //  Chart1.Series[4].AddNullXY(FirstPointXR,FirstPointYR);

    // Chart1.Series[5].AddNullXY(AdjustedRunningDeg - (LensFOV / 2), DecimalTime);

    AdjustedRunningDeg := RunningDegrees;
    if (RunningDegrees + (LensFOV / 2)) < 0 then // this fixes running degrees if it goes under
    begin
      AdjustedRunningDeg := RunningDegrees + 360;
      Chart1.Series[4].AddNullXY(PLastPlotCentPntXR, PLastPlotCentPntYR);

    end;
    if (RunningDegrees + (LensFOV / 2)) > 360 then
    // this fixes running degrees if it goes over
    begin
      AdjustedRunningDeg := RunningDegrees - 360;
      Chart1.Series[4].AddNullXY(PLastPlotCentPntXR, PLastPlotCentPntYR);

    end;

    Chart1.Series[4].AddXY(AdjustedRunningDeg + (LensFOV / 2), DecimalTime, '',
      clGreen);

    PLastPlotCentPntXR := AdjustedRunningDeg + (LensFOV / 2);
    PLastPlotCentPntYR := DecimalTime;

    If FirstPointOnceOnlyFlagR = 0 then
    begin
      FirstPointXR := PLastPlotCentPntXR;
      FirstPointYR := DecimalTime;
      FirstPointOnceOnlyFlagR := 1;
    end;

    Chart1.Series[4].AddNullXY(FirstPointXR,FirstPointYR);

    // Memo1.Lines.Add('B =  ' + FloatToStr(CHSeriesB) + '   A =  ' + FloatToStr(CHSeriesA) + '   C =  ' + FloatToStr(CHSeriesC) + '    SL ' + FloatToStr(Edit3.SelLength) );
    // Chart1.Repaint;
    // Chart1.Refresh;
    If TestInt = GraphSpeed then // redraws graph during full speed ramp loop to make it animated
    Begin
      Chart1.Update;
      TestInt := 0;
    End;

    LastDays := Days;
    Days := 0;

    // Chart1.Invalidate;
  End;
  // Series3.AddNull('');
  Panel71.Caption := FloatToStr(RunningH) + ':' + FormatFloat('00', RunningM)
    + ':' + FormatFloat('00', RunningS);

  Chart1.Series[5].AddNullXY(PLastPlotCentPntXL, PLastPlotCentPntYL);
  Chart1.Series[4].AddNullXY(PLastPlotCentPntXR, PLastPlotCentPntYR);
  Chart1.Series[3].AddNullXY(PLastPlotCentPntXC, PLastPlotCentPntYC);

  // ***RampDown*********************************************************************************************

You can see all the work I had to do with addnulls to stop connecting lines from being drawn. It occurs to me that the problems I have been having could all be related to my using the series number, instead of the series number minus one. This alone may solve my problems with TCharts. What I have been thinking is that I should remove the existing chart and relace it with a new one. Then I would add one or three point series, and change all the ADDXY's to the new series number(s). If all this works, I wonder this. Can I do what i want with only one series ? I was using different series before to help avoid connecting lines, and to have different colors for each line. Now I suspect I don't need to do that. What do you think ?
0
ThommyCommented:
Yes, I think you can do it with just one series that.

You can set different colors for the value markers as follows:
Chart1.Series[0].ValueColor[1]:=clGreen;
0
ChLaAuthor Commented:
At this point I think most likely all the problems I have been having with TCharts come from trying to access series by their indicated number instead of that number minus one. So I am closing this question and the other, and awarding points to Thommy, once again. Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.