Changing color in a TAChart LineSeries lazarus / 55-TAChart ---------------------------------------------------------------------- jhmos · 2011-03-17 03:15 I want to change color of the line plot depending on the value of the item in the series. I tried to use UserDefinedChartSource GetChartDataItem, setting AItem.Color like this: Code: [Select]procedure TTRecForm.UserDefinedChartSource1GetChartDataItem(   ASource: TUserDefinedChartSource; AIndex: Integer; var AItem: TChartDataItem); begin   AItem.X:= AIndex;   AItem.Y:= CurrentTemperatureLog[AIndex];   AItem.Color:= clBlack;   if AItem.Y > 30.0 then     AItem.Color:= clRed;   if AItem.Y < 10.0 then     AItem.Color:= clBlue; end; But it looks like the Color property does not get used from there, I only get the colour that was set before the graph gets drawn (from LineSeries.SeriesColor or LineSeries.LinePen.Color). What would be the best way of changing color in a line plot using TAChart? I am using a 0.9.29 snapshot build under 64bit Ubuntu. ---------------------------------------------------------------------- Ask · 2011-03-17 08:17 Color form the data source is used for drawing points, not lines (try setting ShowPoints = true to see it). QuoteWhat would be the best way of changing color in a line plot using TAChart?If you give a general enough specification, I am ready to implement it. Which line segment should use the color from the data point? Previous one? Next one? Half of both? How should it interact with 3D lines? ---------------------------------------------------------------------- jhmos · 2011-03-17 15:11 I did also try showing points, but the colour of each Series item didn't get used for drawing the points either, only the value already set in LineSeries.Pointer.Pen.Color. Is there some trick that I'm missing? I see what you mean about choosing the colour of the line segment. For my application (when I have just drawn plots in a TImage.Canvas), I chose to have the line take the colour of the destination point but that was fairly arbitrary. Ideally I would change colour at a threshold (an alarm temperature in my case), which might mean dividing the line between two points into 2 segments. Maybe applications like that would be getting too specific for TAChart and I have given no consideration to 3D lines. Having point colour working would probably be enough for me. ---------------------------------------------------------------------- Ask · 2011-03-17 15:34 QuoteI did also try showing points, but the colour of each Series item didn't get used for drawing the points either, only the value already set in LineSeries.Pointer.Pen.Color. Is there some trick that I'm missing? No, it should work. I just tested it and it works for me (see basic demo since r29893). Please post an example project demonstrating your problem. QuoteIdeally I would change colour at a threshold (an alarm temperature in my case)Interesting. How would you set the thresholds? Separate ThresholdSource? I shall think about it -- meanwhile, are you aware of any other charting libraries that provide similar functionality? If you find such a library, it might serve both as an indicator of non-zero user base and an API guideline for this feature. ---------------------------------------------------------------------- Ask · 2011-03-19 12:57 QuoteIdeally I would change colour at a threshold (an alarm temperature in my case) Independently of the line series, you can use axis stripes to achieve similar effect. See axistransform demo, "Logarithm" page for an example. ---------------------------------------------------------------------- jhmos · 2011-03-22 05:43 Quote from: Ask on March 19, 2011, 01:57:02 pmIndependently of the line series, you can use axis stripes to achieve similar effect. See axistransform demo, "Logarithm" page for an example. Thanks, I'll have a look at that. I found what was going wrong with Pointer drawing. I had set the point horizontal and vertical size to 1 (to make it look more like a line), which displayed nothing, both have to be at least 2 pixels to display anything. ---------------------------------------------------------------------- Ask · 2011-03-23 06:46 QuoteI had set the point horizontal and vertical size to 1 (to make it look more like a line), which displayed nothing, both have to be at least 2 pixels to display anything. Since r29988, I have added "Pointers" page to the line demo. It does display all pointer sizes for me on Windows. Can you please run this demo, set "Size" to 1, and post a screenshot?