Recent

Author Topic: [solved] TAChart - bar Chart - beginner's question about the date  (Read 1235 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1308
WP was so kind, to post a wonderful project about bar-charts.
I imported it into my code and it looks promising.

My data are forced from my DB into a martix now, which you see at the sceenshot.
As well you see at the screenshot, - that there is only one bar instead of twelve.
I bet, this is very easy to solve for somebody who worked with this bar charts more.

The code BELOW my lines of the screenshot:
It is taken from WP' project. Probably I have to change there something, - but what?

Code: Pascal  [Select][+][-]
  1.   Chart_KuponsBarSeries1.Source := ListChartSource1;
  2.  
  3.   // Label x axis with the data point labels
  4.   Chart_Kupons.BottomAxis.Marks.Source := ListChartSource1;
  5. //  Chart_Kupons.BottomAxis.Marks.Style := smsLabel;
  6.  
  7.   // For label colors assign the TChartStyles to the Styles property of the series
  8.   Chart_KuponsBarSeries1.Styles := ChartStyles1;
  9.   // Add a style for each y level
  10.   ChartStyles1.Styles.Clear;
  11.   for i := 1 to 3 do
  12.     with ChartStyles1.Add do
  13.     begin
  14.       Brush.Color := Random($FFFFFF);      // Create a random color
  15.       Pen.Color := Brush.Color;
  16.       Text := 'Article ' + IntToStr(i);
  17.     end;
  18.   // Show the style texts in the legend
  19. //  Chart_KuponsBarSeries1.Legend.Multiplicity := lmStyle;
  20.   Chart_Kupons.Legend.Visible := True;  
« Last Edit: February 17, 2024, 02:05:38 pm by Nicole »

wp

  • Hero Member
  • *****
  • Posts: 13433
Re: TAChart - bar Chart - beginner's question about the date
« Reply #1 on: February 16, 2024, 04:05:48 pm »
I assume Tage is a dynamic array (Tage: array of TTagRecord, where TTagRecord = record DATUM_: TDate; BETRAEGE: array[0..2] of Double). Then the first index is 0 not 1. Since you do not put valid data into the 0-th array element is probably contains the date value 0 (30 Dec 1899); this is "far away" from your real date values and all your data collapse to one single bar.

Nicole

  • Hero Member
  • *****
  • Posts: 1308
Re: TAChart - bar Chart - beginner's question about the date
« Reply #2 on: February 17, 2024, 02:05:21 pm »
Yes, this worked, thank you.

My plan was to have the in my array the same number as my foreign key. Therefore I started by 1 instead of zero.
Well, I changed it and now my bars are there.

To use a ChartSource like this is great.




 

TinyPortal © 2005-2018