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.
Of course, what you get rendered should be the chart's empty canvas. I mentioned above it's a valid code, but it is without the series and the series are the actual representation of your data.
I can see you have X and Y values so say you want to plot those in Scatter series you would have to add them to your code:
The chart supports many other series types and the best place to start is the documentation:
http://help.infragistics.com/NetAdvantage/jQuery/2012.1/CLR4.0?page=igDataChart_Landing_Page.html - you will find topics with all types described and a very thorough step-by-step guide on how to add a chart to your page. And you should definately check out the samples - http://samples.infragistics.com/jquery/chart where you can find demos and sample code form almost any coommon scenario.
Please mark any of the replies if they solved your issue so they can guide others.
Thanks Damyan.
Even after adding the series, nothing is getting rendered.
@( Html.Infragistics().DataChart(Model) .ID("chart") .Width("700px") .Height("400px") .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() )
When i View source of the page. I could see points added to igChart
Below is the html rendered: (I have 8000+ points, I have trimmed the rendered HTML for clarity)
<script type="text/javascript">$(function () {$('#chart').igDataChart({ dataSource: [{"X":33.145599,"Y":49.299999},{"X":33.41217,"Y":49.299999},{"X":33.678802,"Y":49.600002},{"X":2021.359863,"Y":40},{"X":2021.359863,"Y":40.100002},{"X":2021.359863,"Y":40.100002},{"X":2021.359863,"Y":40.100002},{"X":2021.359863,"Y":40},{"X":2021.359863,"Y":40},{"X":2021.359863,"Y":40.100002},{"X":2021.359863,"Y":40},{"X":2021.359863,"Y":40},{"X":2021.359863,"Y":40},{"X":2021.359863,"Y":40.200001},{"X":2021.359863,"Y":39.700001},{"X":2021.359863,"Y":39.700001},{"X":2021.359863,"Y":39.799999}], width: '700px', height: '400px', verticalZoomable: true, horizontalZoomable: true, axes: [ { type: 'numericX', name: 'xAxis' }, { type: 'numericY', name: 'yAxis' } ], series: [ { type: 'scatter', name: 'scatterSeries', xAxis: 'xAxis', yAxis: 'yAxis', xMemberPath: 'X', yMemberPath: 'Y' } ] });});</script><script type='text/javascript'>$(document).ready(function() { if ($.ig.TrialWatermark === undefined) { $('<div></div>').appendTo(document.body).css({width: $(document.body).width(), height: $(document.body).height(), position:'absolute', top: 0, left: 0, zIndex: -1}).addClass('ui-igtrialwatermark'); $.ig.TrialWatermark = true; } });</script>
Could not get what could be wrong now ??
What I see as output is absolutely correct and would render a chart just fine, but I do notice something odd - the output script would've been different if you were using the helper's Loader.
That means two things - either you are using jQuery initialized loader or you are adding specific script references yourself, but either way a script file is probaly missing or unavailable for whatever reason (error in the path provided, missing file or even cross-domain restriction in some browsers). Whatever the case - look at your broser console - I'd say there's a high chance you will see something like "Object doens't support property or method igDataChart()" which is pretty much a clear sign script resources loading went wriong somewhere.
Once again I encourage you to reffer to the online guide (direct link: http://help.infragistics.com/NetAdvantage/jQuery/2012.1/CLR4.0?page=igDataChart_Adding.html) as you are probably missing the very first step - Add references to required resources:
Please take a closer look at the documentation, there's even a minimum required scripts list linked in that first step if you want to add them manually.
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.
If you want to use the Infragistics loader (which the MVC wrapper uses by default) then your script references must be in the expected folder structure. The loader expects there to be a subfolder called modules in both the js and css folders that contain most of the resources. You would be best off following the directions in the doc in setting up the folder structure based on what came out of the installer.
If you look at the resource loads in, say, chrome, you can see where the loader is trying to find resources, but failing, so you can make adjustments. But it would be quicker to start with the correct structure.
Hope this helps!
-Graham
Thanks Graham, now its apparent that the root cause was the folder structure.
I would request you and you documentation team to update this information.
If i could have find this information in documentation, I would have saved 2 days :)
Thanks again.
Damyan, you beat me to it! :)