Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
920
How to set text primitive font size in FillSceneGraph on bar chart
posted

Hi

I have a bar chart (see attached PNG) and I use FillSceneGraph to add text at the top of each bar to show the impact of late timesheet completion on the data.

The issue is that the text font is too large, the text is not centered on the bar and text on adjacent bars run into each other.  How do I specify a smaller font size when creating the text primitive and how do I center it on the bar?

I am using Infragistics 15.1 with latest service releases.

The code in FillSceneGraph is shown below. 

Private Sub chartBottomLeft_FillSceneGraph(sender As Object, e As Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgsHandles chartBottomLeft.FillSceneGraph
    If Not _loadingData Then
        Dim sceneGraph As SceneGraph = e.SceneGraph
        Dim actual As Box
        Dim actualDataPoint As NumericDataPoint
        Dim textPrimitive As Infragistics.UltraChart.Core.Primitives.Text
 
        Dim primitivesToAdd As List(Of Infragistics.UltraChart.Core.Primitives.Text) = New List(Of Text)(5)
        Dim difference As Double
 
        Dim dtNoLate As DataTable = getChartDataWithoutLateTimesheetCompletion("Work Life Balance Report Data - Average Hours by Grade - No Late", lvwOfficeLocations, cboAverageHoursByGradeStartDate.Value, cboAverageHoursByGradeEndDate.Value)
 
        Dim rowIndex As Integer = 0
        Dim colIndex As Integer = 1
        For Each p As Primitive In sceneGraph
            actual = TryCast(p, Box)
            If actual IsNot Nothing Then
                actualDataPoint = TryCast(actual.DataPoint, NumericDataPoint)
 
                If actualDataPoint IsNot Nothing Then
                    Dim index As Integer = sceneGraph.IndexOf(actual)
                    If index <> -1 AndAlso index + 1 < sceneGraph.Count Then
 
                        difference = (actualDataPoint.Value - dtNoLate.Rows(rowIndex)(colIndex)) / actualDataPoint.Value
 
                        If Math.Abs(difference) > 0.0 Then
                            
                            Dim _location = New Point(actual.rect.Left + (actual.rect.Width / 2) - 10, actual.rect.Top - 8)
 
                            textPrimitive = New Text(_location, difference.ToString("0.0%;-0.0%;0%"))
 
 
                            primitivesToAdd.Add(textPrimitive)
                        End If
 
                    End If
 
                    If colIndex = 3 Then
                        rowIndex += 1
                        colIndex = 1
                    Else
                        colIndex += 1
                    End If
                End If
            End If
        Next
 
        For Each _text As Text In primitivesToAdd
            sceneGraph.Add(_text)
        Next
    End If
End Sub

Any help greatly appreciated.

Regards

James O'DOherty

Solution and Database Architect

WINSQL Ltd

Parents
  • 23930
    Verified Answer
    Offline posted

    Hi James,

     

    Thank you for posting in our forums.

     

    Have you tried setting the labelStyle.Font property? Please let me know if the following code works for you:

     

    myTextPrim.labelStyle.Font = new Font("Microsoft Sans Serif", 6.5f, FontStyle.Regular)

     

    Please let me know if you have any additional questions.

Reply Children
No Data