Recent

Author Topic: chart with vertical stripes as background  (Read 1215 times)

ronhud

  • Jr. Member
  • **
  • Posts: 84
chart with vertical stripes as background
« on: November 29, 2020, 01:56:09 pm »
I have a tchart with 3 lineseries.    Data points consist of 4 pulse readings per day for one of the series for example.  I would like the background to consist of vertical stripes alternating 2 colours each stripe the width of a day's worth of points.  The reason being to make reading the chart as days with 4 points easier.   So far I havent been able to find a way to do this - it is necessary that the line for each series can be seen over this background.   The xaxis is based on datetime data.   Any help appreciated 

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: chart with vertical stripes as background
« Reply #1 on: November 29, 2020, 04:29:12 pm »
I don't know if this solves your question: Add a TStyles component and link it to to the Marks.Stripes of then BottomAxis. Doubleclick on the Styles component and add two Style elements; set their Brush.Color to what you want. When you are done, the space between the axis labels will be colored in alternating colors defined by the Styles.

If you don't want the color between all labels you can add a second bottom axis to which you assign the TStyles component. Give the normal and the second bottom axis a common non-zero Group value so that they are overlaid, and hide the labels of the second axis (Marks.Visible = false). Use a TListChartSource (assigned to the Marks.Source of the second x axis) in which you define the positions of marks separating the stripes; together with the Styles you can get very individual color stripes this way. (You may have to tweak also the Intervals of the second x axis to avoid interference with automatic axis label generation).

Have a look a the attached demo which colors the region between x=-0.1 and 0.1. The stripes are defined in the DataPoints property of the ListChartSource.

ronhud

  • Jr. Member
  • **
  • Posts: 84
Re: chart with vertical stripes as background
« Reply #2 on: November 30, 2020, 01:54:05 pm »
That works exactly.   Thank you for a clear solution and the example which helped in understanding it.

 

TinyPortal © 2005-2018