in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Is there a way to put text in, in line with, or above a bar?

Last post 04-03-2008 8:22 AM by C1_AndrewM. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-27-2008 1:00 PM

    Is there a way to put text in, in line with, or above a bar?

    I would like to have a bar chart with the bar value (or some arbitrary text) on, next to, or in line with the bar that relates to the text.  Is there a way to do this?  I looked at the online examples and the closest thing I saw was a leader note (which I am curious about as well).

     Thank you for any/all input.

    --
    tomS.
  • 03-27-2008 2:22 PM In reply to

    Re: Is there a way to put text in, in line with, or above a bar?

    I think I found functionality that is similar to what I want with the Series item Data label.  But this assigned a label globally to that series in the chart.  I would like to find a way to put a label on each bar independantly.

    Any ideas?

    --
    tomS.
    Filed under: ,
  • 04-03-2008 8:22 AM In reply to

    Re: Is there a way to put text in, in line with, or above a bar?

    Hello Tom,
     
    It seems that you are looking for ChartLables so that you may assign Text label to each data point. Something like attaching lable to each slice of the Pie Chart. In that case, you may try using following code:
     

    ' get chart data

    Dim data As DataView = _dataSet.Tables["Products"].DefaultView

    data.Sort = "UnitPrice"

    data.RowFilter = "CategoryID = 1"    ' beverages

    ' configure chart

    C1Chart1.Reset()

    C1Chart1.BackColor = Color.White

    C1Chart1.ChartArea.Style.Font = new Font("Tahoma", 8)

    C1Chart1.ChartGroups(0).ChartType = Chart2DTypeEnum.Pie

    ' get series collection (pies have one series per slice)

    Dim dscoll As ChartDataSeriesCollection = C1Chart1.ChartGroups(0).ChartData.SeriesList

    dscoll.Clear()

    ' populate the series

    Dim i As Integer

    For i = 0 To data.Count - 1

    Dim series As ChartDataSeries = dscoll.AddNewSeries()

    series.PointData.Length = 1

    series.Y(0) = data(i)("UnitPrice")

    series.Label = String.Format("{0} ({1:c})", data(i)("ProductName"), data(i)("UnitPrice"))

    Next I

    ' show pie legend

    C1Chart1.Legend.Visible = True

    C1Chart1.Legend.Text = "Product Unit Prices"

    ' hide legend, configure labels

    C1Chart1.Legend.Visible = false

    Dim s As Style = C1Chart1.ChartLabels.DefaultLabelStyle

    s.Font = new Font("Tahoma", 7)

    s.BackColor = SystemColors.Info

    s.Opaque = true

    s.Border.BorderStyle = BorderStyleEnum.Solid

    ' attach labels to each slice

    Dim i As Integer

    For i = 0 To data.Count - 1

      Dim lbl As C1.Win.C1Chart.Label = C1Chart1.ChartLabels.LabelsCollection.AddNewLabel()

      lbl.Text = string.Format("{0} ({1:c})", data(i)("ProductName"), data(i)("UnitPrice"))

      lbl.Compass = LabelCompassEnum.Radial

      lbl.Offset = 20

      lbl.Connected = True

      lbl.Visible = True

      lbl.AttachMethod = AttachMethodEnum.DataIndex

      Dim am As AttachMethodData = lbl.AttachMethodData

      am.GroupIndex = 0

      am.SeriesIndex = I

      am.PointIndex = 0

    Next i

     

    Regards,

    Andrew

    <tomshelley> wrote in message news:203296@10.0.1.98...

    I would like to have a bar chart with the bar value (or some arbitrary text) on, next to, or in line with the bar that relates to the text.  Is there a way to do this?  I looked at the online examples and the closest thing I saw was a leader note (which I am curious about as well).

     Thank you for any/all input.


    --
    tomS.

    http://helpcentral.componentone.com/cs/forums/p/74770/203296.aspx#203296

Page 1 of 1 (3 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.