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
30
How can I change the label of each data item for stack chart?
posted

I made a dataset like below..

=============================

Day | 10/17, 10/18, 10/19

A    |  10       14       23

B    |  5         6         7 

C    |  5         6         7

And I created the stack column chart with this data.

I want the each box has its original value. but default chart print the accumulated value at each box.

In case of 10/17 data. Ultra chart draw the label with 10, 15, 20.

How can I change the accumulated value with the original value?

 P.S. please use c# at reply.

  • 26458
    Verified Answer
    Offline posted

    You need to set the format string to "<DATA_VALUE_ITEM>" instead of "<DATA_VALUE>"
    I'm assuming you're using a ChartTextAppearance object for this?

    ChartTextAppearance chartText = new ChartTextAppearance();
    chartText.ItemFormatString =
    "<DATA_VALUE_ITEM>";
    chartText.Visible =
    true;
    chartText.Row = -2;
    chartText.Column = -2;
    this.ultraChart1.ColumnChart.ChartText.Add(chartText);

  • 30
    posted
    Thanks Max Rivlin. Your answer was perfect. Yesterday, before I received your answer, I solved the problem with another way. This is an informal solution for additional label in column chart.
    
    //Source..---------------------------
    
    this.chartDaily.DataSource = dv;
    
    for (int i=0; i < dv.Table.Rows.Count; i++)
    {
        this.chartDaily.Annotations.Add(GetLabelBox("", dv.Table.Rows[i][1].ToString(), i, 0, Color.Black));
        this.chartDaily.Annotations.Add(GetLabelBox("", dv.Table.Rows[i][2].ToString(), i, 1, Color.Black));
        this.chartDaily.Annotations.Add(GetLabelBox("▼", dv.Table.Rows[i][3].ToString(), i, 2, Color.Blue));                
    }
    
    // Another tip.
    // Please do not use this function at Event ChartDrawItem Function.
    // A ChartDrawItem Event was called whenever mouse leave from the chart.
    
    ---------------------------
    
    private Infragistics.UltraChart.Resources.Appearance.BoxAnnotation GetLabelBox(string strLabelHeader, string iValue, int iX, int iY, Color c)
            {
                Infragistics.UltraChart.Resources.Appearance.BoxAnnotation boxAnn = new Infragistics.UltraChart.Resources.Appearance.BoxAnnotation();
                if (iValue == "0")
                {
                    boxAnn.Text = "";
                }
                else
                {
                    boxAnn.Text = "  " + strLabelHeader + iValue.ToString();
                }
                boxAnn.Location.Type = Infragistics.UltraChart.Shared.Styles.LocationType.RowColumn;
                boxAnn.Location.Row = iX;
                boxAnn.Location.Column = iY;
                boxAnn.Border.Color = System.Drawing.Color.Transparent;
                Infragistics.UltraChart.Shared.Styles.LabelStyle lstyle = new Infragistics.UltraChart.Shared.Styles.LabelStyle();
                lstyle.FontColor = c;
                lstyle.Font = new Font("Arial Bold", 9F);
                boxAnn.TextStyle = lstyle;
                return boxAnn;
    
            }