how to set the series data in a chart?

hsmhsm
edited 4:13PM in FastReport 4.0
Following instructions in user guide pg 149 I have form with a TfrxDBDataSet, TfrxChart and TfrxReport components on it. (the TfrxDBDataSet is linked to a database) and following pages 150- 152 I manually set, under 'Values', the properties 'Label' and 'Y' to point to fields in my dataset (in my case frxDBDataset1."BetweenPeople" and frxDBDataset1."AvgReplyTimeHours" respectively.

This sucessfully created a bar chart. - Great!!!

Now I want about 9 similar reports with the only change being the field selected for the 'Y' value.

I could just make another 8 almost identical forms but would prefer to use one report and set the 'Y' property of the chart by code in the same way that I use script variables to set other things the report like title etc.

(I tried the advice from user guide page 155 but cannot see how to reference the 'Y' property of the chart.)

My form is called TFrm_ReplyTimeCharts and contains

frxDBDataset1 : TfrxDBDataset;
frxReportReplyTimes : TfrxReport;
frxChartObject1 : TfrxChartObject;

The bit of the code that shows the report is

Frm_ReplyTimeCharts.frxReportReplyTimes.Script.Variables := The_Title;
Frm_ReplyTimeCharts.frxReportReplyTimes.Script.Variables := The_Sub_Title;
//---> need to insert code to set Y value of series here

Frm_ReplyTimeCharts.frxReportReplyTimes.ShowReport(true);


So before the 'ShowReport line I want to say something like

Frm_ReplyTimeCharts.frxReportReplyTimes.frxChartObject1.SeriesData[0].Y := frxDBDataset1."Inital_Reply_Time";

but I get an 'erronous type' error on frxChartObject1.

What is the correct syntax for these lines?

Howard

Comments

  • gpigpi
    edited 4:13PM
    Try
    TfrxChartView(frxReport1.FindObject('Chart1')).SeriesData.Items[0].YSource := 'frxDBDataset1."field1"';
  • hsmhsm
    edited 4:13PM
    Thank you, that did it.

    Now that I can see the principle, ie find the object, cast it as a chart and then use the same chart properties that can be seen in the editor, it opens up loads of possibilities for fine tuning other bits of the chart through code as well.

    Most grateful.

    Howard

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.