Hi,
I am using igDataChart as below:
@( Html.Infragistics().DataChart(Model) .ID("chart") .Width("700px") .Height("400px") .VerticalZoomable(true) .HorizontalZoomable(true) .Axes((axes) => getting error on this line { axes.NumericX("xAxis"); axes.NumericY("yAxis"); }) .DataBind() .Render())
Error is as below:
CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
Just as a note the code above is completely valid, event without the series and I just tested it and it produces the correct output. I did test with removing the model reference from my page and I got exactly the same error.
Since I can't see the rest of your code I would assume that can be your issue and to resolve it you will need to reference your model in the View:
Both of those references do the same, use the one fo your preference and let me know if that solves your problem.
If for some reason that is not the issue it would probably be best if you can provide a small sample application that reproduces the issue for us to look at.
Regards,
Damyan
Hi Damyan,
Thanks for your response.
The model is List<DataSeries>
public class ChartDataPoint { public double X { get; set; } public double Y { get; set; }
}
public class DataSeries : List<ChartDataPoint> { }
From controller, I am sendind data to the View as follows:
return
View(dataSeries.AsQueryable());
View Code is as follows:
@model
IQueryable<MMM.CRPL.Shannon.Applications.SpectroscopyWeb.Models.ChartDataPoint>
@( Html.Infragistics().DataChart(Model) .ID("chart") .Width("700px") .Height("400px") .VerticalZoomable(true) .HorizontalZoomable(true) .Axes((axes) => { axes.NumericX("xAxis"); axes.NumericY("yAxis"); }) .DataBind() .Render() )
But now nothing is getting rendered.
Hi Damyan, thanks again for help.
I have checked and verified every dependency and all the file path is correct.
I have created a sample application and the link is
https://www.dropbox.com/s/bts9r7gxxy5npws/Test.zip
The app is not working, although page view source shows everything rendered correctly.
Please check the app and let me know whats the problem.
Hello,
seems I was right - it is the resources. I ran the app and this is what I saw:
Below the error is the view from FIddler(all the requests made by the loader failed with 404 code as the files were not quite there) - the resources have a default folder structure and the loader is looking for files based on that. You have plenty of options to resolve this - either keep the structure or also manually add references to all these to either your _Layout view or the Loader's recources (yes, you can instruct the loader to add specific resources by relative path, but that would not stop the errors from files missing in their intended place).
I chose to simply restore the folder structure as it is the intended and easiest way. There are some files still missing but the minimum requirements are covered and the chart renders as it should and here's the link to the modified project:
http://dl.dropbox.com/u/76144077/Test.zip
On a side note, there's no reason to change/delete the folder structure of the resource files - those files take relatively minimal space on a server and it's the loader's job to only load those needed for the current page and that way you don't need to think which filed should be added.
PS: Also added reference to jQuery UI's file in the _Layout view as it is absolutely required as well.
Now I can see the chart.
Just wondering how to render multiple chartsin a loop, something as shown below:
foreach (DataSeries dataSeries in dataSeriesCollection) { <fieldset> @(Html.Infragistics().DataChart(dataSeries.AsQueryable()) .ID("chart") .VerticalZoomable(true) .HorizontalZoomable(true) .Axes((axes) => { axes.NumericX("xAxis"); axes.NumericY("yAxis"); }) .Series(series => { series.Scatter("scatterSeries") .XAxis("xAxis").YAxis("yAxis") .XMemberPath(dataPoint => dataPoint.X) .YMemberPath(dataPoint => dataPoint.Y); }) .DataBind() .Render() ) </fieldset> }
You are almost there - two small adjustments:
Put a @ before the 'foreach' to let know the Razor egine know that's a code block if you haven't already.
The second and more important thing is to remove the ID property from the chart - jQuery controls are initialized based on their target element's ID and in such loop they are all the same and all charts will attempt to render on the same container. When you remove the ID the MVC helper is smart enough to assign ID and number them automatically so multiple charts can be rendered.
I've modified your Test project's view file to render two charts for example:
(event though I'm using the two halves of one data set, replacing it with multiples, exactly like your foreach code, wil work just as fine).
I am using same in MVC 3 but i get same error for grid, can you please help me with this.
Thanks.
Sushant