ChLa
asked on
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 ?
You may also use the trick to set series line color to background color...
ASKER
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 ?
Can you provide a screenshot of the zigzag lines?
ASKER
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
Twosmallcharts.jpg
ASKER
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 ?
ASKER
ASKER
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 ?
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 ?
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
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
ASKER
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.
ASKER
Here is the .pas file
ChartTest2.pas
ChartTest2.pas
Please also attach the .dpr and .dfm files...
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you please post the part of your code, where you are dynamically drawing the lines?
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!!!
Could you please explain that?
I've never heard of a function PlotXY in TChart!!!
ASKER
I'm sorry. I used AddXY. I misremembered it as PlotXY because that is what it means to me.
ASKER
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.
ASKER
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 (PLastPlot CentPntX,P LastPlotCe ntPntY);
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 (PLastPlot CentPntXL, PLastPlotCentPntYL);
end;
Chart1.Series[4].AddNullXY (PLastPlot CentPntXR, PLastPlotCentPntYR);
Chart1.Series[3].AddNullXY (PLastPlot CentPntXC, 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 (PLastPlot CentPntXL, PLastPlotCentPntYL);
IterationTest := IterationTest + 1;
Memo1.Lines.Add(IntToStr(D ays) + ' Days');
end;
AdjustedRunningDeg := RunningDegrees;
if RunningDegrees < 0 then // this fixes running degrees if it goes under
begin
AdjustedRunningDeg := RunningDegrees + 360;
Chart1.Series[3].AddNullXY (PLastPlot CentPntXC, PLastPlotCentPntYC);
end;
if RunningDegrees > 360 then // this fixes running degrees if it goes over
begin
AdjustedRunningDeg := RunningDegrees - 360;
Chart1.Series[3].AddNullXY (PLastPlot CentPntXC, PLastPlotCentPntYC);
end;
// Chart1.Series[4].AddNullXY (AdjustedR unningDeg, DecimalTim e);
Chart1.Series[3].AddXY(Adj ustedRunni ngDeg, DecimalTime, '', clBlack);
Chart1.Series[3].AddNullXY (AdjustedR unningDeg, 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 (PLastPlot CentPntXL, PLastPlotCentPntYL);
end;
// Chart1.Series[5].AddNullXY (PLastPlot CentPntXL, PLastPlotC entPntYL);
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 (PLastPlot CentPntXL, PLastPlotC entPntYL);
// end;
// Chart1.Series[5].AddNullXY (PLastPlot CentPntXL, PLastPlotC entPntYL);
end;
Chart1.Series[5].AddXY(Adj ustedRunni ngDeg - (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 ((Adjusted RunningDeg - (LensFOV / 2)),DecimalTime);
//Chart1.Series[4].AddNull XY((Adjust edRunningD eg + (LensFOV / 2)),DecimalTime);
//Memo1.Lines.Add('if both ifs');
end;
//Chart1.Series[5].AddNull XY(PLastPl otCentPntX L, 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 (FirstPoin tXL,FirstP ointYL);
// Chart1.Series[4].AddNullXY (FirstPoin tXR,FirstP ointYR);
// Chart1.Series[5].AddNullXY (AdjustedR unningDeg - (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 (PLastPlot CentPntXR, PLastPlotCentPntYR);
end;
if (RunningDegrees + (LensFOV / 2)) > 360 then
// this fixes running degrees if it goes over
begin
AdjustedRunningDeg := RunningDegrees - 360;
Chart1.Series[4].AddNullXY (PLastPlot CentPntXR, PLastPlotCentPntYR);
end;
Chart1.Series[4].AddXY(Adj ustedRunni ngDeg + (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 (FirstPoin tXR,FirstP ointYR);
// 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 (PLastPlot CentPntXL, PLastPlotCentPntYL);
Chart1.Series[4].AddNullXY (PLastPlot CentPntXR, PLastPlotCentPntYR);
Chart1.Series[3].AddNullXY (PLastPlot CentPntXC, 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 ?
// ***FullSpeedPan***********
// Chart1.Series[5].AddNullXY
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
end;
Chart1.Series[4].AddNullXY
Chart1.Series[3].AddNullXY
//Memo1.Lines.Add(IntToStr
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
IterationTest := IterationTest + 1;
Memo1.Lines.Add(IntToStr(D
end;
AdjustedRunningDeg := RunningDegrees;
if RunningDegrees < 0 then // this fixes running degrees if it goes under
begin
AdjustedRunningDeg := RunningDegrees + 360;
Chart1.Series[3].AddNullXY
end;
if RunningDegrees > 360 then // this fixes running degrees if it goes over
begin
AdjustedRunningDeg := RunningDegrees - 360;
Chart1.Series[3].AddNullXY
end;
// Chart1.Series[4].AddNullXY
Chart1.Series[3].AddXY(Adj
Chart1.Series[3].AddNullXY
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
end;
// Chart1.Series[5].AddNullXY
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
// end;
// Chart1.Series[5].AddNullXY
end;
Chart1.Series[5].AddXY(Adj
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
//Chart1.Series[4].AddNull
//Memo1.Lines.Add('if both ifs');
end;
//Chart1.Series[5].AddNull
PLastPlotCentPntXL := AdjustedRunningDeg - (LensFOV / 2);
PLastPlotCentPntYL := DecimalTime;
if FirstPointOnceOnlyFlagL = 0 then
begin
FirstPointXL := PLastPlotCentPntXL;
FirstPointYL := DecimalTime;
FirstPointOnceOnlyFlagL := 1;
end;
Chart1.Series[5].AddNullXY
// Chart1.Series[4].AddNullXY
// Chart1.Series[5].AddNullXY
AdjustedRunningDeg := RunningDegrees;
if (RunningDegrees + (LensFOV / 2)) < 0 then // this fixes running degrees if it goes under
begin
AdjustedRunningDeg := RunningDegrees + 360;
Chart1.Series[4].AddNullXY
end;
if (RunningDegrees + (LensFOV / 2)) > 360 then
// this fixes running degrees if it goes over
begin
AdjustedRunningDeg := RunningDegrees - 360;
Chart1.Series[4].AddNullXY
end;
Chart1.Series[4].AddXY(Adj
clGreen);
PLastPlotCentPntXR := AdjustedRunningDeg + (LensFOV / 2);
PLastPlotCentPntYR := DecimalTime;
If FirstPointOnceOnlyFlagR = 0 then
begin
FirstPointXR := PLastPlotCentPntXR;
FirstPointYR := DecimalTime;
FirstPointOnceOnlyFlagR := 1;
end;
Chart1.Series[4].AddNullXY
// 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
Chart1.Series[4].AddNullXY
Chart1.Series[3].AddNullXY
// ***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 ?
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].ValueColo r[1]:=clGr een;
You can set different colors for the value markers as follows:
Chart1.Series[0].ValueColo
ASKER
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.
You can change at runtime with TChart function ChangeSeriesTyp(..)