Recent

Author Topic: TaChart how to draw buffer chart  (Read 915 times)

Mongkey

  • Sr. Member
  • ****
  • Posts: 438
TaChart how to draw buffer chart
« on: February 13, 2025, 11:57:37 am »
Does any know how to do in TaChart? Or just self draw on a form using TShape with scalling calculation.
« Last Edit: February 13, 2025, 12:02:19 pm by Mongkey »

wp

  • Hero Member
  • *****
  • Posts: 12678
Re: TaChart how to draw buffer chart
« Reply #1 on: February 13, 2025, 12:56:49 pm »
Never heard of that... What is a "buffer chart"?

Mongkey

  • Sr. Member
  • ****
  • Posts: 438
Re: TaChart how to draw buffer chart
« Reply #2 on: February 13, 2025, 01:01:14 pm »
I also did not know until recently i draw many industrial chart, ended on this kind of chart, just like stacking shape based on time, so we know how to read wether any machine or procceses got stuck or not. May be i need to deep dive into barseries chart, all i need just set the tickness of the stacked bars.
« Last Edit: February 13, 2025, 01:52:33 pm by Mongkey »

wp

  • Hero Member
  • *****
  • Posts: 12678
Re: TaChart how to draw buffer chart
« Reply #3 on: February 13, 2025, 04:07:12 pm »
I am attaching a small project which creates something like this. Basically a stacked and rotated bar chart. I don't know what the colors mean, just chose random values.

wp

  • Hero Member
  • *****
  • Posts: 12678
Re: TaChart how to draw buffer chart
« Reply #4 on: February 13, 2025, 07:30:21 pm »
Seems to be something like the "State Time Line" of https://grafana.com/docs/grafana/latest/panels-visualizations/visualizations/state-timeline/. I think this requires for each data point:
- 2 x-values (start time, end time) (or, if there is only 1 x-value the end time of one state should be given by the next time value)
- 1 y-value (always the same ordinal value to identify each "machine", or, when it is sequentially incremented we have a Gantt series!)
- a state variable, this could be the color field or label field in the TChartDataItem record

I think I have a draft of a Gantt series somewhere...

Mongkey

  • Sr. Member
  • ****
  • Posts: 438
Re: TaChart - how to draw buffer chart
« Reply #5 on: February 14, 2025, 01:36:02 am »
Thank you WP!!

wp

  • Hero Member
  • *****
  • Posts: 12678
Re: TaChart how to draw buffer chart
« Reply #6 on: February 14, 2025, 12:39:56 pm »
Since this appears to be a quite useful series type I wrote a TStateSeries class which I am providing in the attachment together with a simple application project:
  • Add a TStateSeries to the form (it is not yet registered in this form - you must create it at runtime: series := TStateSeries.Create(self) and add it to the chart: Chart.AddSeries(series) )
  • Add each state block by calling the AddXY method: the first two arguments are the start and end times of the block. The third argument is the y value, it identifies the machine to be plotted; use always the same y value for the same machine to get a straight-line arrangement of the blocks, or increment them to get a stair-case like display like in a Gantt plot. The fourth parameter identifies the state by a string. In the sample I have four states "Production", "Repair", "Maintainance" and "Development" - select one of them. And the last parameter identifies the color of this block; normally there should be a 1:1 correspondence of state name and color.
  • In order to display the times along the horizontal axis add a TDateTimeIntervalchartSource and link it to the Marks.Source of the bottom axis (and set Marks.Style to smsLabel).
  • In order to display the machine names along the vertical axis, add a TListChartSource to which you add the the machine name together with its y value. Link the chartsource to the Marks.Source of the left axis (and set Marks.Style to smsLabel)
  • Basically, that's all. In the sample project you find other extensions, such as series labels or popup hints with the duration of each state block.

wp

  • Hero Member
  • *****
  • Posts: 12678
Re: TaChart how to draw buffer chart
« Reply #7 on: March 01, 2025, 10:56:39 am »
TStateSeries, a bit modified from this post, is now contained in the official TAChart package of Laz/main (in unit ]"]>BlockedltiSeries). There is also a sample project in the folder demo/stateseries of the TAChart installation showing its application as state series and as Gantt series.

See https://wiki.lazarus.freepascal.org/TAChart_documentation#TStateSeries.
« Last Edit: March 01, 2025, 12:29:24 pm by wp »

 

TinyPortal © 2005-2018