[SOLVED]TaChart Title ,Values !!! Tomak or someone nice ,please help. lazarus / 55-TAChart ---------------------------------------------------------------------- Robert W.B. · 2012-03-30 11:59 Problems again. I try to set an title like I did in Delphi with ChartFX but,it don't work. This is my code: Chart1.Title:=DateToStr(date); //work in Chartfx but not in taChart.  Also.How to set values on the top of the bars?  Best regards and have a nice weekend. Rob ---------------------------------------------------------------------- wp · 2012-03-30 15:02 The title of a chart is turned off by default. So, setting Chart1.Title.Visible := true will show the title. You can do this in the object inspector. To see the series values of a bar chart above the bars select the series in the object inspector and set its property Marks.Style to smsValue. Modify the other sub-properties of Marks to format the marks as needed. ---------------------------------------------------------------------- Robert W.B. · 2012-03-30 18:50 Not that easy. I can see that I could set the text in object inspector but shouldn't this work than? Chart1.Title.Text:='Hello Chart';  or Chart1.Title.Text:=DateToStr(date); but it dosen't work! I got these errors. unit1.pas(221,25) Error: Incompatible type for arg no. 1: Got "Constant String", expected "TStrings" tatypes.pas(462,23) Hint: Found declaration: TChartTitle.SetText(TStrings); The values smsValue didn't show any values on the bars! What am I doing wrong? Best regards Rob ---------------------------------------------------------------------- wp · 2012-03-30 19:25 QuoteShouldn't this work? Chart1.Title.Text:='Hello Chart';  or Chart1.Title.Text:=DateToStr(date); No - the property Text of the Title is a string list to allow for multi-lined titles. So you have to "add" your string:   Chart1.Title.Text.Add('Hello Chart') or:   Chart1.Title.Text.Text := 'Hello Chart'; Or, if the title is fixed you can also use the object inspector at design time by clicking at the "..." next to Chart.Title.Text and enter the text in a dialog box. QuoteThe values smsValue didn't show any values on the bars! The marks also have a "Visible" property - maybe this is off (it should be on by default, though). The attached sample is working fine. ---------------------------------------------------------------------- Robert W.B. · 2012-03-30 20:56 How can I show values on top of the bars? Thanks for all help. best regards //Rob ---------------------------------------------------------------------- wp · 2012-03-30 21:26 Sorry, I don't understand what you mean. Isn't this question answered in the postings above (Series.Marks.Style =smsValue and Series.Marks.visible = true)? Does my demo work? Or do you want a completely different effect? ---------------------------------------------------------------------- Robert W.B. · 2012-03-30 21:55 procedure TForm1.BitBtn6Click(Sender: TObject); var  myarray:array[1..48]of integer;  Bser: TBarSeries; begin Bser:=TBarSeries.Create(Chart1);  Chart1.Title.Text.Add(DateToStr(date));   for i:=1 to 48 do begin     BSer.Add(myarray,IntToStr(i),clAqua);     Chart1.AddSeries(BSer);   end; end.      Rob ---------------------------------------------------------------------- wp · 2012-03-30 22:36 You are calling AddSeries from within the loop that creates the data points, therefore you have 48 series in the chart! Moreover you can add only individual points to the series, not the entire array. That's the way it should work: Code: [Select]procedure TForm1.BitBtn6Click(Sender: TObject); var  myarray:array[1..48] of integer;  Bser: TBarSeries; begin   Bser:=TBarSeries.Create(Chart1);   Chart1.Title.Text.Add(DateToStr(date));   for i:=1 to 48 do begin     myarray[i] := random;  // your data are assigned here, I am just using random numbers here     BSer.Add(myarray[i],IntToStr(i),clAqua);   end;   Chart1.AddSeries(BSer); end; ---------------------------------------------------------------------- Robert W.B. · 2012-03-30 23:12 is it possible to get the 48 values on the bars? BSer.addXY? Best regards Rob ---------------------------------------------------------------------- wp · 2012-03-31 10:31 Again: You should see the marks above the bars if you did what I proposed above. Please report what is wrong. Or post the essential parts of your project. QuoteBSer.addXY? This does not have to do anything with the marks. AddXY allows to specify an x value for the position of bar on the x axis while Add uses the index of the bar as an x coordinate. ---------------------------------------------------------------------- Robert W.B. · 2012-03-31 15:10 To see the series values of a bar chart above the bars select the series in the object inspector and set its property Marks.Style to smsValue. Modify the other sub-properties of Marks to format the marks as needed. There is no values on the bar! Strange!  regards //Rob ---------------------------------------------------------------------- wp · 2012-03-31 16:00 If you create the series at runtime, as I guess from your previously posted code, you have to set the properties manually, of course. Try the attached demo. ---------------------------------------------------------------------- Robert W.B. · 2012-03-31 16:52 i got error when loading it! I got these errors when trying to run it! unit1.pas(41,37) Error: Wrong number of parameters specified for call to "Add" tacustomseries.pas(440,23) Hint: Found declaration: TChartSeries.Add(Double,AnsiString,TGraphicsColor):LongInt; unit1.pas(46) Fatal: There were 1 errors compiling module, stopping Lazarus 0.9.30.4 Best regards Rob ---------------------------------------------------------------------- wp · 2012-03-31 17:17 Sorry - i am using the current snapshot. Use the Add in the same way as you had posted initially, i.e. use the missing color as a third parameter, I had put the color into the bar's SeriesColor. In the demo, replace the click procedure by this: Code: [Select]procedure TForm1.Button1Click(Sender: TObject); const   N =10; var   i: Integer;   BSer: TBarSeries; begin   Chart1.Title.Text.Text := DateToStr(Date());   Chart1.Title.Visible := true;   Chart1.Series.Clear;   BSer := TBarSeries.Create(self);   BSer.Marks.Style := smsValue;   BSer.Marks.Clipped := false;            // optional   BSer.Marks.Linkpen.Color := clRed;      // optional   BSer.Marks.LabelBrush.Color := clGray;  // optional   BSer.Marks.LabelFont.Color := clWhite;  // optional   BSer.Marks.Format := '%0.2f';           // optional, round to 2 decimals   BSer.SeriesColor := clAqua;             // optional   for i:=1 to N do     BSer.Add(random, IntToStr(i), clAqua);   // <---. three parameters needed in 0.30   Chart1.AddSeries(BSer); end; ---------------------------------------------------------------------- Robert W.B. · 2012-03-31 17:28 Thanks for the code but I got Error message when compiling! unit1.pas(929,31) Error: Identifier not found "smsValue"  regards //Rob ---------------------------------------------------------------------- wp · 2012-03-31 17:33 Add TAChartUtils to your uses clause. Didn't you run my demo? ---------------------------------------------------------------------- Robert W.B. · 2012-03-31 17:49 TAChartUtils was the missing piece. Under Chart meny You can choose 11 components to You chart,noone is TAChartUtils.That one You have to put in Yourself under uses. Thank You for learning me about the TaChart. Best regards Rob ---------------------------------------------------------------------- wp · 2012-03-31 17:58 In the Lazarus IDE you see of TAChart only the installed components. However, there are many more units. When you create and modify series at run-time like you did, you have to add the needed units manually. TAChartUtils, just as its name says, is collection of utilities needed throughout the TAChart library, it does not contain any components. To learn more about these units go to your Lazarus folder and browse the directory components\tachart. Moreoer, there is a rather detailed documentation at http://wiki.lazarus.freepascal.org/TAChart_documentation.