Recent

Author Topic: TAChart Line chart options  (Read 3711 times)

JD

  • Hero Member
  • *****
  • Posts: 1848
TAChart Line chart options
« on: June 05, 2018, 05:42:10 pm »
Hi there everyone,

I have a line chart (see the screenshot) and I would like to accomplish the following

a) start the vertical Y axis from zero
b) Change the rectangular data points in the line chart to round, filled and yellow
c) make the line smoother

Thanks for your assistance

JD
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TAChart Line chart options
« Reply #1 on: June 05, 2018, 07:00:21 pm »
a) start the vertical Y axis from zero
Set the "Extent.YMin" of the chart to zero (it already should have this value by default), and activate this setting by "Extent.UseYMin" = true

b) Change the rectangular data points in the line chart to round, filled and yellow
The data point symbols are controlled by the property "Pointer" of the series. Set "Pointer.Style" to psCircle, and "Pointer.Brush.Color" to clYellow (and "Pointer.Brush.Style" to bsSolid - but I think you already have this by default).

c) make the line smoother
You mean the line connecting the data points? There are three specialized series for this. So, instead of TLineSeries use one of the following series types:
  • TCubicSplineSeries: a cubic spline which passes through the data points and draws a smooth curve. May have some overshoot in case of wildly varying data.If you have Laz-trunk you may switch the "SplineType" of the series from "cstNatural" to "cstHermiteMonotone" to avoid the overshoots.
  • TBSplineSeries: a B-Spline which is smoother than the CubicSplineSeries because is does not pass through the data points.
  • TFitSeries: if you know that your data should follow an equation (polynomial, exponential, or power) you can try TFitSeries which adjusts the coefficients of a polynomial, exponential or power function to get least deviation from the data points (http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_ListChartSource,_Logarithmic_Axis,_Fitting#Fitting)
Your y axis labels are very irregular and seem to be taken from the y values of the data points. Normally the axes have "nice" labels, i.e. rounded numbers making it easy to understand the chart by the naked eye. To get "nice" labels remove the chartsource from the yaxis' "Marks.Source" and set the yaxis' "Marks.Style" to smsValue. If the labels are too close increase the yaxis' "Intervals.MaxLength" - usually 80 or 100 is better than the default 50 in particular for horizontal axes (I know, your axis is vertical, so, this step may not be necessary).

 

TinyPortal © 2005-2018