Note that there are some explanatory texts on larger screens.

plurals
  1. POMvc 4 View utilizing wrong model
    primarykey
    data
    text
    <p>I have this error: <a href="http://i.imgur.com/C4xKucH.png" rel="nofollow">http://i.imgur.com/C4xKucH.png</a></p> <p>I know my Message model isent queryable. I'm intending to use a diffrent model, and I don't quite know why/how it is using my "Message" model. I'm intending to use my model "GraphModel". This is how my View looks:</p> <pre><code>@model ChatProj.Models.GraphModel @using Infragistics.Web.Mvc @using System.Linq @{ ViewBag.Title = "RealTime chart"; } &lt;style&gt; #chart1 { position: relative; float: left; } #legend1 { position: relative; float: left; margin-left: 15px; } &lt;/style&gt; &lt;script type="text/javascript"&gt; $.ig.loader({ scriptPath: "js/", cssPath: "css/", resources: "igDataChart.Category" }); $.ig.loader(function () { var queued = 0, data = [], updateData, currCPU = 10.0, currMem = 1024, connection; $("#chart1").igDataChart("option", "dataSource", data); $("#chart1").igDataChart("option", "series", [{ name: "series1", dataSource: data }, { name: "series2", dataSource: data }]); $("#chart1").igDataChart("option", "axes", [{ name: "xAxis", dataSource: data }]); var updateData = function (newItem) { data.push(newItem); $("#chart1").igDataChart("notifyInsertItem", currCPU, data.length - 1, newItem); queued++; if (queued &gt; 2000) { oldItem = data[0]; data.shift(); $("#chart1").igDataChart("notifyRemoveItem", currCPU, 0, oldItem); queued--; } } var generateRandomItem = function () { var newItem = {}, currDate = new Date(), hours = currDate.getHours(), minutes = currDate.getMinutes(), seconds = currDate.getSeconds(); if (Math.random() &gt; .5) { currCPU += Math.random() * 2.0; } else { currCPU -= Math.random() * 2.0; } if (Math.random() &gt; .5) { currMem += Math.random() * 5.0; } else { currMem -= Math.random() * 5.0; } if (currMem &lt;= 0) { currMem = 0; currMem += Math.random() * 5.0; } if (currMem &gt; 4096) { currMem = 4096; currMem -= Math.random() * 5.0; } if (currCPU &lt;= 0) { currCPU = 0; currCPU += Math.random() * 2.0; } if (currCPU &gt; 100) { currCPU = 100; currCPU -= Math.random() * 2.0; } if (hours &gt; 12) { hours = hours - 12; } if (hours &lt; 10) { hours = "0" + hours; } if (minutes &lt; 10) { minutes = "0" + minutes; } if (seconds &lt; 10) { seconds = "0" + seconds; } newItem.DateString = hours + ":" + minutes + ":" + seconds; newItem.CPUUsage = currCPU; newItem.MemUsage = currMem; return newItem; } window.setInterval(function () { var newItem = generateRandomItem(); updateData(newItem); }, 33); /*connection = $.connection('/MessageDataStream'); connection.received(function (dataItem) { var newItem = dataItem; updateData(newItem); }); connection.start();*/ }); &lt;/script&gt; @( Html.Infragistics().DataChart(Model.AsQueryable()) .ID("chart1") .Width("500px") .Height("500px") .VerticalZoomable(true) .HorizontalZoomable(true) .WindowResponse(WindowResponse.Immediate) .Legend((l) =&gt; { l.ID("legend1").Width("150px"); }) .Axes((axes) =&gt; { axes.CategoryX("xAxis").Label((item) =&gt; item.DateString) .LabelExtent(50); axes.NumericY("yAxis") .MinimumValue(0) .MaximumValue(100) .LabelExtent(30); axes.NumericY("yAxis2") .MinimumValue(0) .MaximumValue(4096) .LabelExtent(40) .MajorStroke("transparent") .LabelLocation(AxisLabelsLocation.OutsideRight); }) .Series((series) =&gt; { series .Line("series1") .Title("CPU usage") .XAxis("xAxis").YAxis("yAxis") .ValueMemberPath((item) =&gt; item.CPUUsage) .Thickness(2); series .Line("series2") .Title("Available Memory") .XAxis("xAxis").YAxis("yAxis2") .ValueMemberPath((item) =&gt; item.MemUsage) .Thickness(2); }).DataBind().Render() ) </code></pre> <p>This is how my controller looks like:</p> <pre><code>public ActionResult Chart() { return View(new GraphModel()); } </code></pre> <p>I'm wondering why it is trying to use my "Message" and not my intended "GraphModel" model?</p> <p><strong>Edit</strong>: "GraphModel" looks like this:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace ChatProj.Models { public class GraphModel : List&lt;GraphData&gt; { } public class GraphData { //public double messagesPM { get; set; } //public string DateString { get; set; } public string DateString { get; set; } public double CPUUsage { get; set; } public double MemUsage { get; set; } } } </code></pre> <p>And "Message" model looks like this:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace ChatProj.Models { public class Message { public int MessageID { get; set; } public string Name { get; set; } public string MessageString { get; set; } public DateTime MessageDate { get; set; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload