Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to have a stacked chart with data dependant series?

edited July 2018 in General
I use ReportBuilder + TeeChart integration.

i tried to do a stacked bar chart I see automatically 2 series added to my chart:
image

This is ok in the cases where i know exactly which series i want (i can for example have 4 dataviews: Apples, Oranges, Pears, Bananas) and create my chart hardcoding the series.

This is the result (screenshot taken from RB preview):
image

This is created from a chart with 4 series:
image

There are 4 dataviews, one per series:
image

But in some cases I do not know how many series i have, in my db i could have "any kind of fruit" and i do not want to create an hardcoded dataview for each fruit type.

By looking at the components i do not see a way to achieve this automatic series generation.

Am i right (and therefore this is a limitation) or is there a way?

Somehow i would like to have a dataview with the info about all the fruits, it is a kind of pivot data in fact.

DevExpress has a PivotGrid that sends data automatically to a pivot chart, the series in this case are runtime generated, this is a screenshot from one of my apps:
image
somehow i would like to achieve the same in an end user reporting application.

After writing this long question i realize what i am looking for is a pivot chart. In a dataview where i use dynamic sql i could anyway have as many columns as the fruit types found in the database so i could have a "almost pivot" normal dataview, so if there is a way to generate series on the stacked chart based on the dataview's columns i'd be done.

Thanks.

Comments

  • Hi Francesco,

    It seems feasible that you could create a single dataset that contains the data you want in ReportBuilder as you mention. The then becomes if TeeChart itself can give you a stacked view of this data. This is more of a TeeChart question than a ReportBuilder one. ReportBuilder simply provides a TeeChart wrapper to display charts as images inside reports.

    I would suggest trying to get this working outside ReportBuilder with the Delphi TeeChart components, then moving to ReportBuilder.

    Best Regards,

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

    I got what you mean. TeeChart has some OLAP/Pivot features i never used, but i guess there is no wrapper for those.

    I will explore with TeeChart how to achieve my result with a simple dataset in the meantime.

    Do you confirm ReportBuilder uses TDBChart only?
  • Hi Francesco,

    Yes, ReportBuilder contains wrappers for TChart and TDBChart only. If you find new features that you would like added, let us know and we'll add it to our enhancements list.

    1. One option would be to write code to create a new series for each data record you have. It is fairly easy to do this in TeeChart, even in RAP.

    http://rbwiki.digital-metaphors.com/rcl/chart/how-to-create-a-chart-in-code/

    2. If you are able to use the TChart pivot features to get what you want in Delphi, you can display that chart as an image in a report fairly easily.

    http://rbwiki.digital-metaphors.com/rcl/chart/how-to-chart-as-image/


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Thanks for the message, now things are clearer. Do you have an example of TeeChart and RAP to see the right way to go, please? Thanks.
  • Hi Francesco,

    Check out examples 51 and 52 of the main RAP demo for how to create charts in RAP code. I tried running these myself and apparent these demos have been a bit neglected over time. Below are the steps to get them working with modern versions of Delphi.

    1. Inside the rpMain.pas file, remove the "x" to enable the ppTeeChart definition.

    2. There is an extra semi-colon at the end of line 42 that caused Delphi 10.2.3 to give an error, remove it.

    3. Add "VCLTee" to the Project | Options | Unit Scope Names... list of the main Delphi Compiler window.

    I will make these changes for the next release of RB.


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Hi. Could you please help me in locating demo projects?

    RB is installed in C:\Program Files (x86)\Embarcadero\Studio\17.0\RBuilder

    but i do not see a demos folder.

    Thanks.
  • Hi Francesco,

    RB demos are installed to Public Documents\RBuilder\Delphi X\



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
Sign In or Register to comment.