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
305
How to get a datalabel on top of each stackchart
posted

Hi,

I implemented chartdata titles on top of each chart in a stackchart by annotations. Its not shown in a series. On top of each chart the total sum is should be shown. No we migrated from 2007.3 to 2008.1 and it did not work anymore. So i looked again for other possibilities and i still cant find a way how i can get captions over each stackchart like that below. That example is not perfect. Here a calloutannotation was used and if the last series is too large its in the chart and not out of it.

some chartrows can be 0. In the new version you have to set the CalloutAnnotation.Location.Column not to column count like on 2007.3. You need to set it on the column count that counts columns that have values > 0 .  The same is when you use charttexts..

Thats what i do to get labels above the bars:

        For i As Integer = 0 To DsChart.Rows.Count - 1

            Dim row As DsTables.ChartTableRow = DsChart.Rows(i)         
            If (sum > 0) Then

                Dim a As New UltraChart.Resources.Appearance.CalloutAnnotation ' or Box
                a.Text = AddPointsToNumber(sum)
                a.Location.Type = UltraChart.Shared.Styles.LocationType.RowColumn
                a.Location.Row =-2
                a.Location.Column = annotationCol - 1
                a.FillColor = Drawing.Color.Transparent
                a.Border.Color = Drawing.Color.Transparent
                MyUltraChart.Annotations.Add(a)

            End If
        Next

However. It doesnt work correct. I also tried this:
Dim t As New ChartTextAppearance

t.Row = -2

t.Column = 2 '-1 shows nothing and -2 in each col -> want it on top of the last series

t.HorizontalAlign = Drawing.StringAlignment.Center

t.VerticalAlign = Drawing.StringAlignment.Far ' try near too

dt.Rows.CountMyUltraChart.ColumnChart.ChartText.Add(t)

So i am still looking for a solution that works. I spent now some hours in it. I hope somebody can tell me how we can do this.

Thank you! dixus

  • 305
    posted

    ok i found a way that is not nice but that works:

     

    'define inner chart area dimensions
    Dim w As Integer = 643
    Dim h As Integer = 210
    Dim a As New UltraChart.Resources.Appearance.BoxAnnotation
    
    a.Text = AddPointsToNumber(sum)
    a.Location.Type = UltraChart.Shared.Styles.LocationType.Pixels
    'calculate the X pixel by the current row + Y axis offset
    a.Location.LocationX = (i / DsChart.Rows.Count) * w + w / DsChart.Rows.Count + 50
    'calculate the X pixel by the current maxvalue + offset
    a.Location.LocationY = h - (sum / MaxRowValue) * h + 15
    
    a.FillColor = Drawing.Color.Transparent
    a.Border.Color = Drawing.Color.Transparent
    
    MyUltraChart.Annotations.Add(a)