Hi Problem with TChart lazarus / 55-TAChart ---------------------------------------------------------------------- goldfish999 · 2014-12-14 08:02 I did quite a lot with Delphi and have converted to Lazarus but haven't a clue how TChart works. How do you link a database table? ---------------------------------------------------------------------- howardpc · 2014-12-14 09:06 see http://forum.lazarus.freepascal.org/index.php/topic,19917.msg114056.ht ml#msg114056 ---------------------------------------------------------------------- wp · 2014-12-14 10:54 The folder components/tachart/demo/db of your Lazarus installation contains a little demo for charting database tables. And there's a lot of tutorials on TAChart - see letter "T" in http://wiki.lazarus.freepascal.org/Category:Tutorials P.S. Please use descriptive titles of your postings here, I almost would have missed yours. ---------------------------------------------------------------------- goldfish999 · 2014-12-16 03:50 Thanks for those links. I have got as far as showing the daily Temperatures against the values in the left axis but failed to make the related dates show on the bottom axis ---------------------------------------------------------------------- Jkey · 2014-12-16 07:41 If you fail to display datetime values in axis mark labels, you can find the necessary steps for them in TaChart documentation in "Date and Time axises" section: http://wiki.freepascal.org/TAChart_documentation#Coordinates_and_axise s ---------------------------------------------------------------------- goldfish999 · 2014-12-16 11:24 Thanks for that. Tried it but how do you tell it what data to use? Must you load some thing with a for-loop ---------------------------------------------------------------------- wp · 2014-12-16 11:39 My answer can be only very generic because you don't show us any details. Add a TDateTimeIntervalChartSource, connect it to the Marks.Source of the BottomAxis of the chart, and set the Marks.Style of the bottomaxis to smsLabel. This will do the conversion from date/time numbers to date/time strings. ---------------------------------------------------------------------- goldfish999 · 2014-12-16 16:13 The temperature data is a Firebird table with 3 fields. DATE (Date type), DATE_STR(String type) and READING(Float type). The form only has a Chart and a DateTimeIntervalChartSource which seem to be liked as far as I can see and a Button with this code: procedure TFrmGraph.BitBtn1Click(Sender: TObject); var   i, iCount, x: integer;   sDate: String; begin   x := 0;   with DM1.ZTableAmTempA do   begin     iCount:=RecordCount;     First;     for i := 0 to iCount+5 do     begin       //ShowMessage('x   '+FloatToStr(x));       fReading := FieldByName('READING').AsFloat;       sDate:=FieldByName('DATE').AsString;       //ShowMessage(IntToStr(i)+'   '+FloatToStr(fReading));       AmTemperatureSeries.AddXY(x, fReading);       x := x + 20;       Next;     end;   end; end; this draws a graph nicely. I haven't bothered much with fancy headings etc. That seems pretty elementary. The temperatures are show on the Left axis but the Bottom axis is blank. I hope that helps. Im sure I should be reading the date but I don't see anwhere to do that. Thanks ---------------------------------------------------------------------- wp · 2014-12-16 16:47 What I see in your code is that the values on the x axis are no DateTime values. Then a DateTimeIntervalChartSource is not very helpful. Before I give further advice, tell me what x is? Days past some date? And why does "i" run beyond the end of the last record? (RecordCount + 6) ---------------------------------------------------------------------- goldfish999 · 2014-12-16 17:02 AmTemperatureSeries.AddXY(x, fReading) will only take numeric data. I don't know how to add anything else. I made it run past the end just to see if it was adding all the info. Just me doing the wrong thing to see what happens ---------------------------------------------------------------------- wp · 2014-12-16 17:32 QuoteAmTemperatureSeries.AddXY(x, fReading) will only take numeric data.Sure, but that's not my question: You want to plot dates on the x axis (your posting of 04:50:27 above). But x is not a date,  date numbers start at Jan 1900, x should be something like 40000 these days. Only for this kind of date numbers, the DateTimeIntervalChartSource is useful. You seem to plot something else on the x axis. What is it? You have to convert the x values that you add to the series to strings representing a date. To give you a hint on which function to call I need to know what x is. ---------------------------------------------------------------------- goldfish999 · 2014-12-16 17:40 I thought x was the position of the Temperature value. that's what I got from the Wiki. what should I use to add the temperature and date. The only thing I found was ADDX and ADDXY ---------------------------------------------------------------------- wp · 2014-12-16 17:46 Sorry, I don't understand you, and you don't understand me. Please prepare a little project which shows your issue and upload it here (only pas, lfm, lpi and lpr files, packed into a zip). ---------------------------------------------------------------------- wp · 2014-12-17 10:44 In the attachment you find a little demo which may help you with the date axis although I am sure that it does not exactly cover your situation since you did not answer my questions. The demo contains a memory table with two columns: the date of a measurement and the temperature on this day. First click on "Create table" to fill the database with dummy data. Then you can click on "Plot vs. index" to read the temperature values from the database and to plot them against the index of the measurement. "Plot vs date", on the other hand, reads also the date column and plots the temperature vs date; the x axis is labeled by dates because the datetimeintervalchartsource is activated here. ---------------------------------------------------------------------- goldfish999 · 2014-12-17 11:56 Hi thanks for that. Im sorry I did not reply but I been out for a while. Ill try all that later on when I have more time. Thanks again ---------------------------------------------------------------------- goldfish999 · 2014-12-17 12:32 Im getting a weird error.   'ERead Error Unknown property SuppressPrevUnit'  at address 43C4A1 ---------------------------------------------------------------------- goldfish999 · 2014-12-17 12:44 Hi again. Is the strange maths for the temperature is just to get random results? ---------------------------------------------------------------------- wp · 2014-12-17 12:55 Sorry, no trunk... Please open unit1.lfm by a text editor (notepad or similar) and delete the line with "SuppressPrevUnit". Strange math? My idea was that the temperature during the year follow a cosine function, I multiplied it by -1 to have the lowest temperatures in winter. The rest is standard scalingsuch that the maximum/minimum temperatures are MAX_TEMP and MIN_TEMP, respectively. And I added some noise created by the random() function. ---------------------------------------------------------------------- goldfish999 · 2014-12-17 16:29 That is what I want to do. Thanks so much. I think I can adapt that code to my project. If I get stuck I know where to go. Thanks again ---------------------------------------------------------------------- goldfish999 · 2014-12-18 17:42 OK I have got the graph working now. There are 2 things that I cant get right. I would rather just have a dot or nothing than the little squares for the points but I haven't found how to change that. Is it possible to write the dates at an angle like it is in Delphi? Thanks very much ---------------------------------------------------------------------- goldfish999 · 2014-12-18 19:32 Hi. I have solved the angle of the Date. I should have realised that the figure was degrees. I tried small amounts at first then tried 300 and now that's fixed.  Thanks ---------------------------------------------------------------------- wp · 2014-12-18 22:25 The LabelFont of the axis has a property Orientation which is the rotation angle in tenths of a degree. Using a value of 900 means 90 degrees. The point symbol of a lineseries is defined by the series property Pointer.Style. And you can modify Pointer.HorizSize and Pointer.VertSize to change its size. ---------------------------------------------------------------------- goldfish999 · 2014-12-20 17:53 Thanks for that info. I now have another problem and your knowledge of maths will make it simple. I know its the wrong forum but I am now graphing barometric pressure in inches.  How do you restrict the max and min values to 2 or three decimals.  I get a max and min value from the table as it loads the readings Thanks ---------------------------------------------------------------------- wp · 2014-12-20 19:34 QuoteHow do you restrict the max and min values to 2 or three decimals. You mean the axis labels? Set the Marks.Format of the corresponding axis to %.2f (the "2" being the number of decimals). ---------------------------------------------------------------------- goldfish999 · 2014-12-20 19:40 OK Thank you