Recent

Author Topic: TAChart static axis values  (Read 10476 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8790
  • Programming + Glam Metal + Tae Kwon Do = Me
TAChart static axis values
« on: March 26, 2010, 06:31:03 am »
I need to have static axis values for TAChart. I want the left axis always and only shows 1,2,3, and 4 (inverted) and the bottom always and only shows 1,2,3 up to 7 regardless either window size or the plotted data. How can I achieve it?

lightningchaser

  • New member
  • *
  • Posts: 7
Re: TAChart static axis values
« Reply #1 on: March 26, 2010, 08:05:29 am »
see this topic, you will need a recent build
http://forum.lazarus.freepascal.org/index.php/topic,8887.0.html

Leledumbo

  • Hero Member
  • *****
  • Posts: 8790
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TAChart static axis values
« Reply #2 on: March 26, 2010, 09:16:05 am »
I know, you see I also post there. The problem is: how? what properties should be modified in object inspector? I try to use Extent, but when maximized the graph has 1.5, 2.5, and 3.5 as well. I only want the integers.

lightningchaser

  • New member
  • *
  • Posts: 7
Re: TAChart static axis values
« Reply #3 on: March 26, 2010, 03:24:03 pm »
I know, you see I also post there. The problem is: how? what properties should be modified in object inspector? I try to use Extent, but when maximized the graph has 1.5, 2.5, and 3.5 as well. I only want the integers.

you should use "ListChartSource1.DataPoints.Add", the items seem seperated by a pipe symbol.

make sure the source of the marks point to the listchartsource1 and style is set to smsLabel.

I did use this code to show the date on the axis:

Code: [Select]
 dateaxis:=encodedatetime(yearof(now),1,1,0,0,0,0);

  for i:=1 to DaysInYear(dateaxis) do begin

    //show first day of the month
    if DayOfTheMonth(dateaxis)=1 then begin
      ListChartSource1.DataPoints.Add(inttostr(i)+'|'+inttostr(i)+'|?|'+formatdatetime('yyyymmdd',dateaxis)+'');
    end else begin
      //show first day of the week
      if (dayoftheweek(dateaxis)=1) then
        ListChartSource1.DataPoints.Add(inttostr(i)+'|'+inttostr(i)+'|?|'+formatdatetime('yyyymmdd',dateaxis));
    end;

    dateaxis:=incday(dateaxis,1);
  end;    
« Last Edit: March 26, 2010, 03:26:06 pm by lightningchaser »

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart static axis values
« Reply #4 on: March 26, 2010, 04:36:27 pm »
Quote
The problem is: how? what properties should be modified in object inspector?

First, is you do not already, you have to use recent svn version.
Using it, you can look at components/tachart/demo/axis folder for a sample project.

Quote
You should use "ListChartSource1.DataPoints.Add", the items seem seperated by a pipe symbol.

Well, I really should write some documentation sometime...
Anyway, DataPoints property is mainly intended to allow design-time editing of
list source data.
If you are adding data at run-time, it is more efficient and convenient to
use TListChartSource.Add method:

Code: [Select]
ListChartSource1.Add(i, i, clTAChart, formatdatetime('yyyymmdd',dateaxis));
Also, if you have many data points and want to generate them on-the-fly instead of
storing inside of the source, you can use TUserDefinedChartSource.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8790
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TAChart static axis values
« Reply #5 on: March 28, 2010, 08:30:16 am »
I found it. The axis also has Source property, which I can use to assign different values for left and bottom axis.

 

TinyPortal © 2005-2018