Set pointerstyle at addxy time? lazarus / 55-TAChart ---------------------------------------------------------------------- AnthonyTekatch · 2019-07-28 20:10 I would like to set the pointer style at the same time as the ADDXY time. Currently I use OnGetPointerStyle to change the displayed pointer depending on some property of the data point like seriescolor like this: 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 if SomeCondition then  MyPointerColor:=clWhiteelse  MyPointerColor:=clRed; MyLineSeries.AddXY(PlotRecordTime, MyValue,'', MyPointerColor); 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 TPlotterForm.MyLineSeriesGetPointerStyle(ASender: TChartSeries;  AValueIndex: Integer; var AStyle: TSeriesPointerStyle);begin  if ASender.GetColor(AValueIndex)=clWhite then    AStyle:=psRectangle  else    AStyle:=psTriangle;end; I have other conditions that require different pointer styles, and would like to store some hidden data or metadata at the time of ADDXY so they can be decoded in more detail by OnGetPointerStyle. Are there any other options/suggestions? ---------------------------------------------------------------------- wp · 2019-07-28 21:31 Two solutions (1) Each chart source can house several x and y values per data point. While in case of a LineSeries the additional y values are reserved for additional data levels (such as in a stacked bar series) the additional x values are freely available. So you could stuff additional data point information into the extra x value. Unfortunately there is no direct series method to add an additional x value by a variant of the Add* methods, but you could call the method AddXListYList of the internal listsource to which the AddXY values are stored anyway. 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.PrepareDataForSolution1;var  i: Integer;  x, y: Double;  symbol: TSeriesPointerStyle;  clr: TColor;begin  Chart1LineSeries1.ListSource.XCount := 2;   // prepare for two x values!   for i := 0 to DATA_COUNT do  begin    x := i;    y := Random;    symbol := TSeriesPointerStyle(Random(ord(High(TSeriesPointerStyle)) + 1));  // random pointer style    clr := RGBToColor(Random(256), Random(256), Random(256));    Chart1LineSeries1.ListSource.AddXListYList(      [x, ord(symbol)],    // two x values      [y],                 // one y value      '', clr);            // label and color  end;end; (2) A less "hacky" solution, in my eyes, would be to define your own data type which directly contains the additional data values: 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 type  TData = record    x, y: Double;   // x, y values    Symbol: TPointerStyle; // the pointer style used for this data point    Color: TColor;    // the color of this data point  end;  TDataArray = array of TData; var  data: TDataArray; procedure TForm1.PrepareDataForSolution2;var  i: Integer;begin  Setlength(data, DATA_COUNT);  for i := 0 to DATA_COUNT-1 do begin    data[i].x := i;    data[i].y := Random;    data[i].Symbol := TSeriesPointerStyle(Random(ord(High(TSeriesPointerStyle)) + 1));  // random pointer style    data[i].Color := RGBToColor(Random(256), Random(256), Random(256));  end;   UserDefinedChartSource1.PointsNumber := DATA_COUNT;end; procedure TForm1.UserDefinedChartSource1GetChartDataItem(  ASource: TUserDefinedChartSource; AIndex: Integer; var AItem: TChartDataItem);begin  AItem.X := data[AIndex].x;  AItem.Y := data[AIndex].y;  AItem.Color := data[AIndex].Color;end; Declare a variable "data" of type TDataArray and populate it with your data; add also the Symbol and Color elements needed. In order to pass these data to the series add a TUserDefinedChartSource to the chart and link it to the "Source" property of the series. Once the data array is populated you must set the PointsNumber of the UserDefinedChartSource to the Length of the array. This tells the chartsource how many data points will be passed. Then write an event handler for TUserDefinedChartSeries.OnGetChartDataItem and define how the array data are assigned to the chart data items. Find a demo showing both approaches in the attachment. ---------------------------------------------------------------------- AnthonyTekatch · 2019-07-28 21:50 Thank you for your suggestions. I am trying that now. The example you provided gives me the following error: unit1.pas(100,34) Error: identifier idents no member "AddXListYList" I am currently using Lazarus 2.0.2 FPC 3.0.4 ---------------------------------------------------------------------- wp · 2019-07-28 22:24 Oh, the AddXListYList was only introduced in Laz trunk... With 2.0.2 or older you can replace it by 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 var  j: Integer;...    // This is for Laz 2.0.2 or earlier    j := Chart1LineSeries1.AddXY(x, y, '', clr);    Chart1LineSeries1.XValues[j, 1] := ord(symbol);... ---------------------------------------------------------------------- AnthonyTekatch · 2019-07-28 22:43 Fantastic!! Thanks for your help. ---------------------------------------------------------------------- AnthonyTekatch · 2019-07-29 00:56 I noticed that the X axis range of the chart now includes the extra X value. For example, if I change your code to : 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 x := i+100;The bottom scale still starts at 0 because the second element of X [j,1] is a very small value. Is there a way for the chart to only use the range from the first element of the X array [j,0]? ---------------------------------------------------------------------- wp · 2019-07-29 07:25 Extent calculation has seen considerable changes recently, the bug is fixed in Lazarus trunk. In v2.0.2 or older you can freeze the lower end of the x extent. In the Object Inspector set - Extent.XMin = 100 - Extent.UseXMin = true ---------------------------------------------------------------------- AnthonyTekatch · 2019-07-29 09:03 OK, that should work fine, thanks.