Good day Paul
Thank you for your help.
I have created a separate Class to put the text for the index below the Bar Chart.
The text is placed at the correct positions as the Bar Chart changes dynamically.
However I fail to remove the previously placed text from the chart.
See code below.
Any suggestions is much appreciated!
Kind regards
Ockert.
Slot Monitor::BarIndex.updateIndex
/// Some common parameters for the calculation.
var int32 barSize = BarSize;
var rect bounds = Outline.Bounds;
// Calculate the available space and the distance between two adjacent bars.
// Thereby ensure that the bars are always fully visible. Accordingly reduce
// the space by the size of a single bar.
var float rangeX = bounds.w - barSize;
var float txtY1 = 85.0;
var float txtY2 = 105.0;
var float textMgn = 3.0;
var float x1;
var float x2;
var float ofsX = ( NoOfValues > 1 )? rangeX / ( NoOfValues - 1 ) : 0;
var int32 i;
var Views::Text idxText = new Views::Text;
// Now process all text. Adapt the size/position/color of each text.
for ( i = 0; i < NoOfValues; i++ )
{
// Is it necessary to load the data for the affected bar?
var bool reload = ( i >= invalidFirstValue ) && ( i <= invalidLastValue );
// No corresponding Views::Text found. Then create a new one.
if (!idxText)
{
idxText = new Views::Text;
reload = true;
idxText.Embedded = true;
Add( idxText, 0 );
}
if ( reload )
{
// Following code calculates the position of the view within the Chart component.
x1 = bounds.x1 + ( ofsX * i ) - textMgn;
x2 = x1 + barSize + textMgn;
idxText.Visible = true;
idxText.Color = Monitor::TextDay;
idxText.String = string (i + 1);
idxText.Font = Monitor::FontTextS;
// Arrange the position of the rectangle representing the Text.
idxText.Bounds = rect( int32( x1.round ), int32( txtY1.round), int32( x2.round ), int32( txtY2.round ));
}
// Search for the next already (eventually) existing view.
idxText = (Views::Text)Outline.FindNextView( idxText, Core::ViewState[]);
}
// If the number of bars was reduced in the chart. Remove all superfluous views now.
while ( idxText )
{
var Core::View tmpView = idxText;
// Search for the view following the actual view and then release the actual view.
idxText = (Views::Text)Outline.FindNextView( idxText, Core::ViewState[]);
Remove( tmpView );
}
// The update is finished. Clear the pending invalid flags.
invalidFirstValue = 0x7FFFFFFF;
invalidLastValue = 0;