I am porting a home-brew report Delphi reporting solution into FastReport and I’ve come to the need for a chart showing the distribution of a field in a dataset (A ‘Bell curve’ or normal distribution). Previously I wrote code to sort field values into cells (eg 100 say) and then plotted a TChart histogram of cell counts (Y) against 1-100 (X). FastReport has good integration with TChart and I am plotting lines of field values easily. Is there an existing means of plotting a distribution chart or should I create a new data set of sorted cells and plot that?
Thanks.
I am porting a home-brew report Delphi reporting solution into FastReport and I’ve come
Share
When I realised that there was no direct solution to this, I created a class which others might find useful. It takes a data set and does all the hard work of building a list of frequency cells for a specific field name and then cacheing this to allow a ‘GetValue’ call from a TfrxUserDataSet called ‘Distributions’. The report user can then simply drop a bar chart in the report, nominate ‘Distributions’ as the data set and choose the required field for ‘Y values’. ‘X values’ must be set to the same field name but with ‘-X’ appended – my class then transparently returns X and Y values for the chart having built the frequency cells on the first call. No FastReport code is involved.
Although working, this is fledgling code and could be improved further, for example at present the X values span min to max. A better display would be to use 3 or 6-sigma (standard deviation) but this is easy to modify.