This is a migrated thread and some comments may be shown as answers.

Customizing stacked bar chart in a report

4 Answers 459 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dhruv
Top achievements
Rank 1
Dhruv asked on 13 Jan 2011, 05:14 PM
Hi,
    Attached is an Excel stacked bar chart that we are interested in building inside the report viewer. The chart is intended to compare actual / target "% complete" values across products. Would really appreciate if anyone could indicate whether this layout and color scheme is doable or not, so we can decide whether or not to pursue.

To summarize, here are some of the features we are looking for:

1.) Ability to customize the fill color for each data item in each series

2.) Ability to drill-through the chart. In other words, if a user were to click on the bar for "1", it should open a similar bar chart, showing bars for the individual phases of product "1" with a similar layout, and so on...

Thanks much in advance for the help!
Dhruv

 

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 19 Jan 2011, 09:25 AM
Hello Dhruv,

Thank you for your interest in Telerik Reporting and up to your questions:
  1. Stacked Bar charts are supported type - more info is available in Stacked Bar Charts help article. You can control the fill color for each separate series item through the FillStyle section in Appearance. Generally you can create a CustomPalette to control the styling of your chart or use the predefined ones in the SeriesPalette property, but since your colors would depend on the actual/target values, you would have to control this manually.
  2. Drill-down/through is not available for the report chart item in the current version. However we have this in our plans for subsequent version of the product along with other charting improvements.

Kind regards,
Steve
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
Brant
Top achievements
Rank 1
answered on 24 Feb 2011, 09:13 PM
I am trying to create a stacked bar chart programatically based on the data in a datatable that is created dynamically from a form.  I can't get the axis item labels to match up with the series.  They are always aff.  If I am naming my series item is there a way to go in and match the x-axis textblock to the series it is lined up with ? My data is attached and so is a pdf of my report and the code I use to get it.  Thanks in advance!

Brant

Dim oSeries As Charting.ChartSeries = New Charting.ChartSeries("Open", Charting.ChartSeriesType.StackedBar)
 
 
                Dim cSeries As Charting.ChartSeries = New Charting.ChartSeries("Closed", Charting.ChartSeriesType.StackedBar)
 
                stSeries = ""
 
                For i As Integer = 0 To dt.Rows.Count - 1
                    If stSeries <> dt.Rows(i).Item(0).ToString Then
                        Chart1.PlotArea.XAxis.AddItem(dt.Rows(i).Item(0).ToString)
                        stSeries = dt.Rows(i).Item(0).ToString
                    End If
                    Select Case dt.Rows(i).Item(1)
                        Case Is = 1, 2, 3
                            Dim seriesItem As New Telerik.Reporting.Charting.ChartSeriesItem
                            seriesItem.YValue = dt.Rows(i).Item(iCOL - 1)
                            seriesItem.Appearance.FillStyle.SecondColor = Color.DarkRed
                            seriesItem.Appearance.FillStyle.MainColor = Color.Red
                            seriesItem.Name = dt.Rows(i).Item(0).ToString
                            oSeries.AddItem(seriesItem)
                        Case Is = 4
                            Dim seriesItem As New Telerik.Reporting.Charting.ChartSeriesItem
                            seriesItem.YValue = dt.Rows(i).Item(iCOL - 1)
                            seriesItem.Appearance.FillStyle.SecondColor = Color.DarkGreen
                            seriesItem.Appearance.FillStyle.MainColor = Color.LightGreen
                            seriesItem.Name = dt.Rows(i).Item(0).ToString
                            cSeries.AddItem(seriesItem)
                    End Select
 
 
                Next
                Chart1.PlotArea.XAxis.AutoScale = False
                 
                Chart1.Series.Add(oSeries)
                Chart1.Series.Add(cSeries)



qryChart
suppliername status CountOfCPID
A K PROPERTIES 1 1
CENTEGRA OCCUPATIONAL HEALTH 1 1
EUROTHERM DRIVES 3 1
EUROTHERM DRIVES 4 3
FORMS PLUS 4 1
LANDIS GRINDING SYSTEMS 4 1
MA Inc 1 3
METO-GRAFICS, INC. - 27009 4 1
SENCO PRODUCTS, INC. 1 1
STATE DISBURSEMENT CENTER 4 1
Supplier A 1 1
THE COPY EXPRESS, Inc. 4 1
UNITED WAY of McHENRY COUNTY 4 2
VARIAN PRODUCTS 3 1
VARIAN PRODUCTS 4 5
WAYNE'S COUNTRY MARKET 3 1
WI SCTF 4 1
0
Ves
Telerik team
answered on 02 Mar 2011, 08:20 AM
Hi Brant,

I must agree this is a bit tricky. Actually, the chart will place a ChartSeriesItem at the desired position along the X axis if it is told to do so by setting the ChartSeriesItem.XValue. Otherwise, the items will be placed next to each other, starting from the first X axis position. And this is true for each ChartSeries alone. Here is an example, showing how to position the ChartSeriesItem, using the XValue property, given that the datasource is already sorted, so if there are two records with the same Suppliername, they will come next to each other:

Dim oSeries As ChartSeries = New ChartSeries("Open", ChartSeriesType.StackedBar)
 
Dim cSeries As ChartSeries = New ChartSeries("Closed", ChartSeriesType.StackedBar)
 
Dim stSeries As String = ""
Dim xValue As Double = -1
 
RadChart1.AutoLayout = True
RadChart1.PlotArea.XAxis.Clear()
 
Dim axisItem As ChartAxisItem
 
For i As Integer = 0 To dt.Rows.Count - 1
    If stSeries <> dt.Rows(i).Item(0).ToString Then
        xValue = xValue + 1
        axisItem = New ChartAxisItem(dt.Rows(i).Item(0).ToString)
        axisItem.Value = xValue
        RadChart1.PlotArea.XAxis.AddItem(axisItem)
        stSeries = dt.Rows(i).Item(0).ToString
 
    End If
    Select Case dt.Rows(i).Item(1)
        Case Is = 1, 2, 3
            Dim seriesItem As New ChartSeriesItem
            seriesItem.YValue = dt.Rows(i).Item(2)
            seriesItem.XValue = xValue
            seriesItem.Appearance.FillStyle.SecondColor = Color.DarkRed
            seriesItem.Appearance.FillStyle.MainColor = Color.Red
            seriesItem.Name = dt.Rows(i).Item(0).ToString
            oSeries.AddItem(seriesItem)
        Case Is = 4
            Dim seriesItem As New ChartSeriesItem
            seriesItem.YValue = dt.Rows(i).Item(2)
            seriesItem.XValue = xValue
            seriesItem.Appearance.FillStyle.SecondColor = Color.DarkGreen
            seriesItem.Appearance.FillStyle.MainColor = Color.LightGreen
            seriesItem.Name = dt.Rows(i).Item(0).ToString
            cSeries.AddItem(seriesItem)
    End Select
 
 
Next
 
 
RadChart1.Series.Add(oSeries)
RadChart1.Series.Add(cSeries)


Best regards,
Ves
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Brant
Top achievements
Rank 1
answered on 03 Mar 2011, 03:40 PM
That worked great!  Thanks so much.   I didn't even think to link the xValues.  Thanks again.

Brant
Tags
General Discussions
Asked by
Dhruv
Top achievements
Rank 1
Answers by
Steve
Telerik team
Brant
Top achievements
Rank 1
Ves
Telerik team
Share this question
or