Forum > TAChart

[solved] TAChart - bar Chart - beginner's question about the date


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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  Chart_KuponsBarSeries1.Source := ListChartSource1;   // Label x axis with the data point labels  Chart_Kupons.BottomAxis.Marks.Source := ListChartSource1;//  Chart_Kupons.BottomAxis.Marks.Style := smsLabel;   // For label colors assign the TChartStyles to the Styles property of the series  Chart_KuponsBarSeries1.Styles := ChartStyles1;  // Add a style for each y level  ChartStyles1.Styles.Clear;  for i := 1 to 3 do    with ChartStyles1.Add do    begin      Brush.Color := Random($FFFFFF);      // Create a random color      Pen.Color := Brush.Color;      Text := 'Article ' + IntToStr(i);    end;  // Show the style texts in the legend//  Chart_KuponsBarSeries1.Legend.Multiplicity := lmStyle;  Chart_Kupons.Legend.Visible := True;  

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.

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.


[0] Message Index

Go to full version