Hello
Can I use DataSourceURl in a Pie Chart? I'm trying to do this, but I can't get it
Code:
@(Html.Infragistics().PieChart<EstatusPedimentos>()
.ID("chart") .Width("300px") .Height("300px") .ValueMemberPath("cantidad") .LabelMemberPath("estatus") .ExplodedSlices("0 1") .RadiusFactor(.9) .AllowSliceExplosion(true).DataSourceUrl(Url.Action("ObtenerGrafica1", "Home")) .DataBind() .Render())
Thanks!
Hello Jorge,
You can use DataSourceUrl Method in Pie Chart to set the data chart model: http://help.infragistics.com/doc/jQuery/2014.2/CLR4.0/?page=Infragistics.Web.Mvc~Infragistics.Web.Mvc.PieChart`1~DataSourceUrl.html However I need the whole project to see why your chart can't get the data. Could you provide me with an isolated sample project?
Looking forward to your response.
Regards,
Tsanna
Hi Ysanna
Here is my code:
View:
@(Html.Infragistics().PieChart<EstatusPedimentos>() .ID("chart2") .Width("440px") .Height("420px") .ValueMemberPath("cantidad") .LabelMemberPath("estatus") .ExplodedSlices("0 1") .RadiusFactor(.9) .AllowSliceExplosion(true) .ShowTooltip(true) .DataSourceUrl(Url.Action("ObtenerDatosGrafica2", "Home")) .DataBind() .Render() )
Controller:
public ActionResult ObtenerDatosGrafica2() { GraficasModel.EstatusPedimentos objProcesos = new GraficasModel.EstatusPedimentos(); return View(objProcesos.CargarCantPedimentosURL()); }
Model:
public IQueryable<EstatusPedimentos> CargarCantPedimentosURL() {
stuff ...
return lstCantPedimentos.ToList<EstatusPedimentos>().AsQueryable(); }
And I get this:
$.ig.loader('igPieChart', function() {$('#chart2').igPieChart({ width: '440px', height: '420px', valueMemberPath: 'cantidad', labelMemberPath: 'estatus', explodedSlices: [0,1], radiusFactor: 0.9, allowSliceExplosion: true, showTooltip: true, dataSourceUrl: '/Home/ObtenerDatosGrafica2' });});
The browser shows me this error in the console:
Uncaught TypeError: undefined is not a function localhost:63786/Scripts/IgniteUI/modules/infragistics.dv.core.js:14
Please note that the DataSourceUrl property can point to any url that returns data in a format that the igDataSource can accept: JSON, XML, HTML Table etc.. In the context of MVC application you can use the [DataSourceAction] attribute over the MVC action that supplies the data in order to ensure that it will return the data in JSON format.
I'm attaching also a sample with similar scenario for your reference. If you have any further questions, please let me know.