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

Stacked Bar Chart-Need Help!!!!

3 Answers 186 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
HAREE
Top achievements
Rank 1
HAREE asked on 02 Apr 2012, 11:04 AM
Hello,

I need help with a Telerik stacked bar chart.

I have used a separate data source to get the data. Moreover, I'm passing in  parameter values to get the chart which is absolutely working fine.

I have 4 columns in my table. With Column "A" as X-axis which is to be grouped and "TaskTime" as Y-axis. 

I have to display column "Tasktime" again in the chart with the label names of column "B" and "C" on them. And the length of the stacked bar should vary according to the "TaskTime". I hope you will have a better understanding if you look at the attached files.I'm expected to produce a chart exactly or almost similar to the "Expected" Chart that I have attached.

I have attached two files where one is the "Expected" chart and the other one is the "Resulted" chart which was obtained so far. I have made changes to the data of the " Expected" chart to help you understand better(since the "Resulted" data is not that good for understanding). I have also attached my piece of code for your reference. I managed to produce a chart slightly similar to the "Expected" one. But, I am struck halfway and I don't have any clue how to proceed further. So, I request you to help me.

The issues to be sorted out in the "Resulted" chart are

  1. The X-Axis values should be grouped.
  2. The stacked bar should be differentiated in their colour.
  3. Make the column values of "B and C" appear on their respective "TaskTime" bars in the format "B-C".
  4. Show the sum of the "TaskTime" values appear on the top of their respective bars in case of any stacked bars or just their values.

 I would be glad if this chart can be done in Telerik report chart (Without using Radchart). But, if not possible, I wouldn't mind switching over to Radchart. But, I wanted to get this chart done, somehow. I would be really grateful if you could help me to proceed further. Thank you!!!
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports Telerik.Reporting
Imports Telerik.Reporting.Drawing
Imports Telerik.Web.UI
Imports Telerik.Charting
 
Partial Public Class Report1
    Inherits Telerik.Reporting.Report
    Public Sub New()
        InitializeComponent()
  End Sub
 
   
  Private Sub Report1_NeedDataSource(sender As System.Object, e As System.EventArgs) Handles MyBase.NeedDataSource
    Dim ttasktime As New tasktime
 
    Dim tasktime As New Telerik.Reporting.Charting.ChartSeries("tasktime")
    Chart1.Series.Clear()
    tasktime.DataYColumn = "tasktime"
    tasktime.Name = "tasktime"
    tasktime.DataLabelsColumn = "B"
    tasktime.DataXColumn = "A"
    tasktime.Type = Charting.ChartSeriesType.StackedBar
    Chart1.Series.Add(tasktime)
 
    Chart1.PlotArea.XAxis.DataLabelsColumn = "A"
 
 
    Chart1.DataSource = ttasktime
  End Sub
End Class

3 Answers, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 05 Apr 2012, 12:24 PM
Hello,

I am afraid RadChart does not provide such type of grouping out-of-the-box. Each chart series item can get the values for the corresponding XValue and YValue properties from the underlying data. It can also group the items in series, but still, the XValue will be respected (or if no XValue is set -- the items will be added consecutively).

However, you can manually alter the chart after it has been databound in order to achieve the desired result. I have attached a small page showing this.

All the best,
Evgenia
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
HAREE
Top achievements
Rank 1
answered on 18 Apr 2012, 01:21 PM
Hello Evgenia,

Thanks for your response!!! I do understand that the X-axis values can only be grouped manually.

But, is there an option to code such that a loop is created in the x-axis which gets rid of the repeated x-axis data.

To be clear, if you look at my attachment "Resulted" in my first post, I was not able to group the X-axis data "20" but still managed to create a stacked bar by grouping at least the values of "20" in the chart. Is there any way to get rid of that idle x-value "20" by introducing a loop which loops around to find the repeated x-axis data and gets rid of them while their corresponding value remains stacked in the adjacent bar?? 

I would be grateful if you could come up with some solution.


Thanks,

Haree

0
Evgenia
Telerik team
answered on 24 Apr 2012, 01:41 PM
Hello Haree,

Please note that there is no easy way to achieve this. I suggest that you try the solution I attached in this post. Each element in your data is a single item of new series and is added with specific X and Y properties.


Greetings,
Evgenia
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Chart (Obsolete)
Asked by
HAREE
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
HAREE
Top achievements
Rank 1
Share this question
or