Home General

Variable number of charts on one page

I need to show a variable number of 1 to 8 charts on one page. The charts have the same structure but different data. Data comes from user selected textfiles that are loaded directly by the chart. The charts should automatically scale so that they fill a defined area on one page, no second page should be generated.
I think this should be possible with just one Teechart on the detailband. The problem is that there is no table that the report can traverse. I am looking for the best way to handle this.
I could add a table with headlines with as many records as charts are needed. This would allow me to use a ppDBPipeline. But maybe a ppJITPipeline would be the better approach.
What is the best time to feed the chart with new data ? Probably Detailband.BeforeGenerate ?

Comments

  • Hi Gerhard,

    I would suggest trying a JITPipeline and using its OnGetFieldValue event to populate the chart data. The size of the chart/detail band would need to be dynamically adjusted to fit on a single page based on how many records you are printing as this is not a built-in feature of RB.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Hi NIco,
    using the JITPipeline and calculating the necessary charts height is basically no problem.
    The problem is that I have no idea what the maximum height of the detailbands is.
    I tried to get the footers top position to subtract the headers size to get the remaining height.
    But FooterBand.PrintPosition always returns 0, a previous call to CalcPrintPosition changes nothing.
    I understand that detail positions are dynamic, but the footer is always printed at the same vertical position, so its position is probably known early in the print process.
    How can I find the maximum height of detail bands that I can fill with charts without starting a new page ? I dont know wihich paper size will be used so a calculation at designtime will not help.

    Regards
    Gerhard Sachs
  • Hi Gerhard,

    Use the PrinterSetup.PageDef properties to determine the size of the page being printed to. You will likely want to use the PrintablePageHight which automatically takes the margins out of the calculation.

    The Footer band is always static height so you could then easily calculate the space available for the detail band(s) knowing the printable page height and footer height after the header prints.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Hi Nico,

    currently I resize the detailband before starting the report, I must change this to the time when the operator already selected the printer. Which event would you recommend for this ?
    BeforePrint ?
    OnStartPage ?

    I tried to use the OnGetFieldValue event of the JITPipeline but that event never gets fired.
    Currently I try to use the Detailband.BeforeGenerate event to populate the chart, but there is another problem :
    TeeChart comes with a TSeriesTextSource which populates a chart directly from a textfile.
    I tried to use this component but it seems to be unusable here.
    -> // following line causes error no valid datasource : ts1, ts1 is a TSeriesTextSource
    -> ts1.Series := ppDPTeeChart1.Chart.Series[0];

    This is not really a problem, I can read and scan the textfile by myself and send the data to the chart.

    Regards
    Gerhard Sachs
  • Hi Gerhard,

    Try the BeforePrint. You may need to use an earlier event such as the BeforeOpenDatapipelins or OnInitializeParameters.
    I tried to use the OnGetFieldValue event of the JITPipeline
    Do you have the JITPipeline connected to the report? Are you giving the JITPipeline a record count and at least one field? You can add fields to the pipeline by double clicking the component on the form.

    See the JITPipeline examples in our main reports demo for more help setting it up (Demos 136, 137, etc). Once you get going, they are fairly easy to use.

    It's also possible you could use a TppTextPipeline and a TppDBChart to accomplish what you need. A DBChart can connect directly to a Datapipeline and a TextPipeline can pull data directly from a delimited text file. See the same demos (131 - 140) for examples of this.



    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.