How to use TChart for simple Box-Whiskers plot? lazarus / 55-TAChart ---------------------------------------------------------------------- stephanweber · 2019-06-17 13:23 Hi, I have a chart and at the x-position x=1 I want to place a box- whiskers element, e.g. with the 5 y-entries 0.50 ; 1.0; 1.5 ; 1.9; and 2.70. How can I do this, e.g. using Addxy and an array yval[1..5] of double? I need a simple code example, because currently I see only an empty chart. Bye Stephan ---------------------------------------------------------------------- wp · 2019-06-17 14:12 Just call the AddXY of the BoxAndWhiskerSeries which accepts all five y values in the order lower whisker, lower box, center, upper box, upper whisker: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     function AddXY(      AX, AYLoWhisker, AYLoBox, AY, AYHiBox, AYHiWhisker: Double;      AXLabel: String = ''; AColor: TColor = clTAColor): Integer; overload; In your case: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Chart1BoxAndWhiskerSeries1.AddXY(1, 0.5, 1.0, 1.5, 1.9. 2.7); ---------------------------------------------------------------------- stephanweber · 2019-06-18 07:04 Thanks a lot!! Yesterday I experimented a lot and found this works:     Chart1BoxAndWhiskerSeriesCpk.Clear;     Chart1BoxAndWhiskerSeriesCpk.ListSource.YCount := 5;     ylist[1]:=0.75;     ylist[2]:=1;     ylist[3]:=1.25;     ylist[4]:=0.5;     y0:=1.5;     Chart1BoxAndWhiskerSeriesCpk.AddXY(1, y0, ylist); So the order is really confusing, maybe a bug in my older Lazarus. Bye Stephan ---------------------------------------------------------------------- wp · 2019-06-18 08:35 Read the documentation https://wiki.lazarus.freepascal.org/TAChart_documentation#Multi- valued_sources. For TBoxAndWhiskerSeries, we need five y values. This means, in addition to the ordinary y value, four y values will go into the YList. BUT: YList is a zero-based array. This leads to some unusual indexing: *  "normal" y value --> y index 0 --> stored in Series.ListSource[i ]^.Y *  first extra y value --> y index 1 --> stored in Series.ListSource[i ]^.YList[0] *  second extra y value --> y index 2 --> stored in Series.ListSource[i ]^.YList[1] etc. For 5 values in total, YList is allocated to get 4 values because the other one is outside the array. This means, you have Y, YList[0], YList[1], YList[2], YList[3]. There is not YList[4]! And you did not assign anything to YList[0]... I don't know whether this produces the effect that you mention. But note: TBoxAndWhiskerSeries has an overloaded AddXY method where you simply specify the y values in the order from lowest to highest - this frees you from all these details. The following code snippet compares both methods to add data to a Box- and-whisker series: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);begin//  Chart1BoxAndWhiskerSeries1.ListSource.YCount := 5;  Chart1BoxAndWhiskerSeries1.AddXY(0, 0.5,  1.0, 1.5, 1.9, 2.7);   // specialized for TBoxAndWhiskerSeries  Chart1BoxAndWhiskerSeries1.AddXY(1, 0.5, [1.0, 1.5, 1.9, 2.7]);  // valid for all series typesend; Another note: If your Lazarus version is very old then you must specify the YCount of the chart source before adding data: BoxAndWhiskerSeries.ListSource.YCount := 5. In current versions, this is no longer required.