A chart with 3 series?

TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
Post Reply
realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

A chart with 3 series?

Post by realsol » Mon Mar 13, 2017 4:19 pm

I don't know how I can create this, but I need a chart that looks like the attachment. The top would be a bar chart with 2 series. One for income and on for Expenses by month of the year. I am building it from a SQL query when goes something like this:

Code: Select all

SELECT *, ABS(SUM (AMOUNT)) AS ABSTOTAL, 
  SUM (AMOUNT) AS TOTAL, 
  (cast(strftime('%d', date) as integer)) AS DAY,
  (cast(strftime('%d', date) as integer)) / 7 + 1 AS WEEK,
  (cast(strftime('%m', date) as integer)) AS MONTH,
  (cast(strftime('%m', date) as integer) + 2) / 3 as QTR,
  (cast(strftime('%Y', date) as integer)) AS YEAR
  FROM TRANSACTIONS
  INNER JOIN CATEGORIES
  ON TRANSACTIONS.TREE_NAME=CATEGORIES.CatName
  GROUP BY TREE_NAME
I figure for the Bar Chart I would use Total as from my Income category, and ABSTOTAL as the second series of the bar chart. This way the bars are all above the 0 line.

The 3rd series would use either total because it looks like the pie charts already use ABS amounts when they are built.

But I can figure out how to design it where the bar chart is above, and the pie chart is below. Also how to create the pie chart, so it is flat as it looks in the attachment.

Any help would be appreciated because this is my first project that I am using the Standard FMX TChart component.

Thanks.
Attachments
2017-03-11_0035.png
2017-03-11_0035.png (20.13 KiB) Viewed 20247 times

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

Re: A chart with 3 series?

Post by Yeray » Tue Mar 14, 2017 10:43 am

Hello,

Regarding the data, you should use a TSQLQuery or similar and set it to use your database. Once you have this, you should set your series to use the fields returned by the query as X values, Y values (and Labels optionally). Note the chart should be a TDBChart so the series can be set to use a DataSet as Data source.
This should be very similar to what is explained in the Tutorial 8. Database access. Find all the online Tutorials here.

Regarding the layout, I see two options:
- You can create two charts. One on the top with two TBarSeries, and one on the bottom with a TPieSeries.
- You can create a chart with a TSubChartTool. The main chart could contain the two TBarSeries and the Chart in the SubChartTool could contain the TPieSeries.
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

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: A chart with 3 series?

Post by realsol » Tue Mar 14, 2017 4:44 pm

Thank you for this. Right now I am still trying to code the correct query to get the charts filled. I was hoping to use one query for both charts, but that didn't seem possible due to the grouping of the queries. I am currently using 2 charts on a Tabsheet. I was hoping I could position the two charts showing the 1st chart (bar) only taking up 1/3 of the page while the pie chart takes up 2/3 of the page. But I couldn't find a setting that would give positions is %'s (I want the charts to maintain their % of the screen when the application is resized), so I ended up splitting them with a splitter. Not really what I wanted to do. Is there a setting I am missing?

I didn't know about a subchart possibility. If I choose that, could I position my charts the way I want? Is that available in the Standard version of TeeCharts FMX?

I will look at the tutorials. Hopefully, they might answer my questions about sub-charts. But for some reason, I thought they were only available in the pro version.

Last Question. Is there a way to add a scroll bar to the legend? I have seen scroll bars mentioned in the forum but don't see a setting for it. Instead, my legend just cuts off the bottom when resized.

Thanks.

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

Re: A chart with 3 series?

Post by Yeray » Wed Mar 15, 2017 9:52 am

Hello,
realsol wrote:I am currently using 2 charts on a Tabsheet. I was hoping I could position the two charts showing the 1st chart (bar) only taking up 1/3 of the page while the pie chart takes up 2/3 of the page. But I couldn't find a setting that would give positions is %'s (I want the charts to maintain their % of the screen when the application is resized), so I ended up splitting them with a splitter. Not really what I wanted to do. Is there a setting I am missing?
You could set the Charts Height manually at OnResize event. Ie:

Code: Select all

var DBChart1, DBChart2: TDBChart;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DBChart1:=TDBChart.Create(Self);
  DBChart1.Parent:=Self;
  DBChart1.Align:=TAlignLayout.Top;
  DBChart2:=TDBChart.Create(Self);
  DBChart2.Parent:=Self;
  DBChart2.Align:=TAlignLayout.Client;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  DBChart1.Height:=Self.Height/3;
end;
realsol wrote:I didn't know about a subchart possibility. If I choose that, could I position my charts the way I want?
Same as above. You should do the calculations at OnResize event.
realsol wrote:Is that available in the Standard version of TeeCharts FMX?
realsol wrote:I will look at the tutorials. Hopefully, they might answer my questions about sub-charts. But for some reason, I thought they were only available in the pro version.
I'm afraid the Chart Tools are only available with the Pro version. See the feature matrix here.
realsol wrote:Last Question. Is there a way to add a scroll bar to the legend? I have seen scroll bars mentioned in the forum but don't see a setting for it. Instead, my legend just cuts off the bottom when resized.
the TLegendScrollBar is also a Chart Tool only available with the Pro version.
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

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: A chart with 3 series?

Post by realsol » Wed Mar 15, 2017 6:55 pm

Thanks much.

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: A chart with 3 series?

Post by realsol » Thu Mar 16, 2017 8:18 am

the TLegendScrollBar is also a Chart Tool only available with the Pro version.
Since the scrollbar is a pro version feature, is there a way to create a legend on the right that has more than 1 column in the STD version? If so, is there a way to programmatically add columns as legend items are cut off the page as the user resizes the application.

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

Re: A chart with 3 series?

Post by Yeray » Fri Mar 17, 2017 3:29 pm

Hello,
realsol wrote:Since the scrollbar is a pro version feature, is there a way to create a legend on the right that has more than 1 column in the STD version? If so, is there a way to programmatically add columns as legend items are cut off the page as the user resizes the application.
I'm afraid the legend doesn't support this level of customization.
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

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: A chart with 3 series?

Post by realsol » Fri Mar 17, 2017 3:32 pm

Thanks for the reply. Now with us 11 hours apart, i got up at 4 am hoping you would answer some of my questions. Thank you.

Post Reply