in

C1 Community

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

Stacked Bars from Bound DataSet

Last post 04-07-2008 11:13 AM by C1_GregL. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-07-2004 5:11 PM

    Stacked Bars from Bound DataSet


    I would like to build a stacked bar chart from a bound dataset.
    Do you have any examples of this?

    The chart is bound to a single dataset. The Series X and Y are bound to a field name within that dataset. I am not sure how one would arrange a data set to fit this.

    Thanks,
    Vicki Dillon

    Click here to view the original newsgroup article (read only).

  • 07-09-2004 4:27 PM In reply to

    Re: Stacked Bars from Bound DataSet

    There is no difference when setup data binding for
    stacked and non-stacked chart, you can take a look
    into DataBoundChart sample.

    Saying shortly, you should do following steps:

    - create dataset and data adapter(standard ADO.Net operations)

    - attach data set(or data table) to the chart

    c1Chart1.DataSource = dataSet11.dataTable1

    - setup mapping between series data and field names

    ' first series
    c1Chart1.ChartGroups(0).ChartData(0).X.DataField = "FieldX"
    c1Chart1.ChartGroups(0).ChartData(0).Y.DataField = "FieldY0"

    ' second series
    c1Chart1.ChartGroups(0).ChartData(1).X.DataField = "FieldX"
    c1Chart1.ChartGroups(0).ChartData(1).Y.DataField = "FieldY1"

    ....

    - fill data set

    dataAdapter1.Fill( dataSet11)

    --
    Best regards,
    Alex

    >
    > I would like to build a stacked bar chart from a bound dataset.
    > Do you have any examples of this?
    >
    > The chart is bound to a single dataset. The Series X and Y are bound to a
    field name within that dataset. I am not sure how one would arrange a data
    set to fit this.
    >
    > Thanks,
    > Vicki Dillon
    >


    Click here to view the original newsgroup article (read only).

  • 03-27-2008 12:06 PM In reply to

    Re: Stacked Bars from Bound DataSet

    Hi,

     I have a stacked bar chart that I have created as described above, but I can't get the labels to display correctly.

     If I use the ax.AnnoMethod = AnnotationMethodEnum.ValueLabels; option the axis labels disappear completely. If I choose the ax.AnnoMethod = AnnotationMethodEnum.Values; option, additional values appear on the axis.

    My x axis is integer data. What I want to display are text labels like 83, 87, 88, 90 (or transform them to A, B, C, D etc) but what actually gets displayed is 83, 84, 85, 86, 87, 88, 89, 90.

    How do I create a stacked chart using data from a dataset and still have meaningful labels?

    Thanks in advance.

  • 04-07-2008 11:13 AM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 515

    Re: Stacked Bars from Bound DataSet

    What you can do is use the AnnoMethod ValueLabels and then create a ValueLabelsCollection to specify exactly how the labels appear.  So for example, if your X-Axis range was 80 - 100, and you only wanted the labels at 83, 87, 88, and 90 to appear you could fill the valuelabels with just those values.

    1. C1WebChart1.ChartArea.AxisX.AnnoMethod = C1.Win.C1Chart.AnnotationMethodEnum.ValueLabels;
    2. C1.Win.C1Chart.ValueLabelsCollection vlc = C1WebChart1.ChartArea.AxisX.ValueLabels;
    3. vlc.Add(83, "83");
    4. vlc.Add(87, "87");
    5. vlc.Add(88, "88");
    6. vlc.Add(90, "90");

    If you wanted text such as "A" at axis mark 83, you would just change it to be: vlc.Add(83, "A"); 

    Hope that helps,
    Greg

    Filed under: ,
Page 1 of 1 (4 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.