C1BarChar: How to show BOTH actual value and percentage?

Posted by: debarupa2012 on 10 September 2017, 11:46 am EST

  • Posted 10 September 2017, 11:46 am EST

    I am using a C1BarChart and data binding it with percent values that are coming from the database. So the bars show percentage values and so does the horizontal axis (I could call it the x-axis but it's actually referred to as the y-axis in the C1BarChart properties).

    Now, the requirement is to show both the actual values and percentages on the chart. The actual values could be along the horizontal axis for once or may appear when you hover over the bars or could be shown inside each bar.

    If I have both the actual value and the percentage from the database, is there a way to show both on the chart?

    Thanks in advance.
    Debarupa
  • Replied 10 September 2017, 11:46 am EST

    Hello Debarupa,

    You may use ValueLabels to display custom data on X-axis or you may set the HintContent property to the desired data column so that it can displayed when you hover over the bars. You may also refer to the following blog describing about binding HintField:
    http://our.componentone.com/2011/10/04/defining-tooltips-for-databound-wijmo-charts/

    Regards
    Ashish
  • Replied 10 September 2017, 11:46 am EST

    The HintField is exactly what I was looking for.

    Thank you so very much!!
  • Replied 10 September 2017, 11:46 am EST

    Could you include a sample code on how to use ValueLabels to display custom data on X-axis?
    I would like to learn that method also just in case.

    Thanks a lot!
    Debarupa
  • Replied 10 September 2017, 11:46 am EST

    Hello Debarupa,

    Here is the small code snippet for using ValueLabels in Wijmo Charts:


    For i = 1 To 4
    'create object of ValueLabel class
    Dim vl As New C1.Web.Wijmo.Controls.C1Chart.ValueLabel()
    ' set the x-axis value which you want to replace
    vl.NumericValue = i
    ' set the desired value which you want to show
    vl.Text = "Value" & i.ToString()
    ' add it to the ValueLabel collection
    C1BarChart1.Axis.X.ValueLabelList.Add(vl)
    Next

    'set the annotation to valuelabels instead of values.
    C1BarChart1.Axis.X.AnnoMethod = ChartAxisAnnoMethod.ValueLabels


    Regards
    Ashish
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels