Forum > TAChart
plot discontinuous line?
DMStevenson:
Hi - I was wondering if anyone has had to plot a discontinuous line. That is, for example, plot points 1,2,3 as a line, then no line between points 3,4, then a line again between points 4,5,6. I have tried various combinations of ShowPoints, and LinePen.Styles, but cannot find a way to do this. I could, of course, use multiple lineSeries, but my data sets I am plotting are *very* large, so this seems unworkable. Has anyone else found a need for this?
Thaddy:
If I understand you correctly, you want to do a kind of collision detection?
I.e. if a line crosses another then it should not progress drawing any further?
440bx:
TTBOMK, there is no function (in Windows at least) that will output a number of disconnected line segments.
OTH, even with a large dataset, it takes very little code to implement that. for instance:
Step 1. MoveTo(InitialPoint)
Step 2. Draw line to end point
Step 3. if there are more segments, advance to next segment, go to step 1.
Either a "for" or "while" loop could implement that. It looks like it would be less than 10 lines of code.
HTH.
wp:
Add a NaN ("not a number", defined in math) as y value to the series at an intermediate x point (https://wiki.lazarus.freepascal.org/TAChart_documentation#Skipping_source_items).
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses math; procedure TForm1.FormCreate(Sender: TObject);var i: Integer;begin for i := 0 to 10 do Chart1LineSeries1.AddXY(i, random); Chart1Lineseries1.AddXY(10.5, NaN); for i := 11 to 20 do Chart1lineseries1.AddXY(i, random + 1);end;
But be warned: It is not allowed to do any calculations with NaN, even "if x = NaN" will crash your application (use "if IsNaN(x)" instead). Usage of Nan is in TAChart for more than 10 years, and I hope that all such occurrencies now have been eliminated, but you never can tell...
DMStevenson:
Thank you wp! This will solve my problem exactly, and also thanks for the reference in the lit. (did not find that passage). I need this as data output from one of our instruments occasionally contains 'impossible' values (usually 0), and yet we need to graph the results - skipping the untenable values. This will work beautifully!
Navigation
[0] Message Index
[#] Next page