Recent

Author Topic: tchart change left axis settings  (Read 1612 times)

ladybird

  • Newbie
  • Posts: 6
tchart change left axis settings
« on: December 11, 2019, 05:42:07 pm »
Hello all,

I'm newbie to lazarus. I have an application using a Tchart module.

    Form1.Chart1LineSeries1.AddXY(x, data1);
    Form1.Chart1LineSeries2.AddXY(x, data2);

I'm supposed to get y_axis values between -20 and 20 but the chart is displaying from -1000 to 1000 so i cannot see my data
Please could you help me out change the settings of the Tchart of Lazarus

Best regards

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: tchart change left axis settings
« Reply #1 on: December 11, 2019, 05:49:51 pm »
What are the values of data1 and data2? These are the y values of the two data points that you added.

ladybird

  • Newbie
  • Posts: 6
Re: tchart change left axis settings
« Reply #2 on: December 11, 2019, 05:52:42 pm »
i receive this data through the serial port . so data is known

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: tchart change left axis settings
« Reply #3 on: December 11, 2019, 05:58:28 pm »
Can you zoom in to verify that the graph is displaying data correctly, and it is just the left Y axis mapping that needs to be fixed?
Look to the left axis min/max values in the object inspector to see if they have been forced to a large spread accidentally. 
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

ladybird

  • Newbie
  • Posts: 6
Re: tchart change left axis settings
« Reply #4 on: December 11, 2019, 06:10:12 pm »
Thank you for your reply

I'have just the basic Tchart , it doesnt allow zoom.

I checked the TchartRange
min = 0
max = 0
useMin  = false
useMax = false

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: tchart change left axis settings
« Reply #5 on: December 11, 2019, 06:12:13 pm »
i receive this data through the serial port . so data is known
But I don't. Maybe your data1 and data2 values are 951 and -851 (just examples) instead of -18 and 15 which would explain why your y axis ranges from -1000 to 1000 instead of from -20 to 20. Set a breakpoint before you plot the data, move the mosue over "data1" and "data2" and see their values.
« Last Edit: December 11, 2019, 06:22:33 pm by wp »

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: tchart change left axis settings
« Reply #6 on: December 11, 2019, 06:22:06 pm »
I'have just the basic Tchart , it doesnt allow zoom.
When you did not modify the chart you CAN zoom. Zooming is done by default by dragging with the left mouse button from the top-left corner to the bottom-right corner of the rectangle to be enlarged. Dragging with the right mouse button drags the viewport. A simple click into the chart restores the original view.

As a beginner you maybe should study the getting started tutorial of TAChart (https://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Getting_started). And you should know that there is a wiki documentation of the TAChart features (https://wiki.lazarus.freepascal.org/TAChart_documentation).

ladybird

  • Newbie
  • Posts: 6
Re: tchart change left axis settings
« Reply #7 on: December 11, 2019, 06:25:22 pm »
My received data is between 0 and 255 ( because i have 8 bit serial communication ) 

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: tchart change left axis settings
« Reply #8 on: December 11, 2019, 06:38:16 pm »
But then you can't expect the y axis to adjust to a range between -20 and +20; and it is also not clear why the scales run from -1000 to 1000.

Is there a way that you could extract the chart from your project into a standalone simple demo which shows the issue? Instead of attaching a serial port you could add a TTimer to the form, write an OnTimer handler to create some dummy data in the range you expect and feed them into the chart. When you pack the .pas, .lfm, lpi and lpr files into a zip archive which you can upload here I would see what you are doing exactly and I could assist you better.

ladybird

  • Newbie
  • Posts: 6
Re: tchart change left axis settings
« Reply #9 on: December 11, 2019, 06:46:00 pm »
In fact , i'm adjusting data before displaying , that's why i know what range would be the output.
That's my first time using Lazarus. I've just one form and the chart is included in a timer procedure
 

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: tchart change left axis settings
« Reply #10 on: December 11, 2019, 07:16:14 pm »
Assuming that your x data is some kind of time I assembled a small demo for you. Compare it with your code and find out what is different.

ladybird

  • Newbie
  • Posts: 6
Re: tchart change left axis settings
« Reply #11 on: December 12, 2019, 10:00:53 am »
Thank you so much , i will compare it to my project

 

TinyPortal © 2005-2018