Recent

Author Topic: Tchart distance  (Read 1002 times)

flori

  • Full Member
  • ***
  • Posts: 196
Tchart distance
« on: February 25, 2021, 01:22:15 pm »
Hi everyone!
Does anyone know how can I change the distance between 2021-2022? (very far away) I want to bring it closer.
I changed BarOffsetPercent but not used




wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Tchart distance
« Reply #1 on: February 25, 2021, 01:25:30 pm »
Is this a single BarSeries with multiple y values, or several BarSeries with a single y value each? In either way, there seem to be too many y values.

How did you create the chart, create the series and add the data values?

flori

  • Full Member
  • ***
  • Posts: 196
Re: Tchart distance
« Reply #2 on: February 25, 2021, 01:35:36 pm »
I use 3 piece Chart1BarSeries 1, 2, 3 which has 3 values ​​on it.  1. green-Nitrogen, Blue- Phosphor, Red: Calcium
x line set for different years (2021-2022). These are connect to database.
Displays the nutrient content of the soil in different years.

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Tchart distance
« Reply #3 on: February 25, 2021, 01:51:33 pm »
Still too general. can you create a small project which shows the issue and upload it here (only .pas, .lfm, .lpi, .lpr files backed into a common .zip, do not add the exe and other compiler-generated files)

flori

  • Full Member
  • ***
  • Posts: 196
Re: Tchart distance
« Reply #4 on: February 25, 2021, 02:28:09 pm »
I attached Chart.zip
The GBD content:
             soil nutrients
Years    N      P       K
2021     
2022

Thank you.

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Tchart distance
« Reply #5 on: February 25, 2021, 04:31:59 pm »
Could you transfer the database to a TBufdataset because there is an issue in my Firebird installation?

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Tchart distance
« Reply #6 on: February 25, 2021, 05:02:06 pm »
The BarWidthPercent is too small. The distance from one x value to the other is considered to be 100%. You have three series which share this space. BarWidthPercent is the percentage of that space given to each series (bar). So, with three series, BarWidthPercent would have to be 33.3333% to completely fill the xaxis. If you want some spacing between the bar groups, say 10%, then each bar can only get 30% --> 3 x 30% + 10% = 100%.

Now we must fix the BarOffsetPercent. By default this has the value 0 -- all bars are centered and fully overlapping at the tick mark. You must move the left most bar by one BarWidthPercent to the left, i.e. LeftSeries.BarOffsetPercent := -30. The center bar can stay at the center of the tick mark (CenterSeries.BaroffsetPercent := 0). And the right bar must be shifted by one BarWidthPercent to the right. RightSeries.BaroffsetPercent := 30;

Another important hint: TDBChartSource is pretty awkward do use because it iterates over the entire dataset again and again. Therefore, it is highly recommended to add a TListChartSource for each series and to copy the DBChartSource into the ListChartSource:
Code: Pascal  [Select][+][-]
  1.  ListChartSource.Copyfrom(DBChartSource);
« Last Edit: February 25, 2021, 07:34:04 pm by wp »

flori

  • Full Member
  • ***
  • Posts: 196
Re: Tchart distance
« Reply #7 on: February 25, 2021, 07:17:17 pm »
Yes. Before I used B.off -30:0+30
Thank you !

 

TinyPortal © 2005-2018