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

HTMLChart Stacked Column Series with Items

3 Answers 72 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Hani
Top achievements
Rank 1
Hani asked on 02 May 2015, 08:27 PM

Hello,

 

i have a project class with a list of employees assigned to each project

 

what i want to achieve here is that i want the stacked column chart to display names of projects on X axis for each series then add each resource of this project to the series as a series item with Y-Value of the total hours consumed by this employee on this project which is also a property coming from ProjectResource Class, i do it this way

 

Private Sub LoadAllProjects()

 dim Projects as new list(of Project)

 

Projects = GetAllProjects()

For Each nProject as Project in Projects

 Dim nSeries as new ColumnSeries

 Dim nAxisItem as new AxisItem

nAxisItem.labelstring = nProject.Name

nSeries.name = nProject.Name

For Each nEmp as Employee in Project.Resources

 dim nItem as new SeriesItem

nItem.Name = nEmp.Name

nitem.yvalue = nEmp.TotalUtilized

nSeries.Items.Add(nItem)

 

Next

RadHtmlChart1.PlotArea.Series.Add(nSeries)

Next

End Sub

 

Using this the either all items get loaded into first series or they duplicate in each series, i have tried everything possible and its not working

 also the legend is display the project.names thats because im assigning Series.Name to Project.Name and i have to remove it but i need the legend to display the names of employees in each project

 

Help is really appreciated, thanks

3 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 06 May 2015, 01:05 PM
Hello Hani,

I suggest providing a simple, locally runnable solution which recreates the same scenario with some dummy data source. With the sent code, it is hard to identify what is exactly the source, what data is bound, etc.

Also, you cannot have different names for the Series Names and the labels in Legend.

Regards,
Ianko
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Hani
Top achievements
Rank 1
answered on 06 May 2015, 01:47 PM

HI,

Thanks for your reply, I have simulated what i want with google charts and attaching a snapshot to the reply, basically i have a Projects and each Project has a list of Resources

I load the projects list first then for each project i create a new series and name it to the project then for each project i loop through the list of resources and create a new seriesitem for each one and assign its value,

 

Im not binding im using code behind to programmatically create everything so in order to create a chart similar to the one attached what should i do exactly? i didnt attach the entire project because basically the Project is a class with some properties and fields being populated from sql and each project class has a list of resource class which is also populated from code behind, finally we are getting a list of projects and a list of resources for each project

 

thanks

 

0
Danail Vasilev
Telerik team
answered on 07 May 2015, 10:07 AM
Hi Hani,

Please find my suggestions and comments below:
    - From the provided snap shot I can suggest that you create 5 column series and 1 line series, each of them having 5 items for the 5 categories.  You can examine our demos in order to see how to configure series. The same property and tag names from the markup can also be used for the programmatic creation of the chart as well. You can see a programmatically created chart here - http://demos.telerik.com/aspnet-ajax/htmlchart/examples/serversideapi/programmaticcreation/defaultcs.aspx
    - You should use the new SeriesItems collection when creating the chart. More information is available here - http://www.telerik.com/help/aspnet-ajax/htmlchart-important-changes-regarding-the-series-declaration.html
   - You may also find useful the data source grouping code library, if your data is linear and you want to group it in separate fields for each series - http://www.telerik.com/support/code-library/group-radhtmlchart-data-source


Regards,
Danail Vasilev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Chart (HTML5)
Asked by
Hani
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Hani
Top achievements
Rank 1
Danail Vasilev
Telerik team
Share this question
or