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
65
how to use stackedBarChart with Swap Rows and Columns like this
posted

Hello all

I want get following chart with it's above datasurce, look at the first pictue I uploaded.

What I can do now please look at following code:

 Private Sub UltraChart1_ChartDrawItem(ByVal sender As Object, ByVal e As Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs) Handles UltraChart1.ChartDrawItem

        If e.Primitive Is Nothing Then Exit Sub

        If e.Primitive.Path = "Border.Title.Grid.Chart" Then

'''dv is a datatable from datasource

            Select Case dv.Table.Rows(i).Item("color")

                Case "blue"

                    e.Primitive.PE.Fill = Color.Blue

                    e.Primitive.PE.FillStopColor = Color.Blue

                Case "yellow"

                    e.Primitive.PE.Fill = Color.Yellow

                    e.Primitive.PE.FillStopColor = Color.Yellow

                Case "red"

                    e.Primitive.PE.Fill = Color.Red

                    e.Primitive.PE.FillStopColor = Color.Red

                Case "green"

                    e.Primitive.PE.Fill = Color.Green

                    e.Primitive.PE.FillStopColor = Color.Green

            End Select

            i += 1

        End If

    End Sub

  it works but it is not right what I want.

  my questions is:

  1\ is there others better approach to get the purpose what I what?

  2\ how to do not show the bar border line so that the line between contiguous bar cannot be seen. this make the contiguous bar looks like one picture

  3\ how to show the bar like BackGradientStyle (vertical etc.) with color and color2?

  4\ how to add other bar in the same Chart, now I only can show one bar in the chart.

      I user Swap Rows and Columns so all of row change to column I think.

      but other bars may be come from the rows which some field can distinguish it. just like first picture I uploaded.

  thank you in advance

  Herry

Parents
  • 23930
    Offline posted

    Hi,

    Thank you for contacting Infragistics Developer Support.

    In order to use your data source as the source for a stacked bar chart, you will need to modify it. The chart will treat each row as a separate bar using its numeric values as the values for the fragments and its string value for the label. If you use Swap Rows and Columns it will use each numeric column as a bar and the column key as the label. I would suggest in your case to create series based on your data table, by grouping the rows by the value of the chart field and then adding the value of the length column for each row. As for your other requirements I would use the FillSceneGraph event. In it you can get the box primitives for each fragment of the bars, set its color and add a text primitive with the length field (I actually used the difference of the current box value and the previous box value).

    I have attached a sample which demonstrates this suggestion. I have created the chart as close as possible to the picture you have uploaded. If you want to have a gradient paint elements you can use the Fill, FillStopColor and FillGradientStyle properties.

    Please let me know if you have any additional questions.

    WC_CustomBarChart.zip
Reply Children