Pie chart with dynamic radius lazarus / 55-TAChart ---------------------------------------------------------------------- Ocye · 2015-11-14 23:30 I want to show two pie charts where the total number should be repesented by the size. For instance, if the first one has half the total number of the second it should be sized 50% of the width. My first attempt was to calculate a fraction from FixedRadius. But unfortunately the actual value is not available (it is always 0 for auto size). Any idea how to solve this problem? ---------------------------------------------------------------------- wp · 2015-11-15 10:52 I just uploaded a fixed version which makes the element TPieSeries.Radius public. This is the actual pie radius, in pixels. If you don't want to update to Lazarus trunk please edit the file TASeries.pas: Navigate to the declaration part of TPieSeriesAdd the lines marked below such that the entire declaration is as followsThen recompile the TAChart package.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   { TPieSeries }   TPieSeries = class(TCustomPieSeries)  public                   // <--- new    property Radius;       // <--- new  published    property EdgePen;    property Depth;    property Exploded;    property FixedRadius;    property MarkPositions;    property RotateLabels;    property Source;  end; With this new property you keep the FixedRadius of the "large" pie series at 0. This is important because the radius calculation is quite complex and depends on many factors, so, you should not by-pass it. Otherwise the available space will not be occupied correctly. Then use the Radius of the "large" pie series to calculate the FixedRadius of the "small" pie series, e.g. 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   Chart2PieSeries1.FixedRadius := round(Chart1PieSeries1.Radius * ScaleFactor);  // Scalefactor must be < 1 !!! Call this in the form's OnActivate event after forcing a repaint of Chart1 (the one with the large pie series); this is required because the radius calculation occurs during painting: 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.FormActivate(Sender: TObject);begin  Chart1.Repaint;  Chart2PieSeries1.FixedRadius := round(Chart1PieSeries1.Radius * ScaleFactor);end; If the charts can be resized (e.g. if they are client-aligned in a resizeable form) then you should repeat this code in the OnResize event of the form. ---------------------------------------------------------------------- Ocye · 2015-11-15 11:00 Quotetaseries.pas(111,20) Error: No property found to overrideIs it the FRaidus from TCustomPieSeries that has to be public? 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   TCustomPieSeries = class(TChartSeries)  private    FCenter: TPoint;  FMarkPositions: TPieMarkPositions;    FRadius: Integer;...  public    property Radius: integer read FRadius;... ---------------------------------------------------------------------- Ocye · 2015-11-15 11:10 Works, but with two issues. First, repeated operations decrease the size meaning the original size is not reset with clear or so (did that manually). Secondly, and more of a problem, the fixed radius depends on parent size whereas a defined radius doesn't change. I could easily redo calculation in onresize. Or is it better to hack the chart code? ---------------------------------------------------------------------- wp · 2015-11-15 11:22 Sorry about the confusion with the public... In the trunk version I make the new property of TCustomPieChart protected because it is probably intended to derive other kinds of pie series from this ancestor which should not make the Radius public. The protected property then can be found by the modification I proposed. But of course, your solution is fine for your local installation. Quote from: Ocye on November 15, 2015, 12:10:05 pmrepeated operations decrease the size meaning the original size is not reset with clear or so What do you repeat? Quote from: Ocye on November 15, 2015, 12:10:05 pmThe fixed radius depends on parent size whereas a defined radius doesn't change. I could easily redo calculation in onresize. That's why I wrote to duplicate the FormActivate code in FormResize. Quote from: Ocye on November 15, 2015, 12:10:05 pmOr is it better to hack the chart code?What do you mean? ---------------------------------------------------------------------- Ocye · 2015-11-15 11:50 About "repeated operations", I missed something and the readius declined with every access to the data. It's perfect now. And with "hack chart code" I mean to run the readjustment of radius depending on parent size internally. But you are right, it's only my goal to simulate percentage and others might want to have a fix radius. So I'm happy with the solution. Thanks a lot for quick answer.