Getting stacked bars to work

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
PCSdeZ
Newbie
Newbie
Posts: 2
Joined: Fri Dec 21, 2018 12:00 am

Getting stacked bars to work

Post by PCSdeZ » Thu Jul 04, 2019 12:05 am

Hi,

I need some help to do the following:
Right now, I have a pie chart that shows products being registered on a database table in real time, it is interesting as it evolves rapidly and clearly shows the preference for some products over others. But this chart is cumulative from the start date-time until the current date-time. It does not show what happens on each hour, so for this detail I have another Stack-Bar that groups the products being registered on the same database table in a hour-by-hour basis, however it is not currently differentiating products at the bar level, that is, it only shows one color with the count of the products by each hour.

How could I have a stacked bar that shows the different products by each hour (each one with a different color, basically)? Is it possible to do that at design time or must it be done at runtime creating multiple series? How would a minimal C++ Builder Stacked Bar example look like?

Best regards,
PCSdeZ

Yeray
Site Admin
Site Admin
Posts: 8687
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Getting stacked bars to work

Post by Yeray » Wed Jul 10, 2019 2:12 pm

Hello,

Something like this?
bds_2019-07-10_16-10-32.png
bds_2019-07-10_16-10-32.png (17.02 KiB) Viewed 80 times
I did this at design time, adding 4 series, setting their titles, setting them to be Stacked, and setting their labels "hour1", "hour 2",...

If this is not what you are trying to do, don't hesitate to give us more details.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

PCSdeZ
Newbie
Newbie
Posts: 2
Joined: Fri Dec 21, 2018 12:00 am

Re: Getting stacked bars to work

Post by PCSdeZ » Sat Jul 13, 2019 4:18 pm

Thanks Yerai,

Yes, exactly this kind of chart.

So, I understand now that each bar segment is associated to a particular series and color as well.

However, in my project I need to use a Dataset whose number of products and quantity varies each hour, so how can I make the association of the Dataset with the series to ensure that the bar and their segments appear or disappear, grow or shrink, on runtime?

To be more precise, I'm currently using only one series made at design time connected to a Dataset (see below) with a Summary, Sum of CantMatched column for Calc and using FH_Creacion for Group by, however it shows only one segment and color.

This is the SQL for the Dataset:

Code: Select all

select A.FH_Creacion, B.Keyname, Count(B.Keyname) as CantMatched
from Querys A inner join Keys B on A.IdKey = B.Id, TiposKeys C
where B.Id_TipoKey = C.Id and A.Matched = True
  and ((0 = :Periodo and A.FH_Creacion between (current_date - 90) and (current_date + 1))
     or (1 = :Periodo and A.FH_Creacion between (current_date - 180) and (current_date + 1))
     or (2 = :Periodo and A.FH_Creacion between (current_date - 365) and (current_date + 1))
     or (3 = :Periodo and A.FH_Creacion between (current_date - 365 * 5) and (current_date + 1)))
  and ((0 = :IdTipoKey and C.Id in (1,2,3,4)) or C.Id = :IdTipoKey)
group by A.FH_Creacion, B.Keyname
order by 1, 2
Best regards,
PCSdeZ

Post Reply