How do I use ViewBag as a datasource for an igDataChart
I need to make a line chart with 3 series
I already use model on the page
Have you tried .AsQueryable()?
If I try this :
Html.Infragistics().DataChart(ViewBag.Data_Dage).ID("Graf_Dage").Width("1100px").Height("600px").DataBind().Render();
I get this error :
Typeargumenterne for metoden 'Infragistics.Web.Mvc.InfragisticsSuite<Intranet.mvc.Models.m_Besogstal_Dato>.DataChart<T>(object)' kan ikke afledes fra brugen. Prøv at angive typeargumenterne eksplicit.
the Graph tries to use the model insted of the Viewbag
Dim dt2 As New DataTable()
Dim dcGruppe1 As New DataColumn("Entre", GetType(Integer))
Dim dcGruppe2 As New DataColumn("Gratister", GetType(Integer))
Dim dcGruppe3 As New DataColumn("Medlemsslusen", GetType(Integer))
Dim dcDato As New DataColumn("Uge", GetType(String))
dt2.Columns.Add(dcDato)
dt2.Columns.Add(dcGruppe1)
dt2.Columns.Add(dcGruppe2)
dt2.Columns.Add(dcGruppe3)
depending on the length of the period the graph use dates or week numbers on the x-axis
I would prefer to use viewbag for this graph
Hello Sandoy,
Thank you for posting in our community!
Before proceeding with preparing a sample regarding your question I have the following note: it is recommended to pass complex data structures by using the model and not by viewbag since the code is easier to maintain and more flexible to change further.
Extending the existing model with properties containing information for the chart is a possible implementation.
If you have already considered that option and view bag usage fits better the specificity of your case please let me know.
Looking forwards to hearing from you.